This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
charnames: add CORE:: to hex()
authorKarl Williamson <khw@khw-desktop.(none)>
Wed, 30 Jun 2010 21:19:39 +0000 (15:19 -0600)
committerJesse Vincent <jesse@bestpractical.com>
Sun, 4 Jul 2010 20:43:43 +0000 (21:43 +0100)
Other programs do this; I don't know why just hex() needs to be
protected from user override, but I'm just copying prior art.

lib/charnames.pm

index 3ef3711..5cd9e40 100644 (file)
@@ -438,7 +438,7 @@ sub alias (@)
         $inverse_user_aliases{sprintf("%04X", $value)} = $name;
     }
     elsif ($value =~ $hex_qr) {
         $inverse_user_aliases{sprintf("%04X", $value)} = $name;
     }
     elsif ($value =~ $hex_qr) {
-        my $decimal = hex $1;
+        my $decimal = CORE::hex $1;
         $user_numeric_aliases{$name} = $decimal;
 
         # Must convert to decimal and back to guarantee canonical form
         $user_numeric_aliases{$name} = $decimal;
 
         # Must convert to decimal and back to guarantee canonical form
@@ -668,7 +668,7 @@ sub viacode
   }
 
   # checking the length first is slightly faster
   }
 
   # checking the length first is slightly faster
-  if (length($hex) > 5 && hex($hex) > 0x10FFFF) {
+  if (length($hex) > 5 && CORE::hex($hex) > 0x10FFFF) {
     carp "Unicode characters only allocated up to U+10FFFF (you asked for U+$hex)";
     return;
   }
     carp "Unicode characters only allocated up to U+10FFFF (you asked for U+$hex)";
     return;
   }