make(1): reverse order of the Lst_Find parameters

The other callbacks all have (function, param), only the Lst_Find had
(param, function), which was inconsistent.
This commit is contained in:
rillig 2020-08-23 16:58:02 +00:00
parent 4b0e7734a8
commit 27d66938d5
8 changed files with 58 additions and 57 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: arch.c,v 1.91 2020/08/22 21:58:27 rillig Exp $ */
/* $NetBSD: arch.c,v 1.92 2020/08/23 16:58:02 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -69,14 +69,14 @@
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: arch.c,v 1.91 2020/08/22 21:58:27 rillig Exp $";
static char rcsid[] = "$NetBSD: arch.c,v 1.92 2020/08/23 16:58:02 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.91 2020/08/22 21:58:27 rillig Exp $");
__RCSID("$NetBSD: arch.c,v 1.92 2020/08/23 16:58:02 rillig Exp $");
#endif
#endif /* not lint */
#endif
@ -542,7 +542,7 @@ ArchStatMember(const char *archive, const char *member, Boolean hash)
member = base + 1;
}
ln = Lst_Find(archives, archive, ArchFindArchive);
ln = Lst_Find(archives, ArchFindArchive, archive);
if (ln != NULL) {
ar = Lst_DatumS(ln);

View File

@ -1,4 +1,4 @@
/* $NetBSD: cond.c,v 1.99 2020/08/22 21:42:38 rillig Exp $ */
/* $NetBSD: cond.c,v 1.100 2020/08/23 16:58:02 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.99 2020/08/22 21:42:38 rillig Exp $";
static char rcsid[] = "$NetBSD: cond.c,v 1.100 2020/08/23 16:58:02 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.99 2020/08/22 21:42:38 rillig Exp $");
__RCSID("$NetBSD: cond.c,v 1.100 2020/08/23 16:58:02 rillig Exp $");
#endif
#endif /* not lint */
#endif
@ -284,7 +284,7 @@ CondFindStrMatch(const void *string, const void *pattern)
static Boolean
CondDoMake(int argLen MAKE_ATTR_UNUSED, const char *arg)
{
return Lst_Find(create, arg, CondFindStrMatch) != NULL;
return Lst_Find(create, CondFindStrMatch, arg) != NULL;
}
/* See if the given file exists. */

View File

@ -1,4 +1,4 @@
/* $NetBSD: dir.c,v 1.109 2020/08/22 23:06:51 rillig Exp $ */
/* $NetBSD: dir.c,v 1.110 2020/08/23 16:58:02 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.109 2020/08/22 23:06:51 rillig Exp $";
static char rcsid[] = "$NetBSD: dir.c,v 1.110 2020/08/23 16:58:02 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.109 2020/08/22 23:06:51 rillig Exp $");
__RCSID("$NetBSD: dir.c,v 1.110 2020/08/23 16:58:02 rillig Exp $");
#endif
#endif /* not lint */
#endif
@ -1560,7 +1560,7 @@ Dir_AddDir(Lst path, const char *name)
struct dirent *dp; /* entry in directory */
if (strcmp(name, ".DOTLAST") == 0) {
ln = Lst_Find(path, name, DirFindName);
ln = Lst_Find(path, DirFindName, name);
if (ln != NULL)
return Lst_DatumS(ln);
else {
@ -1573,7 +1573,7 @@ Dir_AddDir(Lst path, const char *name)
}
if (path)
ln = Lst_Find(openDirectories, name, DirFindName);
ln = Lst_Find(openDirectories, DirFindName, name);
if (ln != NULL) {
p = Lst_DatumS(ln);
if (path && Lst_MemberS(path, p) == NULL) {

View File

@ -1,4 +1,4 @@
/* $NetBSD: lst.c,v 1.40 2020/08/23 16:43:34 rillig Exp $ */
/* $NetBSD: lst.c,v 1.41 2020/08/23 16:58:02 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.40 2020/08/23 16:43:34 rillig Exp $";
static char rcsid[] = "$NetBSD: lst.c,v 1.41 2020/08/23 16:58:02 rillig Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: lst.c,v 1.40 2020/08/23 16:43:34 rillig Exp $");
__RCSID("$NetBSD: lst.c,v 1.41 2020/08/23 16:58:02 rillig Exp $");
#endif /* not lint */
#endif
@ -394,20 +394,21 @@ Lst_IsEmpty(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, const void *cmpData, int (*cmp)(const void *, const void *))
Lst_Find(Lst list, LstFindProc cmp, const void *cmpData)
{
return Lst_FindFrom(list, Lst_First(list), cmpData, cmp);
return Lst_FindFrom(list, Lst_First(list), 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_FindFrom(Lst list, LstNode node, const void *cmpData,
int (*cmp)(const void *, const void *))
Lst_FindFrom(Lst list, LstNode node, LstFindProc cmp, const void *cmpData)
{
LstNode tln;
assert(cmp != NULL);
if (!LstIsValid(list) || LstIsEmpty(list) || !LstNodeIsValid(node)) {
return NULL;
}
@ -415,7 +416,7 @@ Lst_FindFrom(Lst list, LstNode node, const void *cmpData,
tln = node;
do {
if ((*cmp)(tln->datum, cmpData) == 0)
if (cmp(tln->datum, cmpData) == 0)
return tln;
tln = tln->next;
} while (tln != node && tln != NULL);

View File

@ -1,4 +1,4 @@
/* $NetBSD: lst.h,v 1.40 2020/08/23 16:43:34 rillig Exp $ */
/* $NetBSD: lst.h,v 1.41 2020/08/23 16:58:02 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@ -146,9 +146,9 @@ void *Lst_DatumS(LstNode);
* Functions for entire lists
*/
/* Find an element in a list */
LstNode Lst_Find(Lst, const void *, LstFindProc);
LstNode Lst_Find(Lst, LstFindProc, const void *);
/* Find an element starting from somewhere */
LstNode Lst_FindFrom(Lst, LstNode, const void *, LstFindProc);
LstNode Lst_FindFrom(Lst, LstNode, LstFindProc, const void *);
/*
* See if the given datum is on the list. Returns the LstNode containing
* the datum

View File

@ -1,4 +1,4 @@
/* $NetBSD: main.c,v 1.310 2020/08/22 18:47:31 rillig Exp $ */
/* $NetBSD: main.c,v 1.311 2020/08/23 16:58:02 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -69,7 +69,7 @@
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: main.c,v 1.310 2020/08/22 18:47:31 rillig Exp $";
static char rcsid[] = "$NetBSD: main.c,v 1.311 2020/08/23 16:58:02 rillig Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
@ -81,7 +81,7 @@ __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993\
#if 0
static char sccsid[] = "@(#)main.c 8.3 (Berkeley) 3/19/94";
#else
__RCSID("$NetBSD: main.c,v 1.310 2020/08/22 18:47:31 rillig Exp $");
__RCSID("$NetBSD: main.c,v 1.311 2020/08/23 16:58:02 rillig Exp $");
#endif
#endif /* not lint */
#endif
@ -1331,7 +1331,7 @@ main(int argc, char **argv)
if (Lst_IsEmpty(sysMkPath))
Fatal("%s: no system rules (%s).", progname,
_PATH_DEFSYSMK);
ln = Lst_Find(sysMkPath, NULL, ReadMakefile);
ln = Lst_Find(sysMkPath, ReadMakefile, NULL);
if (ln == NULL)
Fatal("%s: cannot open %s.", progname,
(char *)Lst_DatumS(ln));
@ -1340,7 +1340,7 @@ main(int argc, char **argv)
if (!Lst_IsEmpty(makefiles)) {
LstNode ln;
ln = Lst_Find(makefiles, NULL, ReadAllMakefiles);
ln = Lst_Find(makefiles, ReadAllMakefiles, NULL);
if (ln != NULL)
Fatal("%s: cannot open %s.", progname,
(char *)Lst_DatumS(ln));
@ -1349,7 +1349,7 @@ main(int argc, char **argv)
VAR_CMD, VARE_WANTRES);
if (p1) {
(void)str2Lst_Append(makefiles, p1, NULL);
(void)Lst_Find(makefiles, NULL, ReadMakefile);
(void)Lst_Find(makefiles, ReadMakefile, NULL);
free(p1);
}
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: meta.c,v 1.98 2020/08/23 16:43:34 rillig Exp $ */
/* $NetBSD: meta.c,v 1.99 2020/08/23 16:58:02 rillig Exp $ */
/*
* Implement 'meta' mode.
@ -1332,14 +1332,14 @@ meta_oodate(GNode *gn, Boolean oodate)
case 'D': /* unlink */
if (*p == '/' && !Lst_IsEmpty(missingFiles)) {
/* remove any missingFiles entries that match p */
if ((ln = Lst_Find(missingFiles, p,
path_match)) != NULL) {
ln = Lst_Find(missingFiles, path_match, p);
if (ln != NULL) {
LstNode nln;
char *tp;
do {
nln = Lst_FindFrom(missingFiles, Lst_Succ(ln),
p, path_match);
path_match, p);
tp = Lst_DatumS(ln);
Lst_RemoveS(missingFiles, ln);
free(tp);
@ -1409,7 +1409,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, p, string_match) == NULL)
if (Lst_Find(missingFiles, string_match, p) == NULL)
Lst_AppendS(missingFiles, bmake_strdup(p));
}
}
@ -1495,7 +1495,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, p, string_match) == NULL)
if (Lst_Find(missingFiles, string_match, p) == NULL)
Lst_AppendS(missingFiles, bmake_strdup(p));
}
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: suff.c,v 1.113 2020/08/23 06:54:01 rillig Exp $ */
/* $NetBSD: suff.c,v 1.114 2020/08/23 16:58:02 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -69,14 +69,14 @@
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: suff.c,v 1.113 2020/08/23 06:54:01 rillig Exp $";
static char rcsid[] = "$NetBSD: suff.c,v 1.114 2020/08/23 16:58:02 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.113 2020/08/23 06:54:01 rillig Exp $");
__RCSID("$NetBSD: suff.c,v 1.114 2020/08/23 16:58:02 rillig Exp $");
#endif
#endif /* not lint */
#endif
@ -609,10 +609,10 @@ SuffParseTransform(char *str, Suff **srcPtr, Suff **targPtr)
*/
for (;;) {
if (srcLn == NULL) {
srcLn = Lst_Find(sufflist, str, SuffSuffIsPrefix);
srcLn = Lst_Find(sufflist, SuffSuffIsPrefix, str);
} else {
srcLn = Lst_FindFrom(sufflist, Lst_Succ(srcLn), str,
SuffSuffIsPrefix);
srcLn = Lst_FindFrom(sufflist, Lst_Succ(srcLn),
SuffSuffIsPrefix, str);
}
if (srcLn == NULL) {
/*
@ -640,7 +640,7 @@ SuffParseTransform(char *str, Suff **srcPtr, Suff **targPtr)
single = src;
singleLn = srcLn;
} else {
targLn = Lst_Find(sufflist, str2, SuffSuffHasNameP);
targLn = Lst_Find(sufflist, SuffSuffHasNameP, str2);
if (targLn != NULL) {
*srcPtr = src;
*targPtr = Lst_DatumS(targLn);
@ -700,7 +700,7 @@ Suff_AddTransform(char *line)
*t; /* target suffix */
LstNode ln; /* Node for existing transformation */
ln = Lst_Find(transforms, line, SuffGNHasNameP);
ln = Lst_Find(transforms, SuffGNHasNameP, line);
if (ln == NULL) {
/*
* Make a new graph node for the transformation. It will be filled in
@ -849,7 +849,7 @@ SuffRebuildGraph(void *transformp, void *sp)
*/
cp = UNCONST(SuffStrIsPrefix(s->name, transform->name));
if (cp != NULL) {
ln = Lst_Find(sufflist, cp, SuffSuffHasNameP);
ln = Lst_Find(sufflist, SuffSuffHasNameP, cp);
if (ln != NULL) {
/*
* Found target. Link in and return, since it can't be anything
@ -873,7 +873,7 @@ SuffRebuildGraph(void *transformp, void *sp)
* Null-terminate the source suffix in order to find it.
*/
cp[1] = '\0';
ln = Lst_Find(sufflist, transform->name, SuffSuffHasNameP);
ln = Lst_Find(sufflist, SuffSuffHasNameP, transform->name);
/*
* Replace the start of the target suffix
*/
@ -976,7 +976,7 @@ Suff_AddSuffix(char *str, GNode **gn)
LstNode ln;
GNodeSuff gs;
ln = Lst_Find(sufflist, str, SuffSuffHasNameP);
ln = Lst_Find(sufflist, SuffSuffHasNameP, str);
if (ln == NULL) {
s = bmake_malloc(sizeof(Suff));
@ -1028,7 +1028,7 @@ Suff_GetPath(char *sname)
LstNode ln;
Suff *s;
ln = Lst_Find(sufflist, sname, SuffSuffHasNameP);
ln = Lst_Find(sufflist, SuffSuffHasNameP, sname);
if (ln == NULL) {
return NULL;
} else {
@ -1123,7 +1123,7 @@ Suff_AddInclude(char *sname)
LstNode ln;
Suff *s;
ln = Lst_Find(sufflist, sname, SuffSuffHasNameP);
ln = Lst_Find(sufflist, SuffSuffHasNameP, sname);
if (ln != NULL) {
s = Lst_DatumS(ln);
s->flags |= SUFF_INCLUDE;
@ -1155,7 +1155,7 @@ Suff_AddLib(char *sname)
LstNode ln;
Suff *s;
ln = Lst_Find(sufflist, sname, SuffSuffHasNameP);
ln = Lst_Find(sufflist, SuffSuffHasNameP, sname);
if (ln != NULL) {
s = Lst_DatumS(ln);
s->flags |= SUFF_LIBRARY;
@ -1460,7 +1460,7 @@ SuffFindCmds(Src *targ, Lst slst)
* The node matches the prefix ok, see if it has a known
* suffix.
*/
ln = Lst_Find(sufflist, &cp[prefLen], SuffSuffHasNameP);
ln = Lst_Find(sufflist, SuffSuffHasNameP, &cp[prefLen]);
if (ln == NULL)
continue;
/*
@ -1753,7 +1753,7 @@ Suff_FindPath(GNode* gn)
LstNode ln;
sd.len = strlen(gn->name);
sd.ename = gn->name + sd.len;
ln = Lst_Find(sufflist, &sd, SuffSuffIsSuffixP);
ln = Lst_Find(sufflist, SuffSuffIsSuffixP, &sd);
if (DEBUG(SUFF)) {
fprintf(debug_file, "Wildcard expanding \"%s\"...", gn->name);
@ -1818,7 +1818,7 @@ SuffApplyTransform(GNode *tGn, GNode *sGn, Suff *t, Suff *s)
* Locate the transformation rule itself
*/
tname = str_concat2(s->name, t->name);
ln = Lst_Find(transforms, tname, SuffGNHasNameP);
ln = Lst_Find(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, &sd, SuffSuffIsSuffixP);
ln = Lst_Find(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, &sd, SuffSuffIsSuffixP);
ln = Lst_FindFrom(sufflist, ln, SuffSuffIsSuffixP, &sd);
if (ln != NULL) {
int prefLen; /* Length of the prefix */
@ -2470,7 +2470,7 @@ SuffFindDeps(GNode *gn, Lst slst)
LstNode ln;
Suff *s;
ln = Lst_Find(sufflist, LIBSUFF, SuffSuffHasNameP);
ln = Lst_Find(sufflist, SuffSuffHasNameP, LIBSUFF);
if (gn->suffix)
gn->suffix->refCount--;
if (ln != NULL) {
@ -2518,7 +2518,7 @@ Suff_SetNull(char *name)
Suff *s;
LstNode ln;
ln = Lst_Find(sufflist, name, SuffSuffHasNameP);
ln = Lst_Find(sufflist, SuffSuffHasNameP, name);
if (ln != NULL) {
s = Lst_DatumS(ln);
if (suffNull != NULL) {