From: Alexandre Duret-Lutz Date: Sun, 2 Feb 2003 10:09:25 +0000 (+0000) Subject: * lib/Automake/DisjConditions.pm (_permutations_worker) X-Git-Tag: Release-1-7-2b~23 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7df3c151557172baa91a599ac63965629472ba1c;p=thirdparty%2Fautomake.git * lib/Automake/DisjConditions.pm (_permutations_worker) (permutations): Remove, so that people aren't tempted to use it. * lib/Automake/tests/DisjConditions.pl (tests_permutations): Remove. --- diff --git a/ChangeLog b/ChangeLog index 718f3eca7..52480c754 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2003-02-02 Alexandre Duret-Lutz + * lib/Automake/DisjConditions.pm (_permutations_worker) + (permutations): Remove, so that people aren't tempted to use it. + * lib/Automake/tests/DisjConditions.pl (tests_permutations): Remove. + * automake.in (variable_conditions_recursive): Remove. (variable_conditionally_defined): Rewrite using traverse_variable_recursively. diff --git a/lib/Automake/DisjConditions.pm b/lib/Automake/DisjConditions.pm index 305dbc9ed..48dca6eb2 100644 --- a/lib/Automake/DisjConditions.pm +++ b/lib/Automake/DisjConditions.pm @@ -61,10 +61,6 @@ Automake::DisjConditions - record a disjunction of Conditions # "(COND1 and !COND2) or (!COND3)" my $str = $set->human; - # Build a new DisjConditions from the permuation of all - # Conditions appearing in $set. - my $perm = $set->permutations; - # Invert a DisjConditions, i.e., create a new DisjConditions # that complements $set. my $inv = $set->invert; @@ -293,86 +289,6 @@ sub human ($ ) } -sub _permutations_worker (@) -{ - my @conds = @_; - 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. - my @ret = (); - foreach my $c (&_permutations_worker (@conds)) - { - push (@ret, $c->merge_conds ($cond)); - push (@ret, $c->merge_conds ($neg)); - } - if (! @ret) - { - push (@ret, new Automake::Condition $cond); - push (@ret, new Automake::Condition $neg); - } - - return @ret; -} - -=item C<$perm = $set-Epermutations> - -Return a permutations of the conditions involved in a C. - -For instance consider this initial C. - - my $set = new Automake::DisjConditions - (new Automake::Condition ("COND1_TRUE", "COND2_TRUE"), - new Automake::Condition ("COND3_FALSE", "COND2_TRUE")); - -Calling C<$set-Epermutations> will return the following DisjConditions. - - new Automake::DisjConditions - (new Automake::Condition ("COND1_TRUE", "COND2_TRUE", "COND3_TRUE"), - new Automake::Condition ("COND1_FALSE","COND2_TRUE", "COND3_TRUE"), - new Automake::Condition ("COND1_TRUE", "COND2_FALSE","COND3_TRUE"), - new Automake::Condition ("COND1_FALSE","COND2_FALSE","COND3_TRUE"), - new Automake::Condition ("COND1_TRUE", "COND2_TRUE", "COND3_FALSE"), - new Automake::Condition ("COND1_FALSE","COND2_TRUE", "COND3_FALSE"), - new Automake::Condition ("COND1_TRUE", "COND2_FALSE","COND3_FALSE"), - new Automake::Condition ("COND1_FALSE","COND2_FALSE","COND3_FALSE")); - -=cut - -sub permutations ($ ) -{ - my ($self) = @_; - - return $self->{'permutations'} if defined $self->{'permutations'}; - - my %atomic_conds = (); - - for my $conditional ($self->conds) - { - for my $cond ($conditional->conds) - { - $cond =~ s/FALSE$/TRUE/; - $atomic_conds{$cond} = 1; - } - } - - 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::DisjConditions @res; - - $self->{'permutations'} = $res; - - return $res; -} - =item C<$prod = $set1->multiply ($set2)> Multiply two conditional sets. diff --git a/lib/Automake/tests/DisjConditions.pl b/lib/Automake/tests/DisjConditions.pl index 6d76e66a1..b5147ebca 100644 --- a/lib/Automake/tests/DisjConditions.pl +++ b/lib/Automake/tests/DisjConditions.pl @@ -44,61 +44,6 @@ sub build_set (@) return new Automake::DisjConditions @set; } -sub test_permutations () -{ - my @tests = ([[["FALSE"]], - [["TRUE"]]], - - [[["TRUE"]], - [["TRUE"]]], - - [[["COND1_TRUE", "COND2_TRUE"], - ["COND3_FALSE", "COND2_TRUE"]], - [["COND1_FALSE","COND2_FALSE","COND3_FALSE"], - ["COND1_TRUE", "COND2_FALSE","COND3_FALSE"], - ["COND1_FALSE","COND2_TRUE", "COND3_FALSE"], - ["COND1_TRUE", "COND2_TRUE", "COND3_FALSE"], - ["COND1_FALSE","COND2_FALSE","COND3_TRUE"], - ["COND1_TRUE", "COND2_FALSE","COND3_TRUE"], - ["COND1_FALSE","COND2_TRUE", "COND3_TRUE"], - ["COND1_TRUE", "COND2_TRUE", "COND3_TRUE"]]], - - [[["COND1_TRUE", "COND2_TRUE"], - ["TRUE"]], - [["COND1_TRUE", "COND2_TRUE"], - ["COND1_FALSE", "COND2_TRUE"], - ["COND1_FALSE", "COND2_FALSE"], - ["COND1_TRUE", "COND2_FALSE"]]], - - [[["COND1_TRUE", "COND2_TRUE"], - ["FALSE"]], - [["COND1_TRUE", "COND2_TRUE"], - ["COND1_FALSE", "COND2_TRUE"], - ["COND1_FALSE", "COND2_FALSE"], - ["COND1_TRUE", "COND2_FALSE"]]], - - [[["COND1_TRUE"], - ["COND2_FALSE"]], - [["COND1_TRUE", "COND2_TRUE"], - ["COND1_FALSE", "COND2_TRUE"], - ["COND1_FALSE", "COND2_FALSE"], - ["COND1_TRUE", "COND2_FALSE"]]] - ); - - for my $t (@tests) - { - my $set = build_set @{$t->[0]}; - my $res = build_set @{$t->[1]}; - my $per = $set->permutations; - if ($per != $res) - { - print " (P) " . $per->string . ' != ' . $res->string . "\n"; - return 1; - } - } - return 0; -} - sub test_invert () { my @tests = ([[["FALSE"]], @@ -302,7 +247,7 @@ sub test_simplify () # Also exercize invert() while we are at it. - # FIXME: Don't run invert() with too much conditions, this is too slow. + # FIXME: Can't run invert() with too much conditions, this is too slow. next if $#{$t->[0][0]} > 8; my $inv1 = $set->invert->simplify; @@ -381,7 +326,6 @@ sub test_sub_conditions () } exit (test_basics - || test_permutations || test_invert || test_simplify || test_sub_conditions);