From: Alexandre Duret-Lutz Date: Wed, 20 Nov 2002 22:03:57 +0000 (+0000) Subject: * automake.in (conditional_ambiguous_p, macro_define, rule_define, X-Git-Tag: Release-1-7-2b~100 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6a95250354b348f76cc07fadaae213c88d5c73bb;p=thirdparty%2Fautomake.git * 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. --- diff --git a/ChangeLog b/ChangeLog index 59c191ce8..5a78c8a7a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,14 @@ 2002-11-20 Alexandre Duret-Lutz + * 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. diff --git a/automake.in b/automake.in index 9a5c4774e..58a123ed4 100755 --- a/automake.in +++ b/automake.in @@ -6074,20 +6074,19 @@ sub conditional_ambiguous_p ($$$) 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 ('', ''); @@ -6295,8 +6294,7 @@ sub macro_define ($$$$$$) 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."); @@ -6321,7 +6319,7 @@ sub macro_define ($$$$$$) { verb ("refusing to override the user definition of:\n" . macro_dump ($var) - ."with `$cond->string' => `$value'"); + ."with `$cond->human' => `$value'"); } else { @@ -7324,7 +7322,8 @@ sub rule_define ($$$$$) 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) { @@ -8933,7 +8932,7 @@ sub require_variables ($$$@) 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; diff --git a/lib/Automake/Conditional.pm b/lib/Automake/Conditional.pm index ccd3e5272..c2d6551f1 100644 --- a/lib/Automake/Conditional.pm +++ b/lib/Automake/Conditional.pm @@ -57,6 +57,10 @@ Automake::Conditional - record a conjunction of conditions # "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; @@ -296,12 +300,53 @@ sub string ($ ) } else { - $res = join (' ', sort $self->conds); + $res = join (' ', $self->conds); } $self->{'string'} = $res; return $res; } +=item C<$cond-Ehuman> + +Build a human readable string which denotes the conditional. + +For instance using the C<$cond> definition from L, +C<$cond-Estring> 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-Esubst_string> Build a C-style string for output in F. diff --git a/lib/Automake/ConditionalSet.pm b/lib/Automake/ConditionalSet.pm index b4302d66b..9ace53bf2 100644 --- a/lib/Automake/ConditionalSet.pm +++ b/lib/Automake/ConditionalSet.pm @@ -37,8 +37,13 @@ Automake::ConditionalSet - record a disjunction of conditions 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; @@ -228,6 +233,39 @@ sub string ($ ) return $res; } +=item C<$cond-Ehuman> + +Build a human readable string which denotes the C. + +=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 (@) { diff --git a/tests/cond27.test b/tests/cond27.test index f43fce377..9b7410639 100755 --- a/tests/cond27.test +++ b/tests/cond27.test @@ -39,5 +39,5 @@ EOF $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 diff --git a/tests/library3.test b/tests/library3.test index 41a9e26f2..d07df886e 100755 --- a/tests/library3.test +++ b/tests/library3.test @@ -54,6 +54,6 @@ END $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 diff --git a/tests/pluseq5.test b/tests/pluseq5.test index cad608689..90ff195fe 100755 --- a/tests/pluseq5.test +++ b/tests/pluseq5.test @@ -40,12 +40,12 @@ cat stderr # for debugging # # 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 @@ -59,5 +59,5 @@ echo 'AUTOMAKE_OPTIONS = -Wno-obsolete' >> Makefile.am $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 diff --git a/tests/pluseq9.test b/tests/pluseq9.test index b4489102b..527215a4c 100755 --- a/tests/pluseq9.test +++ b/tests/pluseq9.test @@ -61,7 +61,7 @@ cat stderr # for debugging # # 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. # @@ -69,7 +69,7 @@ cat stderr # for debugging # 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