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_ForEach to Lst_ForEachS



details:   https://anonhg.NetBSD.org/src/rev/ae924240db92
branches:  trunk
changeset: 943127:ae924240db92
user:      rillig <rillig%NetBSD.org@localhost>
date:      Thu Aug 27 06:53:57 2020 +0000

description:
make(1): migrate Lst_ForEach to Lst_ForEachS

Most lists are always valid.  Only the "targets" variable may be null in
some cases, probably.

diffstat:

 usr.bin/make/compat.c |  12 ++++++------
 usr.bin/make/dir.c    |  10 +++++-----
 usr.bin/make/job.c    |  10 +++++-----
 usr.bin/make/lst.c    |  29 +++--------------------------
 usr.bin/make/lst.h    |   4 +---
 usr.bin/make/main.c   |   8 ++++----
 usr.bin/make/make.c   |  45 +++++++++++++++++++++++----------------------
 usr.bin/make/meta.c   |  10 +++++-----
 usr.bin/make/parse.c  |  32 +++++++++++++++++++-------------
 usr.bin/make/suff.c   |  26 +++++++++++++-------------
 usr.bin/make/targ.c   |  28 ++++++++++++++--------------
 11 files changed, 98 insertions(+), 116 deletions(-)

diffs (truncated from 802 to 300 lines):

diff -r e64a2d9f7814 -r ae924240db92 usr.bin/make/compat.c
--- a/usr.bin/make/compat.c     Thu Aug 27 06:31:46 2020 +0000
+++ b/usr.bin/make/compat.c     Thu Aug 27 06:53:57 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: compat.c,v 1.129 2020/08/23 19:00:19 rillig Exp $      */
+/*     $NetBSD: compat.c,v 1.130 2020/08/27 06:53:57 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: compat.c,v 1.129 2020/08/23 19:00:19 rillig Exp $";
+static char rcsid[] = "$NetBSD: compat.c,v 1.130 2020/08/27 06:53:57 rillig Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)compat.c   8.2 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: compat.c,v 1.129 2020/08/23 19:00:19 rillig Exp $");
+__RCSID("$NetBSD: compat.c,v 1.130 2020/08/27 06:53:57 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -532,7 +532,7 @@
        gn->made = BEINGMADE;
        if ((gn->type & OP_MADE) == 0)
            Suff_FindDeps(gn);
-       Lst_ForEach(gn->children, Compat_Make, gn);
+       Lst_ForEachS(gn->children, Compat_Make, gn);
        if ((gn->flags & REMAKE) == 0) {
            gn->made = ABORTED;
            pgn->flags &= ~(unsigned)REMAKE;
@@ -602,7 +602,7 @@
                    meta_job_start(NULL, gn);
                }
 #endif
-               Lst_ForEach(gn->commands, CompatRunCommand, gn);
+               Lst_ForEachS(gn->commands, CompatRunCommand, gn);
                curTarg = NULL;
            } else {
                Job_Touch(gn, gn->type & OP_SILENT);
@@ -671,7 +671,7 @@
     }
 
 cohorts:
-    Lst_ForEach(gn->cohorts, Compat_Make, pgnp);
+    Lst_ForEachS(gn->cohorts, Compat_Make, pgnp);
     return 0;
 }
 
diff -r e64a2d9f7814 -r ae924240db92 usr.bin/make/dir.c
--- a/usr.bin/make/dir.c        Thu Aug 27 06:31:46 2020 +0000
+++ b/usr.bin/make/dir.c        Thu Aug 27 06:53:57 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: dir.c,v 1.112 2020/08/27 06:28:44 rillig Exp $ */
+/*     $NetBSD: dir.c,v 1.113 2020/08/27 06:53:57 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.112 2020/08/27 06:28:44 rillig Exp $";
+static char rcsid[] = "$NetBSD: dir.c,v 1.113 2020/08/27 06:53:57 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.112 2020/08/27 06:28:44 rillig Exp $");
+__RCSID("$NetBSD: dir.c,v 1.113 2020/08/27 06:53:57 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -924,7 +924,7 @@
        }
     }
     if (DEBUG(DIR)) {
-       Lst_ForEach(expansions, DirPrintWord, NULL);
+       Lst_ForEachS(expansions, DirPrintWord, NULL);
        fprintf(debug_file, "\n");
     }
 }
@@ -1811,5 +1811,5 @@
 void
 Dir_PrintPath(Lst path)
 {
-    Lst_ForEach(path, DirPrintDir, NULL);
+    Lst_ForEachS(path, DirPrintDir, NULL);
 }
diff -r e64a2d9f7814 -r ae924240db92 usr.bin/make/job.c
--- a/usr.bin/make/job.c        Thu Aug 27 06:31:46 2020 +0000
+++ b/usr.bin/make/job.c        Thu Aug 27 06:53:57 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: job.c,v 1.216 2020/08/27 06:31:46 rillig Exp $ */
+/*     $NetBSD: job.c,v 1.217 2020/08/27 06:53:57 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: job.c,v 1.216 2020/08/27 06:31:46 rillig Exp $";
+static char rcsid[] = "$NetBSD: job.c,v 1.217 2020/08/27 06:53:57 rillig Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)job.c      8.2 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: job.c,v 1.216 2020/08/27 06:31:46 rillig Exp $");
+__RCSID("$NetBSD: job.c,v 1.217 2020/08/27 06:53:57 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -1655,7 +1655,7 @@
         * We can do all the commands at once. hooray for sanity
         */
        numCommands = 0;
