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): rename confusing function ReadAllMakef...



details:   https://anonhg.NetBSD.org/src/rev/e9013a1e9e17
branches:  trunk
changeset: 975450:e9013a1e9e17
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Aug 29 07:05:12 2020 +0000

description:
make(1): rename confusing function ReadAllMakefiles

The old name implied that the function would read multiple files, which
was not the case.

The comment above that function was highly confusing.  It's not that the
function returns a boolean, but rather 0 or non-zero, and 0 means that
Lst_Find should stop searching.

One of the next refactorings will be to make Lst_Find return the first
list node for which the function returns TRUE.  This will reduce the
confusion about the several functions called SomethingP in suff.c.  The
P suffix means to return TRUE or FALSE, not 0 or non-zero.

diffstat:

 usr.bin/make/main.c |  25 +++++++------------------
 1 files changed, 7 insertions(+), 18 deletions(-)

diffs (71 lines):

diff -r b03d80ffc29f -r e9013a1e9e17 usr.bin/make/main.c
--- a/usr.bin/make/main.c       Sat Aug 29 06:49:53 2020 +0000
+++ b/usr.bin/make/main.c       Sat Aug 29 07:05:12 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: main.c,v 1.320 2020/08/28 04:48:57 rillig Exp $        */
+/*     $NetBSD: main.c,v 1.321 2020/08/29 07:05:12 rillig Exp $        */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,7 +69,7 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: main.c,v 1.320 2020/08/28 04:48:57 rillig Exp $";
+static char rcsid[] = "$NetBSD: main.c,v 1.321 2020/08/29 07:05:12 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.320 2020/08/28 04:48:57 rillig Exp $");
+__RCSID("$NetBSD: main.c,v 1.321 2020/08/29 07:05:12 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -785,15 +785,9 @@
        return TRUE;
 }
 
-/*-
- * ReadAllMakefiles --
- *     wrapper around ReadMakefile() to read all.
- *
- * Results:
- *     TRUE if ok, FALSE on error
- */
+/* Return 0 if reading the makefile failed, for Lst_Find. */
 static int
-ReadAllMakefiles(const void *p, const void *q)
+ReadMakefileFailed(const void *p, const void *q)
 {
        return ReadMakefile(p, q) == 0;
 }
@@ -1339,7 +1333,7 @@
        if (!Lst_IsEmpty(makefiles)) {
                LstNode ln;
 
-               ln = Lst_Find(makefiles, ReadAllMakefiles, NULL);
+               ln = Lst_Find(makefiles, ReadMakefileFailed, NULL);
                if (ln != NULL)
                        Fatal("%s: cannot open %s.", progname,
                            (char *)Lst_Datum(ln));
@@ -1497,15 +1491,10 @@
        return outOfDate ? 1 : 0;
 }
 
-/*-
- * ReadMakefile  --
- *     Open and parse the given makefile.
+/* Open and parse the given makefile, with all its side effects.
  *
  * Results:
  *     0 if ok. -1 if couldn't open file.
- *
- * Side Effects:
- *     lots
  */
 static int
 ReadMakefile(const void *p, const void *q MAKE_ATTR_UNUSED)



Home | Main Index | Thread Index | Old Index