* lib/Automake/ConditionalSet.pm (sub_conditions): Use it.
Suggested by Raja R Harinath.
2002-11-20 Alexandre Duret-Lutz <adl@gnu.org>
+ * lib/Automake/Conditional.pm (strip): New function.
+ * lib/Automake/ConditionalSet.pm (sub_conditions): Use it.
+ Suggested by Raja R Harinath.
+
* automake.in (conditional_ambiguous_p, macro_define, rule_define,
require_variables): Use ->human instead of ->string.
* lib/Automake/Conditional.pm (string): Don't sort conditions, they
# Likewise, but using a list of atomic conditional strings
my $both2 = $cond->merge_conds ("COND3_FALSE");
+ # Strip from $both any subconditions which are in $other.
+ # This is the opposite of merge.
+ $cond = $both->strip ($other);
+
# Return the list of conditions ("COND1_TRUE", "COND2_FALSE"):
my @conds = $cond->conds;
new Automake::Conditional $self->conds, @conds;
}
+=item C<$newcond = $cond-E<gt>strip ($minuscond)>
+
+Return a new condition which has all the subconditions of C<$cond>
+except those of C<$minuscond>. This is the opposite of C<merge>.
+
+=cut
+
+sub strip ($$)
+{
+ my ($self, $minus) = @_;
+ my @res;
+ foreach my $cond ($self->conds)
+ {
+ push @res, $cond unless $minus->has ($cond);
+ }
+ return new Automake::Conditional @res;
+}
+
=item C<@list = $cond-E<gt>conds>
Return the set of conditions defining C<$cond>, as strings. Note that
# that complements $set.
my $inv = $set->invert;
+ # Multiply two ConditionalSets.
+ my $prod = $set1->multiply ($set2)
+
+ # Return the subconditions of a ConditionalSet with respect to
+ # a Conditional. See the description for a real example.
+ my $subconds = $set->sub_conditions ($cond)
+
=head1 DESCRIPTION
A C<ConditionalSet> is a disjunction of atomic conditions. In
sub sub_conditions ($$)
{
my ($self, $subcond) = @_;
- my @res;
# Make $subcond blindingly apparent in the ConditionalSet.
# For instance `$a->_multiply($b)' (from the POD example) is:
# new Automake::Conditional ("FALSE"));
my $prod = $self->_multiply ($subcond);
- # Now, strip $subcond from the non-false Conditionals.
+ # Now, strip $subcond from the remaining (i.e., non-false) Conditionals.
+ my @res;
foreach my $c ($prod->conds)
{
- if (! $c->false)
- {
- my @rescond;
- foreach my $cc ($c->conds)
- {
- push @rescond, $cc
- unless $subcond->has ($cc);
- }
- push @res, new Automake::Conditional @rescond;
- }
+ push @res, $c->strip ($subcond) unless $c->false;
}
return new Automake::ConditionalSet @res;
}