From: Alexandre Duret-Lutz Date: Thu, 7 Aug 2003 21:20:12 +0000 (+0000) Subject: * lib/Automake/Variable.pm (condition_ambiguous_p): Move ... X-Git-Tag: Release-1-7b~81 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a1be9812ff9ebc9edd412ab531e11392798900f4;p=thirdparty%2Fautomake.git * 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. --- diff --git a/ChangeLog b/ChangeLog index e27b45ec7..48ed31bef 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2003-08-07 Alexandre Duret-Lutz + * 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) diff --git a/automake.in b/automake.in index f92d8e13f..a3eb8d72c 100755 --- a/automake.in +++ b/automake.in @@ -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) diff --git a/lib/Automake/DisjConditions.pm b/lib/Automake/DisjConditions.pm index 8654adee7..633ba5b93 100644 --- a/lib/Automake/DisjConditions.pm +++ b/lib/Automake/DisjConditions.pm @@ -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-Eambiguous_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 under which it is being +defined. C<$condset> is the C 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. diff --git a/lib/Automake/Variable.pm b/lib/Automake/Variable.pm index fca46eb94..63e8d632a 100644 --- a/lib/Automake/Variable.pm +++ b/lib/Automake/Variable.pm @@ -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 under which it is being -defined. C<$condset> is the C 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