-       Lst_ForEach(gn->commands, JobPrintCommand, job);
+       Lst_ForEachS(gn->commands, JobPrintCommand, job);
 
        /*
         * If we didn't print out any commands to the shell script,
@@ -1682,7 +1682,7 @@
         * doesn't do any harm in this case and may do some good.
         */
        if (cmdsOK) {
-           Lst_ForEach(gn->commands, JobPrintCommand, job);
+           Lst_ForEachS(gn->commands, JobPrintCommand, job);
        }
        /*
         * Don't execute the shell, thank you.
diff -r e64a2d9f7814 -r ae924240db92 usr.bin/make/lst.c
--- a/usr.bin/make/lst.c        Thu Aug 27 06:31:46 2020 +0000
+++ b/usr.bin/make/lst.c        Thu Aug 27 06:53:57 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lst.c,v 1.43 2020/08/27 06:28:44 rillig Exp $ */
+/* $NetBSD: lst.c,v 1.44 2020/08/27 06:53:57 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.43 2020/08/27 06:28:44 rillig Exp $";
+static char rcsid[] = "$NetBSD: lst.c,v 1.44 2020/08/27 06:53:57 rillig Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: lst.c,v 1.43 2020/08/27 06:28:44 rillig Exp $");
+__RCSID("$NetBSD: lst.c,v 1.44 2020/08/27 06:53:57 rillig Exp $");
 #endif /* not lint */
 #endif
 
@@ -502,15 +502,6 @@
  * should return 0 if traversal should continue and non-zero if it should
  * abort. */
 int
