automake-patches
[Top][All Lists]
Advanced

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

FYI: use &variable_conditions and &target_conditions


From: Alexandre Duret-Lutz
Subject: FYI: use &variable_conditions and &target_conditions
Date: Wed, 13 Nov 2002 22:57:49 +0100
User-agent: Gnus/5.090008 (Oort Gnus v0.08) Emacs/20.7 (i386-debian-linux-gnu)

I'm checking this in.

I plan to change these functions to return a ConditionalSet soon.

2002-11-13  Alexandre Duret-Lutz  <address@hidden>

        * automake.in (variable_conditions): Split into ...
        (variable_conditions, variable_sorted_conditions): ... these
        functions, where variable_sorted_conditions has the semantic of
        the old variable_condition.
        (target_conditions): New function.
        (msg_var, handle_lib_objects_cond, check_ambiguous_conditional,
        variable_not_always_defined_in_cond, macro_define,
        variable_defined, check_variable_defined_unconditionally,
        variable_conditions_recursive_sub,
        variable_conditions_permutations, variable_value_as_list,
        variable_value_as_list_recursive_worker, append_exeext,
        am_install_var, require_variables_for_macro): Use variable_conditions.
        (msg_target, rule_define): Use target_conditions.
        (define_objects_from_sources, macro_define, macro_dump,
        variable_pretty_output): Use variable_sorted_conditions.

Index: automake.in
===================================================================
RCS file: /cvs/automake/automake/automake.in,v
retrieving revision 1.1384
diff -u -r1.1384 automake.in
--- automake.in 13 Nov 2002 20:11:31 -0000      1.1384
+++ automake.in 13 Nov 2002 21:54:45 -0000
@@ -1248,7 +1248,7 @@
 {
   my ($channel, $var, $msg, %opts) = @_;
   # Don't know which condition is concerned.  Pick any.
-  my $cond = (keys %{$var_value{$var}})[0];
+  my $cond = (variable_conditions ($var))[0];
   msg_cond_var $channel, $cond, $var, $msg, %opts;
 }
 
@@ -1268,7 +1268,7 @@
 {
   my ($channel, $target, $msg, %opts) = @_;
   # Don't know which condition is concerned.  Pick any.
-  my $cond = (keys %{$targets{$target}})[0];
+  my $cond = (target_conditions ($target))[0];
   msg_cond_target ($channel, $cond, $target, $msg, %opts);
 }
 
@@ -2655,7 +2655,7 @@
 
     my $needlinker = "";
     my @allresults = ();
