]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
util/mkinstallvars.pl: replace List::Util::pairs with out own
authorRichard Levitte <levitte@openssl.org>
Tue, 3 Sep 2024 17:16:05 +0000 (19:16 +0200)
committerTomas Mraz <tomas@openssl.org>
Thu, 5 Sep 2024 07:04:28 +0000 (09:04 +0200)
Unfortunately, List::Util::pairs didn't appear in perl core modules
before 5.19.3, and our minimum requirement is 5.10.

Fortunately, we already have a replacement implementation, and can
re-apply it in this script.

Fixes #25366

Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/25367)

util/mkinstallvars.pl

index 52a3d607bde8b21c3bcdf194e7151377967ed1e0..950edf173382e1b3171a1df95cd868b8a29a2c95 100644 (file)
 # form, or passed as variable assignments on the command line.
 # The result is a Perl module creating the package OpenSSL::safe::installdata.
 
+use 5.10.0;
+use strict;
+use warnings;
+use Carp;
+
 use File::Spec;
-use List::Util qw(pairs);
+#use List::Util qw(pairs);
+sub _pairs (@);
 
 # These are expected to be set up as absolute directories
 my @absolutes = qw(PREFIX libdir);
@@ -19,9 +25,9 @@ my @absolutes = qw(PREFIX libdir);
 # as subdirectories to PREFIX or LIBDIR.  The order of the pairs is important,
 # since the LIBDIR subdirectories depend on the calculation of LIBDIR from
 # PREFIX.
-my @subdirs = pairs (PREFIX => [ qw(BINDIR LIBDIR INCLUDEDIR APPLINKDIR) ],
-                     LIBDIR => [ qw(ENGINESDIR MODULESDIR PKGCONFIGDIR
-                                    CMAKECONFIGDIR) ]);
+my @subdirs = _pairs (PREFIX => [ qw(BINDIR LIBDIR INCLUDEDIR APPLINKDIR) ],
+                      LIBDIR => [ qw(ENGINESDIR MODULESDIR PKGCONFIGDIR
+                                     CMAKECONFIGDIR) ]);
 # For completeness, other expected variables
 my @others = qw(VERSION LDLIBS);
 
@@ -151,3 +157,26 @@ our \@LDLIBS                     =
 
 1;
 _____
+
+######## Helpers
+
+# _pairs LIST
+#
+# This operates on an even-sized list, and returns a list of "ARRAY"
+# references, each containing two items from the given LIST.
+#
+# It is a quick cheap reimplementation of List::Util::pairs(), a function
+# we cannot use, because it only appeared in perl v5.19.3, and we claim to
+# support perl versions all the way back to v5.10.
+
+sub _pairs (@) {
+    croak "Odd number of arguments" if @_ & 1;
+
+    my @pairlist = ();
+
+    while (@_) {
+        my $x = [ shift, shift ];
+        push @pairlist, $x;
+    }
+    return @pairlist;
+}