-Lst_ForEach(Lst list, LstActionProc proc, void *procData)
-{
-    return Lst_ForEachFrom(list, Lst_First(list), proc, procData);
-}
-
-/* Apply the given function to each element of the given list. The function
- * should return 0 if traversal should continue and non-zero if it should
- * abort. */
-int
 Lst_ForEachS(Lst list, LstActionProc proc, void *procData)
 {
     if (LstIsEmpty(list))
@@ -522,20 +513,6 @@
  * the given node. The function should return 0 if traversal should continue,
  * and non-zero if it should abort. */
 int
-Lst_ForEachFrom(Lst list, LstNode node,
-               LstActionProc proc, void *procData)
-{
-    if (!LstIsValid(list) || LstIsEmpty(list)) {
-       return 0;
-    }
-
-    return Lst_ForEachFromS(list, node, proc, procData);
-}
-
-/* Apply the given function to each element of the given list, starting from
- * the given node. The function should return 0 if traversal should continue,
- * and non-zero if it should abort. */
-int
 Lst_ForEachFromS(Lst list, LstNode node,
                 LstActionProc proc, void *procData)
 {
diff -r e64a2d9f7814 -r ae924240db92 usr.bin/make/lst.h
--- a/usr.bin/make/lst.h        Thu Aug 27 06:31:46 2020 +0000
+++ b/usr.bin/make/lst.h        Thu Aug 27 06:53:57 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lst.h,v 1.46 2020/08/27 06:28:44 rillig Exp $  */
+/*     $NetBSD: lst.h,v 1.47 2020/08/27 06:53:57 rillig Exp $  */
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -160,10 +160,8 @@
  */
 LstNode                Lst_MemberS(Lst, void *);
 /* Apply a function to all elements of a lst */
-int            Lst_ForEach(Lst, LstActionProc, void *);
 int            Lst_ForEachS(Lst, LstActionProc, void *);
 /* Apply a function to all elements of a lst starting from a certain point. */
-int            Lst_ForEachFrom(Lst, LstNode, LstActionProc, void *);
 int            Lst_ForEachFromS(Lst, LstNode, LstActionProc, void *);
 /*
  * these functions are for dealing with a list as a table, of sorts.
diff -r e64a2d9f7814 -r ae924240db92 usr.bin/make/main.c
--- a/usr.bin/make/main.c       Thu Aug 27 06:31:46 2020 +0000
+++ b/usr.bin/make/main.c       Thu Aug 27 06:53:57 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: main.c,v 1.314 2020/08/26 22:55:46 rillig Exp $        */
+/*     $NetBSD: main.c,v 1.315 2020/08/27 06:53:57 rillig Exp $        */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,7 +69,7 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: main.c,v 1.314 2020/08/26 22:55:46 rillig Exp $";
+static char rcsid[] = "$NetBSD: main.c,v 1.315 2020/08/27 06:53:57 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.314 2020/08/26 22:55:46 rillig Exp $");
+__RCSID("$NetBSD: main.c,v 1.315 2020/08/27 06:53:57 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -2041,7 +2041,7 @@
         */
        Var_Set(".ERROR_TARGET", gn->name, VAR_GLOBAL);
        Var_Delete(".ERROR_CMD", VAR_GLOBAL);
-       Lst_ForEach(gn->commands, addErrorCMD, gn);
+       Lst_ForEachS(gn->commands, addErrorCMD, gn);
     }
     expr = "${MAKE_PRINT_VAR_ON_ERROR:@v@$v='${$v}'\n@}";
     cp = Var_Subst(expr, VAR_GLOBAL, VARE_WANTRES);
diff -r e64a2d9f7814 -r ae924240db92 usr.bin/make/make.c
--- a/usr.bin/make/make.c       Thu Aug 27 06:31:46 2020 +0000
+++ b/usr.bin/make/make.c       Thu Aug 27 06:53:57 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: make.c,v 1.125 2020/08/27 06:31:46 rillig Exp $        */
+/*     $NetBSD: make.c,v 1.126 2020/08/27 06:53:57 rillig Exp $        */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: make.c,v 1.125 2020/08/27 06:31:46 rillig Exp $";
+static char rcsid[] = "$NetBSD: make.c,v 1.126 2020/08/27 06:53:57 rillig Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)make.c     8.1 (Berkeley) 6/6/93";
 #else
-__RCSID("$NetBSD: make.c,v 1.125 2020/08/27 06:31:46 rillig Exp $");
+__RCSID("$NetBSD: make.c,v 1.126 2020/08/27 06:53:57 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -146,7 +146,7 @@
 
     fprintf(debug_file, "make_abort from line %d\n", line);
     Targ_PrintNode(gn, &two);
-    Lst_ForEach(toBeMade, Targ_PrintNode, &two);
+    Lst_ForEachS(toBeMade, Targ_PrintNode, &two);
     Targ_PrintGraph(3);
     abort();
 }
@@ -382,7 +382,7 @@
      * thinking they're out-of-date.
      */
     if (!oodate) {
-       Lst_ForEach(gn->parents, MakeTimeStamp, gn);
+       Lst_ForEachS(gn->parents, MakeTimeStamp, gn);
     }
 
     return oodate;
@@ -735,7 +735,7 @@



Home | Main Index | Thread Index | Old Index