change#5797 didn't do the right thing for "\xff\N{WHITE SMILING FACE}"
Gurusamy Sarathy [Mon, 20 Mar 2000 20:37:42 +0000 (20:37 +0000)]
p4raw-link: @5797 on //depot/perl: e1992b6d91e50ab66a903c570e8d9c48f121f34b

p4raw-id: //depot/perl@5837

t/lib/charnames.t
toke.c

index a6fe47f..7643390 100644 (file)
@@ -8,7 +8,7 @@ BEGIN {
 }
 
 $| = 1;
-print "1..10\n";
+print "1..12\n";
 
 use charnames ':full';
 
@@ -67,4 +67,8 @@ $encoded_bet = "\327\221";
     print "ok 9\n";
     print "not " unless sprintf("%vx", "\N{WHITE SMILING FACE}") eq "263a";
     print "ok 10\n";
+    print "not " unless sprintf("%vx", "\xFF\N{WHITE SMILING FACE}") eq "ff.263a";
+    print "ok 11\n";
+    print "not " unless sprintf("%vx", "\x{ff}\N{WHITE SMILING FACE}") eq "ff.263a";
+    print "ok 12\n";
 }
diff --git a/toke.c b/toke.c
index cb6751a..375d917 100644 (file)
--- a/toke.c
+++ b/toke.c
@@ -1479,8 +1479,14 @@ S_scan_const(pTHX_ char *start)
                    res = new_constant( Nullch, 0, "charnames", 
                                        res, Nullsv, "\\N{...}" );
                    str = SvPV(res,len);
-                   if (len > 1)
+                   if (!has_utf && SvUTF8(res)) {
+                       char *ostart = SvPVX(sv);
+                       SvCUR_set(sv, d - ostart);
+                       SvPOK_on(sv);
+                       sv_utf8_upgrade(sv);
+                       d = SvPVX(sv) + SvCUR(sv);
                        has_utf = TRUE;
+                   }
                    if (len > e - s + 4) {
                        char *odest = SvPVX(sv);