[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
FYI: Variable::condition_ambiguous_p -> DisjConditions::ambiguous_p
From: |
Alexandre Duret-Lutz |
Subject: |
FYI: Variable::condition_ambiguous_p -> DisjConditions::ambiguous_p |
Date: |
Thu, 07 Aug 2003 23:19:47 +0200 |
User-agent: |
Gnus/5.1002 (Gnus v5.10.2) Emacs/21.3 (gnu/linux) |
I'm installing this. condition_ambiguous_p is also used by
the rule code, so it fits better outside the Variable package...
2003-08-07 Alexandre Duret-Lutz <address@hidden>
* 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.
Index: automake.in
===================================================================
RCS file: /cvs/automake/automake/automake.in,v
retrieving revision 1.1496
diff -u -r1.1496 automake.in
--- automake.in 7 Aug 2003 20:30:04 -0000 1.1496
+++ automake.in 7 Aug 2003 21:15:31 -0000
@@ -5616,7 +5616,7 @@
# 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: lib/Automake/DisjConditions.pm
===================================================================
RCS file: /cvs/automake/automake/lib/Automake/DisjConditions.pm,v
retrieving revision 1.6
diff -u -r1.6 DisjConditions.pm
--- lib/Automake/DisjConditions.pm 23 May 2003 21:26:06 -0000 1.6
+++ lib/Automake/DisjConditions.pm 7 Aug 2003 21:15:33 -0000
@@ -66,11 +66,15 @@
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
@@ -435,6 +439,58 @@
push @res, $c->strip ($subcond) unless $c->false;
}
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
Index: lib/Automake/Variable.pm
===================================================================
RCS file: /cvs/automake/automake/lib/Automake/Variable.pm,v
retrieving revision 1.14
diff -u -r1.14 Variable.pm
--- lib/Automake/Variable.pm 3 Aug 2003 21:17:32 -0000 1.14
+++ lib/Automake/Variable.pm 7 Aug 2003 21:15:33 -0000
@@ -34,7 +34,6 @@
var rvar vardef rvardef
variables
scan_variable_expansions check_variable_expansions
- condition_ambiguous_p
variable_delete
variables_dump
set_seen
@@ -503,8 +502,7 @@
{
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 @@
}
-=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)>
--
Alexandre Duret-Lutz
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- FYI: Variable::condition_ambiguous_p -> DisjConditions::ambiguous_p,
Alexandre Duret-Lutz <=