]> sourceware.org Git - automake.git/commitdiff
* lib/Automake/Conditional.pm (strip): New function.
authorAlexandre Duret-Lutz <adl@gnu.org>
Wed, 20 Nov 2002 22:33:15 +0000 (22:33 +0000)
committerAlexandre Duret-Lutz <adl@gnu.org>
Wed, 20 Nov 2002 22:33:15 +0000 (22:33 +0000)
* lib/Automake/ConditionalSet.pm (sub_conditions): Use it.
Suggested by Raja R Harinath.

ChangeLog
lib/Automake/Conditional.pm
lib/Automake/ConditionalSet.pm

index 5a78c8a7ab6f6f0ee28bdb953c47b70c716a7c0e..60fa609ec179cc678bbb0459e6e5d968e096a9f3 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 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
index c2d6551f18c1ca247a55d1fea0cd4c43f58a0092..df36938f2e36c28bba5df2b2152f114904b2de94 100644 (file)
@@ -44,6 +44,10 @@ Automake::Conditional - record a conjunction of conditions
   # 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;
 
@@ -228,6 +232,24 @@ sub merge_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
index 9ace53bf2ae2f566ba235767b4a1996c3bd5a4f0..b9fdb487d155bf1d1d518cb701d1d8868da1d935 100644 (file)
@@ -52,6 +52,13 @@ Automake::ConditionalSet - record a disjunction of conditions
   # 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
@@ -712,7 +719,6 @@ C<ConditionalSet>.
 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:
@@ -723,19 +729,11 @@ sub sub_conditions ($$)
   #     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;
 }
This page took 0.033586 seconds and 5 git commands to generate.