Change 17358 by jhi@alpha on 2002/06/26 14:37:12

        Another Unicode s/// buglet, from SADAHIRO Tomoyuki.

Affected files ...

.... //depot/perl/pp_hot.c#282 edit
.... //depot/perl/t/op/subst.t#32 edit

Differences ...

==== //depot/perl/pp_hot.c#282 (text) ====
Index: perl/pp_hot.c
--- perl/pp_hot.c#281~17353~    Tue Jun 25 08:18:15 2002
+++ perl/pp_hot.c       Wed Jun 26 07:37:12 2002
@@ -1985,6 +1985,15 @@
     if (dstr) {
         c = SvPV(dstr, clen);
        doutf8 = DO_UTF8(dstr);
+       /* replacement needing upgrading? */
+       if (DO_UTF8(TARG) && !doutf8) {
+            SV *nsv = newSVpvn(c, clen);
+            if (PL_encoding)
+                 sv_recode_to_utf8(nsv, PL_encoding);
+            else
+                 sv_utf8_upgrade(nsv);
+            c = SvPV(nsv, clen);
+       }
     }
     else {
         c = Nullch;

==== //depot/perl/t/op/subst.t#32 (xtext) ====
Index: perl/t/op/subst.t
--- perl/t/op/subst.t#31~17353~ Tue Jun 25 08:18:15 2002
+++ perl/t/op/subst.t   Wed Jun 26 07:37:12 2002
@@ -7,7 +7,7 @@
 }
 
 require './test.pl';
-plan( tests => 92 );
+plan( tests => 108 );
 
 $x = 'foo';
 $_ = "x";
@@ -381,6 +381,7 @@
 is($pv1, $pv2);
 
 {   
+    # Gregor Chrupala <[EMAIL PROTECTED]>
     use utf8;
     $a = 'Espa&ntilde;a';
     $a =~ s/&ntilde;/ñ/;
@@ -401,3 +402,46 @@
     like($a, qr/ñ/, "use utf8 LHS and RHS");
 }
 
+{
+    # SADAHIRO Tomoyuki <[EMAIL PROTECTED]>
+
+    $a = "\x{100}\x{101}";
+    $a =~ s/\x{101}/\xFF/;
+    like($a, qr/\xFF/);
+    is(length($a), 2);
+
+    $a = "\x{100}\x{101}";
+    $a =~ s/\x{101}/"\xFF"/e;
+    like($a, qr/\xFF/);
+    is(length($a), 2);
+
+    $a = "\x{100}\x{101}";
+    $a =~ s/\x{101}/\xFF\xFF\xFF/;
+    like($a, qr/\xFF\xFF\xFF/);
+    is(length($a), 4);
+
+    $a = "\x{100}\x{101}";
+    $a =~ s/\x{101}/"\xFF\xFF\xFF"/e;
+    like($a, qr/\xFF\xFF\xFF/);
+    is(length($a), 4);
+
+    $a = "\xFF\x{101}";
+    $a =~ s/\xFF/\x{100}/;
+    like($a, qr/\x{100}/);
+    is(length($a), 2);
+
+    $a = "\xFF\x{101}";
+    $a =~ s/\xFF/"\x{100}"/e;
+    like($a, qr/\x{100}/);
+    is(length($a), 2);
+
+    $a = "\xFF";
+    $a =~ s/\xFF/\x{100}/;
+    like($a, qr/\x{100}/);
+    is(length($a), 1);
+
+    $a = "\xFF";
+    $a =~ s/\xFF/"\x{100}"/e;
+    like($a, qr/\x{100}/);
+    is(length($a), 1);
+}
End of Patch.

Reply via email to