This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
regen/mk_invlists.pl: reformulate a branch and outdent
authorKarl Williamson <khw@cpan.org>
Sat, 16 Dec 2017 18:53:15 +0000 (11:53 -0700)
committerKarl Williamson <khw@cpan.org>
Sun, 17 Dec 2017 04:56:50 +0000 (21:56 -0700)
This turns a test whose one branch dies into a postfix type, which means
there is no need for an else, and that code can be outdented.

charclass_invlists.h
regen/mk_invlists.pl

index b140688..ec7f796 100644 (file)
@@ -97457,5 +97457,5 @@ static const U8 WB_table[24][24] = {
  * 10cb8c6f35fc78401bca052127e19f7906cece98f64e5340003314d4fe8f66d2 lib/unicore/mktables
  * 21653d2744fdd071f9ef138c805393901bb9547cf3e777ebf50215a191f986ea lib/unicore/version
  * 913d2f93f3cb6cdf1664db888bf840bc4eb074eef824e082fceda24a9445e60c regen/charset_translations.pl
- * 3c78a5d6d227dd5c8bb385d9183096ac565b08bd81c245d558a94fc9afcda35e regen/mk_invlists.pl
+ * 6eea8721774d54b2da54d130ae4e568a486cc2f2572a5a55dec021e3c5d2294d regen/mk_invlists.pl
  * ex: set ro: */
index 7272251..8b40c54 100644 (file)
@@ -310,143 +310,142 @@ sub output_invmap ($$$$$$$) {
             @enums = uniques(@$invmap);
         }
 
-        if (! @enums) {
-            die "Only enum properties are currently handled; '$prop_name' isn't one";
-        }
-        else {
-            my @expected_enums = @{$hard_coded_enums{lc $short_name}};
-            my @canonical_input_enums;
-            if (@expected_enums) {
-                if (@expected_enums < @enums) {
-                    die 'You need to update %hard_coded_enums to reflect new'
-                    . " entries in this Unicode version\n"
-                    . "Expected: " . join(", ", sort @expected_enums) . "\n"
-                    . "     Got: " . join(", ", sort @enums);
-                }
-
-                if (! defined prop_aliases($prop_name)) {
 
-                    # Convert the input enums into canonical form and
-                    # save for use below
-                    @canonical_input_enums = map { lc ($_ =~ s/_//gr) }
-                                                                    @enums;
-                }
-                @enums = sort @expected_enums;
+        die "Only enum properties are currently handled; '$prop_name' isn't one"
+                                                                  unless @enums;
+
+        my @expected_enums = @{$hard_coded_enums{lc $short_name}};
+        my @canonical_input_enums;
+        if (@expected_enums) {
+            if (@expected_enums < @enums) {
+                die 'You need to update %hard_coded_enums to reflect new'
+                . " entries in this Unicode version\n"
+                . "Expected: " . join(", ", sort @expected_enums) . "\n"
+                . "     Got: " . join(", ", sort @enums);
             }
 
-            # The internal enums come last, and in the order specified
-            my @extras;
-            if ($extra_enums ne "") {
-                @extras = split /,/, $extra_enums;
-                push @enums, @extras;
-            }
+            if (! defined prop_aliases($prop_name)) {
 
-            # Assign a value to each element of the enum.  The default
-            # value always gets 0; the others are arbitrarily assigned.
-            my $enum_val = 0;
-            my $canonical_default = prop_value_aliases($prop_name, $default);
-            $default = $canonical_default if defined $canonical_default;
-            $enums{$default} = $enum_val++;
-            for my $enum (@enums) {
-                $enums{$enum} = $enum_val++ unless exists $enums{$enum};
+                # Convert the input enums into canonical form and
+                # save for use below
+                @canonical_input_enums = map { lc ($_ =~ s/_//gr) }
+                                                                @enums;
             }
+            @enums = sort @expected_enums;
+        }
 
-            # Calculate the enum values for certain properties like
-            # _Perl_GCB and _Perl_LB, because we output special tables for
-            # them.
-            if ($name =~ / ^  _Perl_ (?: GCB | LB | WB ) $ /x) {
-
-                # We use string evals to allow the same code to work on
-                # all tables we're doing.
-                my $type = lc $prop_name;
-
-                # We use lowercase single letter names for any property
-                # values not in the release of Unicode being compiled now.
-                my $placeholder = "a";
-
-                # Skip if we've already done this code, which populated
-                # this hash
-                if (eval "! \%${type}_enums") {
-
-                    # For each enum ...
-                    foreach my $enum (sort keys %enums) {
-                        my $value = $enums{$enum};
-                        my $short;
-                        my $abbreviated_from;
-
-                        # Special case this wb property value to make the
-                        # name more clear
-                        if ($enum eq 'Perl_Tailored_HSpace') {
-                            $short = 'hs';
-                            $abbreviated_from = $enum;
-                        }
-                        elsif (grep { $_ eq $enum } @extras) {
+        # The internal enums come last, and in the order specified
+        my @extras;
+        if ($extra_enums ne "") {
+            @extras = split /,/, $extra_enums;
+            push @enums, @extras;
+        }
 
-                            # The 'short' name for one of the property
-                            # values added by this file is just the
-                            # lowercase of it
-                            $short = lc $enum;
-                        }
-                        elsif (grep {$_ eq lc ( $enum =~ s/_//gr) }
-                                                    @canonical_input_enums)
-                        {   # On Unicode versions that predate the
-                            # official property, we have set up this array
-                            # to be the canonical form of each enum in the
-                            # substitute property.  If the enum we're
-                            # looking at is canonically the same as one of
-                            # these, use its name instead of generating a
-                            # placeholder one in the next clause (which
-                            # will happen because prop_value_aliases()
-                            # will fail because it only works on official
-                            # properties)
-                            $short = $enum;
-                        }
-                        else {
-                            # Use the official short name for the other
-                            # property values, which should all be
-                            # official ones.
-                            ($short) = prop_value_aliases($type, $enum);
-
-                            # But create a placeholder for ones not in
-                            # this Unicode version.
-                            $short = $placeholder++ unless defined $short;
-                        }
+        # Assign a value to each element of the enum.  The default
+        # value always gets 0; the others are arbitrarily assigned.
+        my $enum_val = 0;
+        my $canonical_default = prop_value_aliases($prop_name, $default);
+        $default = $canonical_default if defined $canonical_default;
+        $enums{$default} = $enum_val++;
+        for my $enum (@enums) {
+            $enums{$enum} = $enum_val++ unless exists $enums{$enum};
+        }
+
+        # Calculate the enum values for certain properties like
+        # _Perl_GCB and _Perl_LB, because we output special tables for
+        # them.
+        if ($name =~ / ^  _Perl_ (?: GCB | LB | WB ) $ /x) {
+
+            # We use string evals to allow the same code to work on
+            # all tables we're doing.
+            my $type = lc $prop_name;
+
+            # We use lowercase single letter names for any property
+            # values not in the release of Unicode being compiled now.
+            my $placeholder = "a";
+
+            # Skip if we've already done this code, which populated
+            # this hash
+            if (eval "! \%${type}_enums") {
+
+                # For each enum ...
+                foreach my $enum (sort keys %enums) {
+                    my $value = $enums{$enum};
+                    my $short;
+                    my $abbreviated_from;
+
+                    # Special case this wb property value to make the
+                    # name more clear
+                    if ($enum eq 'Perl_Tailored_HSpace') {
+                        $short = 'hs';
+                        $abbreviated_from = $enum;
+                    }
+                    elsif (grep { $_ eq $enum } @extras) {
+
+                        # The 'short' name for one of the property
+                        # values added by this file is just the
+                        # lowercase of it
+                        $short = lc $enum;
+                    }
+                    elsif (grep {$_ eq lc ( $enum =~ s/_//gr) }
+                                                @canonical_input_enums)
+                    {   # On Unicode versions that predate the
+                        # official property, we have set up this array
+                        # to be the canonical form of each enum in the
+                        # substitute property.  If the enum we're
+                        # looking at is canonically the same as one of
+                        # these, use its name instead of generating a
+                        # placeholder one in the next clause (which
+                        # will happen because prop_value_aliases()
+                        # will fail because it only works on official
+                        # properties)
+                        $short = $enum;
+                    }
+                    else {
+                        # Use the official short name for the other
+                        # property values, which should all be
+                        # official ones.
+                        ($short) = prop_value_aliases($type, $enum);
+
+                        # But create a placeholder for ones not in
+                        # this Unicode version.
+                        $short = $placeholder++ unless defined $short;
+                    }
 
-                        # If our short name is too long, or we already
-                        # know that the name is an abbreviation, truncate
-                        # to make sure it's short enough, and remember
-                        # that we did this so we can later place in a
-                        # comment in the generated file
-                        if (   $abbreviated_from
-                            || length $short > $max_hdr_len)
-                            {
-                            $short = substr($short, 0, $max_hdr_len);
-                            $abbreviated_from = $enum
-                                                unless $abbreviated_from;
-                            # If the name we are to display conflicts, try
-                            # another.
-                            while (eval "exists
-                                            \$${type}_abbreviations{$short}")
-                            {
-                                die $@ if $@;
-                                $short++;
-                            }
-
-                            eval "\$${type}_abbreviations{$short} = '$enum'";
+                    # If our short name is too long, or we already
+                    # know that the name is an abbreviation, truncate
+                    # to make sure it's short enough, and remember
+                    # that we did this so we can later place in a
+                    # comment in the generated file
+                    if (   $abbreviated_from
+                        || length $short > $max_hdr_len)
+                        {
+                        $short = substr($short, 0, $max_hdr_len);
+                        $abbreviated_from = $enum
+                                            unless $abbreviated_from;
+                        # If the name we are to display conflicts, try
+                        # another.
+                        while (eval "exists
+                                        \$${type}_abbreviations{$short}")
+                        {
                             die $@ if $@;
+                            $short++;
                         }
 
-                        # Remember the mapping from the property value
-                        # (enum) name to its value.
-                        eval "\$${type}_enums{$enum} = $value";
-                        die $@ if $@;
-
-                        # Remember the inverse mapping to the short name
-                        # so that we can properly label the generated
-                        # table's rows and columns
-                        eval "\$${type}_short_enums[$value] = '$short'";
+                        eval "\$${type}_abbreviations{$short} = '$enum'";
                         die $@ if $@;
                     }
+
+                    # Remember the mapping from the property value
+                    # (enum) name to its value.
+                    eval "\$${type}_enums{$enum} = $value";
+                    die $@ if $@;
+
+                    # Remember the inverse mapping to the short name
+                    # so that we can properly label the generated
+                    # table's rows and columns
+                    eval "\$${type}_short_enums[$value] = '$short'";
+                    die $@ if $@;
                 }
             }
         }