]> sourceware.org Git - automake.git/commitdiff
* automake.in (conditional_ambiguous_p, macro_define, rule_define,
authorAlexandre Duret-Lutz <adl@gnu.org>
Wed, 20 Nov 2002 22:03:55 +0000 (22:03 +0000)
committerAlexandre Duret-Lutz <adl@gnu.org>
Wed, 20 Nov 2002 22:03:55 +0000 (22:03 +0000)
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.

ChangeLog
automake.in
lib/Automake/Conditional.pm
lib/Automake/ConditionalSet.pm
tests/cond27.test
tests/library3.test
tests/pluseq5.test
tests/pluseq9.test

index 59c191ce8aebe669e4ad49a3b966dbbd1d31b01e..5a78c8a7ab6f6f0ee28bdb953c47b70c716a7c0e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
 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.
index 9a5c4774e556ed81c4bf691b35aa6712badb0eea..58a123ed46982c6c224bce245c5b75c1b669b460 100755 (executable)
@@ -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;
index ccd3e5272d961727028f9fe6cb121dab7cd1150b..c2d6551f18c1ca247a55d1fea0cd4c43f58a0092 100644 (file)
@@ -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-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>.
index b4302d66bfcda8eda3498312ef06aa2b7b2caecb..9ace53bf2ae2f566ba235767b4a1996c3bd5a4f0 100644 (file)
@@ -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-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 (@)
 {
index f43fce377a48ab204257aa7e3eb577ea4d04c982..9b7410639a743594ef035c5e595ab36ade5f49b0 100755 (executable)
@@ -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
index 41a9e26f23f42ccd81ee2201a93a856af508c22b..d07df886e5a98ad3029c5dbc8cee8f826558090d 100755 (executable)
@@ -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
index cad6086895b7d94321e73f6063d36c2272373aea..90ff195fed48fc35b70037e76083f11d3a29b17a 100755 (executable)
@@ -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
index b4489102b6d690bb1669d368bffacece6f22312a..527215a4cbea2116284a91ab09fcf185e8a5d013 100755 (executable)
@@ -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
 
This page took 0.049633 seconds and 5 git commands to generate.