Changeset 280 in kBuild for branches/GNU/src/gmake/expand.c
- Timestamp:
- May 16, 2005 4:54:02 PM (20 years ago)
- Location:
- branches/GNU/src/gmake
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/GNU/src/gmake
- Property svn:ignore
-
old new 34 34 README.DOS 35 35 README.W32 36 README.OS2 36 37 aclocal.m4 37 38 autom4te.cache
-
- Property svn:ignore
-
branches/GNU/src/gmake/expand.c
r54 r280 155 155 warn_undefined (name, length); 156 156 157 if (v == 0 || *v->value == '\0') 157 /* If there's no variable by that name or it has no value, stop now. */ 158 if (v == 0 || (*v->value == '\0' && !v->append)) 158 159 return o; 159 160 … … 306 307 warn_undefined (beg, colon - beg); 307 308 309 /* If the variable is not empty, perform the 310 substitution. */ 308 311 if (v != 0 && *v->value != '\0') 309 312 { 310 char *value = (v->recursive ? recursively_expand (v) 313 char *pattern, *replace, *ppercent, *rpercent; 314 char *value = (v->recursive 315 ? recursively_expand (v) 311 316 : v->value); 312 char *pattern, *percent; 313 if (free_beg) 314 { 315 *subst_end = '\0'; 316 pattern = subst_beg; 317 } 317 318 /* Copy the pattern and the replacement. Add in an 319 extra % at the beginning to use in case there 320 isn't one in the pattern. */ 321 pattern = (char *) alloca (subst_end - subst_beg + 2); 322 *(pattern++) = '%'; 323 bcopy (subst_beg, pattern, subst_end - subst_beg); 324 pattern[subst_end - subst_beg] = '\0'; 325 326 replace = (char *) alloca (replace_end 327 - replace_beg + 2); 328 *(replace++) = '%'; 329 bcopy (replace_beg, replace, 330 replace_end - replace_beg); 331 replace[replace_end - replace_beg] = '\0'; 332 333 /* Look for %. Set the percent pointers properly 334 based on whether we find one or not. */ 335 ppercent = find_percent (pattern); 336 if (ppercent) 337 { 338 ++ppercent; 339 rpercent = 0; 340 } 318 341 else 319 { 320 pattern = (char *) alloca (subst_end - subst_beg 321 + 1); 322 bcopy (subst_beg, pattern, subst_end - subst_beg); 323 pattern[subst_end - subst_beg] = '\0'; 324 } 325 percent = find_percent (pattern); 326 if (percent != 0) 327 { 328 char *replace; 329 if (free_beg) 330 { 331 *replace_end = '\0'; 332 replace = replace_beg; 333 } 334 else 335 { 336 replace = (char *) alloca (replace_end 337 - replace_beg 338 + 1); 339 bcopy (replace_beg, replace, 340 replace_end - replace_beg); 341 replace[replace_end - replace_beg] = '\0'; 342 } 343 344 o = patsubst_expand (o, value, pattern, replace, 345 percent, (char *) 0); 346 } 347 else 348 o = subst_expand (o, value, 349 pattern, replace_beg, 350 strlen (pattern), 351 end - replace_beg, 352 0, 1); 342 { 343 ppercent = pattern; 344 rpercent = replace; 345 --pattern; 346 --replace; 347 } 348 349 o = patsubst_expand (o, value, pattern, replace, 350 ppercent, rpercent); 351 353 352 if (v->recursive) 354 353 free (value); … … 447 446 FILE's commands were found. Expansion uses FILE's variable set list. */ 448 447 449 staticchar *448 char * 450 449 variable_expand_for_file (char *line, struct file *file) 451 450 {
Note:
See TracChangeset
for help on using the changeset viewer.