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): migrate Lst_Find to Lst_FindS



details:   https://anonhg.NetBSD.org/src/rev/330b13086aea
branches:  trunk
changeset: 975368:330b13086aea
user:      rillig <rillig%NetBSD.org@localhost>
date:      Fri Aug 28 04:28:45 2020 +0000

description:
make(1): migrate Lst_Find to Lst_FindS

diffstat:

 usr.bin/make/arch.c |   8 ++++----
 usr.bin/make/cond.c |   8 ++++----
 usr.bin/make/dir.c  |  12 +++++++-----
 usr.bin/make/lst.c  |  39 +++------------------------------------
 usr.bin/make/lst.h  |   4 +---
 usr.bin/make/main.c |  12 ++++++------
 usr.bin/make/meta.c |  10 +++++-----
 usr.bin/make/suff.c |  16 ++++++++--------
 8 files changed, 38 insertions(+), 71 deletions(-)

diffs (truncated from 388 to 300 lines):

diff -r b642b541a732 -r 330b13086aea usr.bin/make/arch.c
--- a/usr.bin/make/arch.c       Fri Aug 28 04:16:57 2020 +0000
+++ b/usr.bin/make/arch.c       Fri Aug 28 04:28:45 2020 +0000
@@ -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 @@
        member = base + 1;
     }
 
-    ln = Lst_Find(archives, ArchFindArchive, archive);
+    ln = Lst_FindS(archives, ArchFindArchive, archive);
     if (ln != NULL) {
        ar = Lst_DatumS(ln);
 
diff -r b642b541a732 -r 330b13086aea usr.bin/make/cond.c
--- a/usr.bin/make/cond.c       Fri Aug 28 04:16:57 2020 +0000
+++ b/usr.bin/make/cond.c       Fri Aug 28 04:28:45 2020 +0000
@@ -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 @@
 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. */
diff -r b642b541a732 -r 330b13086aea usr.bin/make/dir.c
--- a/usr.bin/make/dir.c        Fri Aug 28 04:16:57 2020 +0000
+++ b/usr.bin/make/dir.c        Fri Aug 28 04:28:45 2020 +0000
@@ -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 @@
  * 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 @@
     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 @@
     }
 
     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) {
diff -r b642b541a732 -r 330b13086aea usr.bin/make/lst.c
--- a/usr.bin/make/lst.c        Fri Aug 28 04:16:57 2020 +0000
+++ b/usr.bin/make/lst.c        Fri Aug 28 04:28:45 2020 +0000
@@ -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 @@
  * 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 @@
 /* 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 @@
  * 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;
diff -r b642b541a732 -r 330b13086aea usr.bin/make/lst.h
--- a/usr.bin/make/lst.h        Fri Aug 28 04:16:57 2020 +0000
+++ b/usr.bin/make/lst.h        Fri Aug 28 04:28:45 2020 +0000
@@ -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 @@
  * 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
diff -r b642b541a732 -r 330b13086aea usr.bin/make/main.c
--- a/usr.bin/make/main.c       Fri Aug 28 04:16:57 2020 +0000
+++ b/usr.bin/make/main.c       Fri Aug 28 04:28:45 2020 +0000
@@ -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 @@
 #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 @@
                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 @@
        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 @@
                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);
            }
        }
diff -r b642b541a732 -r 330b13086aea usr.bin/make/meta.c
--- a/usr.bin/make/meta.c       Fri Aug 28 04:16:57 2020 +0000
+++ b/usr.bin/make/meta.c       Fri Aug 28 04:28:45 2020 +0000
@@ -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 @@
                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 @@



Home | Main Index | Thread Index | Old Index