diff options
author | Simon J. Gerraty <sjg@FreeBSD.org> | 2013-05-20 22:51:11 +0000 |
---|---|---|
committer | Simon J. Gerraty <sjg@FreeBSD.org> | 2013-05-20 22:51:11 +0000 |
commit | 52d86256168d7f996587fd411f4c692fa750ff72 (patch) | |
tree | c22bfafacf1ef1525514f8ec6e3ff8d81ab28b8d /contrib/bmake/suff.c | |
parent | b3f35be0c65ed70515d14d9441d8397a606e1554 (diff) | |
parent | dca4585d16e9cd593a0b85c0d317ceab4bb4b3c0 (diff) | |
download | src-52d86256168d7f996587fd411f4c692fa750ff72.tar.gz src-52d86256168d7f996587fd411f4c692fa750ff72.zip |
Sync with upstream version (20130520) that includes same fixes made last week.
Notes
Notes:
svn path=/head/; revision=250837
Diffstat (limited to 'contrib/bmake/suff.c')
-rw-r--r-- | contrib/bmake/suff.c | 181 |
1 files changed, 91 insertions, 90 deletions
diff --git a/contrib/bmake/suff.c b/contrib/bmake/suff.c index 8a7a2e0afac4..d4f0eb183fc7 100644 --- a/contrib/bmake/suff.c +++ b/contrib/bmake/suff.c @@ -1,4 +1,4 @@ -/* $NetBSD: suff.c,v 1.69 2011/09/29 23:38:04 sjg Exp $ */ +/* $NetBSD: suff.c,v 1.70 2013/05/18 13:13:34 sjg Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -69,14 +69,14 @@ */ #ifndef MAKE_NATIVE -static char rcsid[] = "$NetBSD: suff.c,v 1.69 2011/09/29 23:38:04 sjg Exp $"; +static char rcsid[] = "$NetBSD: suff.c,v 1.70 2013/05/18 13:13:34 sjg Exp $"; #else #include <sys/cdefs.h> #ifndef lint #if 0 static char sccsid[] = "@(#)suff.c 8.4 (Berkeley) 3/21/94"; #else -__RCSID("$NetBSD: suff.c,v 1.69 2011/09/29 23:38:04 sjg Exp $"); +__RCSID("$NetBSD: suff.c,v 1.70 2013/05/18 13:13:34 sjg Exp $"); #endif #endif /* not lint */ #endif @@ -2063,118 +2063,119 @@ SuffFindNormalDeps(GNode *gn, Lst slst) if (!(gn->type & OP_PHONY)) { - while (ln != NULL) { + while (ln != NULL) { + /* + * Look for next possible suffix... + */ + ln = Lst_FindFrom(sufflist, ln, &sd, SuffSuffIsSuffixP); + + if (ln != NULL) { + int prefLen; /* Length of the prefix */ + + /* + * Allocate a Src structure to which things can be transformed + */ + targ = bmake_malloc(sizeof(Src)); + targ->file = bmake_strdup(gn->name); + targ->suff = (Suff *)Lst_Datum(ln); + targ->suff->refCount++; + targ->node = gn; + targ->parent = NULL; + targ->children = 0; +#ifdef DEBUG_SRC + targ->cp = Lst_Init(FALSE); +#endif + + /* + * Allocate room for the prefix, whose end is found by + * subtracting the length of the suffix from + * the end of the name. + */ + prefLen = (eoname - targ->suff->nameLen) - sopref; + targ->pref = bmake_malloc(prefLen + 1); + memcpy(targ->pref, sopref, prefLen); + targ->pref[prefLen] = '\0'; + + /* + * Add nodes from which the target can be made + */ + SuffAddLevel(srcs, targ); + + /* + * Record the target so we can nuke it + */ + (void)Lst_AtEnd(targs, targ); + + /* + * Search from this suffix's successor... + */ + ln = Lst_Succ(ln); + } + } + /* - * Look for next possible suffix... + * Handle target of unknown suffix... */ - ln = Lst_FindFrom(sufflist, ln, &sd, SuffSuffIsSuffixP); - - if (ln != NULL) { - int prefLen; /* Length of the prefix */ + if (Lst_IsEmpty(targs) && suffNull != NULL) { + if (DEBUG(SUFF)) { + fprintf(debug_file, "\tNo known suffix on %s. Using .NULL suffix\n", gn->name); + } - /* - * Allocate a Src structure to which things can be transformed - */ targ = bmake_malloc(sizeof(Src)); targ->file = bmake_strdup(gn->name); - targ->suff = (Suff *)Lst_Datum(ln); + targ->suff = suffNull; targ->suff->refCount++; targ->node = gn; targ->parent = NULL; targ->children = 0; + targ->pref = bmake_strdup(sopref); #ifdef DEBUG_SRC targ->cp = Lst_Init(FALSE); #endif /* - * Allocate room for the prefix, whose end is found by subtracting - * the length of the suffix from the end of the name. + * Only use the default suffix rules if we don't have commands + * defined for this gnode; traditional make programs used to + * not define suffix rules if the gnode had children but we + * don't do this anymore. */ - prefLen = (eoname - targ->suff->nameLen) - sopref; - targ->pref = bmake_malloc(prefLen + 1); - memcpy(targ->pref, sopref, prefLen); - targ->pref[prefLen] = '\0'; + if (Lst_IsEmpty(gn->commands)) + SuffAddLevel(srcs, targ); + else { + if (DEBUG(SUFF)) + fprintf(debug_file, "not "); + } - /* - * Add nodes from which the target can be made - */ - SuffAddLevel(srcs, targ); + if (DEBUG(SUFF)) + fprintf(debug_file, "adding suffix rules\n"); - /* - * Record the target so we can nuke it - */ (void)Lst_AtEnd(targs, targ); - - /* - * Search from this suffix's successor... - */ - ln = Lst_Succ(ln); - } - } - - /* - * Handle target of unknown suffix... - */ - if (Lst_IsEmpty(targs) && suffNull != NULL) { - if (DEBUG(SUFF)) { - fprintf(debug_file, "\tNo known suffix on %s. Using .NULL suffix\n", gn->name); } - targ = bmake_malloc(sizeof(Src)); - targ->file = bmake_strdup(gn->name); - targ->suff = suffNull; - targ->suff->refCount++; - targ->node = gn; - targ->parent = NULL; - targ->children = 0; - targ->pref = bmake_strdup(sopref); -#ifdef DEBUG_SRC - targ->cp = Lst_Init(FALSE); -#endif - /* - * Only use the default suffix rules if we don't have commands - * defined for this gnode; traditional make programs used to - * not define suffix rules if the gnode had children but we - * don't do this anymore. + * Using the list of possible sources built up from the target + * suffix(es), try and find an existing file/target that matches. */ - if (Lst_IsEmpty(gn->commands)) - SuffAddLevel(srcs, targ); - else { - if (DEBUG(SUFF)) - fprintf(debug_file, "not "); - } - - if (DEBUG(SUFF)) - fprintf(debug_file, "adding suffix rules\n"); - - (void)Lst_AtEnd(targs, targ); - } + bottom = SuffFindThem(srcs, slst); - /* - * Using the list of possible sources built up from the target suffix(es), - * try and find an existing file/target that matches. - */ - bottom = SuffFindThem(srcs, slst); - - if (bottom == NULL) { - /* - * No known transformations -- use the first suffix found for setting - * the local variables. - */ - if (!Lst_IsEmpty(targs)) { - targ = (Src *)Lst_Datum(Lst_First(targs)); + if (bottom == NULL) { + /* + * No known transformations -- use the first suffix found + * for setting the local variables. + */ + if (!Lst_IsEmpty(targs)) { + targ = (Src *)Lst_Datum(Lst_First(targs)); + } else { + targ = NULL; + } } else { - targ = NULL; + /* + * Work up the transformation path to find the suffix of the + * target to which the transformation was made. + */ + for (targ = bottom; targ->parent != NULL; targ = targ->parent) + continue; } - } else { - /* - * Work up the transformation path to find the suffix of the - * target to which the transformation was made. - */ - for (targ = bottom; targ->parent != NULL; targ = targ->parent) - continue; - } } Var_Set(TARGET, gn->path ? gn->path : gn->name, gn, 0); |