From: Karl Williamson Date: Sat, 27 Jun 2015 20:30:30 +0000 (-0600) Subject: regen/mk_invlists.pl: Properly handle empty properties X-Git-Tag: v5.23.2~87^2~41 X-Git-Url: https://perl5.git.perl.org/perl5.git/commitdiff_plain/ad85f59a463da286e27a75852dc2baf65903ecab regen/mk_invlists.pl: Properly handle empty properties This failed to adequately handle empty properties; something that wasn't seen until compiling older Unicode releases. --- diff --git a/charclass_invlists.h b/charclass_invlists.h index 70b5ac2..d2349e3 100644 --- a/charclass_invlists.h +++ b/charclass_invlists.h @@ -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 - * f199f92c0b5f87882b0198936ea8ef3dc43627b57a77ac3eb9250bd2664bbd88 regen/mk_invlists.pl + * 3ea229d7bcbcb5864f985bcdcb6007f51949870d54f1dc469f299778051a9c94 regen/mk_invlists.pl * ex: set ro: */ diff --git a/regen/mk_invlists.pl b/regen/mk_invlists.pl index 42f5b1c..ac0470c 100644 --- a/regen/mk_invlists.pl +++ b/regen/mk_invlists.pl @@ -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 - && 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; - if ($invlist->[0] != 0) { + if (@$invlist && $invlist->[0] != 0) { 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) { - 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'); - 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/; + } } } - 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