From 8415275dbd5cbd11f3c9e22407a4deeecd0c1ed8 Mon Sep 17 00:00:00 2001 From: christos Date: Wed, 29 Dec 2004 00:43:02 +0000 Subject: [PATCH] Dir_MTime did not search for a file using the correct parh; i.e. it was ignoring suffix-specific path search. So if a node was marked .MADE, then suffix rules would not be applied to it, and we would look for the file only in the default path, not the suffix-specific path. XXX: Now that we looked for the suffix, we can save it in the GNode, but we don't do this yet. --- usr.bin/make/dir.c | 8 ++--- usr.bin/make/nonints.h | 3 +- usr.bin/make/suff.c | 78 ++++++++++++++++++++++++------------------ 3 files changed, 51 insertions(+), 38 deletions(-) diff --git a/usr.bin/make/dir.c b/usr.bin/make/dir.c index f737e483ad38..3bb581e27012 100644 --- a/usr.bin/make/dir.c +++ b/usr.bin/make/dir.c @@ -1,4 +1,4 @@ -/* $NetBSD: dir.c,v 1.43 2004/07/01 20:38:09 jmc Exp $ */ +/* $NetBSD: dir.c,v 1.44 2004/12/29 00:43:02 christos Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -70,14 +70,14 @@ */ #ifndef MAKE_NATIVE -static char rcsid[] = "$NetBSD: dir.c,v 1.43 2004/07/01 20:38:09 jmc Exp $"; +static char rcsid[] = "$NetBSD: dir.c,v 1.44 2004/12/29 00:43:02 christos Exp $"; #else #include #ifndef lint #if 0 static char sccsid[] = "@(#)dir.c 8.2 (Berkeley) 1/2/94"; #else -__RCSID("$NetBSD: dir.c,v 1.43 2004/07/01 20:38:09 jmc Exp $"); +__RCSID("$NetBSD: dir.c,v 1.44 2004/12/29 00:43:02 christos Exp $"); #endif #endif /* not lint */ #endif @@ -1430,7 +1430,7 @@ Dir_MTime(GNode *gn) if (gn->type & OP_NOPATH) fullName = NULL; else - fullName = Dir_FindFile (gn->name, dirSearchPath); + fullName = Dir_FindFile (gn->name, Suff_FindPath(gn)); } else { fullName = gn->path; } diff --git a/usr.bin/make/nonints.h b/usr.bin/make/nonints.h index 8b9d3b199e96..bc72c883069a 100644 --- a/usr.bin/make/nonints.h +++ b/usr.bin/make/nonints.h @@ -1,4 +1,4 @@ -/* $NetBSD: nonints.h,v 1.32 2004/05/07 08:12:16 sjg Exp $ */ +/* $NetBSD: nonints.h,v 1.33 2004/12/29 00:43:02 christos Exp $ */ /*- * Copyright (c) 1988, 1989, 1990, 1993 @@ -153,6 +153,7 @@ void Suff_DoPaths(void); void Suff_AddInclude(char *); void Suff_AddLib(char *); void Suff_FindDeps(GNode *); +Lst Suff_FindPath(GNode *); void Suff_SetNull(char *); void Suff_Init(void); void Suff_End(void); diff --git a/usr.bin/make/suff.c b/usr.bin/make/suff.c index 08a597df57f4..f2731df795d6 100644 --- a/usr.bin/make/suff.c +++ b/usr.bin/make/suff.c @@ -1,4 +1,4 @@ -/* $NetBSD: suff.c,v 1.45 2004/05/07 00:04:40 ross Exp $ */ +/* $NetBSD: suff.c,v 1.46 2004/12/29 00:43:02 christos Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -69,14 +69,14 @@ */ #ifndef MAKE_NATIVE -static char rcsid[] = "$NetBSD: suff.c,v 1.45 2004/05/07 00:04:40 ross Exp $"; +static char rcsid[] = "$NetBSD: suff.c,v 1.46 2004/12/29 00:43:02 christos Exp $"; #else #include #ifndef lint #if 0 static char sccsid[] = "@(#)suff.c 8.4 (Berkeley) 3/21/94"; #else -__RCSID("$NetBSD: suff.c,v 1.45 2004/05/07 00:04:40 ross Exp $"); +__RCSID("$NetBSD: suff.c,v 1.46 2004/12/29 00:43:02 christos Exp $"); #endif #endif /* not lint */ #endif @@ -1505,7 +1505,6 @@ SuffExpandChildren(LstNode prevLN, GNode *pgn) { GNode *cgn = (GNode *) Lst_Datum(prevLN); GNode *gn; /* New source 8) */ - LstNode ln; /* List element for old source */ char *cp; /* Expanded value */ /* @@ -1633,37 +1632,9 @@ SuffExpandChildren(LstNode prevLN, GNode *pgn) } else if (Dir_HasWildcards(cgn->name)) { Lst explist; /* List of expansions */ Lst path; /* Search path along which to expand */ - SuffixCmpData sd; /* Search string data */ - /* - * Find a path along which to expand the word. - * - * If the word has a known suffix, use that path. - * If it has no known suffix and we're allowed to use the null - * suffix, use its path. - * Else use the default system search path. - */ - sd.len = strlen(cgn->name); - sd.ename = cgn->name + sd.len; - ln = Lst_Find(sufflist, (ClientData)&sd, SuffSuffIsSuffixP); + path = Suff_FindPath(cgn); - if (DEBUG(SUFF)) { - printf("Wildcard expanding \"%s\"...", cgn->name); - } - - if (ln != NILLNODE) { - Suff *s = (Suff *)Lst_Datum(ln); - - if (DEBUG(SUFF)) { - printf("suffix is \"%s\"...", s->name); - } - path = s->searchPath; - } else { - /* - * Use default search path - */ - path = dirSearchPath; - } /* * Expand the word along the chosen path @@ -1712,6 +1683,47 @@ SuffExpandChildren(LstNode prevLN, GNode *pgn) return(0); } +/* + * Find a path along which to expand the word. + * + * If the word has a known suffix, use that path. + * If it has no known suffix and we're allowed to use the null + * suffix, use its path. + * Else use the default system search path. + */ +Lst +Suff_FindPath(GNode* gn) +{ + Suff *suff = gn->suffix; + + if (suff == NULL) { + SuffixCmpData sd; /* Search string data */ + LstNode ln; + sd.len = strlen(gn->name); + sd.ename = gn->name + sd.len; + ln = Lst_Find(sufflist, (ClientData)&sd, SuffSuffIsSuffixP); + + if (DEBUG(SUFF)) { + printf("Wildcard expanding \"%s\"...", gn->name); + } + if (ln != NILLNODE) + suff = (Suff *)Lst_Datum(ln); + /* XXX: Here we can save the suffix so we don't have to do this again */ + } + + if (suff != NULL) { + if (DEBUG(SUFF)) { + printf("suffix is \"%s\"...", suff->name); + } + return suff->searchPath; + } else { + /* + * Use default search path + */ + return dirSearchPath; + } +} + /*- *----------------------------------------------------------------------- * SuffApplyTransform --