Ignore:
Timestamp:
Oct 29, 2008, 1:37:51 AM (17 years ago)
Author:
bird
Message:

Merged in current GNU Make code (CVS from 2008-10-28). Ref #55.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kmk/variable.c

    r1978 r1993  
    11/* Internals of variables for GNU Make.
    22Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
    3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software
     31998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software
    44Foundation, Inc.
    55This file is part of GNU Make.
     
    77GNU Make is free software; you can redistribute it and/or modify it under the
    88terms of the GNU General Public License as published by the Free Software
    9 Foundation; either version 2, or (at your option) any later version.
     9Foundation; either version 3 of the License, or (at your option) any later
     10version.
    1011
    1112GNU Make is distributed in the hope that it will be useful, but WITHOUT ANY
     
    1415
    1516You should have received a copy of the GNU General Public License along with
    16 GNU Make; see the file COPYING.  If not, write to the Free Software
    17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.  */
     17this program.  If not, see <http://www.gnu.org/licenses/>.  */
    1818
    1919#include "make.h"
     
    388388
    389389static struct variable *
    390 handle_special_var (struct variable *var)
     390lookup_special_var (struct variable *var)
    391391{
    392392  static unsigned long last_var_count = 0;
     
    492492      v = (struct variable *) strcache2_get_user_val (&variable_strcache, name);
    493493      if (MY_PREDICT_TRUE (v))
    494         return MY_PREDICT_FALSE (v->special) ? handle_special_var (v) : v;
     494        return MY_PREDICT_FALSE (v->special) ? lookup_special_var (v) : v;
    495495      assert (setlist->next == 0);
    496496      return 0;
     
    506506      if (   (void *)v != hash_deleted_item
    507507          && v->name == name)
    508         return MY_PREDICT_FALSE (v->special) ? handle_special_var (v) : v;
     508        return MY_PREDICT_FALSE (v->special) ? lookup_special_var (v) : v;
    509509
    510510      /* the rest of the loop  */
     
    521521          if (   (void *)v != hash_deleted_item
    522522              && v->name == name)
    523             return MY_PREDICT_FALSE (v->special) ? handle_special_var (v) : v;
     523            return MY_PREDICT_FALSE (v->special) ? lookup_special_var (v) : v;
    524524        } /* inner collision loop */
    525525    }
     
    537537          v = (struct variable *) strcache2_get_user_val (&variable_strcache, name);
    538538          if (MY_PREDICT_TRUE (v))
    539             return MY_PREDICT_FALSE (v->special) ? handle_special_var (v) : v;
     539            return MY_PREDICT_FALSE (v->special) ? lookup_special_var (v) : v;
    540540          assert (setlist->next == 0);
    541541          return 0;
     
    551551          if (   (void *)v != hash_deleted_item
    552552              && v->name == name)
    553             return MY_PREDICT_FALSE (v->special) ? handle_special_var (v) : v;
     553            return MY_PREDICT_FALSE (v->special) ? lookup_special_var (v) : v;
    554554
    555555          /* the rest of the loop  */
     
    565565              if (   (void *)v != hash_deleted_item
    566566                  && v->name == name)
    567                 return MY_PREDICT_FALSE (v->special) ? handle_special_var (v) : v;
     567                return MY_PREDICT_FALSE (v->special) ? lookup_special_var (v) : v;
    568568            } /* inner collision loop */
    569569        }
     
    591591      v = (struct variable *) hash_find_item_strcached (&setlist->set->table, &var_key);
    592592      if (v)
    593         return MY_PREDICT_FALSE (v->special) ? handle_special_var (v) : v;
     593        return MY_PREDICT_FALSE (v->special) ? lookup_special_var (v) : v;
    594594    }
    595595  return 0;
     
    639639# endif /* CONFIG_WITH_STRCACHE2 */
    640640      if (v)
    641         return v->special ? handle_special_var (v) : v;
     641        return v->special ? lookup_special_var (v) : v;
    642642    }
    643643
     
    13661366     isn't one there.  */
    13671367  v = define_variable ("SHELL", 5, default_shell, o_default, 0);
     1368#ifdef __MSDOS__
     1369  v->export = v_export;  /*  Export always SHELL.  */
     1370#endif
    13681371
    13691372  /* On MSDOS we do use SHELL from environment, since it isn't a standard
     
    15171520
    15181521              case v_noexport:
    1519                 /* If this is the SHELL variable and it's not exported, then
    1520                    add the value from our original environment.  */
    1521                 if (streq (v->name, "SHELL"))
    1522                   {
    1523                     extern struct variable shell_var;
    1524                     v = &shell_var;
    1525                     break;
    1526                   }
    1527                 continue;
     1522                {
     1523                  /* If this is the SHELL variable and it's not exported,
     1524                     then add the value from our original environment, if
     1525                     the original environment defined a value for SHELL.  */
     1526                  extern struct variable shell_var;
     1527                  if (streq (v->name, "SHELL") && shell_var.value)
     1528                    {
     1529                      v = &shell_var;
     1530                      break;
     1531                    }
     1532                  continue;
     1533                }
    15281534
    15291535              case v_ifset:
     
    17151721}
    17161722#endif /* CONFIG_WITH_VALUE_LENGTH */
     1723
     1724
     1725static struct variable *
     1726set_special_var (struct variable *var)
     1727{
     1728  if (streq (var->name, RECIPEPREFIX_NAME))
     1729    {
     1730      /* The user is resetting the command introduction prefix.  This has to
     1731         happen immediately, so that subsequent rules are interpreted
     1732         properly.  */
     1733      cmd_prefix = var->value[0]=='\0' ? RECIPEPREFIX_DEFAULT : var->value[0];
     1734    }
     1735
     1736  return var;
     1737}
    17171738
    17181739
     
    17831804      v = lookup_variable (varname, varname_len);
    17841805      if (v)
    1785         return v;
     1806#ifndef CONFIG_WITH_VALUE_LENGTH
     1807        return v->special ? set_special_var (v) : v;
     1808#else  /* CONFIG_WITH_VALUE_LENGTH */
     1809        {
     1810          if (free_value)
     1811            free (free_value);
     1812          return v->special ? set_special_var (v) : v;
     1813        }
     1814#endif /* CONFIG_WITH_VALUE_LENGTH */
    17861815
    17871816      conditional = 1;
     
    19972026        }
    19982027      else
    1999         v = lookup_variable (varname, varname_len);
     2028        {
     2029          if (alloc_value)
     2030            free (alloc_value);
     2031
     2032          alloc_value = allocated_variable_expand (p);
     2033          if (find_and_set_default_shell (alloc_value))
     2034            {
     2035              v = define_variable_in_set (varname, varname_len, p,
     2036                                          origin, flavor == f_recursive,
     2037                                          (target_var
     2038                                           ? current_variable_set_list->set
     2039                                           : NULL),
     2040                                          flocp);
     2041              no_default_sh_exe = 0;
     2042            }
     2043          else
     2044            v = lookup_variable (varname, varname_len);
     2045        }
    20002046    }
    20012047  else
     
    20312077#endif
    20322078
    2033   return v;
     2079  return v->special ? set_special_var (v) : v;
    20342080}
    20352081
Note: See TracChangeset for help on using the changeset viewer.