Index: ChangeLog
from Akim Demaille <[EMAIL PROTECTED]>
* automake.in (&conditional_true_when): Modernize, simplify.
Warning: `$comp' is now private (my), while it used to be
`inherited' from a `local' elsewhere in the code. AFAICT it was
wrong, but some dirty side effect might show up.
(&conditionals_true_when): New.
(&variable_conditions_sub, &variable_conditions_reduce): Use it.
Index: automake.in
--- automake.in Sun, 18 Feb 2001 16:45:51 +0100 akim (am/f/39_automake.i 1.49 755)
+++ automake.in Sun, 18 Feb 2001 17:51:23 +0100 akim (am/f/39_automake.i 1.49 755)
@@ -3700,6 +3700,8 @@ sub handle_merge_targets
}
+# &do_one_merge_target ($NAME, @VALUES)
+# -------------------------------------
# Helper for handle_merge_targets. Note that handle_merge_targets
# relies on the fact that this doesn't add an extra \n at the end.
sub do_one_merge_target
@@ -3754,6 +3756,7 @@ sub do_one_merge_target
&depend ('.PHONY', $name . '-am', $name);
}
+
# Handle check merge target specially.
sub do_check_merge_target
{
@@ -5291,27 +5294,27 @@ sub target_defined
# See if two conditionals are the same.
sub conditional_same
{
- local ($cond1, $cond2) = @_;
+ my ($cond1, $cond2) = @_;
return (&conditional_true_when ($cond1, $cond2)
&& &conditional_true_when ($cond2, $cond1));
}
+
+# $BOOLEAN
+# &conditional_true_when ($COND, $WHEN)
+# -------------------------------------
# See if a conditional is true. Both arguments are conditional
# strings. This returns true if the first conditional is true when
# the second conditional is true.
-sub conditional_true_when
+# For instance with $COND = @FOO@@BAR@, and $WHEN = @FOO@@BAR@@BAZ@,
+# obviously return 1, and 0 when, for instance, $WHEN = @FOO@.
+sub conditional_true_when ($$)
{
- local ($cond, $when) = @_;
-
- # Check the easy case first.
- if ($cond eq $when)
- {
- return 1;
- }
+ my ($cond, $when) = @_;
# Check each component of $cond, which looks @COND1@@COND2@.
- foreach $comp (split ('@', $cond))
+ foreach my $comp (split ('@', $cond))
{
# The way we split will give null strings between each
# condition.
@@ -5326,6 +5329,33 @@ sub conditional_true_when
return 1;
}
+
+# $BOOLEAN
+# &conditionals_true_when (@CONDS, @WHENS)
+# ----------------------------------------
+# Same as above, but true if all the @CONDS are true when *ALL*
+# the @WHENS are sufficient.
+#
+# If there are no @CONDS, then return true, of course. *BUT*, even if there
+# are @CONDS but @WHENS is empty, return true. This is counter intuitive,
+# and against all the rules of logic, but is needed by the current code.
+# FIXME: Do something saner when the logic of conditionals is understood.
+sub conditionals_true_when (@@)
+{
+ my (@conds, @whens) = @_;
+
+ foreach my $cond (@conds)
+ {
+ foreach my $when (@whens)
+ {
+ return 0
+ unless conditional_true_when ($cond, $when);
+ }
+ }
+
+ return 1;
+}
+
# Check for an ambiguous conditional. This is called when a variable
# or target is being defined conditionally. If we already know about
# a definition that is true under the same conditions, then we have an
@@ -5455,12 +5485,14 @@ sub variable_conditions
return @uniq_list;
}
+# &variable_conditions_sub ($VAR, $PARENT, @PARENT_CONDS)
+# -------------------------------------------------------
# A subroutine of variable_conditions. We only return conditions
# which are true for all the conditions in @PARENT_CONDS.
sub variable_conditions_sub
{
- local ($var, $parent, @parent_conds) = @_;
- local (@new_conds) = ();
+ my ($var, $parent, @parent_conds) = @_;
+ my @new_conds = ();
if (defined $vars_scanned{$var})
{
@@ -5486,8 +5518,8 @@ sub variable_conditions_sub
# Now we want to return all permutations of the subvariable
# conditions.
- local (%allconds, $item);
- foreach $item (@new_conds)
+ my %allconds = ();
+ foreach my $item (@new_conds)
{
foreach (split ('@', $item))
{
@@ -5511,21 +5543,8 @@ sub variable_conditions_sub
local ($cond) = shift (@condvals);
local ($val) = &unquote_cond_val (shift (@condvals));
- if (@parent_conds)
- {
- local ($ok) = 1;
- local ($parent_cond);
- foreach $parent_cond (@parent_conds)
- {
- if (! &conditional_true_when ($parent_cond, $cond))
- {
- $ok = 0;
- last;
- }
- }
-
- next if ! $ok;
- }
+ next
+ if ! conditionals_true_when ((@parent_conds), ($cond));
push (@this_conds, $cond);
@@ -5591,21 +5610,8 @@ sub variable_conditions_sub
}
next if ! $ok;
- if (@parent_conds)
- {
- local ($ok) = 1;
- local ($parent_cond);
- foreach $parent_cond (@parent_conds)
- {
- if (! &conditional_true_when ($parent_cond, $perm))
- {
- $ok = 0;
- last;
- }
- }
-
- next if ! $ok;
- }
+ next
+ if ! conditionals_true_when ((@parent_conds), ($perm));
# This permutation was not already handled, and is valid
# for the parents.
@@ -5637,17 +5643,8 @@ sub variable_conditions_reduce
local ($cond);
foreach $cond (sort variable_conditions_cmp @conds)
{
- local ($ok) = 1;
- local ($scan);
- foreach $scan (@ret)
- {
- if (&conditional_true_when ($cond, $scan))
- {
- $ok = 0;
- last;
- }
- }
- next if ! $ok;
+ next
+ if ! conditionals_true_when (($cond), (@ret));
push (@ret, $cond);
}
@@ -5686,7 +5683,7 @@ sub variable_conditions_permutations
# are using the value of a variable.
sub variable_conditionally_defined
{
- local ($var, $parent) = @_;
+ my ($var, $parent) = @_;
if ($conditional{$var})
{
if ($parent)