]> git.ipfire.org Git - thirdparty/automake.git/commitdiff
* lib/Automake/Variable.pm (condition_ambiguous_p): Move ...
authorAlexandre Duret-Lutz <adl@gnu.org>
Thu, 7 Aug 2003 21:20:12 +0000 (21:20 +0000)
committerAlexandre Duret-Lutz <adl@gnu.org>
Thu, 7 Aug 2003 21:20:12 +0000 (21:20 +0000)
* lib/Automake/DisjConditions.pm (ambiguous_p): ... here.
* automake.in (rule_define): Adjust usage.
* lib/Automake/Variable.pm (_check_ambiguous_condition): Likewise.

ChangeLog
automake.in
lib/Automake/DisjConditions.pm
lib/Automake/Variable.pm

index e27b45ec7ddccce02793d207c3ac27d2fcdf7f96..48ed31bef2007c8215975ae1ef3e5aa2ad78ce2d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2003-08-07  Alexandre Duret-Lutz  <adl@gnu.org>
 
+       * lib/Automake/Variable.pm (condition_ambiguous_p): Move ...
+       * lib/Automake/DisjConditions.pm (ambiguous_p): ... here.
+       * automake.in (rule_define): Adjust usage.
+       * lib/Automake/Variable.pm (_check_ambiguous_condition): Likewise.
+
        * lib/Automake/Options.pm: New file.
        * lib/Automake/Makefile.am (dist_perllib_DATA): Add Options.pm.
        * automake.in (FOREIGN, GNU, GNITS, $default_strictness)
index f92d8e13f35e1aeb09d754f619c6eb7c05ae65e9..a3eb8d72c0c0362a2b6a06bc0a9d35a9b74e6ed2 100755 (executable)
@@ -5616,7 +5616,7 @@ sub rule_define ($$$$$)
 
   # Check ambiguous conditional definitions.
   my ($message, $ambig_cond) =
-    condition_ambiguous_p ($target, $cond, target_conditions ($target));
+    target_conditions ($target)->ambiguous_p ($target, $cond);
   if ($message)                        # We have an ambiguty.
     {
       if ($owner == TARGET_USER)
index 8654adee766dc2ea250a6e949bd8a475efb1b5f6..633ba5b9395bf3e5be01c1cf15467dbc5ec5f934 100644 (file)
@@ -66,11 +66,15 @@ Automake::DisjConditions - record a disjunction of Conditions
   my $inv = $set->invert;
 
   # Multiply two DisjConditions.
-  my $prod = $set1->multiply ($set2)
+  my $prod = $set1->multiply ($set2);
 
   # Return the subconditions of a DisjConditions with respect to
   # a Condition.  See the description for a real example.
-  my $subconds = $set->sub_conditions ($cond)
+  my $subconds = $set->sub_conditions ($cond);
+
+  # Check whether a new definition in condition $cond would be
+  # ambiguous w.r.t. existing definitions in $set.
+  ($msg, $ambig_cond) = $set->ambiguous_p ($what, $cond);
 
 =head1 DESCRIPTION
 
@@ -437,6 +441,58 @@ sub sub_conditions ($$)
   return new Automake::DisjConditions @res;
 }
 
+=item C<($string, $ambig_cond) = $condset-E<gt>ambiguous_p ($what, $cond)>
+
+Check for an ambiguous condition.  Return an error message and the
+other condition involved if we have an ambiguity.  Return two empty
+strings otherwise.
+
+C<$what> is the name of the thing being defined, to use in the error
+message.  C<$cond> is the C<Condition> under which it is being
+defined.  C<$condset> is the C<DisjConditions> under which it had
+already been defined.
+
+=cut
+
+sub ambiguous_p ($$$)
+{
+  my ($condset, $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.
+      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 ('', '');
+}
+
 =head1 SEE ALSO
 
 L<Automake::Condition>.
index fca46eb94a99bd86a00d67f5335cb708f1e62aaa..63e8d632aa2981e117eeb60ac1a94d15b59ad026 100644 (file)
@@ -34,7 +34,6 @@ use vars '@ISA', '@EXPORT', '@EXPORT_OK';
              var rvar vardef rvardef
              variables
              scan_variable_expansions check_variable_expansions
-             condition_ambiguous_p
              variable_delete
              variables_dump
              set_seen
@@ -503,8 +502,7 @@ sub _check_ambiguous_condition ($$$)
 {
   my ($self, $cond, $where) = @_;
   my $var = $self->name;
-  my ($message, $ambig_cond) =
-    condition_ambiguous_p ($var, $cond, $self->conditions);
+  my ($message, $ambig_cond) = $self->conditions->ambiguous_p ($var, $cond);
 
   # We allow silent variables to be overridden silently.
   my $def = $self->def ($cond);
@@ -892,56 +890,6 @@ sub check_variable_expansions ($$)
 }
 
 
-=item C<($string, $ambig_cond) = condition_ambiguous_p ($what, $cond, $condset)>
-
-Check for an ambiguous condition.  Return an error message and
-the other condition involved if we have one, two empty strings otherwise.
-
-C<$what> is the name of the thing being defined, to use in the error
-message.  C<$cond> is the C<Condition> under which it is being
-defined.  C<$condset> is the C<DisjConditions> under which it had
-already been defined.
-
-=cut
-
-sub condition_ambiguous_p ($$$)
-{
-  my ($var, $cond, $condset) = @_;
-
-  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.
-      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 ('', '');
-}
 
 =item C<Automake::Variable::define($varname, $owner, $type, $cond, $value, $comment, $where, $pretty)>