Module Name: src Committed By: rillig Date: Fri Aug 28 04:28:45 UTC 2020
Modified Files: src/usr.bin/make: arch.c cond.c dir.c lst.c lst.h main.c meta.c suff.c Log Message: make(1): migrate Lst_Find to Lst_FindS To generate a diff of this commit: cvs rdiff -u -r1.99 -r1.100 src/usr.bin/make/arch.c cvs rdiff -u -r1.101 -r1.102 src/usr.bin/make/cond.c cvs rdiff -u -r1.117 -r1.118 src/usr.bin/make/dir.c cvs rdiff -u -r1.48 -r1.49 src/usr.bin/make/lst.c cvs rdiff -u -r1.51 -r1.52 src/usr.bin/make/lst.h cvs rdiff -u -r1.318 -r1.319 src/usr.bin/make/main.c cvs rdiff -u -r1.104 -r1.105 src/usr.bin/make/meta.c cvs rdiff -u -r1.123 -r1.124 src/usr.bin/make/suff.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/usr.bin/make/arch.c diff -u src/usr.bin/make/arch.c:1.99 src/usr.bin/make/arch.c:1.100 --- src/usr.bin/make/arch.c:1.99 Thu Aug 27 19:15:35 2020 +++ src/usr.bin/make/arch.c Fri Aug 28 04:28:45 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: arch.c,v 1.99 2020/08/27 19:15:35 rillig Exp $ */ +/* $NetBSD: arch.c,v 1.100 2020/08/28 04:28:45 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -69,14 +69,14 @@ */ #ifndef MAKE_NATIVE -static char rcsid[] = "$NetBSD: arch.c,v 1.99 2020/08/27 19:15:35 rillig Exp $"; +static char rcsid[] = "$NetBSD: arch.c,v 1.100 2020/08/28 04:28:45 rillig Exp $"; #else #include <sys/cdefs.h> #ifndef lint #if 0 static char sccsid[] = "@(#)arch.c 8.2 (Berkeley) 1/2/94"; #else -__RCSID("$NetBSD: arch.c,v 1.99 2020/08/27 19:15:35 rillig Exp $"); +__RCSID("$NetBSD: arch.c,v 1.100 2020/08/28 04:28:45 rillig Exp $"); #endif #endif /* not lint */ #endif @@ -548,7 +548,7 @@ ArchStatMember(const char *archive, cons member = base + 1; } - ln = Lst_Find(archives, ArchFindArchive, archive); + ln = Lst_FindS(archives, ArchFindArchive, archive); if (ln != NULL) { ar = Lst_DatumS(ln); Index: src/usr.bin/make/cond.c diff -u src/usr.bin/make/cond.c:1.101 src/usr.bin/make/cond.c:1.102 --- src/usr.bin/make/cond.c:1.101 Thu Aug 27 19:15:35 2020 +++ src/usr.bin/make/cond.c Fri Aug 28 04:28:45 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: cond.c,v 1.101 2020/08/27 19:15:35 rillig Exp $ */ +/* $NetBSD: cond.c,v 1.102 2020/08/28 04:28:45 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -70,14 +70,14 @@ */ #ifndef MAKE_NATIVE -static char rcsid[] = "$NetBSD: cond.c,v 1.101 2020/08/27 19:15:35 rillig Exp $"; +static char rcsid[] = "$NetBSD: cond.c,v 1.102 2020/08/28 04:28:45 rillig Exp $"; #else #include <sys/cdefs.h> #ifndef lint #if 0 static char sccsid[] = "@(#)cond.c 8.2 (Berkeley) 1/2/94"; #else -__RCSID("$NetBSD: cond.c,v 1.101 2020/08/27 19:15:35 rillig Exp $"); +__RCSID("$NetBSD: cond.c,v 1.102 2020/08/28 04:28:45 rillig Exp $"); #endif #endif /* not lint */ #endif @@ -284,7 +284,7 @@ CondFindStrMatch(const void *string, con static Boolean CondDoMake(int argLen MAKE_ATTR_UNUSED, const char *arg) { - return Lst_Find(create, CondFindStrMatch, arg) != NULL; + return Lst_FindS(create, CondFindStrMatch, arg) != NULL; } /* See if the given file exists. */ Index: src/usr.bin/make/dir.c diff -u src/usr.bin/make/dir.c:1.117 src/usr.bin/make/dir.c:1.118 --- src/usr.bin/make/dir.c:1.117 Fri Aug 28 04:16:57 2020 +++ src/usr.bin/make/dir.c Fri Aug 28 04:28:45 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: dir.c,v 1.117 2020/08/28 04:16:57 rillig Exp $ */ +/* $NetBSD: dir.c,v 1.118 2020/08/28 04:28:45 rillig 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.117 2020/08/28 04:16:57 rillig Exp $"; +static char rcsid[] = "$NetBSD: dir.c,v 1.118 2020/08/28 04:28:45 rillig Exp $"; #else #include <sys/cdefs.h> #ifndef lint #if 0 static char sccsid[] = "@(#)dir.c 8.2 (Berkeley) 1/2/94"; #else -__RCSID("$NetBSD: dir.c,v 1.117 2020/08/28 04:16:57 rillig Exp $"); +__RCSID("$NetBSD: dir.c,v 1.118 2020/08/28 04:28:45 rillig Exp $"); #endif #endif /* not lint */ #endif @@ -1544,6 +1544,8 @@ Dir_MTime(GNode *gn, Boolean recheck) * Input: * path the path to which the directory should be * added + * XXX: Why would this ever be NULL, and what does + * that mean? * name the name of the directory to add * * Results: @@ -1563,7 +1565,7 @@ Dir_AddDir(Lst path, const char *name) struct dirent *dp; /* entry in directory */ if (strcmp(name, ".DOTLAST") == 0) { - ln = Lst_Find(path, DirFindName, name); + ln = path != NULL ? Lst_FindS(path, DirFindName, name) : NULL; if (ln != NULL) return Lst_DatumS(ln); else { @@ -1576,7 +1578,7 @@ Dir_AddDir(Lst path, const char *name) } if (path) - ln = Lst_Find(openDirectories, DirFindName, name); + ln = Lst_FindS(openDirectories, DirFindName, name); if (ln != NULL) { p = Lst_DatumS(ln); if (path && Lst_MemberS(path, p) == NULL) { Index: src/usr.bin/make/lst.c diff -u src/usr.bin/make/lst.c:1.48 src/usr.bin/make/lst.c:1.49 --- src/usr.bin/make/lst.c:1.48 Fri Aug 28 04:14:31 2020 +++ src/usr.bin/make/lst.c Fri Aug 28 04:28:45 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: lst.c,v 1.48 2020/08/28 04:14:31 rillig Exp $ */ +/* $NetBSD: lst.c,v 1.49 2020/08/28 04:28:45 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -37,11 +37,11 @@ #include "make.h" #ifndef MAKE_NATIVE -static char rcsid[] = "$NetBSD: lst.c,v 1.48 2020/08/28 04:14:31 rillig Exp $"; +static char rcsid[] = "$NetBSD: lst.c,v 1.49 2020/08/28 04:28:45 rillig Exp $"; #else #include <sys/cdefs.h> #ifndef lint -__RCSID("$NetBSD: lst.c,v 1.48 2020/08/28 04:14:31 rillig Exp $"); +__RCSID("$NetBSD: lst.c,v 1.49 2020/08/28 04:28:45 rillig Exp $"); #endif /* not lint */ #endif @@ -330,18 +330,6 @@ LstNode_SetNullS(LstNode node) * Node-specific functions */ -/* Return the first node from the given list, or NULL if the list is empty or - * invalid. */ -static LstNode -Lst_First(Lst list) -{ - if (!LstIsValid(list) || LstIsEmpty(list)) { - return NULL; - } else { - return list->first; - } -} - /* Return the first node from the given list, or NULL if the list is empty. */ LstNode Lst_FirstS(Lst list) @@ -402,14 +390,6 @@ Lst_IsEmptyS(Lst list) /* Return the first node from the given list for which the given comparison * function returns 0, or NULL if none of the nodes matches. */ LstNode -Lst_Find(Lst list, LstFindProc cmp, const void *cmpData) -{ - return Lst_FindFrom(list, Lst_First(list), cmp, cmpData); -} - -/* Return the first node from the given list for which the given comparison - * function returns 0, or NULL if none of the nodes matches. */ -LstNode Lst_FindS(Lst list, LstFindProc cmp, const void *cmpData) { if (LstIsEmpty(list)) @@ -421,19 +401,6 @@ Lst_FindS(Lst list, LstFindProc cmp, con * which the given comparison function returns 0, or NULL if none of the nodes * matches. */ LstNode -Lst_FindFrom(Lst list, LstNode node, LstFindProc cmp, const void *cmpData) -{ - if (!LstIsValid(list) || LstIsEmpty(list) || !LstNodeIsValid(node)) { - return NULL; - } - - return Lst_FindFromS(list, node, cmp, cmpData); -} - -/* Return the first node from the given list, starting at the given node, for - * which the given comparison function returns 0, or NULL if none of the nodes - * matches. */ -LstNode Lst_FindFromS(Lst list, LstNode node, LstFindProc cmp, const void *cmpData) { LstNode tln; Index: src/usr.bin/make/lst.h diff -u src/usr.bin/make/lst.h:1.51 src/usr.bin/make/lst.h:1.52 --- src/usr.bin/make/lst.h:1.51 Fri Aug 28 04:16:57 2020 +++ src/usr.bin/make/lst.h Fri Aug 28 04:28:45 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: lst.h,v 1.51 2020/08/28 04:16:57 rillig Exp $ */ +/* $NetBSD: lst.h,v 1.52 2020/08/28 04:28:45 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -145,10 +145,8 @@ void *Lst_DatumS(LstNode); * Functions for entire lists */ /* Find an element in a list */ -LstNode Lst_Find(Lst, LstFindProc, const void *); LstNode Lst_FindS(Lst, LstFindProc, const void *); /* Find an element starting from somewhere */ -LstNode Lst_FindFrom(Lst, LstNode, LstFindProc, const void *); LstNode Lst_FindFromS(Lst, LstNode, LstFindProc, const void *); /* * See if the given datum is on the list. Returns the LstNode containing Index: src/usr.bin/make/main.c diff -u src/usr.bin/make/main.c:1.318 src/usr.bin/make/main.c:1.319 --- src/usr.bin/make/main.c:1.318 Fri Aug 28 04:14:31 2020 +++ src/usr.bin/make/main.c Fri Aug 28 04:28:45 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.318 2020/08/28 04:14:31 rillig Exp $ */ +/* $NetBSD: main.c,v 1.319 2020/08/28 04:28:45 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -69,7 +69,7 @@ */ #ifndef MAKE_NATIVE -static char rcsid[] = "$NetBSD: main.c,v 1.318 2020/08/28 04:14:31 rillig Exp $"; +static char rcsid[] = "$NetBSD: main.c,v 1.319 2020/08/28 04:28:45 rillig Exp $"; #else #include <sys/cdefs.h> #ifndef lint @@ -81,7 +81,7 @@ __COPYRIGHT("@(#) Copyright (c) 1988, 19 #if 0 static char sccsid[] = "@(#)main.c 8.3 (Berkeley) 3/19/94"; #else -__RCSID("$NetBSD: main.c,v 1.318 2020/08/28 04:14:31 rillig Exp $"); +__RCSID("$NetBSD: main.c,v 1.319 2020/08/28 04:28:45 rillig Exp $"); #endif #endif /* not lint */ #endif @@ -1330,7 +1330,7 @@ main(int argc, char **argv) if (Lst_IsEmptyS(sysMkPath)) Fatal("%s: no system rules (%s).", progname, _PATH_DEFSYSMK); - ln = Lst_Find(sysMkPath, ReadMakefile, NULL); + ln = Lst_FindS(sysMkPath, ReadMakefile, NULL); if (ln == NULL) Fatal("%s: cannot open %s.", progname, (char *)Lst_DatumS(ln)); @@ -1339,7 +1339,7 @@ main(int argc, char **argv) if (!Lst_IsEmptyS(makefiles)) { LstNode ln; - ln = Lst_Find(makefiles, ReadAllMakefiles, NULL); + ln = Lst_FindS(makefiles, ReadAllMakefiles, NULL); if (ln != NULL) Fatal("%s: cannot open %s.", progname, (char *)Lst_DatumS(ln)); @@ -1348,7 +1348,7 @@ main(int argc, char **argv) VAR_CMD, VARE_WANTRES); if (p1) { (void)str2Lst_Append(makefiles, p1, NULL); - (void)Lst_Find(makefiles, ReadMakefile, NULL); + (void)Lst_FindS(makefiles, ReadMakefile, NULL); free(p1); } } Index: src/usr.bin/make/meta.c diff -u src/usr.bin/make/meta.c:1.104 src/usr.bin/make/meta.c:1.105 --- src/usr.bin/make/meta.c:1.104 Fri Aug 28 04:14:31 2020 +++ src/usr.bin/make/meta.c Fri Aug 28 04:28:45 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: meta.c,v 1.104 2020/08/28 04:14:31 rillig Exp $ */ +/* $NetBSD: meta.c,v 1.105 2020/08/28 04:28:45 rillig Exp $ */ /* * Implement 'meta' mode. @@ -1334,13 +1334,13 @@ meta_oodate(GNode *gn, Boolean oodate) case 'D': /* unlink */ if (*p == '/' && !Lst_IsEmptyS(missingFiles)) { /* remove any missingFiles entries that match p */ - ln = Lst_Find(missingFiles, path_match, p); + ln = Lst_FindS(missingFiles, path_match, p); if (ln != NULL) { LstNode nln; char *tp; do { - nln = Lst_FindFrom(missingFiles, Lst_SuccS(ln), + nln = Lst_FindFromS(missingFiles, Lst_SuccS(ln), path_match, p); tp = Lst_DatumS(ln); Lst_RemoveS(missingFiles, ln); @@ -1411,7 +1411,7 @@ meta_oodate(GNode *gn, Boolean oodate) if ((link_src != NULL && cached_lstat(p, &fs) < 0) || (link_src == NULL && cached_stat(p, &fs) < 0)) { if (!meta_ignore(gn, p)) { - if (Lst_Find(missingFiles, string_match, p) == NULL) + if (Lst_FindS(missingFiles, string_match, p) == NULL) Lst_AppendS(missingFiles, bmake_strdup(p)); } } @@ -1497,7 +1497,7 @@ meta_oodate(GNode *gn, Boolean oodate) * A referenced file outside of CWD is missing. * We cannot catch every eventuality here... */ - if (Lst_Find(missingFiles, string_match, p) == NULL) + if (Lst_FindS(missingFiles, string_match, p) == NULL) Lst_AppendS(missingFiles, bmake_strdup(p)); } } Index: src/usr.bin/make/suff.c diff -u src/usr.bin/make/suff.c:1.123 src/usr.bin/make/suff.c:1.124 --- src/usr.bin/make/suff.c:1.123 Fri Aug 28 04:14:31 2020 +++ src/usr.bin/make/suff.c Fri Aug 28 04:28:45 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: suff.c,v 1.123 2020/08/28 04:14:31 rillig Exp $ */ +/* $NetBSD: suff.c,v 1.124 2020/08/28 04:28:45 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -69,14 +69,14 @@ */ #ifndef MAKE_NATIVE -static char rcsid[] = "$NetBSD: suff.c,v 1.123 2020/08/28 04:14:31 rillig Exp $"; +static char rcsid[] = "$NetBSD: suff.c,v 1.124 2020/08/28 04:28:45 rillig 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.123 2020/08/28 04:14:31 rillig Exp $"); +__RCSID("$NetBSD: suff.c,v 1.124 2020/08/28 04:28:45 rillig Exp $"); #endif #endif /* not lint */ #endif @@ -624,7 +624,7 @@ SuffParseTransform(char *str, Suff **src if (srcLn == NULL) { srcLn = Lst_FindS(sufflist, SuffSuffIsPrefix, str); } else { - srcLn = Lst_FindFrom(sufflist, Lst_SuccS(srcLn), + srcLn = Lst_FindFromS(sufflist, Lst_SuccS(srcLn), SuffSuffIsPrefix, str); } if (srcLn == NULL) { @@ -713,7 +713,7 @@ Suff_AddTransform(char *line) *t; /* target suffix */ LstNode ln; /* Node for existing transformation */ - ln = Lst_Find(transforms, SuffGNHasNameP, line); + ln = Lst_FindS(transforms, SuffGNHasNameP, line); if (ln == NULL) { /* * Make a new graph node for the transformation. It will be filled in @@ -1818,7 +1818,7 @@ SuffApplyTransform(GNode *tGn, GNode *sG * Locate the transformation rule itself */ tname = str_concat2(s->name, t->name); - ln = Lst_Find(transforms, SuffGNHasNameP, tname); + ln = Lst_FindS(transforms, SuffGNHasNameP, tname); free(tname); if (ln == NULL) { @@ -1983,7 +1983,7 @@ SuffFindArchiveDeps(GNode *gn, Lst slst) */ sd.len = eoarch - gn->name; sd.ename = eoarch; - ln = Lst_Find(ms->parents, SuffSuffIsSuffixP, &sd); + ln = Lst_FindS(ms->parents, SuffSuffIsSuffixP, &sd); if (ln != NULL) { /* @@ -2093,7 +2093,7 @@ SuffFindNormalDeps(GNode *gn, Lst slst) /* * Look for next possible suffix... */ - ln = Lst_FindFrom(sufflist, ln, SuffSuffIsSuffixP, &sd); + ln = Lst_FindFromS(sufflist, ln, SuffSuffIsSuffixP, &sd); if (ln != NULL) { int prefLen; /* Length of the prefix */