summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMathieu Lirzin <mthl@gnu.org>2018-03-03 23:50:10 +0100
committerMathieu Lirzin <mthl@gnu.org>2018-03-08 21:33:14 +0100
commit74902aa24d4c313ab51fa684142d9240f636971a (patch)
treef906ad5581f51d5ebf5159643d27ae0594396ac1
parent9385c161707c6d2295d610eef81fe4d1a44b44de (diff)
downloadautomake-74902aa24d4c313ab51fa684142d9240f636971a.tar.gz
automake: Don't rely on List::Util to provide 'none'
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.
-rw-r--r--NEWS3
-rw-r--r--bin/automake.in3
-rw-r--r--lib/Automake/General.pm20
-rw-r--r--t/list-of-tests.mk1
-rw-r--r--t/pm/General.pl27
5 files changed, 51 insertions, 3 deletions
diff --git a/NEWS b/NEWS
index f2cedfc48..ae26be3bd 100644
--- 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)
diff --git a/bin/automake.in b/bin/automake.in
index 16fb45182..a52a48951 100644
--- a/bin/automake.in
+++ b/bin/automake.in
@@ -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
diff --git a/lib/Automake/General.pm b/lib/Automake/General.pm
index 32f5c8db7..aa2de38b8 100644
--- a/lib/Automake/General.pm
+++ b/lib/Automake/General.pm
@@ -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
diff --git a/t/list-of-tests.mk b/t/list-of-tests.mk
index 271bfb573..84dd29af0 100644
--- a/t/list-of-tests.mk
+++ b/t/list-of-tests.mk
@@ -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
index 000000000..0caefe7cf
--- /dev/null
+++ b/t/pm/General.pl
@@ -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;