summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarl Williamson <khw@cpan.org>2015-02-18 11:57:02 -0700
committerKarl Williamson <khw@cpan.org>2015-02-18 12:51:34 -0700
commit5c1d8161bf92d6173f51e2f071ab9f34c6291591 (patch)
tree8050c37ae32ad06a65034aaad0a10b1f3b105008
parent91e7847033aefac6cf5b500a5c72811c8d6b8fbc (diff)
downloadperl-5c1d8161bf92d6173f51e2f071ab9f34c6291591.tar.gz
Unicode::UCD::prop_value_aliases() Don't return invalid value
Prior to this commit, if you said prop_value_aliases("Any", "foo") it would return "foo". But there really aren't any synonyms for the "Any" property values, so it should return undef instead.
-rw-r--r--charclass_invlists.h2
-rw-r--r--lib/Unicode/UCD.pm13
-rw-r--r--lib/Unicode/UCD.t2
-rw-r--r--pod/perldelta.pod7
4 files changed, 22 insertions, 2 deletions
diff --git a/charclass_invlists.h b/charclass_invlists.h
index 0135c7f499..e3f0099111 100644
--- a/charclass_invlists.h
+++ b/charclass_invlists.h
@@ -50101,7 +50101,7 @@ static const UV XPosixXDigit_invlist[] = { /* for EBCDIC POSIX-BC */
#endif /* EBCDIC POSIX-BC */
/* Generated from:
- * 522e6488a0de8931f0ae95d4841471102ffa35f42217d4864570e2a8f70aa6c1 lib/Unicode/UCD.pm
+ * 56a23229a7896d5edf8fc138694f73fedc006c544ef3f8bf28afe5c2426bb7dc lib/Unicode/UCD.pm
* 827aa7ee45ca9fe09f3e0969a5a27a69ce58a6c7134548125266210018d27b49 lib/unicore/ArabicShaping.txt
* 3748fbbe9d280a9da700bfd0c28beaaf6f32a67ec263a124fcb0a4095a30fae5 lib/unicore/BidiBrackets.txt
* 3925329c2432fa7248b2e180cddcedb9a4f9eafbbb10ab9e105eaf833043b2fb lib/unicore/BidiMirroring.txt
diff --git a/lib/Unicode/UCD.pm b/lib/Unicode/UCD.pm
index 5d3115dcfe..da2e1c36f8 100644
--- a/lib/Unicode/UCD.pm
+++ b/lib/Unicode/UCD.pm
@@ -2130,7 +2130,18 @@ sub prop_value_aliases ($$) {
# anything, like most (if not all) string properties. These don't have
# synonyms anyway. Simply return the input. For example, there is no
# synonym for ('Uppercase_Mapping', A').
- return $value if ! exists $prop_value_aliases{$prop};
+ if (! exists $prop_value_aliases{$prop}) {
+
+ # Here, we have a legal property, but an unknown value. Since the
+ # property is legal, if it isn't in the prop_aliases hash, it must be
+ # a Perl-extension All perl extensions are binary, hence are
+ # enumerateds, which means that we know that the input unknown value
+ # is illegal.
+ return if ! exists $Unicode::UCD::prop_aliases{$prop};
+
+ # Otherwise, we assume it's valid, as documented.
+ return $value;
+ }
# The value name may be loosely or strictly matched; we don't know yet.
# But both types use lower-case.
diff --git a/lib/Unicode/UCD.t b/lib/Unicode/UCD.t
index e54c5ee4fc..419c338dd6 100644
--- a/lib/Unicode/UCD.t
+++ b/lib/Unicode/UCD.t
@@ -727,6 +727,8 @@ is(prop_value_aliases(undef, undef), undef,
is((prop_value_aliases("na", "A")), "A", "test that prop_value_aliases returns its input for properties that don't have synonyms");
is(prop_value_aliases("isgc", "C"), undef, "prop_value_aliases('isgc', 'C') returns <undef> since is not covered Perl extension");
is(prop_value_aliases("gc", "isC"), undef, "prop_value_aliases('gc', 'isC') returns <undef> since is not covered Perl extension");
+is(prop_value_aliases("Any", "None"), undef, "prop_value_aliases('Any', 'None') returns <undef> since is Perl extension and 'None' is not valid");
+is(prop_value_aliases("lc", "A"), "A", "prop_value_aliases('lc', 'A') returns its input, as docs say it does");
# We have no way of knowing if mktables omitted a Perl extension that it
# shouldn't have, but we can check if it omitted an official Unicode property
diff --git a/pod/perldelta.pod b/pod/perldelta.pod
index c968f91fe2..673b8138ed 100644
--- a/pod/perldelta.pod
+++ b/pod/perldelta.pod
@@ -196,6 +196,13 @@ it was incorrect.
=item *
+A bug has been fixed so that
+L<prop_value_aliases()|Unicode::UCD/prop_value_aliases()>
+returns C<undef> instead of a wrong result for properties that are Perl
+extensions.
+
+=item *
+
This module now works on EBCDIC platforms.
=back