From: Alexandre Duret-Lutz Date: Fri, 15 Nov 2002 10:12:11 +0000 (+0000) Subject: * lib/Automake/ConditionalSet.pm (_permutations_worker): Ignore TRUE X-Git-Tag: Release-1-7b~373 X-Git-Url: https://sourceware.org/git/?a=commitdiff_plain;h=92967d2efe3d5ce81bedb9d9bc499e09da660664;p=automake.git * lib/Automake/ConditionalSet.pm (_permutations_worker): Ignore TRUE conditions. (permutations): Treat empty permutations as TRUE. (invert): Simplify. Suggested by Raja R Harinath. --- diff --git a/ChangeLog b/ChangeLog index 519b1b89..27521ac0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2002-11-15 Alexandre Duret-Lutz + + * lib/Automake/ConditionalSet.pm (_permutations_worker): Ignore TRUE + conditions. + (permutations): Treat empty permutations as TRUE. + (invert): Simplify. + Suggested by Raja R Harinath. + 2002-11-14 Alexandre Duret-Lutz * automake.in (variable_defined): Thinko. diff --git a/lib/Automake/ConditionalSet.pm b/lib/Automake/ConditionalSet.pm index c0020961..1a630c78 100644 --- a/lib/Automake/ConditionalSet.pm +++ b/lib/Automake/ConditionalSet.pm @@ -2,7 +2,7 @@ package Automake::ConditionalSet; use Carp; use strict; -use Automake::Conditional; +use Automake::Conditional qw/TRUE FALSE/; =head1 NAME @@ -247,23 +247,23 @@ sub _permutations_worker (@) return () unless @conds; my $cond = shift @conds; + + # Ignore "TRUE" conditions, since they add nothing to permutations. + return &_permutations_worker (@conds) if $cond eq "TRUE"; + (my $neg = $cond) =~ s/TRUE$/FALSE/; # Recurse. - - # Don't merge `FALSE' conditions, since this will just create - # a false Conditional, and we'll drop them later in ConditionalSet. - # (Dropping them now limits the combinatoric explosion.) my @ret = (); foreach my $c (&_permutations_worker (@conds)) { push (@ret, $c->merge_conds ($cond)); - push (@ret, $c->merge_conds ($neg)) if $neg ne 'FALSE'; + push (@ret, $c->merge_conds ($neg)); } if (! @ret) { push (@ret, new Automake::Conditional $cond); - push (@ret, new Automake::Conditional $neg) if $neg ne 'FALSE'; + push (@ret, new Automake::Conditional $neg); } return @ret; @@ -311,6 +311,9 @@ sub permutations ($ ) } my @res = _permutations_worker (keys %atomic_conds); + # An empty permutation is TRUE, because we ignore TRUE conditions + # in the recursions. + @res = (TRUE) unless @res; my $res = new Automake::ConditionalSet @res; $self->{'permutations'} = $res; @@ -343,24 +346,17 @@ sub invert($ ) # Generate permutations for all subconditions. my @perm = $self->permutations->conds; - # Remove redundant conditions. - @perm = Automake::Conditional::reduce @perm; # Now remove all conditions which imply one of the input conditions. my @conds = $self->conds; - my @notconds = (); - foreach my $perm (@perm) - { - push @notconds, $perm - if ! $perm->implies_any (@conds); - } - + my @notconds = + grep { ! $_->implies_any (@conds) } $self->permutations->conds; my $res = new Automake::ConditionalSet @notconds; # Cache result. $self->{'invert'} = $res; # It's tempting to also set $res->{'invert'} to $self, but that - # isn't a bad idea as $self hasn't been normalized in any way. + # is a bad idea as $self hasn't been normalized in any way. # (Different inputs can produce the same inverted set.) return $res; }