This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Fix charnames::viacode not accepting U+... param
authorKarl Williamson <khw@khw-desktop.(none)>
Sat, 29 May 2010 19:29:53 +0000 (13:29 -0600)
committerDavid Golden <dagolden@cpan.org>
Mon, 28 Jun 2010 23:49:10 +0000 (19:49 -0400)
The commit e10d7780a27dcfeb9c50ab28b66f2df8763d8016 introduced a bug in
which a parameter to viacode of the form U+... no longer worked.  This
is fixed, as well as tests added.

lib/charnames.pm
lib/charnames.t

index 2bf36ac..637c215 100644 (file)
@@ -265,7 +265,7 @@ sub viacode
     $hex = sprintf "%04X", $arg;
   } elsif ($arg =~ /^(?:[Uu]\+|0[xX])?([[:xdigit:]]+)$/) {
     # Below is the line that differs from the _getcode() source
-    $hex = sprintf "%04X", hex $arg;
+    $hex = sprintf "%04X", hex $1;
   } else {
     carp("unexpected arg \"$arg\" to charnames::viacode()");
     return;
index f9bbdbc..9efd07a 100644 (file)
@@ -16,7 +16,7 @@ require File::Spec;
 
 $| = 1;
 
-plan(83);
+plan(85);
 
 use charnames ':full';
 
@@ -196,7 +196,10 @@ is("\N{U+263A}", "\N{WHITE SMILING FACE}");
 ok(! defined charnames::viacode(0x110000));
 ok(! grep { /you asked for U+110000/ } @WARN);
 
-is("NULL", charnames::viacode(0));
+is(charnames::viacode(0), "NULL");
+is(charnames::viacode("BE"), "VULGAR FRACTION THREE QUARTERS");
+is(charnames::viacode("U+00000000000FEED"), "ARABIC LETTER WAW ISOLATED FORM");
+
 
 # ---- Alias extensions