-    foreach my $cond (variable_conditions ($var))
+    foreach my $cond (variable_sorted_conditions ($var))
     {
        my @result;
        foreach my $val (&variable_value_as_list ($var, $cond, $parent))
@@ -3020,7 +3020,7 @@
     {
       my $depvar = $xname . '_DEPENDENCIES';
       if ((conditional_ambiguous_p ($depvar, $cond,
-                                   keys %{$var_value{$depvar}}))[0] ne '')
+                                   variable_conditions ($depvar)))[0] ne '')
        {
          # Note that we've examined this.
          &examine_variable ($depvar);
@@ -6069,7 +6069,7 @@
 {
   my ($var, $cond, $where) = @_;
   my ($message, $ambig_cond) =
-    conditional_ambiguous_p ($var, $cond, keys %{$var_value{$var}});
+    conditional_ambiguous_p ($var, $cond, variable_conditions ($var));
   if ($message)
     {
       msg 'syntax', $where, "$message ...", partial => 1;
@@ -6194,7 +6194,7 @@
   #     COND1_TRUE.  This yields an empty list and we are done.
 
   my @res = ();
-  my @cond_defs = keys %{$var_value{$var}}; # (1)
+  my @cond_defs = variable_conditions ($var); # (1)
   foreach my $icond (invert_conditions (@cond_defs)) # (2)
     {
       prog_error "invert_conditions returned an input condition"
@@ -6284,7 +6284,7 @@
        $var_value{$var}{$cond} .= $value;
     }
   # 2. append (+=) to a variable defined for *another* condition
-  elsif ($type eq '+' && keys %{$var_value{$var}})
+  elsif ($type eq '+' && variable_conditions ($var))
     {
       # * Generally, $cond is not TRUE.  For instance:
       #     FOO = foo
@@ -6335,7 +6335,7 @@
        }
 
       # Add VALUE to all definitions of VAR.
-      foreach my $vcond (keys %{$var_value{$var}})
+      foreach my $vcond (variable_conditions ($var))
         {
          # We have a bit of error detection to do here.
          # This:
@@ -6463,7 +6463,7 @@
   else
     {
       $text .= "  $var $var_type{$var}=\n  {\n";
-      foreach my $vcond (sort by_condition keys %{$var_value{$var}})
+      foreach my $vcond (variable_sorted_conditions ($var))
        {
          prog_error ("`$var' is a key in \$var_value, "
                      . "but not in \$var_owner\n")
@@ -6550,7 +6550,7 @@
        if (exists $targets{$var}
            && (! defined $cond || exists $targets{$var}{$cond}))
          {
-           for my $tcond ($cond || keys %{$targets{$var}})
+           for my $tcond ($cond || target_conditions ($var))
              {
                prog_error ("\$targets{$var}{$tcond} exists but "
                            . "\$target_owner doesn't")
@@ -6658,11 +6658,31 @@
 sub variable_conditions ($)
 {
     my ($var) = @_;
-    my @conds = keys %{$var_value{$var}};
-    return sort by_condition @conds;
+    return keys %{$var_value{$var}};
 }
 
 
+# @CONDS
+# variable_sorted_conditions ($VAR)
+# ---------------------------------
+# Same as &variable_conditions, but return a sorted list.
+sub variable_sorted_conditions ($)
+{
+    my ($var) = @_;
+    return sort by_condition variable_conditions $var;
+}
+
+
+# @CONDS
+# target_conditions ($TARGET)
+# ---------------------------
+# Get the list of conditions that a target is defined with.
+sub target_conditions ($)
+{
+    my ($target) = @_;
+    return keys %{$targets{$target}};
+}
+
 # $BOOLEAN
 # &variable_conditionally_defined ($VAR)
 # --------------------------------------
@@ -6746,7 +6766,7 @@
 
     my @this_conds = ();
     # Examine every condition under which $VAR is defined.
-    foreach my $vcond (keys %{$var_value{$var}})
+    foreach my $vcond (variable_conditions ($var))
     {
       push (@this_conds, $vcond);
 
@@ -6902,7 +6922,7 @@
 sub check_variable_defined_unconditionally ($$)
 {
   my ($var, $parent) = @_;
-  foreach my $cond (keys %{$var_value{$var}})
+  foreach my $cond (variable_conditions ($var))
     {
       next
        if $cond->true || $cond->false;
@@ -7038,7 +7058,7 @@
 
     # Get value for given condition
     my $onceflag;
-    foreach my $vcond (keys %{$var_value{$var}})
+    foreach my $vcond (variable_conditions ($var))
     {
        my $val = $var_value{$var}{$vcond};
 
@@ -7097,7 +7117,7 @@
     elsif ($cond eq 'all')
     {
        $vars_scanned{$var} = 1;
-       foreach my $vcond (keys %{$var_value{$var}})
+       foreach my $vcond (variable_conditions ($var))
        {
            push (@result, &value_to_list ($var,
                                           $var_value{$var}{$vcond},
@@ -7110,7 +7130,7 @@
     {
        $vars_scanned{$var} = 1;
        my $onceflag;
-       foreach my $vcond (keys %{$var_value{$var}})
+       foreach my $vcond (variable_conditions ($var))
        {
            my $val = $var_value{$var}{$vcond};
            my $where = $var_location{$var}{$vcond};
@@ -7143,10 +7163,10 @@
 {
   my ($var, @conds) = @_;
 
-  @conds = keys %{$var_value{$var}}
+  @conds = variable_sorted_conditions $var
     unless @conds;
 
-  foreach my $cond (sort by_condition @conds)
+  foreach my $cond (@conds)
     {
       prog_error ("unknown condition `$cond' for `$var'")
        unless exists $var_value{$var}{$cond};
@@ -7174,10 +7194,10 @@
 {
   my ($var, @conds) = @_;
 
-  @conds = keys %{$var_value{$var}}
+  @conds = variable_sorted_conditions $var
     unless @conds;
 
-  foreach my $cond (sort by_condition @conds)
+  foreach my $cond (@conds)
     {
       prog_error ("unknown condition `$cond' for `$var'")
        unless exists $var_value{$var}{$cond};
@@ -7530,7 +7550,7 @@
 
   # Check ambiguous conditional definitions.
   my ($message, $ambig_cond) =
-    conditional_ambiguous_p ($target, $cond, keys %{$targets{$target}});
+    conditional_ambiguous_p ($target, $cond, target_conditions ($target));
   if ($message)                        # We have an ambiguty.
     {
       if ($owner == TARGET_USER)
@@ -7562,7 +7582,7 @@
          # was already defined in condition COND1 and we want to define
          # it in condition TRUE, then define it only in condition !COND1.
          # (See cond14.test and cond15.test for some test cases.)
-         my @defined_conds = keys %{$targets{$target}};
+         my @defined_conds = target_conditions ($target);
          @conds = ();
          for my $undefined_cond (invert_conditions(@defined_conds))
            {
@@ -8366,7 +8386,7 @@
   # FIXME: Currently it's a bit hard to chose a condition becose the
   # set of input condition is different from the set of ouput
   # conditions.  See also PR/352.   So we just pick the first one.
-  my $cond = (keys %{$var_value{$macro}})[0];
+  my $cond = (variable_conditions ($macro))[0];
   my $where = $var_location{$macro}{$cond};
 
   macro_delete ($macro);
@@ -8545,7 +8565,7 @@
       # Use the location of the currently processed variable.
       # We are not processing a particular condition, so pick the first
       # available.
-      my $tmpcond = (keys %{$var_value{$one_name}})[0];
+      my $tmpcond = (variable_conditions ($one_name))[0];
       my $where = $var_location{$one_name}{$tmpcond}->clone;
 
       # Append actual contents of where_PRIMARY variable to
@@ -9095,7 +9115,7 @@
 sub require_variables_for_macro ($$@)
 {
   my ($macro, $reason, @args) = @_;
-  for my $cond (keys %{$var_value{$macro}})
+  for my $cond (variable_conditions ($macro))
     {
       return require_variables ($var_location{$macro}{$cond}, $reason,
                                $cond, @args);

-- 
Alexandre Duret-Lutz





reply via email to

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