Changeset 900 for vendor/gnumake/current/variable.c
- Timestamp:
- May 23, 2007, 5:13:11 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
vendor/gnumake/current/variable.c
r501 r900 43 43 44 44 struct pattern_var * 45 create_pattern_var (char *target, char *suffix) 46 { 47 register struct pattern_var *p 48 = (struct pattern_var *) xmalloc (sizeof (struct pattern_var)); 45 create_pattern_var (const char *target, const char *suffix) 46 { 47 register struct pattern_var *p = xmalloc (sizeof (struct pattern_var)); 49 48 50 49 if (last_pattern_var != 0) … … 65 64 66 65 static struct pattern_var * 67 lookup_pattern_var (struct pattern_var *start, c har *target)66 lookup_pattern_var (struct pattern_var *start, const char *target) 68 67 { 69 68 struct pattern_var *p; … … 72 71 for (p = start ? start->next : pattern_vars; p != 0; p = p->next) 73 72 { 74 c har *stem;73 const char *stem; 75 74 unsigned int stemlen; 76 75 … … 163 162 struct variable * 164 163 define_variable_in_set (const char *name, unsigned int length, 165 c har *value, enum variable_origin origin,164 const char *value, enum variable_origin origin, 166 165 int recursive, struct variable_set *set, 167 166 const struct floc *flocp) … … 209 208 /* Create a new variable definition and add it to the hash table. */ 210 209 211 v = (struct variable *)xmalloc (sizeof (struct variable));210 v = xmalloc (sizeof (struct variable)); 212 211 v->name = savestring (name, length); 213 212 v->length = length; … … 318 317 } 319 318 320 bcopy (v->name, p, l);319 memcpy (p, v->name, l); 321 320 p += l; 322 321 *(p++) = ' '; … … 445 444 parent of FILE's variable set. 446 445 447 If we're READ inga makefile, don't do the pattern variable search now,446 If we're READING a makefile, don't do the pattern variable search now, 448 447 since the pattern variable might not have been defined yet. */ 449 448 … … 457 456 l = (struct variable_set_list *) 458 457 xmalloc (sizeof (struct variable_set_list)); 459 l->set = (struct variable_set *)xmalloc (sizeof (struct variable_set));458 l->set = xmalloc (sizeof (struct variable_set)); 460 459 hash_init (&l->set->table, PERFILE_VARIABLE_BUCKETS, 461 460 variable_hash_1, variable_hash_2, variable_hash_cmp); … … 553 552 register struct variable_set *set; 554 553 555 set = (struct variable_set *)xmalloc (sizeof (struct variable_set));554 set = xmalloc (sizeof (struct variable_set)); 556 555 hash_init (&set->table, SMALL_SCOPE_VARIABLE_BUCKETS, 557 556 variable_hash_1, variable_hash_2, variable_hash_cmp); … … 578 577 hash_map (&list->set->table, free_variable_name_and_value); 579 578 hash_free (&list->set->table, 1); 580 free ( (char *)list->set);581 free ( (char *)list);579 free (list->set); 580 free (list); 582 581 } 583 582 … … 635 634 636 635 /* Free the one we no longer need. */ 637 free ( (char *)setlist);636 free (setlist); 638 637 hash_map (&set->table, free_variable_name_and_value); 639 638 hash_free (&set->table, 1); 640 free ( (char *)set);639 free (set); 641 640 } 642 641 … … 953 952 hash_delete (&table, &makelevel_key); 954 953 955 result = result_0 = (char **)xmalloc ((table.ht_fill + 2) * sizeof (char *));954 result = result_0 = xmalloc ((table.ht_fill + 2) * sizeof (char *)); 956 955 957 956 v_slot = (struct variable **) table.ht_vec; … … 974 973 convert_Path_to_windows32(value, ';'); 975 974 #endif 976 *result++ = concat (v->name, "=", value);975 *result++ = xstrdup (concat (v->name, "=", value)); 977 976 free (value); 978 977 } … … 984 983 convert_Path_to_windows32(v->value, ';'); 985 984 #endif 986 *result++ = concat (v->name, "=", v->value);985 *result++ = xstrdup (concat (v->name, "=", v->value)); 987 986 } 988 987 } 989 988 990 *result = (char *)xmalloc (100);991 (void)sprintf (*result, "%s=%u", MAKELEVEL_NAME, makelevel + 1);989 *result = xmalloc (100); 990 sprintf (*result, "%s=%u", MAKELEVEL_NAME, makelevel + 1); 992 991 *++result = 0; 993 992 … … 1003 1002 struct variable * 1004 1003 do_variable_definition (const struct floc *flocp, const char *varname, 1005 c har *value, enum variable_origin origin,1004 const char *value, enum variable_origin origin, 1006 1005 enum variable_flavor flavor, int target_var) 1007 1006 { 1008 char *p, *alloc_value = NULL; 1007 const char *p; 1008 char *alloc_value = NULL; 1009 1009 struct variable *v; 1010 1010 int append = 0; … … 1071 1071 1072 1072 unsigned int oldlen, vallen; 1073 char *val; 1073 const char *val; 1074 char *tp; 1074 1075 1075 1076 val = value; … … 1088 1089 oldlen = strlen (v->value); 1089 1090 vallen = strlen (val); 1090 p = (char *) alloca (oldlen + 1 + vallen + 1); 1091 bcopy (v->value, p, oldlen); 1092 p[oldlen] = ' '; 1093 bcopy (val, &p[oldlen + 1], vallen + 1); 1091 tp = alloca (oldlen + 1 + vallen + 1); 1092 memcpy (tp, v->value, oldlen); 1093 tp[oldlen] = ' '; 1094 memcpy (&tp[oldlen + 1], val, vallen + 1); 1095 p = tp; 1094 1096 } 1095 1097 } … … 1117 1119 1118 1120 /* See if we can find "/bin/sh.exe", "/bin/sh.com", etc. */ 1119 if (__dosexec_find_on_path (p, (char **)0, shellpath))1121 if (__dosexec_find_on_path (p, NULL, shellpath)) 1120 1122 { 1121 char *p; 1122 1123 for (p = shellpath; *p; p++) 1124 { 1125 if (*p == '\\') 1126 *p = '/'; 1127 } 1123 char *tp; 1124 1125 for (tp = shellpath; *tp; tp++) 1126 if (*tp == '\\') 1127 *tp = '/'; 1128 1128 1129 v = define_variable_loc (varname, strlen (varname), 1129 1130 shellpath, origin, flavor == f_recursive, … … 1132 1133 else 1133 1134 { 1134 c har *shellbase, *bslash;1135 const char *shellbase, *bslash; 1135 1136 struct variable *pathv = lookup_variable ("PATH", 4); 1136 1137 char *path_string; … … 1153 1154 if (pathv) 1154 1155 pathlen = strlen (pathv->value); 1155 path_string = (char *)xmalloc (5 + pathlen + 2 + 1);1156 path_string = xmalloc (5 + pathlen + 2 + 1); 1156 1157 /* On MSDOS, current directory is considered as part of $PATH. */ 1157 1158 sprintf (path_string, "PATH=.;%s", pathv ? pathv->value : ""); 1158 1159 fake_env[0] = path_string; 1159 fake_env[1] = (char *)0;1160 fake_env[1] = 0; 1160 1161 if (__dosexec_find_on_path (shellbase, fake_env, shellpath)) 1161 1162 { 1162 char *p; 1163 1164 for (p = shellpath; *p; p++) 1165 { 1166 if (*p == '\\') 1167 *p = '/'; 1168 } 1163 char *tp; 1164 1165 for (tp = shellpath; *tp; tp++) 1166 if (*tp == '\\') 1167 *tp = '/'; 1168 1169 1169 v = define_variable_loc (varname, strlen (varname), 1170 1170 shellpath, origin, … … 1320 1320 1321 1321 /* Expand the name, so "$(foo)bar = baz" works. */ 1322 name = (char *)alloca (end - beg + 1);1323 bcopy (beg, name, end - beg);1322 name = alloca (end - beg + 1); 1323 memcpy (name, beg, end - beg); 1324 1324 name[end - beg] = '\0'; 1325 1325 v->name = allocated_variable_expand (name); … … 1374 1374 print_variable (const void *item, void *arg) 1375 1375 { 1376 const struct variable *v = (struct variable *)item;1377 const char *prefix = (char *)arg;1376 const struct variable *v = item; 1377 const char *prefix = arg; 1378 1378 const char *origin; 1379 1379 … … 1489 1489 1490 1490 void 1491 print_file_variables ( struct file *file)1491 print_file_variables (const struct file *file) 1492 1492 { 1493 1493 if (file->variables != 0) … … 1516 1516 */ 1517 1517 convert_Path_to_windows32 (path, ';'); 1518 environ_path = concat ("PATH", "=", path);1518 environ_path = xstrdup (concat ("PATH", "=", path)); 1519 1519 putenv (environ_path); 1520 1520 free (path);
Note:
See TracChangeset
for help on using the changeset viewer.