Index: ChangeLog from Raja R Harinath * lib/Automake/DisjConditions.pm (ambiguous_p): Simplify slightly. * lib/Automake/tests/DisjConditions.pl (test_ambig): Test Automake::Disjunctions::ambiguous_p. Index: lib/Automake/DisjConditions.pm =================================================================== RCS file: /cvs/automake/automake/lib/Automake/DisjConditions.pm,v retrieving revision 1.7 diff -u -p -r1.7 DisjConditions.pm --- lib/Automake/DisjConditions.pm 7 Aug 2003 21:20:12 -0000 1.7 +++ lib/Automake/DisjConditions.pm 9 Aug 2003 00:15:31 -0000 @@ -456,41 +456,35 @@ already been defined. sub ambiguous_p ($$$) { - my ($condset, $var, $cond) = @_; + my ($self, $var, $cond) = @_; - foreach my $vcond ($condset->conds) + # Note that these rules doesn't consider the following + # example as ambiguous. + # + # if COND1 + # FOO = foo + # endif + # if COND2 + # FOO = bar + # endif + # + # It's up to the user to not define COND1 and COND2 + # simultaneously. + + return ("$var multiply defined in condition " . $cond->human, $cond) + if exists $self->{'hash'}{$cond}; + + foreach my $vcond ($self->conds) { - # Note that these rules doesn't consider the following - # example as ambiguous. - # - # if COND1 - # FOO = foo - # endif - # if COND2 - # FOO = bar - # endif - # - # It's up to the user to not define COND1 and COND2 - # simultaneously. - my $message; - if ($vcond eq $cond) - { - return ("$var multiply defined in condition " . $cond->human, - $vcond); - } - elsif ($vcond->true_when ($cond)) - { - return ("$var was already defined in condition " . $vcond->human - . ", which implies condition ". $cond->human, $vcond); - } - elsif ($cond->true_when ($vcond)) - { - return ("$var was already defined in condition " - . $vcond->human . ", which is implied by condition " - . $cond->human, $vcond); - } + return ("$var was already defined in condition " . $vcond->human + . ", which includes condition ". $cond->human, $vcond) + if $vcond->true_when ($cond); + + return ("$var was already defined in condition " . $vcond->human + . ", which is included in condition " . $cond->human, $vcond) + if $cond->true_when ($vcond); } - return ('', ''); + return ('', FALSE); } =head1 SEE ALSO Index: lib/Automake/tests/DisjConditions.pl =================================================================== RCS file: /cvs/automake/automake/lib/Automake/tests/DisjConditions.pl,v retrieving revision 1.5 diff -u -p -r1.5 DisjConditions.pl --- lib/Automake/tests/DisjConditions.pl 12 Apr 2003 16:41:59 -0000 1.5 +++ lib/Automake/tests/DisjConditions.pl 9 Aug 2003 00:15:31 -0000 @@ -314,10 +314,58 @@ sub test_sub_conditions () } } +sub test_ambig () +{ + my @tests = ([[["TRUE"]], + ["TRUE"], + "multiply defined"], + [[["C1_TRUE"]], + ["C1_TRUE"], + "multiply defined"], + [[["TRUE"]], + ["C1_FALSE"], + "which includes"], + [[["C1_TRUE"]], + ["C1_TRUE", "C2_TRUE"], + "which includes"], + [[["C1_TRUE", "C2_TRUE"]], + ["C2_TRUE"], + "which is included in"], + [[["C1_TRUE"]], + ["C2_TRUE"], + ''], + [[["C1_TRUE"], + ["C2_FALSE"]], + ["C1_FALSE", "C2_TRUE"], + '']); + + for my $t (@tests) + { + my $t1 = build_set @{$t->[0]}; + my $t2 = new Automake::Condition @{$t->[1]}; + my $t3 = $t->[2]; + my ($ans, $cond) = $t1->ambiguous_p("FOO", $t2); + if ($t3 && $ans !~ /FOO.*$t3/) + { + print " (AC) " . $t1->string . " vs. " . $t2->string . "\n\t" + . "Error message '$ans' does not match '$t3'\n"; + return 1; + } + if (!$t3 && $ans ne '') + { + print " (AC) " . $t1->string . " vs. " . $t2->string . "\n\t" + . "Unexpected error message: $ans\n"; + return 1; + } + } + return 0; +} + exit (test_basics || test_invert || test_simplify - || test_sub_conditions); + || test_sub_conditions + || test_ambig); ### Setup "GNU" style for perl-mode and cperl-mode. ## Local Variables: