Changeset 3140 for trunk/src/kmk/variable.c
- Timestamp:
- Mar 14, 2018, 10:28:10 PM (7 years ago)
- Location:
- trunk/src/kmk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kmk
-
Property svn:mergeinfo
set to
/vendor/gnumake/current merged eligible
-
Property svn:mergeinfo
set to
-
trunk/src/kmk/variable.c
r3090 r3140 1 1 /* Internals of variables for GNU Make. 2 Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 4 2010 Free Software Foundation, Inc. 2 Copyright (C) 1988-2016 Free Software Foundation, Inc. 5 3 This file is part of GNU Make. 6 4 … … 17 15 this program. If not, see <http://www.gnu.org/licenses/>. */ 18 16 19 #include "make .h"17 #include "makeint.h" 20 18 21 19 #include <assert.h> 22 20 21 #include "filedef.h" 23 22 #include "dep.h" 24 #include "filedef.h"25 23 #include "job.h" 26 24 #include "commands.h" … … 65 63 #endif 66 64 65 /* Incremented every time we add or remove a global variable. */ 66 static unsigned long variable_changenum; 67 67 68 68 /* Chain of all pattern-specific variables. */ … … 135 135 { 136 136 struct pattern_var *p; 137 unsigned int targlen = strlen (target);137 unsigned int targlen = strlen (target); 138 138 139 139 for (p = start ? start->next : pattern_vars; p != 0; p = p->next) … … 203 203 #endif /* !CONFIG_WITH_STRCACHE2 */ 204 204 205 #ifndef 205 #ifndef VARIABLE_BUCKETS 206 206 # ifdef KMK /* Move to Makefile.kmk? (insanely high, but wtf, it gets the collitions down) */ 207 # define VARIABLE_BUCKETS 207 # define VARIABLE_BUCKETS 65535 208 208 # else /*!KMK*/ 209 #define VARIABLE_BUCKETS 209 #define VARIABLE_BUCKETS 523 210 210 # endif /*!KMK*/ 211 211 #endif 212 #ifndef 212 #ifndef PERFILE_VARIABLE_BUCKETS 213 213 # ifdef KMK /* Move to Makefile.kmk? */ 214 # define PERFILE_VARIABLE_BUCKETS 214 # define PERFILE_VARIABLE_BUCKETS 127 215 215 # else 216 #define PERFILE_VARIABLE_BUCKETS23216 #define PERFILE_VARIABLE_BUCKETS 23 217 217 # endif 218 218 #endif 219 #ifndef 219 #ifndef SMALL_SCOPE_VARIABLE_BUCKETS 220 220 # ifdef KMK /* Move to Makefile.kmk? */ 221 221 # define SMALL_SCOPE_VARIABLE_BUCKETS 63 222 222 # else 223 #define SMALL_SCOPE_VARIABLE_BUCKETS13223 #define SMALL_SCOPE_VARIABLE_BUCKETS 13 224 224 # endif 225 225 #endif … … 247 247 #ifndef CONFIG_WITH_STRCACHE2 248 248 hash_init (&global_variable_set.table, VARIABLE_BUCKETS, 249 249 variable_hash_1, variable_hash_2, variable_hash_cmp); 250 250 #else /* CONFIG_WITH_STRCACHE2 */ 251 251 strcache2_init (&variable_strcache, "variable", 262144, 0, 0, 0); … … 268 268 int duplicate_value, enum variable_origin origin, 269 269 int recursive, struct variable_set *set, 270 const structfloc *flocp)270 const floc *flocp) 271 271 #else 272 272 struct variable * … … 274 274 const char *value, enum variable_origin origin, 275 275 int recursive, struct variable_set *set, 276 const structfloc *flocp)276 const floc *flocp) 277 277 #endif 278 278 { … … 316 316 var_key.length = length; 317 317 var_slot = (struct variable **) hash_find_slot (&set->table, &var_key); 318 v = *var_slot; 319 320 #ifdef VMS 321 /* VMS does not populate envp[] with DCL symbols and logical names which 322 historically are mapped to environent variables. 323 If the variable is not yet defined, then we need to check if getenv() 324 can find it. Do not do this for origin == o_env to avoid infinte 325 recursion */ 326 if (HASH_VACANT (v) && (origin != o_env)) 327 { 328 struct variable * vms_variable; 329 char * vname = alloca (length + 1); 330 char * vvalue; 331 332 strncpy (vname, name, length); 333 vvalue = getenv(vname); 334 335 /* Values starting with '$' are probably foreign commands. 336 We want to treat them as Shell aliases and not look them up here */ 337 if ((vvalue != NULL) && (vvalue[0] != '$')) 338 { 339 vms_variable = lookup_variable(name, length); 340 /* Refresh the slot */ 341 var_slot = (struct variable **) hash_find_slot (&set->table, 342 &var_key); 343 v = *var_slot; 344 } 345 } 346 #endif 318 347 319 348 /* if (env_overrides && origin == o_env) 320 349 origin = o_env_override; - bird moved this up */ 321 350 322 v = *var_slot;323 351 #else /* CONFIG_WITH_STRCACHE2 */ 324 352 name = strcache2_add (&variable_strcache, name, length); … … 343 371 #endif 344 372 if (env_overrides && v->origin == o_env) 345 346 347 373 /* V came from in the environment. Since it was defined 374 before the switches were parsed, it wasn't affected by -e. */ 375 v->origin = o_env_override; 348 376 349 377 /* A variable of this name is already defined. 350 351 378 If the old definition is from a stronger source 379 than this one, don't redefine it. */ 352 380 if ((int) origin >= (int) v->origin) 353 381 { 354 382 #ifdef CONFIG_WITH_VALUE_LENGTH 355 383 if (value_len == ~0U) … … 390 418 v->value_length = value_len; 391 419 #else /* !CONFIG_WITH_VALUE_LENGTH */ 392 if (v->value != 0) 393 free (v->value); 394 v->value = xstrdup (value); 420 free (v->value); 421 v->value = xstrdup (value); 395 422 #endif /* !CONFIG_WITH_VALUE_LENGTH */ 396 423 if (flocp != 0) … … 398 425 else 399 426 v->fileinfo.filenm = 0; 400 401 402 VARIABLE_CHANGED (v);403 427 v->origin = origin; 428 v->recursive = recursive; 429 VARIABLE_CHANGED (v); 430 } 404 431 return v; 405 432 } … … 419 446 v->length = length; 420 447 hash_insert_at (&set->table, v, var_slot); 448 if (set == &global_variable_set) 449 ++variable_changenum; 450 421 451 #ifdef CONFIG_WITH_VALUE_LENGTH 422 452 if (value_len == ~0U) … … 507 537 508 538 static void 509 free_variable_name_and_value (const void *item); 539 free_variable_name_and_value (const void *item) 540 { 541 struct variable *v = (struct variable *) item; 542 #ifndef CONFIG_WITH_STRCACHE2 543 free (v->name); 544 #endif 545 #ifdef CONFIG_WITH_COMPILER 546 if (v->evalprog || v->expandprog) 547 kmk_cc_variable_deleted (v); 548 #endif 549 #ifdef CONFIG_WITH_RDONLY_VARIABLE_VALUE 550 if (!v->rdonly_val) 551 #endif 552 free (v->value); 553 } 554 555 void 556 free_variable_set (struct variable_set_list *list) 557 { 558 hash_map (&list->set->table, free_variable_name_and_value); 559 #ifndef CONFIG_WITH_ALLOC_CACHES 560 hash_free (&list->set->table, 1); 561 free (list->set); 562 free (list); 563 #else 564 hash_free_cached (&list->set->table, 1, &variable_cache); 565 alloccache_free (&variable_set_cache, list->set); 566 alloccache_free (&variable_set_list_cache, list); 567 #endif 568 } 510 569 511 570 void … … 547 606 { 548 607 if (v->aliased) 549 error (NULL, _("Cannot undefine the aliased variable '%s'"), v->name);608 OS (error, NULL, _("Cannot undefine the aliased variable '%s'"), v->name); 550 609 else 551 error (NULL, _("Cannot undefine the variable alias '%s'"), v->name);610 OS (error, NULL, _("Cannot undefine the variable alias '%s'"), v->name); 552 611 return; 553 612 } … … 555 614 556 615 if (env_overrides && v->origin == o_env) 557 558 559 560 561 /* If the definition is from a stronger source than this one, don't562 undefine it. */616 /* V came from in the environment. Since it was defined 617 before the switches were parsed, it wasn't affected by -e. */ 618 v->origin = o_env_override; 619 620 /* Undefine only if this undefinition is from an equal or stronger 621 source than the variable definition. */ 563 622 if ((int) origin >= (int) v->origin) 564 623 { 565 624 hash_delete_at (&set->table, var_slot); 566 625 #ifdef CONFIG_WITH_STRCACHE2 … … 569 628 #endif 570 629 free_variable_name_and_value (v); 571 } 630 free (v); 631 if (set == &global_variable_set) 632 ++variable_changenum; 633 } 572 634 } 573 635 } … … 580 642 define_variable_alias_in_set (const char *name, unsigned int length, 581 643 struct variable *target, enum variable_origin origin, 582 struct variable_set *set, const structfloc *flocp)644 struct variable_set *set, const floc *flocp) 583 645 { 584 646 struct variable *v; … … 707 769 lookup_special_var (struct variable *var) 708 770 { 709 static unsigned long last_ var_count= 0;771 static unsigned long last_changenum = 0; 710 772 711 773 … … 735 797 */ 736 798 737 if (streq (var->name, ".VARIABLES") 738 && global_variable_set.table.ht_fill != last_var_count) 799 if (variable_changenum != last_changenum && streq (var->name, ".VARIABLES")) 739 800 { 740 801 #ifndef CONFIG_WITH_VALUE_LENGTH … … 783 844 VARIABLE_CHANGED (var); 784 845 785 /* Remember how many variables are in our current count. Since we never 786 remove variables from the list, this is a reliable way to know whether 787 the list is up to date or needs to be recomputed. */ 788 789 last_var_count = global_variable_set.table.ht_fill; 846 /* Remember the current variable change number. */ 847 last_changenum = variable_changenum; 790 848 } 791 849 … … 920 978 /* Lookup a variable whose name is a string starting at NAME 921 979 and with LENGTH chars. NAME need not be null-terminated. 922 Returns address of the `struct variable' containing all info980 Returns address of the 'struct variable' containing all info 923 981 on the variable, or nil if no such variable is defined. */ 924 982 … … 980 1038 # endif 981 1039 MAKE_STATS_2 (v->references++); 982 1040 return v->special ? lookup_special_var (v) : v; 983 1041 } 984 1042 … … 996 1054 #endif /* KMK - need for speed */ 997 1055 #ifdef VMS 998 /* since we don't read envp[] on startup, try to get the999 variable via getenv() here.*/1056 /* VMS does not populate envp[] with DCL symbols and logical names which 1057 historically are mapped to enviroment varables and returned by getenv() */ 1000 1058 { 1001 1059 char *vname = alloca (length + 1); … … 1127 1185 /* Lookup a variable whose name is a string starting at NAME 1128 1186 and with LENGTH chars in set SET. NAME need not be null-terminated. 1129 Returns address of the `struct variable' containing all info1187 Returns address of the 'struct variable' containing all info 1130 1188 on the variable, or nil if no such variable is defined. */ 1131 1189 … … 1204 1262 #ifndef CONFIG_WITH_ALLOC_CACHES 1205 1263 l = (struct variable_set_list *) 1206 1264 xmalloc (sizeof (struct variable_set_list)); 1207 1265 l->set = xmalloc (sizeof (struct variable_set)); 1208 1266 #else /* CONFIG_WITH_ALLOC_CACHES */ … … 1331 1389 #ifndef CONFIG_WITH_STRCACHE2 1332 1390 hash_init (&set->table, SMALL_SCOPE_VARIABLE_BUCKETS, 1333 1391 variable_hash_1, variable_hash_2, variable_hash_cmp); 1334 1392 #else /* CONFIG_WITH_STRCACHE2 */ 1335 1393 hash_init_strcached (&set->table, SMALL_SCOPE_VARIABLE_BUCKETS, … … 1351 1409 } 1352 1410 1353 static void1354 free_variable_name_and_value (const void *item)1355 {1356 struct variable *v = (struct variable *) item;1357 #ifndef CONFIG_WITH_STRCACHE21358 free (v->name);1359 #endif1360 #ifdef CONFIG_WITH_COMPILER1361 if (v->evalprog || v->expandprog)1362 kmk_cc_variable_deleted (v);1363 #endif1364 #ifdef CONFIG_WITH_RDONLY_VARIABLE_VALUE1365 if (!v->rdonly_val)1366 #endif1367 free (v->value);1368 }1369 1370 void1371 free_variable_set (struct variable_set_list *list)1372 {1373 hash_map (&list->set->table, free_variable_name_and_value);1374 #ifndef CONFIG_WITH_ALLOC_CACHES1375 hash_free (&list->set->table, 1);1376 free (list->set);1377 free (list);1378 #else1379 hash_free_cached (&list->set->table, 1, &variable_cache);1380 alloccache_free (&variable_set_cache, list->set);1381 alloccache_free (&variable_set_list_cache, list);1382 #endif1383 }1384 1385 1411 /* Create a new variable set and push it on the current setlist. 1386 1412 If we're pushing a global scope (that is, the current scope is the global … … 1392 1418 push_new_variable_scope (void) 1393 1419 { 1394 current_variable_set_list = create_new_variable_set ();1420 current_variable_set_list = create_new_variable_set (); 1395 1421 if (current_variable_set_list->next == &global_setlist) 1396 1422 { … … 1415 1441 1416 1442 /* Can't call this if there's no scope to pop! */ 1417 assert (current_variable_set_list->next != NULL);1443 assert (current_variable_set_list->next != NULL); 1418 1444 1419 1445 if (current_variable_set_list != &global_setlist) … … 1460 1486 struct variable **from_var_end = from_var_slot + from_set->table.ht_size; 1461 1487 1488 int inc = to_set == &global_variable_set ? 1 : 0; 1489 1462 1490 for ( ; from_var_slot < from_var_end; from_var_slot++) 1463 1491 if (! HASH_VACANT (*from_var_slot)) 1464 1492 { 1465 1466 1493 struct variable *from_var = *from_var_slot; 1494 struct variable **to_var_slot 1467 1495 #ifndef CONFIG_WITH_STRCACHE2 1468 1496 = (struct variable **) hash_find_slot (&to_set->table, *from_var_slot); 1469 1497 #else /* CONFIG_WITH_STRCACHE2 */ 1470 1498 = (struct variable **) hash_find_slot_strcached (&to_set->table, 1471 1499 *from_var_slot); 1472 1500 #endif /* CONFIG_WITH_STRCACHE2 */ 1473 if (HASH_VACANT (*to_var_slot)) 1474 hash_insert_at (&to_set->table, from_var, to_var_slot); 1475 else 1476 { 1477 /* GKM FIXME: delete in from_set->table */ 1501 if (HASH_VACANT (*to_var_slot)) 1502 { 1503 hash_insert_at (&to_set->table, from_var, to_var_slot); 1504 variable_changenum += inc; 1505 } 1506 else 1507 { 1508 /* GKM FIXME: delete in from_set->table */ 1478 1509 #ifdef KMK 1479 1510 if (from_var->aliased) 1480 fatal(NULL, ("Attempting to delete aliased variable '%s'"), from_var->name);1511 OS (fatal, NULL, ("Attempting to delete aliased variable '%s'"), from_var->name); 1481 1512 if (from_var->alias) 1482 fatal(NULL, ("Attempting to delete variable aliased '%s'"), from_var->name);1513 OS (fatal, NULL, ("Attempting to delete variable aliased '%s'"), from_var->name); 1483 1514 #endif 1484 1515 #ifdef CONFIG_WITH_COMPILER … … 1490 1521 #endif 1491 1522 free (from_var->value); 1492 1493 1523 free (from_var); 1524 } 1494 1525 } 1495 1526 } … … 1525 1556 { 1526 1557 if (last0 == 0) 1527 1558 *setlist0 = setlist1; 1528 1559 else 1529 1560 last0->next = setlist1; 1530 1561 } 1531 1562 } … … 1563 1594 define_automatic_variables (void) 1564 1595 { 1565 #if defined(WINDOWS32) || defined(__EMX__) 1566 extern char* default_shell; 1567 #else 1568 extern char default_shell[]; 1569 #endif 1570 register struct variable *v; 1596 struct variable *v; 1571 1597 #ifndef KMK 1572 1598 char buf[200]; … … 1588 1614 1589 1615 sprintf (buf, "%s%s%s", 1590 1591 1592 1593 1594 1616 version_string, 1617 (remote_description == 0 || remote_description[0] == '\0') 1618 ? "" : "-", 1619 (remote_description == 0 || remote_description[0] == '\0') 1620 ? "" : remote_description); 1595 1621 #ifndef KMK 1596 1622 define_variable_cname ("MAKE_VERSION", buf, o_default, 0); 1623 define_variable_cname ("MAKE_HOST", make_host, o_default, 0); 1597 1624 #else /* KMK */ 1598 1625 … … 1619 1646 val = envvar1 ? envvar1->value : envvar2 ? envvar2->value : KBUILD_HOST; 1620 1647 if (envvar1 && envvar2 && strcmp (envvar1->value, envvar2->value)) 1621 error (NULL, _("KBUILD_HOST and BUILD_PLATFORM differs, using KBUILD_HOST=%s."), val);1648 OS (error, NULL, _("KBUILD_HOST and BUILD_PLATFORM differs, using KBUILD_HOST=%s."), val); 1622 1649 if (!envvar1) 1623 1650 define_variable_cname ("KBUILD_HOST", val, o_default, 0); … … 1629 1656 val = envvar1 ? envvar1->value : envvar2 ? envvar2->value : KBUILD_HOST_ARCH; 1630 1657 if (envvar1 && envvar2 && strcmp (envvar1->value, envvar2->value)) 1631 error (NULL, _("KBUILD_HOST_ARCH and BUILD_PLATFORM_ARCH differs, using KBUILD_HOST_ARCH=%s."), val);1658 OS (error, NULL, _("KBUILD_HOST_ARCH and BUILD_PLATFORM_ARCH differs, using KBUILD_HOST_ARCH=%s."), val); 1632 1659 if (!envvar1) 1633 1660 define_variable_cname ("KBUILD_HOST_ARCH", val, o_default, 0); … … 1639 1666 val = envvar1 ? envvar1->value : envvar2 ? envvar2->value : KBUILD_HOST_CPU; 1640 1667 if (envvar1 && envvar2 && strcmp (envvar1->value, envvar2->value)) 1641 error (NULL, _("KBUILD_HOST_CPU and BUILD_PLATFORM_CPU differs, using KBUILD_HOST_CPU=%s."), val);1668 OS (error, NULL, _("KBUILD_HOST_CPU and BUILD_PLATFORM_CPU differs, using KBUILD_HOST_CPU=%s."), val); 1642 1669 if (!envvar1) 1643 1670 define_variable_cname ("KBUILD_HOST_CPU", val, o_default, 0); … … 1861 1888 if (mshp) 1862 1889 (void) define_variable (shell_str, shlen, 1863 1890 mshp->value, o_env_override, 0); 1864 1891 else if (comp) 1865 1892 { 1866 1867 1868 1869 1870 1893 /* $(COMSPEC) shouldn't override $(SHELL). */ 1894 struct variable *shp = lookup_variable (shell_str, shlen); 1895 1896 if (!shp) 1897 (void) define_variable (shell_str, shlen, comp->value, o_env, 0); 1871 1898 } 1872 1899 } … … 1886 1913 if (!replace || !*replace->value) 1887 1914 if (shell && *shell->value && (shell->origin == o_env 1888 1889 1890 1891 free(shell->value);1892 1893 1894 1915 || shell->origin == o_env_override)) 1916 { 1917 /* overwrite whatever we got from the environment */ 1918 free (shell->value); 1919 shell->value = xstrdup (default_shell); 1920 shell->origin = o_default; 1921 } 1895 1922 1896 1923 /* Some people do not like cmd to be used as the default … … 1912 1939 /* overwrite $SHELL */ 1913 1940 (void) define_variable (shell_str, shlen, replace->value, 1914 1941 replace->origin, 0); 1915 1942 else 1916 1943 /* provide a definition if there is none */ 1917 1944 (void) define_variable (shell_str, shlen, default_shell, 1918 1945 o_default, 0); 1919 1946 } 1920 1947 … … 1958 1985 the automatic variables they are variations of. */ 1959 1986 1960 #ifdef VMS 1961 define_variable_cname ("@D", "$(dir $@)", o_automatic, 1); 1962 define_variable_cname ("%D", "$(dir $%)", o_automatic, 1); 1963 define_variable_cname ("*D", "$(dir $*)", o_automatic, 1); 1964 define_variable_cname ("<D", "$(dir $<)", o_automatic, 1); 1965 define_variable_cname ("?D", "$(dir $?)", o_automatic, 1); 1966 define_variable_cname ("^D", "$(dir $^)", o_automatic, 1); 1967 define_variable_cname ("+D", "$(dir $+)", o_automatic, 1); 1968 #else 1987 #if defined(__MSDOS__) || defined(WINDOWS32) 1988 /* For consistency, remove the trailing backslash as well as slash. */ 1989 define_variable_cname ("@D", "$(patsubst %/,%,$(patsubst %\\,%,$(dir $@)))", 1990 o_automatic, 1); 1991 define_variable_cname ("%D", "$(patsubst %/,%,$(patsubst %\\,%,$(dir $%)))", 1992 o_automatic, 1); 1993 define_variable_cname ("*D", "$(patsubst %/,%,$(patsubst %\\,%,$(dir $*)))", 1994 o_automatic, 1); 1995 define_variable_cname ("<D", "$(patsubst %/,%,$(patsubst %\\,%,$(dir $<)))", 1996 o_automatic, 1); 1997 define_variable_cname ("?D", "$(patsubst %/,%,$(patsubst %\\,%,$(dir $?)))", 1998 o_automatic, 1); 1999 define_variable_cname ("^D", "$(patsubst %/,%,$(patsubst %\\,%,$(dir $^)))", 2000 o_automatic, 1); 2001 define_variable_cname ("+D", "$(patsubst %/,%,$(patsubst %\\,%,$(dir $+)))", 2002 o_automatic, 1); 2003 #else /* not __MSDOS__, not WINDOWS32 */ 1969 2004 define_variable_cname ("@D", "$(patsubst %/,%,$(dir $@))", o_automatic, 1); 1970 2005 define_variable_cname ("%D", "$(patsubst %/,%,$(dir $%))", o_automatic, 1); … … 2073 2108 2074 2109 /* Create a new environment for FILE's commands. 2075 If FILE is nil, this is for the `shell' function.2110 If FILE is nil, this is for the 'shell' function. 2076 2111 The child's MAKELEVEL variable is incremented. */ 2077 2112 … … 2103 2138 #ifndef CONFIG_WITH_STRCACHE2 2104 2139 hash_init (&table, ENVIRONMENT_VARIABLE_BUCKETS, 2105 2140 variable_hash_1, variable_hash_2, variable_hash_cmp); 2106 2141 #else /* CONFIG_WITH_STRCACHE2 */ 2107 2142 hash_init_strcached (&table, ENVIRONMENT_VARIABLE_BUCKETS, … … 2124 2159 v_end = v_slot + set->table.ht_size; 2125 2160 for ( ; v_slot < v_end; v_slot++) 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2161 if (! HASH_VACANT (*v_slot)) 2162 { 2163 struct variable **new_slot; 2164 struct variable *v = *v_slot; 2165 2166 /* If this is a per-target variable and it hasn't been touched 2167 already then look up the global version and take its export 2168 value. */ 2169 if (v->per_target && v->export == v_default) 2170 { 2171 struct variable *gv; 2137 2172 2138 2173 #ifndef CONFIG_WITH_VALUE_LENGTH 2139 gv = lookup_variable_in_set (v->name, strlen(v->name),2174 gv = lookup_variable_in_set (v->name, strlen (v->name), 2140 2175 &global_variable_set); 2141 2176 #else 2142 2177 assert ((int)strlen(v->name) == v->length); 2143 2178 gv = lookup_variable_in_set (v->name, v->length, 2144 2145 #endif 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2179 &global_variable_set); 2180 #endif 2181 if (gv) 2182 v->export = gv->export; 2183 } 2184 2185 switch (v->export) 2186 { 2187 case v_default: 2188 if (v->origin == o_default || v->origin == o_automatic) 2189 /* Only export default variables by explicit request. */ 2190 continue; 2156 2191 2157 2192 /* The variable doesn't have a name that can be exported. */ … … 2159 2194 continue; 2160 2195 2161 if (! export_all_variables 2162 && v->origin != o_command 2163 && v->origin != o_env && v->origin != o_env_override) 2164 continue; 2165 break; 2166 2167 case v_export: 2168 break; 2169 2170 case v_noexport: 2171 { 2172 /* If this is the SHELL variable and it's not exported, 2173 then add the value from our original environment, if 2174 the original environment defined a value for SHELL. */ 2175 extern struct variable shell_var; 2176 if (streq (v->name, "SHELL") && shell_var.value) 2177 { 2178 v = &shell_var; 2179 break; 2180 } 2181 continue; 2182 } 2183 2184 case v_ifset: 2185 if (v->origin == o_default) 2186 continue; 2187 break; 2188 } 2196 if (! export_all_variables 2197 && v->origin != o_command 2198 && v->origin != o_env && v->origin != o_env_override) 2199 continue; 2200 break; 2201 2202 case v_export: 2203 break; 2204 2205 case v_noexport: 2206 { 2207 /* If this is the SHELL variable and it's not exported, 2208 then add the value from our original environment, if 2209 the original environment defined a value for SHELL. */ 2210 if (streq (v->name, "SHELL") && shell_var.value) 2211 { 2212 v = &shell_var; 2213 break; 2214 } 2215 continue; 2216 } 2217 2218 case v_ifset: 2219 if (v->origin == o_default) 2220 continue; 2221 break; 2222 } 2189 2223 2190 2224 #ifndef CONFIG_WITH_STRCACHE2 2191 2225 new_slot = (struct variable **) hash_find_slot (&table, v); 2192 2226 #else /* CONFIG_WITH_STRCACHE2 */ 2193 2227 assert (strcache2_is_cached (&variable_strcache, v->name)); 2194 2228 new_slot = (struct variable **) hash_find_slot_strcached (&table, v); 2195 2229 #endif /* CONFIG_WITH_STRCACHE2 */ 2196 2197 2198 2230 if (HASH_VACANT (*new_slot)) 2231 hash_insert_at (&table, v, new_slot); 2232 } 2199 2233 } 2200 2234 … … 2216 2250 2217 2251 #ifndef CONFIG_WITH_STRCACHE2 2218 makelevel_key.name = MAKELEVEL_NAME;2252 makelevel_key.name = (char *)MAKELEVEL_NAME; 2219 2253 makelevel_key.length = MAKELEVEL_LENGTH; 2220 2254 hash_delete (&table, &makelevel_key); … … 2239 2273 if (! HASH_VACANT (*v_slot)) 2240 2274 { 2241 2242 2243 2244 2245 2246 2247 2248 2275 struct variable *v = *v_slot; 2276 2277 /* If V is recursively expanded and didn't come from the environment, 2278 expand its value. If it came from the environment, it should 2279 go back into the environment unchanged. */ 2280 if (v->recursive 2281 && v->origin != o_env && v->origin != o_env_override) 2282 { 2249 2283 #ifndef CONFIG_WITH_VALUE_LENGTH 2250 2284 char *value = recursively_expand_for_file (v, file); 2251 2285 #else 2252 2286 char *value = recursively_expand_for_file (v, file, NULL); 2253 2287 #endif 2254 2288 #ifdef WINDOWS32 2255 if (strcmp(v->name, "Path") == 0 ||2256 strcmp(v->name, "PATH") == 0)2257 convert_Path_to_windows32(value, ';');2258 #endif 2259 2260 2261 2262 2263 2289 if (strcmp (v->name, "Path") == 0 || 2290 strcmp (v->name, "PATH") == 0) 2291 convert_Path_to_windows32 (value, ';'); 2292 #endif 2293 *result++ = xstrdup (concat (3, v->name, "=", value)); 2294 free (value); 2295 } 2296 else 2297 { 2264 2298 #ifdef WINDOWS32 2265 if (strcmp (v->name, "Path") == 0 ||2266 strcmp (v->name, "PATH") == 0)2267 convert_Path_to_windows32 (v->value, ';');2268 #endif 2269 2270 2299 if (strcmp (v->name, "Path") == 0 || 2300 strcmp (v->name, "PATH") == 0) 2301 convert_Path_to_windows32 (v->value, ';'); 2302 #endif 2303 *result++ = xstrdup (concat (3, v->name, "=", v->value)); 2304 } 2271 2305 } 2272 2306 … … 2354 2388 2355 2389 struct variable * 2356 do_variable_definition_append (const structfloc *flocp, struct variable *v,2390 do_variable_definition_append (const floc *flocp, struct variable *v, 2357 2391 const char *value, unsigned int value_len, 2358 2392 int simple_value, enum variable_origin origin, … … 2411 2445 2412 2446 2447 /* Given a string, shell-execute it and return a malloc'ed string of the 2448 * result. This removes only ONE newline (if any) at the end, for maximum 2449 * compatibility with the *BSD makes. If it fails, returns NULL. */ 2450 2451 static char * 2452 shell_result (const char *p) 2453 { 2454 char *buf; 2455 unsigned int len; 2456 char *args[2]; 2457 char *result; 2458 2459 install_variable_buffer (&buf, &len); 2460 2461 args[0] = (char *) p; 2462 args[1] = NULL; 2463 variable_buffer_output (func_shell_base (variable_buffer, args, 0), "\0", 1); 2464 result = strdup (variable_buffer); 2465 2466 restore_variable_buffer (buf, len); 2467 return result; 2468 } 2469 2470 2413 2471 /* Given a variable, a value, and a flavor, define the variable. 2414 2472 See the try_variable_definition() function for details on the parameters. */ … … 2416 2474 struct variable * 2417 2475 #ifndef CONFIG_WITH_VALUE_LENGTH 2418 do_variable_definition (const structfloc *flocp, const char *varname,2476 do_variable_definition (const floc *flocp, const char *varname, 2419 2477 const char *value, enum variable_origin origin, 2420 2478 enum variable_flavor flavor, int target_var) 2421 2479 #else /* CONFIG_WITH_VALUE_LENGTH */ 2422 do_variable_definition_2 (const structfloc *flocp,2480 do_variable_definition_2 (const floc *flocp, 2423 2481 const char *varname, const char *value, 2424 2482 unsigned int value_len, int simple_value, … … 2454 2512 /* A simple variable definition "var := value". Expand the value. 2455 2513 We have to allocate memory since otherwise it'll clobber the 2456 2514 variable buffer, and we may still need that if we're looking at a 2457 2515 target-specific variable. */ 2458 2516 #ifndef CONFIG_WITH_VALUE_LENGTH … … 2476 2534 #endif /* CONFIG_WITH_VALUE_LENGTH */ 2477 2535 break; 2536 case f_shell: 2537 { 2538 /* A shell definition "var != value". Expand value, pass it to 2539 the shell, and store the result in recursively-expanded var. */ 2540 char *q = allocated_variable_expand (value); 2541 p = alloc_value = shell_result (q); 2542 free (q); 2543 flavor = f_recursive; 2544 break; 2545 } 2478 2546 case f_conditional: 2479 2547 /* A conditional variable definition "var ?= value". … … 2496 2564 case f_recursive: 2497 2565 /* A recursive variable definition "var = value". 2498 2566 The value is used verbatim. */ 2499 2567 p = value; 2500 2568 break; … … 2605 2673 } 2606 2674 2607 if (tp) 2608 free (tp); 2675 free (tp); 2609 2676 #endif /* !CONFIG_WITH_VALUE_LENGTH */ 2610 2677 } … … 2615 2682 /* Many Unix Makefiles include a line saying "SHELL=/bin/sh", but 2616 2683 non-Unix systems don't conform to this default configuration (in 2617 fact, most of them don't even have `/bin'). On the other hand,2684 fact, most of them don't even have '/bin'). On the other hand, 2618 2685 $SHELL in the environment, if set, points to the real pathname of 2619 2686 the shell. … … 2634 2701 /* See if we can find "/bin/sh.exe", "/bin/sh.com", etc. */ 2635 2702 if (__dosexec_find_on_path (p, NULL, shellpath)) 2636 2637 2638 2639 2703 { 2704 char *tp; 2705 2706 for (tp = shellpath; *tp; tp++) 2640 2707 if (*tp == '\\') 2641 2708 *tp = '/'; 2642 2709 2643 2710 v = define_variable_loc (varname, varname_len, 2644 2711 shellpath, origin, flavor == f_recursive, 2645 2712 flocp); 2646 2713 } 2647 2714 else 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2715 { 2716 const char *shellbase, *bslash; 2717 struct variable *pathv = lookup_variable ("PATH", 4); 2718 char *path_string; 2719 char *fake_env[2]; 2720 size_t pathlen = 0; 2721 2722 shellbase = strrchr (p, '/'); 2723 bslash = strrchr (p, '\\'); 2724 if (!shellbase || bslash > shellbase) 2725 shellbase = bslash; 2726 if (!shellbase && p[1] == ':') 2727 shellbase = p + 1; 2728 if (shellbase) 2729 shellbase++; 2730 else 2731 shellbase = p; 2732 2733 /* Search for the basename of the shell (with standard 2734 executable extensions) along the $PATH. */ 2735 if (pathv) 2736 pathlen = strlen (pathv->value); 2737 path_string = xmalloc (5 + pathlen + 2 + 1); 2738 /* On MSDOS, current directory is considered as part of $PATH. */ 2739 sprintf (path_string, "PATH=.;%s", pathv ? pathv->value : ""); 2740 fake_env[0] = path_string; 2741 fake_env[1] = 0; 2742 if (__dosexec_find_on_path (shellbase, fake_env, shellpath)) 2743 { 2744 char *tp; 2745 2746 for (tp = shellpath; *tp; tp++) 2680 2747 if (*tp == '\\') 2681 2748 *tp = '/'; 2682 2749 2683 2750 v = define_variable_loc (varname, varname_len, 2684 2751 shellpath, origin, 2685 2752 flavor == f_recursive, flocp); 2686 2753 } 2687 2688 2689 2690 2691 2754 else 2755 v = lookup_variable (varname, varname_len); 2756 2757 free (path_string); 2758 } 2692 2759 } 2693 2760 else … … 2698 2765 && streq (varname, "SHELL")) 2699 2766 { 2700 extern c har *default_shell;2767 extern const char *default_shell; 2701 2768 2702 2769 /* Call shell locator function. If it returns TRUE, then 2703 2770 set no_default_sh_exe to indicate sh was found and 2704 2771 set new value for SHELL variable. */ 2705 2772 … … 2739 2806 v = lookup_variable (varname, varname_len); 2740 2807 2741 if (tp) 2742 free (tp); 2808 free (tp); 2743 2809 } 2744 2810 } … … 2768 2834 2769 2835 #ifndef CONFIG_WITH_VALUE_LENGTH 2770 if (alloc_value) 2771 free (alloc_value); 2836 free (alloc_value); 2772 2837 #else 2773 2838 if (free_value) … … 2781 2846 /* Parse P (a null-terminated string) as a variable definition. 2782 2847 2783 If it is not a variable definition, return NULL. 2848 If it is not a variable definition, return NULL and the contents of *VAR 2849 are undefined, except NAME is set to the first non-space character or NIL. 2784 2850 2785 2851 If it is a variable definition, return a pointer to the char after the 2786 assignment token and set *FLAVOR to the type of variable assignment. */ 2852 assignment token and set the following fields (only) of *VAR: 2853 name : name of the variable (ALWAYS SET) (NOT NUL-TERMINATED!) 2854 length : length of the variable name 2855 value : value of the variable (nul-terminated) 2856 flavor : flavor of the variable 2857 Other values in *VAR are unchanged. 2858 */ 2787 2859 2788 2860 char * 2789 parse_variable_definition (const char *p, enum variable_flavor *flavor)2861 parse_variable_definition (const char *p, struct variable *var) 2790 2862 { 2791 2863 int wspace = 0; 2792 2793 p = next_token (p); 2864 const char *e = NULL; 2865 2866 /** @todo merge 4.2.1: parse_variable_definition does more now */ 2867 NEXT_TOKEN (p); 2868 var->name = (char *)p; 2869 var->length = 0; 2794 2870 2795 2871 while (1) … … 2798 2874 2799 2875 /* If we find a comment or EOS, it's not a variable definition. */ 2800 if ( c == '\0' || c == '#')2801 2876 if (STOP_SET (c, MAP_COMMENT|MAP_NUL)) 2877 return NULL; 2802 2878 2803 2879 if (c == '$') 2804 { 2805 /* This begins a variable expansion reference. Make sure we don't 2806 treat chars inside the reference as assignment tokens. */ 2807 char closeparen; 2808 int count; 2809 c = *p++; 2810 if (c == '(') 2811 closeparen = ')'; 2812 else if (c == '{') 2813 closeparen = '}'; 2814 else 2880 { 2881 /* This begins a variable expansion reference. Make sure we don't 2882 treat chars inside the reference as assignment tokens. */ 2883 char closeparen; 2884 unsigned int count; 2885 2886 c = *p++; 2887 if (c == '(') 2888 closeparen = ')'; 2889 else if (c == '{') 2890 closeparen = '}'; 2891 else if (c == '\0') 2892 return NULL; 2893 else 2815 2894 /* '$$' or '$X'. Either way, nothing special to do here. */ 2816 continue; 2817 2818 /* P now points past the opening paren or brace. 2819 Count parens or braces until it is matched. */ 2820 count = 0; 2821 for (; *p != '\0'; ++p) 2822 { 2823 if (*p == c) 2824 ++count; 2825 else if (*p == closeparen && --count < 0) 2826 { 2827 ++p; 2828 break; 2829 } 2830 } 2895 continue; 2896 2897 /* P now points past the opening paren or brace. 2898 Count parens or braces until it is matched. */ 2899 for (count = 1; *p != '\0'; ++p) 2900 { 2901 if (*p == closeparen && --count == 0) 2902 { 2903 ++p; 2904 break; 2905 } 2906 if (*p == c) 2907 ++count; 2908 } 2831 2909 continue; 2832 2910 } 2833 2911 2834 2912 /* If we find whitespace skip it, and remember we found it. */ 2835 if ( isblank ((unsigned char)c))2913 if (ISBLANK (c)) 2836 2914 { 2837 2915 wspace = 1; 2838 p = next_token (p); 2916 e = p - 1; 2917 NEXT_TOKEN (p); 2839 2918 c = *p; 2840 2919 if (c == '\0') … … 2845 2924 2846 2925 if (c == '=') 2847 { 2848 *flavor = f_recursive; 2849 return (char *)p; 2850 } 2851 2852 /* Match assignment variants (:=, +=, ?=) */ 2926 { 2927 var->flavor = f_recursive; 2928 if (! e) 2929 e = p - 1; 2930 break; 2931 } 2932 2933 /* Match assignment variants (:=, +=, ?=, !=) */ 2853 2934 if (*p == '=') 2854 2935 { … … 2856 2937 { 2857 2938 case ':': 2858 *flavor = f_simple;2939 var->flavor = f_simple; 2859 2940 break; 2860 2941 case '+': 2861 *flavor = f_append;2942 var->flavor = f_append; 2862 2943 break; 2863 2944 #ifdef CONFIG_WITH_PREPEND_ASSIGNMENT 2864 2945 case '<': 2865 *flavor = f_prepend;2946 var->flavor = f_prepend; 2866 2947 break; 2867 2948 #endif 2868 2949 case '?': 2869 *flavor = f_conditional; 2950 var->flavor = f_conditional; 2951 break; 2952 case '!': 2953 var->flavor = f_shell; 2870 2954 break; 2871 2955 default: … … 2877 2961 continue; 2878 2962 } 2879 return (char *)++p; 2963 if (! e) 2964 e = p - 1; 2965 ++p; 2966 break; 2880 2967 } 2881 else if (c == ':') 2882 /* A colon other than := is a rule line, not a variable defn. */ 2883 return NULL; 2968 2969 /* Check for POSIX ::= syntax */ 2970 if (c == ':') 2971 { 2972 /* A colon other than :=/::= is not a variable defn. */ 2973 if (*p != ':' || p[1] != '=') 2974 return NULL; 2975 2976 /* POSIX allows ::= to be the same as GNU make's := */ 2977 var->flavor = f_simple; 2978 if (! e) 2979 e = p - 1; 2980 p += 2; 2981 break; 2982 } 2884 2983 2885 2984 /* If we skipped whitespace, non-assignments means no var. */ … … 2888 2987 } 2889 2988 2989 var->length = e - var->name; 2990 var->value = next_token (p); 2991 #ifdef CONFIG_WITH_VALUE_LENGTH 2992 var->value_alloc_len = ~(unsigned int)0; 2993 var->value_length = -1; 2994 # ifdef CONFIG_WITH_RDONLY_VARIABLE_VALUE 2995 var->rdonly_val = 0; 2996 # endif 2997 #endif 2890 2998 return (char *)p; 2891 2999 } … … 2894 3002 /* Try to interpret LINE (a null-terminated string) as a variable definition. 2895 3003 2896 If LINE was recognized as a variable definition, a pointer to its `struct3004 If LINE was recognized as a variable definition, a pointer to its 'struct 2897 3005 variable' is returned. If LINE is not a variable definition, NULL is 2898 3006 returned. */ 2899 3007 2900 3008 struct variable * 2901 assign_variable_definition (struct variable *v, char *line IF_WITH_VALUE_LENGTH_PARAM(char *eos)) 2902 { 2903 char *beg; 2904 char *end; 2905 enum variable_flavor flavor; 3009 assign_variable_definition (struct variable *v, const char *line IF_WITH_VALUE_LENGTH_PARAM(char *eos)) 3010 { 2906 3011 #ifndef CONFIG_WITH_VALUE_LENGTH 2907 3012 char *name; 2908 3013 #endif 2909 3014 2910 beg = next_token (line); 2911 line = parse_variable_definition (beg, &flavor); 2912 if (!line) 3015 if (!parse_variable_definition (line, v)) 2913 3016 return NULL; 2914 3017 2915 end = line - (flavor == f_recursive ? 1 : 2);2916 while (end > beg && isblank ((unsigned char)end[-1]))2917 --end;2918 line = next_token (line);2919 v->value = line;2920 v->flavor = flavor;2921 3018 #ifdef CONFIG_WITH_VALUE_LENGTH 2922 v->value_alloc_len = ~(unsigned int)0; 2923 v->value_length = eos != NULL ? eos - line : -1; 2924 assert (eos == NULL || strchr (line, '\0') == eos); 2925 # ifdef CONFIG_WITH_RDONLY_VARIABLE_VALUE 2926 v->rdonly_val = 0; 2927 # endif 3019 if (eos) 3020 { 3021 v->value_length = eos - v->value; 3022 assert (strchr (v->value, '\0') == eos); 3023 } 2928 3024 #endif 2929 3025 2930 3026 /* Expand the name, so "$(foo)bar = baz" works. */ 2931 3027 #ifndef CONFIG_WITH_VALUE_LENGTH 2932 name = alloca ( end - beg+ 1);2933 memcpy (name, beg, end - beg);2934 name[ end - beg] = '\0';3028 name = alloca (v->length + 1); 3029 memcpy (name, v->name, v->length); 3030 name[v->length] = '\0'; 2935 3031 v->name = allocated_variable_expand (name); 2936 3032 #else /* CONFIG_WITH_VALUE_LENGTH */ 2937 v->name = allocated_variable_expand_2 ( beg, end - beg, NULL);3033 v->name = allocated_variable_expand_2 (v->name, v->length, NULL); 2938 3034 #endif /* CONFIG_WITH_VALUE_LENGTH */ 2939 3035 2940 3036 if (v->name[0] == '\0') 2941 fatal (&v->fileinfo, _("empty variable name"));3037 O (fatal, &v->fileinfo, _("empty variable name")); 2942 3038 2943 3039 return v; … … 2954 3050 See the comments for assign_variable_definition(). 2955 3051 2956 If LINE was recognized as a variable definition, a pointer to its `struct3052 If LINE was recognized as a variable definition, a pointer to its 'struct 2957 3053 variable' is returned. If LINE is not a variable definition, NULL is 2958 3054 returned. */ 2959 3055 2960 3056 struct variable * 2961 try_variable_definition (const struct floc *flocp,char *line3057 try_variable_definition (const floc *flocp, const char *line 2962 3058 IF_WITH_VALUE_LENGTH_PARAM(char *eos), 2963 3059 enum variable_origin origin, int target_var) … … 3025 3121 switch (v->origin) 3026 3122 { 3123 case o_automatic: 3124 origin = _("automatic"); 3125 break; 3027 3126 case o_default: 3028 3127 origin = _("default"); … … 3041 3140 break; 3042 3141 case o_override: 3043 origin = _("`override' directive"); 3044 break; 3045 case o_automatic: 3046 origin = _("automatic"); 3142 origin = _("'override' directive"); 3047 3143 break; 3048 3144 #ifdef CONFIG_WITH_LOCAL_VARIABLES … … 3061 3157 #ifndef KMK 3062 3158 if (v->fileinfo.filenm) 3063 printf (_(" (from `%s', line %lu)"),3064 v->fileinfo.filenm, v->fileinfo.lineno );3159 printf (_(" (from '%s', line %lu)"), 3160 v->fileinfo.filenm, v->fileinfo.lineno + v->fileinfo.offset); 3065 3161 #else /* KMK */ 3066 3162 if (alias->fileinfo.filenm) … … 3139 3235 fputs (prefix, stdout); 3140 3236 3141 /* Is this a `define'? */3237 /* Is this a 'define'? */ 3142 3238 if (v->recursive && strchr (v->value, '\n') != 0) 3143 3239 #ifndef KMK /** @todo language feature for aliases */ … … 3159 3255 p = next_token (v->value); 3160 3256 if (p != v->value && *p == '\0') 3161 3162 3257 /* All whitespace. */ 3258 printf ("$(subst ,,%s)", v->value); 3163 3259 else if (v->recursive) 3164 3260 fputs (v->value, stdout); 3165 3261 else 3166 3167 3168 3169 3170 3171 3172 3262 /* Double up dollar signs. */ 3263 for (p = v->value; *p != '\0'; ++p) 3264 { 3265 if (*p == '$') 3266 putchar ('$'); 3267 putchar (*p); 3268 } 3173 3269 putchar ('\n'); 3174 3270 } 3271 } 3272 3273 3274 static void 3275 print_auto_variable (const void *item, void *arg) 3276 { 3277 const struct variable *v = item; 3278 3279 if (v->origin == o_automatic) 3280 print_variable (item, arg); 3281 } 3282 3283 3284 static void 3285 print_noauto_variable (const void *item, void *arg) 3286 { 3287 const struct variable *v = item; 3288 3289 if (v->origin != o_automatic) 3290 print_variable (item, arg); 3175 3291 } 3176 3292 … … 3179 3295 the actual variable definitions (everything else is comments). */ 3180 3296 3297 #ifndef KMK 3298 static 3299 #endif 3181 3300 void 3182 print_variable_set (struct variable_set *set, c har *prefix)3301 print_variable_set (struct variable_set *set, const char *prefix, int pauto) 3183 3302 { 3184 3303 #if defined (CONFIG_WITH_COMPILER) || defined (CONFIG_WITH_MAKE_STATS) … … 3196 3315 #endif 3197 3316 3198 hash_map_arg (&set->table, print_variable, prefix); 3317 hash_map_arg (&set->table, (pauto ? print_auto_variable : print_variable), 3318 (void *)prefix); 3199 3319 3200 3320 if (set->table.ht_fill) … … 3266 3386 puts (_("\n# Variables\n")); 3267 3387 3268 print_variable_set (&global_variable_set, "" );3388 print_variable_set (&global_variable_set, "", 0); 3269 3389 3270 3390 puts (_("\n# Pattern-specific Variable Values")); … … 3272 3392 { 3273 3393 struct pattern_var *p; 3274 int rules = 0;3394 unsigned int rules = 0; 3275 3395 3276 3396 for (p = pattern_vars; p != 0; p = p->next) … … 3278 3398 ++rules; 3279 3399 printf ("\n%s :\n", p->target); 3280 print_variable (&p->variable, "# ");3400 print_variable (&p->variable, (void *)"# "); 3281 3401 } 3282 3402 … … 3308 3428 { 3309 3429 if (file->variables != 0) 3310 print_variable_set (file->variables->set, "# "); 3430 print_variable_set (file->variables->set, "# ", 1); 3431 } 3432 3433 void 3434 print_target_variables (const struct file *file) 3435 { 3436 if (file->variables != 0) 3437 { 3438 int l = strlen (file->name); 3439 char *t = alloca (l + 3); 3440 3441 strcpy (t, file->name); 3442 t[l] = ':'; 3443 t[l+1] = ' '; 3444 t[l+2] = '\0'; 3445 3446 hash_map_arg (&file->variables->set->table, print_noauto_variable, t); 3447 } 3311 3448 } 3312 3449 … … 3321 3458 return; 3322 3459 3323 /* 3324 * If done this before, don't leak memory unnecessarily. 3325 * Free the previous entry before allocating new one. 3326 */ 3327 if (environ_path) 3328 free (environ_path); 3329 3330 /* 3331 * Create something WINDOWS32 world can grok 3332 */ 3460 /* If done this before, free the previous entry before allocating new one. */ 3461 free (environ_path); 3462 3463 /* Create something WINDOWS32 world can grok. */ 3333 3464 convert_Path_to_windows32 (path, ';'); 3334 3465 environ_path = xstrdup (concat (3, "PATH", "=", path));
Note:
See TracChangeset
for help on using the changeset viewer.