require_variables): Use ->human instead of ->string.
* lib/Automake/Conditional.pm (string): Don't sort conditions, they
are already sorted.
(_to_human, human): New functions.
* lib/Automake/ConditionalSet.pm (human): New function.
* tests/cond27.test, tests/library3.test, tests/pluseq5.test,
tests/pluseq9.test: Adjust.
2002-11-20 Alexandre Duret-Lutz <adl@gnu.org>
+ * automake.in (conditional_ambiguous_p, macro_define, rule_define,
+ require_variables): Use ->human instead of ->string.
+ * lib/Automake/Conditional.pm (string): Don't sort conditions, they
+ are already sorted.
+ (_to_human, human): New functions.
+ * lib/Automake/ConditionalSet.pm (human): New function.
+ * tests/cond27.test, tests/library3.test, tests/pluseq5.test,
+ tests/pluseq9.test: Adjust.
+
* lib/Automake/Conditional.pm [SYNOPSIS]: Fix not's description.
* lib/Automake/ConditionalSet.pm (sub_conditions): New function.
(multiply): Also accept an Automake::Conditional as argument.
my $message;
if ($vcond eq $cond)
{
- return ("$var multiply defined in condition ". $cond->string,
+ return ("$var multiply defined in condition " . $cond->human,
$vcond);
}
elsif ($vcond->true_when ($cond))
{
- return ("$var was already defined in condition "
- . $vcond->string . ", "
- . "which implies condition ". $cond->string, $vcond);
+ 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->string . ", "
- . "which is implied by condition " . $cond->string, $vcond);
+ . $vcond->human . ", which is implied by condition "
+ . $cond->human, $vcond);
}
}
return ('', '');
err ($where,
"Cannot apply `+=' because `$var' is not defined "
. "in\nthe following conditions:\n "
- . join ("\n ",
- map { $_->string } $undef_cond->conds)
+ . join ("\n ", map { $_->human } $undef_cond->conds)
. "\nEither define `$var' in these conditions,"
. " or use\n`+=' in the same conditions as"
. " the definitions.");
{
verb ("refusing to override the user definition of:\n"
. macro_dump ($var)
- ."with `$cond->string' => `$value'");
+ ."with `$cond->human' => `$value'");
}
else
{
my $oldowner = $target_owner{$target}{$cond};
# Don't mention true conditions in diagnostics.
- my $condmsg = $cond == TRUE ? " in condition `" . $cond->string . "'" : '';
+ my $condmsg =
+ $cond == TRUE ? " in condition `" . $cond->human . "'" : '';
if ($owner == TARGET_USER)
{
if (! $undef_cond->true)
{
$text .= ("in the following conditions:\n "
- . join ("\n ", map { $_->string } $undef_cond->conds));
+ . join ("\n ", map { $_->human } $undef_cond->conds));
}
++$res;
# "COND1_TRUE COND2_FALSE"
my $str = $cond->string;
+ # Return the list of conditions as a human readable string:
+ # "COND1 and !COND2"
+ my $str = $cond->human;
+
# Return the list of conditions as a AC_SUBST-style string:
# "@COND1_TRUE@@COND2_FALSE@"
my $subst = $cond->subst_string;
}
else
{
- $res = join (' ', sort $self->conds);
+ $res = join (' ', $self->conds);
}
$self->{'string'} = $res;
return $res;
}
+=item C<$cond-E<gt>human>
+
+Build a human readable string which denotes the conditional.
+
+For instance using the C<$cond> definition from L<SYNOPSYS>,
+C<$cond-E<gt>string> will return C<"COND1 and !COND2">.
+
+=cut
+
+sub _to_human ($ )
+{
+ my ($s) = @_;
+ if ($s =~ /^(.*)_(TRUE|FALSE)$/)
+ {
+ return (($2 eq 'FALSE') ? '!' : '') . $1;
+ }
+ else
+ {
+ return $s;
+ }
+}
+
+sub human ($ )
+{
+ my ($self) = @_;
+
+ return $self->{'human'} if defined $self->{'human'};
+
+ my $res = '';
+ if ($self->false)
+ {
+ $res = 'FALSE';
+ }
+ else
+ {
+ $res = join (' and ', map { _to_human $_ } $self->conds);
+ }
+ $self->{'human'} = $res;
+ return $res;
+}
+
=item C<$cond-E<gt>subst_string>
Build a C<AC_SUBST>-style string for output in F<Makefile.in>.
if ($set->false) { ... }
# Return a string representing the ConditionalSet.
+ # "COND1_TRUE COND2_FALSE | COND3_FALSE"
my $str = $set->string;
+ # Return a human readable string representing the ConditionalSet.
+ # "(COND1 and !COND2) or (!COND3)"
+ my $str = $set->human;
+
# Build a new ConditionalSet from the permuation of all
# subconditions appearing in $set.
my $perm = $set->permutations;
return $res;
}
+=item C<$cond-E<gt>human>
+
+Build a human readable string which denotes the C<ConditionalSet>.
+
+=cut
+
+sub human ($ )
+{
+ my ($self) = @_;
+
+ return $self->{'human'} if defined $self->{'human'};
+
+ my $res = '';
+ if ($self->false)
+ {
+ $res = 'FALSE';
+ }
+ else
+ {
+ my @c = $self->conds;
+ if (1 == @c)
+ {
+ $res = $self->human;
+ }
+ else
+ {
+ $res = '(' . join (') or (', map { $_->human } $self->conds) . ')';
+ }
+ }
+ $self->{'human'} = $res;
+ return $res;
+}
+
sub _permutations_worker (@)
{
$ACLOCAL
$AUTOMAKE 2>stderr && exit 1
cat stderr
-grep USE_FOO_TRUE stderr && exit 1
-grep USE_FOO_FALSE stderr
+grep ' USE_FOO' stderr && exit 1
+grep '!USE_FOO' stderr
$ACLOCAL
$AUTOMAKE 2>stderr && exit 1
cat stderr
-grep '^Makefile.am:.*: A_FALSE C_FALSE D_FALSE$' stderr
+grep '^Makefile.am:.*: !A and !C and !D$' stderr
# Is there only one missing condition?
test `grep ': ' stderr | wc -l` = 1 || exit 1
#
# Makefile.am:4: Cannot apply `+=' because `INCLUDES' is not defined in
# Makefile.am:4: the following conditions:
-# Makefile.am:4: CHECK_FALSE
+# Makefile.am:4: !CHECK
# Makefile.am:4: Either define `INCLUDES' in these conditions, or use
# Makefile.am:4: `+=' in the same conditions as the definitions.
-# Is CHECK_FALSE mentioned?
-grep ':.*CHECK_FALSE$' stderr || exit 1
+# Is !CHECK mentioned?
+grep ':.*!CHECK$' stderr || exit 1
# Is there only one missing condition?
test `grep ': ' stderr | wc -l` = 1 || exit 1
$AUTOMAKE 2>stderr && exit 1
cat stderr
grep AM_CPPFLAGS stderr && exit 1
-# CHECK_FALSE should still be mentioned.
-grep ':.*CHECK_FALSE$' stderr || exit 1
+# !CHECK should still be mentioned.
+grep ':.*!CHECK$' stderr || exit 1
#
# Makefile.am:19: Cannot apply `+=' because `B' is not defined in
# Makefile.am:19: the following conditions:
-# Makefile.am:19: COND1_FALSE COND3_FALSE
+# Makefile.am:19: !COND1 and !COND3
# Makefile.am:19: Either define `B' in these conditions, or use
# Makefile.am:19: `+=' in the same conditions as the definitions.
#
# COND1_FALSE (merging the last two conditions), so we'll support
# this case in the check too.
-grep ': COND1_FALSE COND3_FALSE$' stderr || exit 1
+grep ': !COND1 and !COND3$' stderr || exit 1
# Make sure there is exactly one missing condition.
test `grep ': ' stderr | wc -l` = 1 || exit 1