mirror of
https://github.com/Perl/perl5.git
synced 2026-01-27 01:44:43 +00:00
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:
parent
da3350397f
commit
a39c5dfbc6
@ -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
|
||||
|
||||
@ -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]+)$/) {
|
||||
|
||||
|
||||
@ -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');
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user