Akim, what do you think of this patch?
2001-05-05 Tom Tromey <[EMAIL PROTECTED]>
* automake.in (conditional_true_when): Use a hash, not index().
Also, a TRUE component always results in a true return.
Fixes test cond10.test. For PR automake/164.
I think the old code wasn't too reliable since index() doesn't tell us
if one condition is an initial substring of another. Also the old
code failed when $COND was `TRUE'.
Tom
Index: automake.in
===================================================================
RCS file: /cvs/automake/automake/automake.in,v
retrieving revision 1.1067
diff -u -r1.1067 automake.in
--- automake.in 2001/05/05 21:16:36 1.1067
+++ automake.in 2001/05/06 00:40:00
@@ -5487,13 +5487,16 @@
{
my ($cond, $when) = @_;
+ # Make a hash holding all the values from $WHEN.
+ my (%cond_vals);
+ grep ($cond_vals{$_} = 1, split (' ', $when));
+
# Check each component of $cond, which looks `COND1 COND2'.
foreach my $comp (split (' ', $cond))
{
- if (index ($when, $comp) == -1)
- {
- return 0;
- }
+ # TRUE is always true.
+ return 1 if $comp eq 'TRUE';
+ return 0 if ! defined $cond_vals{$comp};
}
return 1;