From: H.Merijn Brand Date: Fri, 21 Aug 2020 13:46:22 +0000 (+0200) Subject: Modernize getverlist X-Git-Tag: 5.34.0~17 X-Git-Url: https://perl5.git.perl.org/metaconfig.git/commitdiff_plain/a464ca209b0a081acb31b8aa06888b1d043af677 Modernize getverlist - use strict/warnings - pack "s>s>s>" to ensure best sorting - fix small typo in comment --- diff --git a/U/installdirs/inc_version_list.U b/U/installdirs/inc_version_list.U index 8a6548b..ca2eadf 100644 --- a/U/installdirs/inc_version_list.U +++ b/U/installdirs/inc_version_list.U @@ -51,37 +51,39 @@ ?T:stem : Determine list of previous versions to include in @INC $cat > getverlist <> getverlist <<'EOPL' -# The list found is store twice for each entry: the original name, and -# the binary broken down version as pack "sss", so sorting is easy and -# unambiguous. This will work for all versions that have a maximum of -# three digit groups, separate by '.'s or '_'s. Names are extended with -# ".0.0" to ensure at least three elements for the pack. -# -- H.Merijn Brand (m)'06 23-10-2006 +# The list found is stored twice for each entry: the original name, and +# the binary broken down version into pack "s>s>s>", so sorting is easy +# and unambiguous. This will work for all versions that have a maximum +# of three digit per group separate by '.'s or '_'s. Names are extended +# with ".0.0" to ensure at least three elements for the pack. +# -- H.Merijn Brand (m)'06 23-10-2006 -# Can't have leading @ because metaconfig interprets it as a command! -;@inc_version_list=(); +my @inc_version_list; +my @candidates; # XXX Redo to do opendir/readdir? if (-d $stem) { chdir($stem); ;@candidates = map { - [ $_, pack "sss", split m/[._]/, "$_.0.0" ] } glob("5.*"); + [ $_, pack "s>s>s>", split m/[._]/, "$_.0.0" ] } glob("5.*"); ;@candidates = sort { $a->[1] cmp $b->[1]} @candidates; } else { ;@candidates = (); } -($pversion, $aversion, $vsn5005) = map { - pack "sss", split m/[._]/, "$_.0.0" } $version, $api_versionstring, "5.005"; -foreach $d (@candidates) { +my ($pversion, $aversion, $vsn5005) = map { + pack "s>s>s>", split m/[._]/, "$_.0.0" } $version, $api_versionstring, "5.005"; +foreach my $d (@candidates) { if ($d->[1] lt $pversion) { if ($d->[1] ge $aversion) { unshift(@inc_version_list, grep { -d } $d->[0]."/$archname", $d->[0]);