This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
regen/mk_invlists.pl: Properly handle empty properties
authorKarl Williamson <khw@cpan.org>
Sat, 27 Jun 2015 20:30:30 +0000 (14:30 -0600)
committerKarl Williamson <khw@cpan.org>
Wed, 29 Jul 2015 04:15:55 +0000 (22:15 -0600)
This failed to adequately handle empty properties; something that wasn't
seen until compiling older Unicode releases.

charclass_invlists.h
regen/mk_invlists.pl

index 70b5ac2..d2349e3 100644 (file)
@@ -99524,5 +99524,5 @@ static const UV XPosixXDigit_invlist[] = { /* for EBCDIC POSIX-BC */
  * 668579029ac0720853bf19781ec10ec922495271543c91531d7a6db3fcdffba9 lib/unicore/mktables
  * 462c9aaa608fb2014cd9649af1c5c009485c60b9c8b15b89401fdc10cf6161c6 lib/unicore/version
  * c6884f4d629f04d1316f3476cb1050b6a1b98ca30c903262955d4eae337c6b1e regen/charset_translations.pl
  * 668579029ac0720853bf19781ec10ec922495271543c91531d7a6db3fcdffba9 lib/unicore/mktables
  * 462c9aaa608fb2014cd9649af1c5c009485c60b9c8b15b89401fdc10cf6161c6 lib/unicore/version
  * c6884f4d629f04d1316f3476cb1050b6a1b98ca30c903262955d4eae337c6b1e regen/charset_translations.pl
- * f199f92c0b5f87882b0198936ea8ef3dc43627b57a77ac3eb9250bd2664bbd88 regen/mk_invlists.pl
+ * 3ea229d7bcbcb5864f985bcdcb6007f51949870d54f1dc469f299778051a9c94 regen/mk_invlists.pl
  * ex: set ro: */
  * ex: set ro: */
index 42f5b1c..ac0470c 100644 (file)
@@ -176,15 +176,14 @@ sub output_invlist ($$;$) {
     my $charset = shift // "";  # name of character set for comment
 
     die "No inversion list for $name" unless defined $invlist
     my $charset = shift // "";  # name of character set for comment
 
     die "No inversion list for $name" unless defined $invlist
-                                             && ref $invlist eq 'ARRAY'
-                                             && @$invlist;
+                                             && ref $invlist eq 'ARRAY';
 
     # Output the inversion list $invlist using the name $name for it.
     # It is output in the exact internal form for inversion lists.
 
     # Is the last element of the header 0, or 1 ?
     my $zero_or_one = 0;
 
     # Output the inversion list $invlist using the name $name for it.
     # It is output in the exact internal form for inversion lists.
 
     # Is the last element of the header 0, or 1 ?
     my $zero_or_one = 0;
-    if ($invlist->[0] != 0) {
+    if (@$invlist && $invlist->[0] != 0) {
         unshift @$invlist, 0;
         $zero_or_one = 1;
     }
         unshift @$invlist, 0;
         $zero_or_one = 1;
     }
@@ -489,20 +488,37 @@ for my $charset (get_supported_code_pages()) {
         else {
             @invlist = prop_invlist($lookup_prop, '_perl_core_internal_ok');
             if (! @invlist) {
         else {
             @invlist = prop_invlist($lookup_prop, '_perl_core_internal_ok');
             if (! @invlist) {
-                my ($list_ref, $map_ref, $format, $default);
 
 
-                ($list_ref, $map_ref, $format, $default)
+                # If couldn't find a non-empty inversion list, see if it is
+                # instead an inversion map
+                my ($list_ref, $map_ref, $format, $default)
                           = prop_invmap($lookup_prop, '_perl_core_internal_ok');
                           = prop_invmap($lookup_prop, '_perl_core_internal_ok');
-                die "Could not find inversion list for '$lookup_prop'" unless $list_ref;
+                if (! $list_ref) {
+                    # An empty return here could mean an unknown property, or
+                    # merely that the original inversion list is empty.  Call
+                    # in scalar context to differentiate
+                    my $count = prop_invlist($lookup_prop,
+                                             '_perl_core_internal_ok');
+                    die "Could not find inversion list for '$lookup_prop'"
+                                                          unless defined $count;
+                }
+                else {
                 @invlist = @$list_ref;
                 @invmap = @$map_ref;
                 $map_format = $format;
                 $map_default = $default;
                 $maps_to_code_point = $map_format =~ /x/;
                 $to_adjust = $map_format =~ /a/;
                 @invlist = @$list_ref;
                 @invmap = @$map_ref;
                 $map_format = $format;
                 $map_default = $default;
                 $maps_to_code_point = $map_format =~ /x/;
                 $to_adjust = $map_format =~ /a/;
+                }
             }
         }
             }
         }
-        die "Could not find inversion list for '$lookup_prop'" unless @invlist;
+
+
+        # Short-circuit an empty inversion list.
+        if (! @invlist) {
+            output_invlist($prop_name, \@invlist, $charset);
+            next;
+        }
 
         # Re-order the Unicode code points to native ones for this platform.
         # This is only needed for code points below 256, because native code
 
         # Re-order the Unicode code points to native ones for this platform.
         # This is only needed for code points below 256, because native code