summaryrefslogtreecommitdiff
path: root/regen
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2011-12-22 10:05:16 -0800
committerFather Chrysostomos <sprout@cpan.org>2011-12-24 09:25:13 -0800
commit88da30d732bdf35367c4008b31d9d07c1022434a (patch)
treeb9bbdc89329350f8af6ae9e844c3e389a2a894cf /regen
parent11b275493edbf41bb61a1176850d2f49ab83398a (diff)
downloadperl-88da30d732bdf35367c4008b31d9d07c1022434a.tar.gz
feature.pl: Gen %feature_bundle from %UniqueBundles
%UniqueBundles was added for generating constants in feature.h, but we can use it for feature.pm’s %feature_bundle as well, simplify- ing the code. This eliminates this piece of code in feature.pm, spelling it out longhand: # Each of these is the same as the previous bundle for (12,13,14,16) { $feature_bundle{"5.$_"} = $feature_bundle{"5.".($_-1)} } While that code might be neat, it would make the generation code unduly complex. (It was designed for hand-editing anyway.)
Diffstat (limited to 'regen')
-rw-r--r--regen/feature.pl34
1 files changed, 11 insertions, 23 deletions
diff --git a/regen/feature.pl b/regen/feature.pl
index d4e23368a3..018ed0f7ef 100644
--- a/regen/feature.pl
+++ b/regen/feature.pl
@@ -98,31 +98,19 @@ for(sort { length $a <=> length $b } keys %default_feature) {
print $pm ");\n\n";
print $pm "our %feature_bundle = (\n";
-my $prevkey;
-my $prev;
-my @same;
-$width = length longest keys %feature_bundle;
-for( sort keys %feature_bundle ) {
- my $value = join(' ', sort @{$feature_bundle{$_}});
- if (/^5\.\d\d\z/ && $prevkey
- && substr($_,-2) - substr($prevkey,-2) == 1 && $value eq $prev) {
- push @same, $_;
- $prevkey = $_;
- next;
- }
- if(/^5\.\d\d\z/) {
- $prev = $value;
- $prevkey = $_;
- }
- print $pm qq' "$_"' . " "x($width-length) . qq' => [qw($value)],\n';
+$width = length longest values %UniqueBundles;
+for( sort { $UniqueBundles{$a} cmp $UniqueBundles{$b} }
+ keys %UniqueBundles ) {
+ my $bund = $UniqueBundles{$_};
+ print $pm qq' "$bund"' . " "x($width-length $bund)
+ . qq' => [qw($_)],\n';
}
print $pm ");\n\n";
-print $pm "
-# Each of these is the same as the previous bundle
-for (", join(',',map /\.(.*)/, @same), ') {
- $feature_bundle{"5.$_"} = $feature_bundle{"5.".($_-1)}
-}';
+for (sort keys %Aliases) {
+ print $pm
+ qq'\$feature_bundle{"$_"} = \$feature_bundle{"$Aliases{$_}"};\n';
+};
while (<DATA>) {
@@ -144,7 +132,7 @@ perlh: {
or die "Non-contiguous bits in $bits (binary for $hex):\n\n$_\n ";
$HintShift = length $1;
my $bits_needed =
- length sprintf "%b", scalar keys(%feature_bundle) - @same;
+ length sprintf "%b", scalar keys %UniqueBundles;
$bits =~ /1{$bits_needed}/
or die "Not enough bits (need $bits_needed)"
. " in $bits (binary for $hex):\n\n$_\n";