Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/make make(1): reverse order of the Lst_Find parameters



details:   https://anonhg.NetBSD.org/src/rev/e612e083f9a8
branches:  trunk
changeset: 975220:e612e083f9a8
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Aug 23 16:58:02 2020 +0000

description:
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.

diffstat:

 usr.bin/make/arch.c |   8 ++++----
 usr.bin/make/cond.c |   8 ++++----
 usr.bin/make/dir.c  |  10 +++++-----
 usr.bin/make/lst.c  |  17 +++++++++--------
 usr.bin/make/lst.h  |   6 +++---
 usr.bin/make/main.c |  12 ++++++------
 usr.bin/make/meta.c |  12 ++++++------
 usr.bin/make/suff.c |  42 +++++++++++++++++++++---------------------
 8 files changed, 58 insertions(+), 57 deletions(-)

diffs (truncated from 467 to 300 lines):

diff -r d00d326f2871 -r e612e083f9a8 usr.bin/make/arch.c
--- a/usr.bin/make/arch.c       Sun Aug 23 16:43:34 2020 +0000
+++ b/usr.bin/make/arch.c       Sun Aug 23 16:58:02 2020 +0000
@@ -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 @@
        member = base + 1;
     }
 
-    ln = Lst_Find(archives, archive, ArchFindArchive);
+    ln = Lst_Find(archives, ArchFindArchive, archive);
     if (ln != NULL) {
        ar = Lst_DatumS(ln);
 
diff -r d00d326f2871 -r e612e083f9a8 usr.bin/make/cond.c
--- a/usr.bin/make/cond.c       Sun Aug 23 16:43:34 2020 +0000
+++ b/usr.bin/make/cond.c       Sun Aug 23 16:58:02 2020 +0000
@@ -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 @@
 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. */
diff -r d00d326f2871 -r e612e083f9a8 usr.bin/make/dir.c
--- a/usr.bin/make/dir.c        Sun Aug 23 16:43:34 2020 +0000
+++ b/usr.bin/make/dir.c        Sun Aug 23 16:58:02 2020 +0000
@@ -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 @@
     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 @@
     }
 
     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) {
diff -r d00d326f2871 -r e612e083f9a8 usr.bin/make/lst.c
--- a/usr.bin/make/lst.c        Sun Aug 23 16:43:34 2020 +0000
+++ b/usr.bin/make/lst.c        Sun Aug 23 16:58:02 2020 +0000
@@ -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 @@
 /* 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 @@
     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);
diff -r d00d326f2871 -r e612e083f9a8 usr.bin/make/lst.h
--- a/usr.bin/make/lst.h        Sun Aug 23 16:43:34 2020 +0000
+++ b/usr.bin/make/lst.h        Sun Aug 23 16:58:02 2020 +0000
@@ -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 @@
  * 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
diff -r d00d326f2871 -r e612e083f9a8 usr.bin/make/main.c
--- a/usr.bin/make/main.c       Sun Aug 23 16:43:34 2020 +0000
+++ b/usr.bin/make/main.c       Sun Aug 23 16:58:02 2020 +0000
@@ -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 @@
 #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 @@
                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 @@
        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 @@
                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);
            }
        }
diff -r d00d326f2871 -r e612e083f9a8 usr.bin/make/meta.c
--- a/usr.bin/make/meta.c       Sun Aug 23 16:43:34 2020 +0000
+++ b/usr.bin/make/meta.c       Sun Aug 23 16:58:02 2020 +0000
@@ -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 @@
                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 @@
                    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 @@
                             * 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));
                        }
                    }
diff -r d00d326f2871 -r e612e083f9a8 usr.bin/make/suff.c
--- a/usr.bin/make/suff.c       Sun Aug 23 16:43:34 2020 +0000
+++ b/usr.bin/make/suff.c       Sun Aug 23 16:58:02 2020 +0000
@@ -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 $        */
 
 /*



Home | Main Index | Thread Index | Old Index