Skip to content

Commit

Permalink
create the :42 feature bundle
Browse files Browse the repository at this point in the history
The FEATURE_BUNDLE_xxx constants in feature.h must be ordered by
version. The 'as_bundles' sort function ensures that all bundles will
be sorted correctly (except for 5.9.5, which ends up between 5.41 and 41).
  • Loading branch information
book committed Dec 11, 2024
1 parent 2f81b2b commit 9393df2
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 10 deletions.
5 changes: 3 additions & 2 deletions lib/feature.pm

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 22 additions & 8 deletions regen/feature.pl
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,18 @@ BEGIN
"5.39" => [ +V5_39 ],
# using 5.41 features bundle
"5.41" => [ +V5_41 ],
# using 41 features bundle
"41" => [ +V5_41 ],
);

# actually, 5.9.5 ends up between 5.41 and 41
sub as_bundles {
$a eq 'default' ? -1 : $b eq 'default' ? 1 # default first
: $a eq 'all' ? 1 : $b eq 'all' ? -1 # all last
: $a =~ /\./ ? $b =~ /\./ ? $a cmp $b : -1 # 5.x in order, before
: $b =~ /\./ ? 1 : $a <=> $b; # integers in order
}

my @noops = qw( postderef lexical_subs );
my @removed = qw( array_base switch );

Expand All @@ -128,13 +138,18 @@ BEGIN
}

for (keys %feature_bundle) {
next unless /^5\.(\d*[13579])\z/;
$feature_bundle{"5.".($1+1)} ||= $feature_bundle{$_};
if (/^5\.(\d*[13579])\z/) { # 5.x dev series
$feature_bundle{"5.".($1+1)} ||= $feature_bundle{$_};
}
elsif (/^([4-9][13579]|[1-9][0-9]+[13579])\z/) { # 41 and above
$feature_bundle{($1+1)} ||= $feature_bundle{$_};
}
}
delete $feature_bundle{"5.42"}; # this one does not exist

my %UniqueBundles; # "say state switch" => 5.10
my %Aliases; # 5.12 => 5.11
for( sort keys %feature_bundle ) {
for( sort as_bundles keys %feature_bundle ) {
my $value = join(' ', sort @{$feature_bundle{$_}});
if (exists $UniqueBundles{$value}) {
$Aliases{$_} = $UniqueBundles{$value};
Expand All @@ -146,8 +161,7 @@ BEGIN
# start end
my %BundleRanges; # say => ['5.10', '5.15'] # unique bundles for values
for my $bund (
sort { $a eq 'default' ? -1 : $b eq 'default' ? 1 : $a cmp $b }
values %UniqueBundles
sort as_bundles values %UniqueBundles
) {
next if $bund =~ /[^\d.]/ and $bund ne 'default';
for (@{$feature_bundle{$bund}}) {
Expand Down Expand Up @@ -193,7 +207,7 @@ BEGIN
die "No HINT_UNI_8_BIT defined in perl.h" unless $Uni8Bit;

my @HintedBundles =
('default', grep !/[^\d.]/, sort values %UniqueBundles);
('default', grep !/[^\d.]/, sort as_bundles values %UniqueBundles);


###########################################################################
Expand Down Expand Up @@ -240,7 +254,7 @@ sub longest {
}
print $pm ");\n\n";

for (sort keys %Aliases) {
for (sort as_bundles keys %Aliases) {
print $pm
qq'\$feature_bundle{"$_"} = \$feature_bundle{"$Aliases{$_}"};\n';
};
Expand Down Expand Up @@ -277,7 +291,7 @@ sub longest {
$::bundle, $::feature
.

for ('default', sort grep /\.\d[02468]/, keys %feature_bundle) {
for ('default', sort as_bundles grep /[02468]\z/, keys %feature_bundle) {
$::bundle = ":$_";
$::feature = join ' ', @{$feature_bundle{$_}};
write $pm;
Expand Down

0 comments on commit 9393df2

Please sign in to comment.