automake-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

FYI: owner handling of +=, and turn ambiguous errors into warnings


From: Alexandre Duret-Lutz
Subject: FYI: owner handling of +=, and turn ambiguous errors into warnings
Date: 18 Sep 2002 21:36:14 +0200
User-agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/20.7

While changing ambiguous errors into warnings, I've found that
macro_define was mistakenly updating $var_owner{$var}{$cond} in 
some wrong $cond; hence this 2 in 1 patch.   
(This occurs during some += assigments, cond21.test FAILed because of this).

2002-09-18  Alexandre Duret-Lutz  <address@hidden>

        * automake.in (check_ambiguous_conditional, rule_define): Issue
        syntactic warnings, not errors.
        (macro_define): Don't adjust the owner of a variable which is being
        appended in a condition different from its definition.
        (variable_output, variable_pretty_output): Make sure the
        requested condition exists.

Index: automake.in
===================================================================
RCS file: /cvs/automake/automake/automake.in,v
retrieving revision 1.1356
diff -u -r1.1356 automake.in
--- automake.in 18 Sep 2002 18:43:23 -0000      1.1356
+++ automake.in 18 Sep 2002 19:29:59 -0000
@@ -6068,8 +6068,8 @@
     conditional_ambiguous_p ($var, $cond, keys %{$var_value{$var}});
   if ($message)
     {
-      err $where, "$message ...";
-      err_var ($var, "... `$var' previously defined here.");
+      msg 'syntax', $where, "$message ...";
+      msg_var ('syntax', $var, "... `$var' previously defined here.");
       verb (macro_dump ($var));
     }
 }
@@ -6205,6 +6205,9 @@
 {
   my ($var, $owner, $type, $cond, $value, $where) = @_;
 
+  # We will adjust the owener of this variable unless told otherwise.
+  my $adjust_owner = 1;
+
   err $where, "bad characters in variable name `$var'"
     if $var !~ /$MACRO_PATTERN/o;
 
@@ -6254,7 +6257,7 @@
   # Differentiate assignment types.
 
   # 1. append (+=) to a variable defined for current condition
-  if ($type eq '+' && defined $var_value{$var}{$cond})
+  if ($type eq '+' && exists $var_value{$var}{$cond})
     {
       if (chomp $var_value{$var}{$cond})
        {
@@ -6346,13 +6349,16 @@
              &macro_define ($var, $owner, '+', $vcond, $value, $where);
            }
        }
+      # Don't adjust the owner.  The above &macro_define did it in the
+      # right conditions.
+      $adjust_owner = 0;
     }
   # 3. first assignment (=, :=, or +=)
   else
     {
       # If Automake tries to override a value specified by the user,
       # just don't let it do.
-      if (defined $var_value{$var}{$cond}
+      if (exists $var_value{$var}{$cond}
          && $var_owner{$var} != VAR_AUTOMAKE
          && $owner == VAR_AUTOMAKE)
        {
@@ -6366,7 +6372,7 @@
          # an Automake variable or an AC_SUBST variable for an existing
          # condition.
          check_ambiguous_conditional ($var, $cond, $where)
-           unless (exists $var_value{$var}{$cond}
+           unless (exists $var_owner{$var}{$cond}
                    && (($var_owner{$var}{$cond} == VAR_AUTOMAKE
                         && $owner != VAR_AUTOMAKE)
                        || $var_owner{$var}{$cond} == VAR_CONFIGURE));
@@ -6381,8 +6387,9 @@
 
   # The owner of a variable can only increase, because an Automake
   # variable can be given to the user, but not the converse.
-  if (! exists $var_owner{$var}{$cond}
-      || $owner > $var_owner{$var}{$cond})
+  if ($adjust_owner &&
+      (! exists $var_owner{$var}{$cond}
+       || $owner > $var_owner{$var}{$cond}))
     {
       $var_owner{$var}{$cond} = $owner;
     }
@@ -7144,9 +7151,11 @@
   @conds = keys %{$var_value{$var}}
     unless @conds;
 
-
   foreach my $cond (sort by_condition @conds)
     {
+      prog_error ("unknown condition `$cond' for `$var'")
+       unless exists $var_value{$var}{$cond};
+
       if (exists $var_comment{$var} && exists $var_comment{$var}{$cond})
        {
          $output_vars .= $var_comment{$var}{$cond};
@@ -7174,6 +7183,9 @@
 
   foreach my $cond (sort by_condition @conds)
     {
+      prog_error ("unknown condition `$cond' for `$var'")
+       unless exists $var_value{$var}{$cond};
+
       if (exists $var_comment{$var} && exists $var_comment{$var}{$cond})
        {
          $output_vars .= $var_comment{$var}{$cond};
@@ -7421,8 +7433,8 @@
        {
          if ($oldowner eq TARGET_USER)
            {
-             err ($where, "redefinition of `$target'$condmsg...");
-             err_cond_target ($cond, $target,
+             msg ('syntax', $where, "redefinition of `$target'$condmsg...");
+             msg_cond_target ('syntax', $cond, $target,
                               "... `$target' previously defined here.");
              return ();
            }
@@ -7455,8 +7467,8 @@
              my $oldsource = $target_source{$target}{$cond};
              return () if $source eq $oldsource;
 
-             err ($where, "redefinition of `$target'$condmsg...");
-             err_cond_target ($cond, $target,
+             msg ('syntax', $where, "redefinition of `$target'$condmsg...");
+             msg_cond_target ('syntax', $cond, $target,
                               "... `$target' previously defined here.");
              return ();
            }
@@ -7481,8 +7493,8 @@
       if ($owner == TARGET_USER)
        {
          # For user rules, just diagnose the ambiguity.
-         err $where, "$message ...";
-         err_cond_target ($ambig_cond, $target,
+         msg 'syntax', $where, "$message ...";
+         msg_cond_target ('syntax', $ambig_cond, $target,
                           "... `$target' previously defined here.");
          return ();
        }
@@ -7517,8 +7529,8 @@
          # Warn, because our workaround is meaningless in this case.
          if (scalar @conds == 0)
            {
-             err $where, "$message ...";
-             err_cond_target ($ambig_cond, $target,
+             msg 'syntax', $where, "$message ...";
+             msg_cond_target ('syntax', $ambig_cond, $target,
                               "... `$target' previously defined here.");
              return ();
            }

-- 
Alexandre Duret-Lutz





reply via email to

[Prev in Thread] Current Thread [Next in Thread]