]> git.ipfire.org Git - thirdparty/automake.git/commitdiff
automake: Don't rely on List::Util to provide 'none'
authorMathieu Lirzin <mthl@gnu.org>
Sat, 3 Mar 2018 22:50:10 +0000 (23:50 +0100)
committerMathieu Lirzin <mthl@gnu.org>
Thu, 8 Mar 2018 20:33:14 +0000 (21:33 +0100)
This change fixes automake bug#30631.

This removes the use of List::Util which is not supported by Perl 5.6,
by reimplementing the 'none' subroutine.

* lib/Automake/General.pm (none): New subroutine.
* bin/automake.in (handle_single_transform): Use it.
* t/pm/General.pl: New test.
* t/list-of-tests.mk (perl_TESTS): Add it.
* NEWS: Update.

NEWS
bin/automake.in
lib/Automake/General.pm
t/list-of-tests.mk
t/pm/General.pl [new file with mode: 0644]

diff --git a/NEWS b/NEWS
index f2cedfc4847eb538ad6b9497cdf397dfdb1eb8ee..ae26be3bd0afcb79cb8fefa0492f29701d706583 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -66,6 +66,9 @@ New in ?.?.?:
 
 * Bugs fixed:
 
+  - 'automake' does not depend on the 'none' subroutine of the List::Util
+    module anymore to support older Perl version. (automake bug#30631)
+
   - A regression in AM_PYTHON_PATH causing the rejection of non literal
     minimum version parameter hasn't been fixed. (automake bug#30616)
 
index 16fb45182640da539885be1124223ed71f5225e2..a52a48951b02b158d68e0d55e4985a04e8cf68e6 100644 (file)
@@ -73,7 +73,6 @@ use Automake::Wrap 'makefile_wrap';
 use Automake::Language;
 use File::Basename;
 use File::Spec;
-use List::Util 'none';
 use Carp;
 
 ## ----------------------- ##
@@ -1793,7 +1792,7 @@ sub handle_single_transform
                 my $dname = $derived;
                 if ($directory ne ''
                     && option 'subdir-objects'
-                    && none { $dname =~ /$_$/ } @dup_shortnames)
+                    && none { $dname =~ /$_[0]$/ } @dup_shortnames)
                   {
                     # At this point, we don't clear information about what
                     # parts of $derived are truly file name components.  We can
index 32f5c8db74124f5763d492ba08e0758d6fb0c677..aa2de38b8d98acd573d4c28110e97b4d1bde85e7 100644 (file)
@@ -23,7 +23,7 @@ use File::Basename;
 use vars qw (@ISA @EXPORT);
 
 @ISA = qw (Exporter);
-@EXPORT = qw (&uniq $me);
+@EXPORT = qw (&uniq &none $me);
 
 # Variable we share with the main package.  Be sure to have a single
 # copy of them: using 'my' together with multiple inclusion of this
@@ -66,5 +66,23 @@ sub uniq (@)
    return wantarray ? @res : "@res";
 }
 
+# $RES
+# none (&PRED, @LIST)
+# ------------
+# Return 1 when no element in LIST satisfies predicate PRED otherwise 0.
+sub none (&@)
+{
+  my ($pred, @list) = @_;
+  my $res = 1;
+  foreach my $item (@list)
+    {
+      if ($pred->($item))
+        {
+          $res = 0;
+          last;
+        }
+    }
+  return $res;
+}
 
 1; # for require
index 271bfb5738275091e52d0409106e71fa825f433c..84dd29af0f87eb587bc19194347c1bc099450a62 100644 (file)
@@ -54,6 +54,7 @@ t/pm/DisjCon2.pl \
 t/pm/DisjCon3.pl \
 t/pm/DisjConditions.pl \
 t/pm/DisjConditions-t.pl \
+t/pm/General.pl \
 t/pm/Version.pl \
 t/pm/Version2.pl \
 t/pm/Version3.pl \
diff --git a/t/pm/General.pl b/t/pm/General.pl
new file mode 100644 (file)
index 0000000..0caefe7
--- /dev/null
@@ -0,0 +1,27 @@
+# Copyright (C) 2018 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <https://www.gnu.org/licenses/>.
+
+use Automake::General;
+
+my $failed = 0;
+
+# Check 'none'.
+my $none_positive = none { $_[0] < 0 } (1, 7, 3, 8, 9);
+$failed = 1 if ($none_positive == 0);
+
+my $none_gt_8 = none { $_[0] >= 8 } (1, 7, 3, 8, 9);
+$failed = 1 if ($none_gt_8 == 1);
+
+exit $failed;