[lintian] 01/03: L::Relation: Special-case "and" with exactly one non empty arg
This is an automated email from the git hooks/post-receive script.
nthykier pushed a commit to branch master
in repository lintian.
commit af374e3da1ded74804d01931c3da2c895b778c14
Author: Niels Thykier <niels@thykier.net>
Date: Thu Feb 4 22:26:30 2016 +0000
L::Relation: Special-case "and" with exactly one non empty arg
Signed-off-by: Niels Thykier <niels@thykier.net>
---
lib/Lintian/Relation.pm | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/lib/Lintian/Relation.pm b/lib/Lintian/Relation.pm
index 9599de1..63805fb 100644
--- a/lib/Lintian/Relation.pm
+++ b/lib/Lintian/Relation.pm
@@ -252,7 +252,7 @@ are Lintian::Relation objects already.
sub and {
my ($class, @args) = @_;
- my @result;
+ my (@result, $last_rel, $rels);
foreach my $arg (@args) {
my $rel = $arg;
unless ($arg && ref $arg eq 'Lintian::Relation') {
@@ -260,6 +260,9 @@ sub and {
next unless $arg;
$rel = Lintian::Relation->new($arg);
}
+ next if $rel->empty;
+ ++$rels;
+ $last_rel = $rel;
if ($rel->[0] eq 'AND') {
my @r = @$rel;
push @result, @r[1..$#r];
@@ -270,6 +273,7 @@ sub and {
if ($class eq 'Lintian::Relation') {
return $EMPTY_RELATION if not @result;
+ return $last_rel if $rels == 1;
}
my $self;
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/lintian/lintian.git
Reply to: