This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Bodge to make Tk work - like the UTF8 flag, the READONLY flag has too
authorNicholas Clark <nick@ccl4.org>
Mon, 12 Jul 2004 17:27:28 +0000 (17:27 +0000)
committerNicholas Clark <nick@ccl4.org>
Mon, 12 Jul 2004 17:27:28 +0000 (17:27 +0000)
many meanings. const const vs mutable in this case.

p4raw-id: //depot/perl@23085

sv.c

diff --git a/sv.c b/sv.c
index aaf23e3..50501e7 100644 (file)
--- a/sv.c
+++ b/sv.c
@@ -3941,7 +3941,13 @@ Perl_sv_utf8_upgrade_flags(pTHX_ register SV *sv, I32 flags)
        return 0;
     if (!SvPOK(sv)) {
        STRLEN len = 0;
        return 0;
     if (!SvPOK(sv)) {
        STRLEN len = 0;
-       (void) SvPV_force(sv,len);
+       if (SvREADONLY(sv) && (SvPOKp(sv) || SvIOKp(sv) || SvNOKp(sv))) {
+           (void) sv_2pv_flags(sv,&len, flags);
+           if (SvUTF8(sv))
+               return len;
+       } else {
+           (void) SvPV_force(sv,len);
+       }
     }
 
     if (SvUTF8(sv)) {
     }
 
     if (SvUTF8(sv)) {