charnames: Explicitly return undef for empty input

Rather it returns an empty list for undefined or zero width input names.

This fixes #17768
This commit is contained in:
Karl Williamson 2020-05-12 22:18:54 -06:00 committed by Sawyer X
parent da3350397f
commit a39c5dfbc6
3 changed files with 9 additions and 2 deletions

View File

@ -6,7 +6,7 @@
package _charnames;
use strict;
use warnings;
our $VERSION = '1.47';
our $VERSION = '1.48';
use unicore::Name; # mktables-generated algorithmically-defined names
use bytes (); # for $bytes::hint_bits

View File

@ -1,7 +1,7 @@
package charnames;
use strict;
use warnings;
our $VERSION = '1.47';
our $VERSION = '1.48';
use unicore::Name; # mktables-generated algorithmically-defined names
use _charnames (); # The submodule for this where most of the work gets done
@ -41,6 +41,7 @@ sub vianame
# found, undef otherwise.
my $arg = shift;
return () unless length $arg;
if ($arg =~ /^U\+([0-9a-fA-F]+)$/) {
@ -70,6 +71,7 @@ sub string_vianame {
}
my $arg = shift;
return () unless length $arg;
if ($arg =~ /^U\+([0-9a-fA-F]+)$/) {

View File

@ -264,6 +264,11 @@ sub test_vianame ($$$) {
cmp_ok($warning_count, '==', scalar @WARN, "Verify vianame doesn't warn on unknown names");
ok (! defined charnames::string_vianame("MORE NONE SUCH"), "Verify string_vianame returns undef for an undefined name");
cmp_ok($warning_count, '==', scalar @WARN, "Verify string_vianame doesn't warn on unknown names");
ok (! defined charnames::vianame(""), "Verify vianame returns undef for an empty value");
cmp_ok($warning_count, '==', scalar @WARN, "... and no warning is generated");
ok (! defined charnames::string_vianame(""), "Verify string_vianame returns undef for an empty value");
cmp_ok($warning_count, '==', scalar @WARN, "... and no warning is generated");
eval "qr/\\p{name=MORE NONE SUCH}/";
like($@, qr/Can't find Unicode property definition "name=MORE NONE SUCH"/,
'\p{name=} returns an appropriate error message on an undefined name');