Ignore:
Timestamp:
Sep 15, 2006, 4:30:32 AM (19 years ago)
Author:
bird
Message:

Load make-3.81/ into vendor/gnumake/current.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • vendor/gnumake/current/variable.c

    r280 r501  
    11/* Internals of variables for GNU Make.
    2 Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1996, 1997,
    3 2002 Free Software Foundation, Inc.
     2Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
     31998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software
     4Foundation, Inc.
    45This file is part of GNU Make.
    56
    6 GNU Make is free software; you can redistribute it and/or modify
    7 it under the terms of the GNU General Public License as published by
    8 the Free Software Foundation; either version 2, or (at your option)
    9 any later version.
    10 
    11 GNU Make is distributed in the hope that it will be useful,
    12 but WITHOUT ANY WARRANTY; without even the implied warranty of
    13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    14 GNU General Public License for more details.
    15 
    16 You should have received a copy of the GNU General Public License
    17 along with GNU Make; see the file COPYING.  If not, write to
    18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    19 Boston, MA 02111-1307, USA.  */
     7GNU Make is free software; you can redistribute it and/or modify it under the
     8terms of the GNU General Public License as published by the Free Software
     9Foundation; either version 2, or (at your option) any later version.
     10
     11GNU Make is distributed in the hope that it will be useful, but WITHOUT ANY
     12WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
     13A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
     14
     15You should have received a copy of the GNU General Public License along with
     16GNU Make; see the file COPYING.  If not, write to the Free Software
     17Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.  */
    2018
    2119#include "make.h"
     20
     21#include <assert.h>
     22
    2223#include "dep.h"
    2324#include "filedef.h"
     
    450451initialize_file_variables (struct file *file, int reading)
    451452{
    452   register struct variable_set_list *l = file->variables;
     453  struct variable_set_list *l = file->variables;
    453454
    454455  if (l == 0)
     
    546547   and free all its storage.  */
    547548
    548 static void
    549 free_variable_name_and_value (const void *item)
    550 {
    551   struct variable *v = (struct variable *) item;
    552   free (v->name);
    553   free (v->value);
    554 }
    555 
    556 void
    557 pop_variable_scope (void)
    558 {
    559   struct variable_set_list *setlist = current_variable_set_list;
    560   struct variable_set *set = setlist->set;
    561 
    562   current_variable_set_list = setlist->next;
    563   free ((char *) setlist);
    564 
    565   hash_map (&set->table, free_variable_name_and_value);
    566   hash_free (&set->table, 1);
    567 
    568   free ((char *) set);
    569 }
    570 
    571549struct variable_set_list *
    572550create_new_variable_set (void)
     
    587565}
    588566
    589 /* Create a new variable set and push it on the current setlist.  */
     567static void
     568free_variable_name_and_value (const void *item)
     569{
     570  struct variable *v = (struct variable *) item;
     571  free (v->name);
     572  free (v->value);
     573}
     574
     575void
     576free_variable_set (struct variable_set_list *list)
     577{
     578  hash_map (&list->set->table, free_variable_name_and_value);
     579  hash_free (&list->set->table, 1);
     580  free ((char *) list->set);
     581  free ((char *) list);
     582}
     583
     584/* Create a new variable set and push it on the current setlist.
     585   If we're pushing a global scope (that is, the current scope is the global
     586   scope) then we need to "push" it the other way: file variable sets point
     587   directly to the global_setlist so we need to replace that with the new one.
     588 */
    590589
    591590struct variable_set_list *
    592591push_new_variable_scope (void)
    593592{
    594   return (current_variable_set_list = create_new_variable_set());
     593  current_variable_set_list = create_new_variable_set();
     594  if (current_variable_set_list->next == &global_setlist)
     595    {
     596      /* It was the global, so instead of new -> &global we want to replace
     597         &global with the new one and have &global -> new, with current still
     598         pointing to &global  */
     599      struct variable_set *set = current_variable_set_list->set;
     600      current_variable_set_list->set = global_setlist.set;
     601      global_setlist.set = set;
     602      current_variable_set_list->next = global_setlist.next;
     603      global_setlist.next = current_variable_set_list;
     604      current_variable_set_list = &global_setlist;
     605    }
     606  return (current_variable_set_list);
     607}
     608
     609void
     610pop_variable_scope (void)
     611{
     612  struct variable_set_list *setlist;
     613  struct variable_set *set;
     614
     615  /* Can't call this if there's no scope to pop!  */
     616  assert(current_variable_set_list->next != NULL);
     617
     618  if (current_variable_set_list != &global_setlist)
     619    {
     620      /* We're not pointing to the global setlist, so pop this one.  */
     621      setlist = current_variable_set_list;
     622      set = setlist->set;
     623      current_variable_set_list = setlist->next;
     624    }
     625  else
     626    {
     627      /* This set is the one in the global_setlist, but there is another global
     628         set beyond that.  We want to copy that set to global_setlist, then
     629         delete what used to be in global_setlist.  */
     630      setlist = global_setlist.next;
     631      set = global_setlist.set;
     632      global_setlist.set = setlist->set;
     633      global_setlist.next = setlist->next;
     634    }
     635
     636  /* Free the one we no longer need.  */
     637  free ((char *) setlist);
     638  hash_map (&set->table, free_variable_name_and_value);
     639  hash_free (&set->table, 1);
     640  free ((char *) set);
    595641}
    596642
     
    628674                          struct variable_set_list *setlist1)
    629675{
    630   register struct variable_set_list *list0 = *setlist0;
     676  struct variable_set_list *to = *setlist0;
    631677  struct variable_set_list *last0 = 0;
    632678
    633   while (setlist1 != 0 && list0 != 0)
    634     {
    635       struct variable_set_list *next = setlist1;
    636       setlist1 = setlist1->next;
    637 
    638       merge_variable_sets (list0->set, next->set);
    639 
    640       last0 = list0;
    641       list0 = list0->next;
    642     }
    643 
    644   if (setlist1 != 0)
     679  /* If there's nothing to merge, stop now.  */
     680  if (!setlist1)
     681    return;
     682
     683  /* This loop relies on the fact that all setlists terminate with the global
     684     setlist (before NULL).  If that's not true, arguably we SHOULD die.  */
     685  if (to)
     686    while (setlist1 != &global_setlist && to != &global_setlist)
     687      {
     688        struct variable_set_list *from = setlist1;
     689        setlist1 = setlist1->next;
     690
     691        merge_variable_sets (to->set, from->set);
     692
     693        last0 = to;
     694        to = to->next;
     695      }
     696
     697  if (setlist1 != &global_setlist)
    645698    {
    646699      if (last0 == 0)
     
    11271180#endif /* __MSDOS__ */
    11281181#ifdef WINDOWS32
    1129   if ((origin == o_file || origin == o_override) && streq (varname, "SHELL"))
     1182  if ((origin == o_file || origin == o_override || origin == o_command)
     1183      && streq (varname, "SHELL"))
    11301184    {
    11311185      extern char *default_shell;
Note: See TracChangeset for help on using the changeset viewer.