Changeset 1993 for trunk/src/kmk/variable.c
- Timestamp:
- Oct 29, 2008, 1:37:51 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kmk/variable.c
r1978 r1993 1 1 /* Internals of variables for GNU Make. 2 2 Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software 4 4 Foundation, Inc. 5 5 This file is part of GNU Make. … … 7 7 GNU Make is free software; you can redistribute it and/or modify it under the 8 8 terms of the GNU General Public License as published by the Free Software 9 Foundation; either version 2, or (at your option) any later version. 9 Foundation; either version 3 of the License, or (at your option) any later 10 version. 10 11 11 12 GNU Make is distributed in the hope that it will be useful, but WITHOUT ANY … … 14 15 15 16 You 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. */ 17 this program. If not, see <http://www.gnu.org/licenses/>. */ 18 18 19 19 #include "make.h" … … 388 388 389 389 static struct variable * 390 handle_special_var (struct variable *var)390 lookup_special_var (struct variable *var) 391 391 { 392 392 static unsigned long last_var_count = 0; … … 492 492 v = (struct variable *) strcache2_get_user_val (&variable_strcache, name); 493 493 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; 495 495 assert (setlist->next == 0); 496 496 return 0; … … 506 506 if ( (void *)v != hash_deleted_item 507 507 && 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; 509 509 510 510 /* the rest of the loop */ … … 521 521 if ( (void *)v != hash_deleted_item 522 522 && 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; 524 524 } /* inner collision loop */ 525 525 } … … 537 537 v = (struct variable *) strcache2_get_user_val (&variable_strcache, name); 538 538 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; 540 540 assert (setlist->next == 0); 541 541 return 0; … … 551 551 if ( (void *)v != hash_deleted_item 552 552 && 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; 554 554 555 555 /* the rest of the loop */ … … 565 565 if ( (void *)v != hash_deleted_item 566 566 && 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; 568 568 } /* inner collision loop */ 569 569 } … … 591 591 v = (struct variable *) hash_find_item_strcached (&setlist->set->table, &var_key); 592 592 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; 594 594 } 595 595 return 0; … … 639 639 # endif /* CONFIG_WITH_STRCACHE2 */ 640 640 if (v) 641 return v->special ? handle_special_var (v) : v;641 return v->special ? lookup_special_var (v) : v; 642 642 } 643 643 … … 1366 1366 isn't one there. */ 1367 1367 v = define_variable ("SHELL", 5, default_shell, o_default, 0); 1368 #ifdef __MSDOS__ 1369 v->export = v_export; /* Export always SHELL. */ 1370 #endif 1368 1371 1369 1372 /* On MSDOS we do use SHELL from environment, since it isn't a standard … … 1517 1520 1518 1521 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 } 1528 1534 1529 1535 case v_ifset: … … 1715 1721 } 1716 1722 #endif /* CONFIG_WITH_VALUE_LENGTH */ 1723 1724 1725 static struct variable * 1726 set_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 } 1717 1738 1718 1739 … … 1783 1804 v = lookup_variable (varname, varname_len); 1784 1805 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 */ 1786 1815 1787 1816 conditional = 1; … … 1997 2026 } 1998 2027 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 } 2000 2046 } 2001 2047 else … … 2031 2077 #endif 2032 2078 2033 return v ;2079 return v->special ? set_special_var (v) : v; 2034 2080 } 2035 2081
Note:
See TracChangeset
for help on using the changeset viewer.