SvPV() (via mg_get() of sv_2pv()) can update the UTF8ness of the SVs.
Jarkko Hietaniemi [Wed, 11 Oct 2000 03:16:05 +0000 (03:16 +0000)]
p4raw-id: //depot/perl@7201

pp_hot.c
t/pragma/utf8.t

index 400350d..4ddb12c 100644 (file)
--- a/pp_hot.c
+++ b/pp_hot.c
@@ -167,13 +167,15 @@ PP(pp_concat)
             U8 *l, *c, *olds = NULL;
             STRLEN targlen;
            s = (U8*)SvPV(right,len);
+           right_utf |= DO_UTF8(right);
             if (TARG == right) {
                /* Take a copy since we're about to overwrite TARG */
-               olds = s = (U8*)savepvn((char*)s, len);
+               olds = s = (U8*)savepvn((char*)s, len);
            }
            if (!SvOK(left) && SvTYPE(left) <= SVt_PVMG)
                sv_setpv(left, "");     /* Suppress warning. */
             l = (U8*)SvPV(left, targlen);
+           left_utf |= DO_UTF8(left);
             if (TARG != left)
                 sv_setpvn(TARG, (char*)l, targlen);
             if (!left_utf)
index 1b6ca91..2b208cc 100755 (executable)
@@ -10,7 +10,7 @@ BEGIN {
     }
 }
 
-print "1..72\n";
+print "1..75\n";
 
 my $test = 1;
 
@@ -344,3 +344,33 @@ sub nok_bytes {
        $latin =~ s!(s)tr(?:aß|s+e)!$1tr.!; # \303\237 after the a
     }
 }
+
+{
+    $_ = $dx = "\x{10f2}";
+    s/($dx)/$dx$1/;
+    {
+       use bytes;
+       print "not " unless $_ eq "$dx$dx";
+       print "ok $test\n";
+       $test++;
+    }
+
+    $_ = $dx = "\x{10f2}";
+    s/($dx)/$1$dx/;
+    {
+       use bytes;
+       print "not " unless $_ eq "$dx$dx";
+       print "ok $test\n";
+       $test++;
+    }
+
+    $dx = "\x{10f2}";
+    $_  = "\x{10f2}\x{10f2}";
+    s/($dx)($dx)/$1$2/;
+    {
+       use bytes;
+       print "not " unless $_ eq "$dx$dx";
+       print "ok $test\n";
+       $test++;
+    }
+}