This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
PATCH [perl #72624] charnames::viacode(0) returns undef
authorKarl Williamson <khw@khw-desktop.(none)>
Fri, 16 Apr 2010 04:12:32 +0000 (22:12 -0600)
committerRafael Garcia-Suarez <rgs@consttype.org>
Sun, 25 Apr 2010 14:51:16 +0000 (16:51 +0200)
commite10d7780a27dcfeb9c50ab28b66f2df8763d8016
tree721bf64d58c761695dc88ca19bb24b4c1c51ecb5
parent6e1bad6cc227c8e8bc81402ccd56b118e265a861
PATCH [perl #72624] charnames::viacode(0) returns undef

The viacode() function contained the code from the _getcode() function from
Unicode::UCD, unchanged.  However, the rest of viacode() requires that
the result be specially formatted to do a string match with leading
zeros inserted to bring the length up to 4 if less than that.  The
original function only needs to get the number right, as a numerical
comparison is done, so it doesn't do this.  This showed up with calling
viacode with 0, but the bug also affected any input that looked like a
hex number, or a U+ number, such as 'BEE' or 'U+EF'.  These need to be
massaged into '0BEE' and '00EF' for the pattern match later in the
routine to succeed.

The patch also adds a test case to Unicode::UCD to verify that it really
does work ok on 0.
lib/Unicode/UCD.pm
lib/Unicode/UCD.t
lib/charnames.pm
lib/charnames.t