Module Name: src Committed By: rillig Date: Thu Aug 27 06:28:44 UTC 2020
Modified Files: src/usr.bin/make: dir.c lst.c lst.h Log Message: make(1): migrate remaining code from Lst_Open to Lst_OpenS To generate a diff of this commit: cvs rdiff -u -r1.111 -r1.112 src/usr.bin/make/dir.c cvs rdiff -u -r1.42 -r1.43 src/usr.bin/make/lst.c cvs rdiff -u -r1.45 -r1.46 src/usr.bin/make/lst.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/usr.bin/make/dir.c diff -u src/usr.bin/make/dir.c:1.111 src/usr.bin/make/dir.c:1.112 --- src/usr.bin/make/dir.c:1.111 Wed Aug 26 22:55:46 2020 +++ src/usr.bin/make/dir.c Thu Aug 27 06:28:44 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: dir.c,v 1.111 2020/08/26 22:55:46 rillig Exp $ */ +/* $NetBSD: dir.c,v 1.112 2020/08/27 06:28:44 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.111 2020/08/26 22:55:46 rillig Exp $"; +static char rcsid[] = "$NetBSD: dir.c,v 1.112 2020/08/27 06:28:44 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.111 2020/08/26 22:55:46 rillig Exp $"); +__RCSID("$NetBSD: dir.c,v 1.112 2020/08/27 06:28:44 rillig Exp $"); #endif #endif /* not lint */ #endif @@ -795,13 +795,12 @@ DirExpandInt(const char *word, Lst path, { LstNode ln; /* Current node */ - if (Lst_Open(path) == SUCCESS) { - while ((ln = Lst_NextS(path)) != NULL) { - Path *p = Lst_DatumS(ln); - DirMatchFiles(word, p, expansions); - } - Lst_CloseS(path); + Lst_OpenS(path); + while ((ln = Lst_NextS(path)) != NULL) { + Path *p = Lst_DatumS(ln); + DirMatchFiles(word, p, expansions); } + Lst_CloseS(path); } /* Print a word in the list of expansions. @@ -840,6 +839,9 @@ Dir_Expand(const char *word, Lst path, L { const char *cp; + assert(path != NULL); + assert(expansions != NULL); + DIR_DEBUG1("Expanding \"%s\"... ", word); cp = strchr(word, '{'); @@ -1128,12 +1130,13 @@ Dir_FindFile(const char *name, Lst path) DIR_DEBUG1("Searching for %s ...", name); - if (Lst_Open(path) == FAILURE) { + if (path == NULL) { DIR_DEBUG0("couldn't open path, file not found\n"); misses += 1; return NULL; } + Lst_OpenS(path); if ((ln = Lst_First(path)) != NULL) { p = Lst_DatumS(ln); if (p == dotLast) { @@ -1660,7 +1663,8 @@ Dir_MakeFlags(const char *flag, Lst path Buf_Init(&buf, 0); - if (Lst_Open(path) == SUCCESS) { + if (path != NULL) { + Lst_OpenS(path); while ((ln = Lst_NextS(path)) != NULL) { Path *p = Lst_DatumS(ln); Buf_AddStr(&buf, " "); @@ -1780,7 +1784,6 @@ void Dir_PrintDirectories(void) { LstNode ln; - Path *p; fprintf(debug_file, "#*** Directory Cache:\n"); fprintf(debug_file, @@ -1788,14 +1791,14 @@ Dir_PrintDirectories(void) hits, misses, nearmisses, bigmisses, percentage(hits, hits + bigmisses + nearmisses)); fprintf(debug_file, "# %-20s referenced\thits\n", "directory"); - if (Lst_Open(openDirectories) == SUCCESS) { - while ((ln = Lst_NextS(openDirectories)) != NULL) { - p = Lst_DatumS(ln); - fprintf(debug_file, "# %-20s %10d\t%4d\n", p->name, p->refCount, - p->hits); - } - Lst_CloseS(openDirectories); + + Lst_OpenS(openDirectories); + while ((ln = Lst_NextS(openDirectories)) != NULL) { + Path *p = Lst_DatumS(ln); + fprintf(debug_file, "# %-20s %10d\t%4d\n", p->name, p->refCount, + p->hits); } + Lst_CloseS(openDirectories); } static int Index: src/usr.bin/make/lst.c diff -u src/usr.bin/make/lst.c:1.42 src/usr.bin/make/lst.c:1.43 --- src/usr.bin/make/lst.c:1.42 Wed Aug 26 22:55:46 2020 +++ src/usr.bin/make/lst.c Thu Aug 27 06:28:44 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: lst.c,v 1.42 2020/08/26 22:55:46 rillig Exp $ */ +/* $NetBSD: lst.c,v 1.43 2020/08/27 06:28:44 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.42 2020/08/26 22:55:46 rillig Exp $"; +static char rcsid[] = "$NetBSD: lst.c,v 1.43 2020/08/27 06:28:44 rillig Exp $"; #else #include <sys/cdefs.h> #ifndef lint -__RCSID("$NetBSD: lst.c,v 1.42 2020/08/26 22:55:46 rillig Exp $"); +__RCSID("$NetBSD: lst.c,v 1.43 2020/08/27 06:28:44 rillig Exp $"); #endif /* not lint */ #endif @@ -637,18 +637,6 @@ Lst_AppendAllS(Lst dst, Lst src) /* Open a list for sequential access. A list can still be searched, etc., * without confusing these functions. */ -ReturnStatus -Lst_Open(Lst list) -{ - if (!LstIsValid(list)) { - return FAILURE; - } - Lst_OpenS(list); - return SUCCESS; -} - -/* Open a list for sequential access. A list can still be searched, etc., - * without confusing these functions. */ void Lst_OpenS(Lst list) { Index: src/usr.bin/make/lst.h diff -u src/usr.bin/make/lst.h:1.45 src/usr.bin/make/lst.h:1.46 --- src/usr.bin/make/lst.h:1.45 Wed Aug 26 23:00:47 2020 +++ src/usr.bin/make/lst.h Thu Aug 27 06:28:44 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: lst.h,v 1.45 2020/08/26 23:00:47 rillig Exp $ */ +/* $NetBSD: lst.h,v 1.46 2020/08/27 06:28:44 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -171,7 +171,6 @@ int Lst_ForEachFromS(Lst, LstNode, LstA * between Lst_Open() and Lst_Close(). */ /* Open the list */ -ReturnStatus Lst_Open(Lst); void Lst_OpenS(Lst); /* Next element please, or NULL */ LstNode Lst_NextS(Lst);