summaryrefslogtreecommitdiffstats
path: root/usr.bin
diff options
context:
space:
mode:
authorharti <harti@FreeBSD.org>2004-12-08 16:22:01 +0000
committerharti <harti@FreeBSD.org>2004-12-08 16:22:01 +0000
commitbcb1f1f6f57e4630d36245b7c5fb2ce234218041 (patch)
tree033640eae93833ae9810ed9247ac98509312f27b /usr.bin
parenta3e11dfa9b1fa344ae2ae1129eaf1c441f32d88e (diff)
downloadFreeBSD-src-bcb1f1f6f57e4630d36245b7c5fb2ce234218041.zip
FreeBSD-src-bcb1f1f6f57e4630d36245b7c5fb2ce234218041.tar.gz
Get rid of the sequential access feature of the lists. This was used
only in a couple of places and all of them except for one were easily converted to use Lst_First/Lst_Succ. The one place is compatibility mode in job.c where the it was used to advance to the next command on each invocation of JobStart. For this case add a pointer to the node to hold the currently executed command.
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/make/Makefile4
-rw-r--r--usr.bin/make/arch.c9
-rw-r--r--usr.bin/make/dir.c53
-rw-r--r--usr.bin/make/job.c63
-rw-r--r--usr.bin/make/lst.h22
-rw-r--r--usr.bin/make/lst.lib/lstClose.c80
-rw-r--r--usr.bin/make/lst.lib/lstInit.c2
-rw-r--r--usr.bin/make/lst.lib/lstIsAtEnd.c81
-rw-r--r--usr.bin/make/lst.lib/lstNext.c106
-rw-r--r--usr.bin/make/lst.lib/lstOpen.c83
-rw-r--r--usr.bin/make/lst.lib/lstRemove.c13
-rw-r--r--usr.bin/make/make.c84
-rw-r--r--usr.bin/make/make.h3
-rw-r--r--usr.bin/make/suff.c40
-rw-r--r--usr.bin/make/targ.c6
15 files changed, 98 insertions, 551 deletions
diff --git a/usr.bin/make/Makefile b/usr.bin/make/Makefile
index e8ee5b2..d3e5f56 100644
--- a/usr.bin/make/Makefile
+++ b/usr.bin/make/Makefile
@@ -6,9 +6,9 @@ PROG= make
CFLAGS+=-I${.CURDIR}
SRCS= arch.c buf.c compat.c cond.c dir.c for.c hash.c job.c main.c \
make.c parse.c str.c suff.c targ.c util.c var.c var_modify.c
-SRCS+= lstAppend.c lstClose.c lstConcat.c lstDeQueue.c lstDestroy.c \
+SRCS+= lstAppend.c lstConcat.c lstDeQueue.c lstDestroy.c \
lstDupl.c lstFindFrom.c lstForEachFrom.c lstInit.c lstInsert.c \
- lstIsAtEnd.c lstMember.c lstNext.c lstOpen.c lstRemove.c
+ lstMember.c lstRemove.c
.PATH: ${.CURDIR}/lst.lib
WARNS?= 3
diff --git a/usr.bin/make/arch.c b/usr.bin/make/arch.c
index cd5ffc0..a74713d 100644
--- a/usr.bin/make/arch.c
+++ b/usr.bin/make/arch.c
@@ -1021,11 +1021,7 @@ Arch_MemMTime(GNode *gn)
char *nameStart,
*nameEnd;
- if (Lst_Open(gn->parents) != SUCCESS) {
- gn->mtime = 0;
- return (0);
- }
- while ((ln = Lst_Next(gn->parents)) != NULL) {
+ for (ln = Lst_First(gn->parents); ln != NULL; ln = Lst_Succ(ln)) {
pgn = Lst_Datum(ln);
if (pgn->type & OP_ARCHV) {
@@ -1052,9 +1048,6 @@ Arch_MemMTime(GNode *gn)
break;
}
}
-
- Lst_Close(gn->parents);
-
return (gn->mtime);
}
diff --git a/usr.bin/make/dir.c b/usr.bin/make/dir.c
index c4ed050..fdaf768 100644
--- a/usr.bin/make/dir.c
+++ b/usr.bin/make/dir.c
@@ -506,15 +506,9 @@ static void
DirExpandInt(const char *word, Lst *path, Lst *expansions)
{
LstNode *ln; /* Current node */
- Path *p; /* Directory in the node */
- if (Lst_Open(path) == SUCCESS) {
- while ((ln = Lst_Next(path)) != NULL) {
- p = Lst_Datum(ln);
- DirMatchFiles(word, p, expansions);
- }
- Lst_Close(path);
- }
+ for (ln = Lst_First(path); ln != NULL; ln = Lst_Succ(ln))
+ DirMatchFiles(word, (Path *)Lst_Datum(ln), expansions);
}
/*-
@@ -716,12 +710,6 @@ Dir_FindFile(char *name, Lst *path)
return (estrdup(name));
}
- if (Lst_Open(path) == FAILURE) {
- DEBUGF(DIR, ("couldn't open path, file not found\n"));
- misses += 1;
- return (NULL);
- }
-
/*
* We look through all the directories on the path seeking one which
* contains the final component of the given name and whose final
@@ -730,7 +718,7 @@ Dir_FindFile(char *name, Lst *path)
* and return the resulting string. If we don't find any such thing,
* we go on to phase two...
*/
- while ((ln = Lst_Next(path)) != NULL) {
+ for (ln = Lst_First(path); ln != NULL; ln = Lst_Succ(ln)) {
p = Lst_Datum(ln);
DEBUGF(DIR, ("%s...", p->name));
if (Hash_FindEntry(&p->files, cp) != NULL) {
@@ -761,7 +749,6 @@ Dir_FindFile(char *name, Lst *path)
}
file = str_concat(p->name, cp, STR_ADDSLASH);
DEBUGF(DIR, ("returning %s\n", file));
- Lst_Close(path);
p->hits += 1;
hits += 1;
return (file);
@@ -776,7 +763,6 @@ Dir_FindFile(char *name, Lst *path)
p1++, p2++)
continue;
if (*p1 == '\0' && p2 == cp - 1) {
- Lst_Close(path);
if (*cp == '\0' || ISDOT(cp) || ISDOTDOT(cp)) {
DEBUGF(DIR, ("returning %s\n", name));
return (estrdup(name));
@@ -811,8 +797,7 @@ Dir_FindFile(char *name, Lst *path)
Boolean checkedDot = FALSE;
DEBUGF(DIR, ("failed. Trying subdirectories..."));
- Lst_Open(path);
- while ((ln = Lst_Next(path)) != NULL) {
+ for (ln = Lst_First(path); ln != NULL; ln = Lst_Succ(ln)) {
p = Lst_Datum(ln);
if (p != dot) {
file = str_concat(p->name, name, STR_ADDSLASH);
@@ -829,8 +814,6 @@ Dir_FindFile(char *name, Lst *path)
if (stat(file, &stb) == 0) {
DEBUGF(DIR, ("got it.\n"));
- Lst_Close(path);
-
/*
* We've found another directory to search. We
* know there's a slash in 'file' because we put
@@ -867,7 +850,6 @@ Dir_FindFile(char *name, Lst *path)
}
DEBUGF(DIR, ("failed. "));
- Lst_Close(path);
if (checkedDot) {
/*
@@ -1120,16 +1102,13 @@ Dir_MakeFlags(char *flag, Lst *path)
str = estrdup("");
- if (Lst_Open(path) == SUCCESS) {
- while ((ln = Lst_Next(path)) != NULL) {
- p = Lst_Datum(ln);
- tstr = str_concat(flag, p->name, 0);
- nstr = str_concat(str, tstr, STR_ADDSPACE);
- free(str);
- free(tstr);
- str = nstr;
- }
- Lst_Close(path);
+ for (ln = Lst_First(path); ln != NULL; ln = Lst_Succ(ln)) {
+ p = Lst_Datum(ln);
+ tstr = str_concat(flag, p->name, 0);
+ nstr = str_concat(str, tstr, STR_ADDSPACE);
+ free(str);
+ free(tstr);
+ str = nstr;
}
return (str);
@@ -1237,13 +1216,9 @@ Dir_PrintDirectories(void)
(hits + bigmisses + nearmisses ?
hits * 100 / (hits + bigmisses + nearmisses) : 0));
printf("# %-20s referenced\thits\n", "directory");
- if (Lst_Open(openDirectories) == SUCCESS) {
- while ((ln = Lst_Next(openDirectories)) != NULL) {
- p = Lst_Datum(ln);
- printf("# %-20s %10d\t%4d\n", p->name, p->refCount,
- p->hits);
- }
- Lst_Close(openDirectories);
+ for (ln = Lst_First(openDirectories); ln != NULL; ln = Lst_Succ(ln)) {
+ p = Lst_Datum(ln);
+ printf("# %-20s %10d\t%4d\n", p->name, p->refCount, p->hits);
}
}
diff --git a/usr.bin/make/job.c b/usr.bin/make/job.c
index adde86e..7a598f2 100644
--- a/usr.bin/make/job.c
+++ b/usr.bin/make/job.c
@@ -844,8 +844,8 @@ JobFinish(Job *job, int *status)
* try and restart the job on the next command. If JobStart says it's
* ok, it's ok. If there's an error, this puppy is done.
*/
- if (compatMake && (WIFEXITED(*status) &&
- !Lst_IsAtEnd(job->node->commands))) {
+ if (compatMake && WIFEXITED(*status) &&
+ Lst_Succ(job->node->compat_command) != NULL) {
switch (JobStart(job->node, job->flags & JOB_IGNDOTS, job)) {
case JOB_RUNNING:
done = FALSE;
@@ -1461,31 +1461,28 @@ JobStart(GNode *gn, int flags, Job *previous)
* and print it to the command file. If the command was an
* ellipsis, note that there's nothing more to execute.
*/
- if ((job->flags&JOB_FIRST) && (Lst_Open(gn->commands) != SUCCESS)){
- cmdsOK = FALSE;
- } else {
- LstNode *ln = Lst_Next(gn->commands);
+ if (job->flags & JOB_FIRST)
+ gn->compat_command = Lst_First(gn->commands);
+ else
+ gn->compat_command = Lst_Succ(gn->compat_command);
- if ((ln == NULL) ||
- JobPrintCommand(Lst_Datum(ln), job))
- {
- noExec = TRUE;
- Lst_Close(gn->commands);
- }
- if (noExec && !(job->flags & JOB_FIRST)) {
- /*
- * If we're not going to execute anything, the job
- * is done and we need to close down the various
- * file descriptors we've opened for output, then
- * call JobDoOutput to catch the final characters or
- * send the file to the screen... Note that the i/o streams
- * are only open if this isn't the first job.
- * Note also that this could not be done in
- * Job_CatchChildren b/c it wasn't clear if there were
- * more commands to execute or not...
- */
- JobClose(job);
- }
+ if (gn->compat_command == NULL ||
+ JobPrintCommand(Lst_Datum(gn->compat_command), job))
+ noExec = TRUE;
+
+ if (noExec && !(job->flags & JOB_FIRST)) {
+ /*
+ * If we're not going to execute anything, the job
+ * is done and we need to close down the various
+ * file descriptors we've opened for output, then
+ * call JobDoOutput to catch the final characters or
+ * send the file to the screen... Note that the i/o streams
+ * are only open if this isn't the first job.
+ * Note also that this could not be done in
+ * Job_CatchChildren b/c it wasn't clear if there were
+ * more commands to execute or not...
+ */
+ JobClose(job);
}
} else {
/*
@@ -2032,17 +2029,13 @@ Job_CatchOutput(int flag)
if (--nfds <= 0)
return;
}
- if (Lst_Open(jobs) == FAILURE) {
- Punt("Cannot open job table");
- }
- while (nfds && (ln = Lst_Next(jobs)) != NULL) {
+ for (ln = Lst_First(jobs); nfds != 0 && ln != NULL; ln = Lst_Succ(ln)) {
job = Lst_Datum(ln);
if (FD_ISSET(job->inPipe, &readfds)) {
JobDoOutput(job, FALSE);
nfds -= 1;
}
}
- Lst_Close(jobs);
#endif /* !USE_KQUEUE */
}
}
@@ -2615,13 +2608,12 @@ static void
JobInterrupt(int runINTERRUPT, int signo)
{
LstNode *ln; /* element in job table */
- Job *job = NULL; /* job descriptor in that element */
+ Job *job; /* job descriptor in that element */
GNode *interrupt; /* the node describing the .INTERRUPT target */
aborting = ABORT_INTERRUPT;
- Lst_Open(jobs);
- while ((ln = Lst_Next(jobs)) != NULL) {
+ for (ln = Lst_First(jobs); ln != NULL; ln = Lst_Succ(ln)) {
job = Lst_Datum(ln);
if (!Targ_Precious(job->node)) {
@@ -2742,8 +2734,7 @@ Job_AbortAll(void)
aborting = ABORT_ERROR;
if (nJobs) {
- Lst_Open(jobs);
- while ((ln = Lst_Next(jobs)) != NULL) {
+ for (ln = Lst_First(jobs); ln != NULL; ln = Lst_Succ(ln)) {
job = Lst_Datum(ln);
/*
diff --git a/usr.bin/make/lst.h b/usr.bin/make/lst.h
index 5324f24..0f59980 100644
--- a/usr.bin/make/lst.h
+++ b/usr.bin/make/lst.h
@@ -79,15 +79,6 @@ typedef enum {
struct Lst {
LstNode *firstPtr; /* first node in list */
LstNode *lastPtr; /* last node in list */
- /*
- * fields for sequential access
- */
- LstWhere atEnd; /* Where in the list the last access was */
- Boolean isOpen; /* true if list has been Lst_Open'ed */
- LstNode *curPtr; /* current node, if open. NULL if
- * *just* opened */
- LstNode *prevPtr; /* Previous node, if open. Used by
- * Lst_Remove */
};
typedef struct Lst Lst;
@@ -172,19 +163,6 @@ void Lst_ForEach(Lst *, DoProc *, void *);
* beginning of the list again.
*/
void Lst_ForEachFrom(Lst *, LstNode *, DoProc *, void *);
-/*
- * these functions are for dealing with a list as a table, of sorts.
- * An idea of the "current element" is kept and used by all the functions
- * between Lst_Open() and Lst_Close().
- */
-/* Open the list */
-ReturnStatus Lst_Open(Lst *);
-/* Next element please */
-LstNode *Lst_Next(Lst *);
-/* Done yet? */
-Boolean Lst_IsAtEnd(Lst *);
-/* Finish table access */
-void Lst_Close(Lst *);
/*
* for using the list as a queue
diff --git a/usr.bin/make/lst.lib/lstClose.c b/usr.bin/make/lst.lib/lstClose.c
deleted file mode 100644
index 4ab02ba..0000000
--- a/usr.bin/make/lst.lib/lstClose.c
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright (c) 1988, 1989, 1990, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Adam de Boor.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * @(#)lstClose.c 8.1 (Berkeley) 6/6/93
- */
-
-#ifndef lint
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-#endif /* not lint */
-
-/*-
- * LstClose.c --
- * Close a list for sequential access.
- * The sequential functions access the list in a slightly different way.
- * CurPtr points to their idea of the current node in the list and they
- * access the list based on it. Lst_IsAtEnd must be used to determine
- * when to stop.
- */
-
-#include "make.h"
-#include "lst.h"
-
-/*-
- *-----------------------------------------------------------------------
- * Lst_Close --
- * Close a list which was opened for sequential access.
- *
- * Results:
- * None.
- *
- * Arguments:
- * l The list to close
- *
- * Side Effects:
- * The list is closed.
- *
- *-----------------------------------------------------------------------
- */
-void
-Lst_Close(Lst *list)
-{
-
- if (Lst_Valid(list) == TRUE) {
- list->isOpen = FALSE;
- list->atEnd = LstUnknown;
- }
-}
diff --git a/usr.bin/make/lst.lib/lstInit.c b/usr.bin/make/lst.lib/lstInit.c
index 20c62b4..7fc775d 100644
--- a/usr.bin/make/lst.lib/lstInit.c
+++ b/usr.bin/make/lst.lib/lstInit.c
@@ -71,8 +71,6 @@ Lst_Init(void)
nList->firstPtr = NULL;
nList->lastPtr = NULL;
- nList->isOpen = FALSE;
- nList->atEnd = LstUnknown;
return (nList);
}
diff --git a/usr.bin/make/lst.lib/lstIsAtEnd.c b/usr.bin/make/lst.lib/lstIsAtEnd.c
deleted file mode 100644
index 46c3fcc..0000000
--- a/usr.bin/make/lst.lib/lstIsAtEnd.c
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Copyright (c) 1988, 1989, 1990, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Adam de Boor.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * @(#)lstIsAtEnd.c 8.1 (Berkeley) 6/6/93
- */
-
-#ifndef lint
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-#endif /* not lint */
-
-/*-
- * LstIsAtEnd.c --
- * Tell if the current node is at the end of the list.
- * The sequential functions access the list in a slightly different way.
- * CurPtr points to their idea of the current node in the list and they
- * access the list based on it. Lst_IsAtEnd must be used to determine
- * when to stop.
- */
-
-#include "make.h"
-#include "lst.h"
-
-/*-
- *-----------------------------------------------------------------------
- * Lst_IsAtEnd --
- * Return true if have reached the end of the given list.
- *
- * Results:
- * TRUE if at the end of the list (this includes the list not being
- * open or being invalid) or FALSE if not. We return TRUE if the list
- * is invalid or unopend so as to cause the caller to exit its loop
- * asap, the assumption being that the loop is of the form
- * while (!Lst_IsAtEnd (l)) {
- * ...
- * }
- *
- * Side Effects:
- * None.
- *
- *-----------------------------------------------------------------------
- */
-Boolean
-Lst_IsAtEnd(Lst *list)
-{
-
- return (!Lst_Valid(list) || !list->isOpen ||
- (list->atEnd == LstHead) || (list->atEnd == LstTail));
-}
diff --git a/usr.bin/make/lst.lib/lstNext.c b/usr.bin/make/lst.lib/lstNext.c
deleted file mode 100644
index 0855673..0000000
--- a/usr.bin/make/lst.lib/lstNext.c
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Copyright (c) 1988, 1989, 1990, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Adam de Boor.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * @(#)lstNext.c 8.1 (Berkeley) 6/6/93
- */
-
-#ifndef lint
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-#endif /* not lint */
-
-/*-
- * LstNext.c --
- * Return the next node for a list.
- * The sequential functions access the list in a slightly different way.
- * CurPtr points to their idea of the current node in the list and they
- * access the list based on it. Lst_IsAtEnd must be used to determine
- * when to stop.
- */
-
-#include "make.h"
-#include "lst.h"
-
-/*-
- *-----------------------------------------------------------------------
- * Lst_Next --
- * Return the next node for the given list.
- *
- * Results:
- * The next node or NULL if the list has yet to be opened or the end
- * has been reached.
- *
- * Side Effects:
- * the curPtr field is updated.
- *
- *-----------------------------------------------------------------------
- */
-LstNode *
-Lst_Next(Lst *list)
-{
- LstNode *tln;
-
- if ((Lst_Valid(list) == FALSE) || (list->isOpen == FALSE)) {
- return (NULL);
- }
-
- list->prevPtr = list->curPtr;
-
- if (list->curPtr == NULL) {
- if (list->atEnd == LstUnknown) {
- /*
- * If we're just starting out, atEnd will be Unknown.
- * Then we want to start this thing off in the right
- * direction -- at the start with atEnd being Middle.
- */
- list->curPtr = tln = list->firstPtr;
- list->atEnd = LstMiddle;
- } else {
- tln = NULL;
- list->atEnd = LstTail;
- }
- } else {
- tln = list->curPtr->nextPtr;
- list->curPtr = tln;
-
- if (tln == NULL) {
- list->atEnd = LstTail;
- } else {
- list->atEnd = LstMiddle;
- }
- }
-
- return (tln);
-}
diff --git a/usr.bin/make/lst.lib/lstOpen.c b/usr.bin/make/lst.lib/lstOpen.c
deleted file mode 100644
index 0ac9299..0000000
--- a/usr.bin/make/lst.lib/lstOpen.c
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright (c) 1988, 1989, 1990, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Adam de Boor.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * @(#)lstOpen.c 8.1 (Berkeley) 6/6/93
- */
-
-#ifndef lint
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-#endif /* not lint */
-
-/*-
- * LstOpen.c --
- * Open a list for sequential access. The sequential functions access the
- * list in a slightly different way. CurPtr points to their idea of the
- * current node in the list and they access the list based on it.
- * Lst_IsAtEnd must be used to determine when to stop.
- */
-
-#include "make.h"
-#include "lst.h"
-
-/*-
- *-----------------------------------------------------------------------
- * Lst_Open --
- * Open a list for sequential access. A list can still be searched,
- * etc., without confusing these functions.
- *
- * Results:
- * SUCCESS or FAILURE.
- *
- * Side Effects:
- * isOpen is set TRUE and curPtr is set to NULL so the
- * other sequential functions no it was just opened and can choose
- * the first element accessed based on this.
- *
- *-----------------------------------------------------------------------
- */
-ReturnStatus
-Lst_Open(Lst *l)
-{
-
- if (Lst_Valid(l) == FALSE) {
- return (FAILURE);
- }
- l->isOpen = TRUE;
- l->atEnd = Lst_IsEmpty(l) ? LstHead : LstUnknown;
- l->curPtr = NULL;
-
- return (SUCCESS);
-}
diff --git a/usr.bin/make/lst.lib/lstRemove.c b/usr.bin/make/lst.lib/lstRemove.c
index 0a5e940..035218d 100644
--- a/usr.bin/make/lst.lib/lstRemove.c
+++ b/usr.bin/make/lst.lib/lstRemove.c
@@ -94,19 +94,6 @@ Lst_Remove(Lst *list, LstNode *ln)
}
/*
- * Sequential access stuff. If the node we're removing is the current
- * node in the list, reset the current node to the previous one. If the
- * previous one was non-existent (prevPtr == NULL), we set the
- * end to be Unknown, since it is.
- */
- if (list->isOpen && (list->curPtr == ln)) {
- list->curPtr = list->prevPtr;
- if (list->curPtr == NULL) {
- list->atEnd = LstUnknown;
- }
- }
-
- /*
* the only way firstPtr can still point to ln is if ln is the last
* node on the list. The list is, therefore, empty and is marked as such
*/
diff --git a/usr.bin/make/make.c b/usr.bin/make/make.c
index 93411f8..f064348 100644
--- a/usr.bin/make/make.c
+++ b/usr.bin/make/make.c
@@ -310,17 +310,14 @@ Make_HandleUse(GNode *cgn, GNode *pgn)
Lst_Concat(pgn->commands, cgn->commands, LST_CONCNEW);
}
- if (Lst_Open(cgn->children) == SUCCESS) {
- while ((ln = Lst_Next(cgn->children)) != NULL) {
- gn = Lst_Datum(ln);
-
- if (Lst_Member(pgn->children, gn) == NULL) {
- Lst_AtEnd(pgn->children, gn);
- Lst_AtEnd(gn->parents, pgn);
- pgn->unmade += 1;
- }
+ for (ln = Lst_First(cgn->children); ln != NULL; ln = Lst_Succ(ln)) {
+ gn = Lst_Datum(ln);
+
+ if (Lst_Member(pgn->children, gn) == NULL) {
+ Lst_AtEnd(pgn->children, gn);
+ Lst_AtEnd(gn->parents, pgn);
+ pgn->unmade += 1;
}
- Lst_Close(cgn->children);
}
pgn->type |= cgn->type & ~(OP_OPMASK | OP_USE | OP_TRANSFORM);
@@ -378,6 +375,8 @@ Make_Update(GNode *cgn)
char *cname; /* the child's name */
LstNode *ln; /* Element in parents and iParents lists */
char *p1;
+ char *ptr;
+ char *cpref;
cname = Var_Value(TARGET, cgn, &p1);
free(p1);
@@ -447,35 +446,33 @@ Make_Update(GNode *cgn)
#endif
}
- if (Lst_Open(cgn->parents) == SUCCESS) {
- while ((ln = Lst_Next(cgn->parents)) != NULL) {
- pgn = Lst_Datum(ln);
- if (pgn->make) {
- pgn->unmade -= 1;
-
- if (!(cgn->type & (OP_EXEC | OP_USE))) {
- if (cgn->made == MADE) {
- pgn->childMade = TRUE;
- if (pgn->cmtime < cgn->mtime) {
- pgn->cmtime = cgn->mtime;
- }
- } else {
- Make_TimeStamp(pgn, cgn);
+ for (ln = Lst_First(cgn->parents); ln != NULL; ln = Lst_Succ(ln)) {
+ pgn = Lst_Datum(ln);
+ if (pgn->make) {
+ pgn->unmade -= 1;
+
+ if (!(cgn->type & (OP_EXEC | OP_USE))) {
+ if (cgn->made == MADE) {
+ pgn->childMade = TRUE;
+ if (pgn->cmtime < cgn->mtime) {
+ pgn->cmtime = cgn->mtime;
}
- }
- if (pgn->unmade == 0) {
- /*
- * Queue the node up -- any unmade predecessors will
- * be dealt with in MakeStartJobs.
- */
- Lst_EnQueue(toBeMade, pgn);
- } else if (pgn->unmade < 0) {
- Error("Graph cycles through %s", pgn->name);
+ } else {
+ Make_TimeStamp(pgn, cgn);
}
}
+ if (pgn->unmade == 0) {
+ /*
+ * Queue the node up -- any unmade predecessors will
+ * be dealt with in MakeStartJobs.
+ */
+ Lst_EnQueue(toBeMade, pgn);
+ } else if (pgn->unmade < 0) {
+ Error("Graph cycles through %s", pgn->name);
+ }
}
- Lst_Close(cgn->parents);
}
+
/*
* Deal with successor nodes. If any is marked for making and has an unmade
* count of 0, has not been made and isn't in the examination queue,
@@ -496,20 +493,15 @@ Make_Update(GNode *cgn)
* Set the .PREFIX and .IMPSRC variables for all the implied parents
* of this node.
*/
- if (Lst_Open(cgn->iParents) == SUCCESS) {
- char *ptr;
- char *cpref = Var_Value(PREFIX, cgn, &ptr);
-
- while ((ln = Lst_Next(cgn->iParents)) != NULL) {
- pgn = Lst_Datum (ln);
- if (pgn->make) {
- Var_Set(IMPSRC, cname, pgn);
- Var_Set(PREFIX, cpref, pgn);
- }
+ cpref = Var_Value(PREFIX, cgn, &ptr);
+ for (ln = Lst_First(cgn->iParents); ln != NULL; ln = Lst_Succ(ln)) {
+ pgn = Lst_Datum (ln);
+ if (pgn->make) {
+ Var_Set(IMPSRC, cname, pgn);
+ Var_Set(PREFIX, cpref, pgn);
}
- free(ptr);
- Lst_Close(cgn->iParents);
}
+ free(ptr);
}
/*-
diff --git a/usr.bin/make/make.h b/usr.bin/make/make.h
index bd894bd..a6a3b71 100644
--- a/usr.bin/make/make.h
+++ b/usr.bin/make/make.h
@@ -136,6 +136,9 @@ typedef struct GNode {
Lst *context; /* The local variables */
Lst *commands; /* Creation commands */
+ /* current command executing in compat mode */
+ LstNode *compat_command;
+
struct _Suff *suffix; /* Suffix for the node (determined by
* Suff_FindDeps and opaque to everyone
* but the Suff module) */
diff --git a/usr.bin/make/suff.c b/usr.bin/make/suff.c
index 715cdd8..4802f2b 100644
--- a/usr.bin/make/suff.c
+++ b/usr.bin/make/suff.c
@@ -403,23 +403,19 @@ SuffRemove(Lst *l, Suff *s)
static void
SuffInsert(Lst *l, Suff *s)
{
- LstNode *ln; /* current element in l we're examining */
- Suff *s2 = NULL; /* the suffix descriptor in this element */
+ LstNode *ln; /* current element in l we're examining */
+ Suff *s2; /* the suffix descriptor in this element */
- if (Lst_Open(l) == FAILURE) {
- return;
- }
- while ((ln = Lst_Next(l)) != NULL) {
+ s2 = NULL;
+ for (ln = Lst_First(l); ln != NULL; ln = Lst_Succ(ln)) {
s2 = Lst_Datum(ln);
- if (s2->sNum >= s->sNum) {
+ if (s2->sNum >= s->sNum)
break;
- }
}
if (s2 == NULL) {
DEBUGF(SUFF, ("inserting an empty list?..."));
}
- Lst_Close(l);
DEBUGF(SUFF, ("inserting %s(%d)...", s->name, s->sNum));
if (ln == NULL) {
DEBUGF(SUFF, ("at end of list\n"));
@@ -863,14 +859,10 @@ Suff_DoPaths(void)
Lst *inIncludes; /* Cumulative .INCLUDES path */
Lst *inLibs; /* Cumulative .LIBS path */
- if (Lst_Open(sufflist) == FAILURE) {
- return;
- }
-
inIncludes = Lst_Init();
inLibs = Lst_Init();
- while ((ln = Lst_Next(sufflist)) != NULL) {
+ for (ln = Lst_First(sufflist); ln != NULL; ln = Lst_Succ(ln)) {
s = Lst_Datum(ln);
if (!Lst_IsEmpty(s->searchPath)) {
#ifdef INCLUDES
@@ -897,8 +889,6 @@ Suff_DoPaths(void)
Lst_Destroy(inIncludes, Dir_Destroy);
Lst_Destroy(inLibs, Dir_Destroy);
-
- Lst_Close(sufflist);
}
/*-
@@ -1056,6 +1046,7 @@ SuffAddLevel(Lst *l, Src *targ)
*----------------------------------------------------------------------
* SuffRemoveSrc --
* Free all src structures in list that don't have a reference count
+ * XXX this actually frees only the first of these.
*
* Results:
* True if a src was removed
@@ -1067,21 +1058,19 @@ SuffAddLevel(Lst *l, Src *targ)
static int
SuffRemoveSrc(Lst *l)
{
- LstNode *ln;
+ LstNode *ln, *ln1;
Src *s;
int t = 0;
- if (Lst_Open(l) == FAILURE) {
- return (0);
- }
#ifdef DEBUG_SRC
printf("cleaning %lx: ", (unsigned long) l);
Lst_ForEach(l, PrintAddr, (void *)NULL);
printf("\n");
#endif
+ for (ln = Lst_First(l); ln != NULL; ln = ln1) {
+ ln1 = Lst_Succ(ln);
- while ((ln = Lst_Next(l)) != NULL) {
s = (Src *)Lst_Datum(ln);
if (s->children == 0) {
free(s->file);
@@ -1102,8 +1091,7 @@ SuffRemoveSrc(Lst *l)
Lst_Remove(l, ln);
free(s);
t |= 1;
- Lst_Close(l);
- return TRUE;
+ return (TRUE);
}
#ifdef DEBUG_SRC
else {
@@ -1114,8 +1102,6 @@ SuffRemoveSrc(Lst *l)
#endif
}
- Lst_Close(l);
-
return (t);
}
@@ -1205,10 +1191,9 @@ SuffFindCmds (Src *targ, Lst *slst)
char *cp;
t = targ->node;
- Lst_Open(t->children);
prefLen = strlen(targ->pref);
- while ((ln = Lst_Next(t->children)) != NULL) {
+ for (ln = Lst_First(t->children); ln != NULL; ln = Lst_Succ(ln)) {
s = Lst_Datum(ln);
cp = strrchr(s->name, '/');
@@ -1260,7 +1245,6 @@ SuffFindCmds (Src *targ, Lst *slst)
}
}
}
- Lst_Close(t->children);
return (NULL);
}
diff --git a/usr.bin/make/targ.c b/usr.bin/make/targ.c
index b10180d..5a93d7f 100644
--- a/usr.bin/make/targ.c
+++ b/usr.bin/make/targ.c
@@ -286,10 +286,7 @@ Targ_FindList(Lst *names, int flags)
nodes = Lst_Init();
- if (Lst_Open(names) == FAILURE) {
- return (nodes);
- }
- while ((ln = Lst_Next(names)) != NULL) {
+ for (ln = Lst_First(names); ln != NULL; ln = Lst_Succ(ln)) {
name = Lst_Datum(ln);
gn = Targ_FindNode(name, flags);
if (gn != NULL) {
@@ -306,7 +303,6 @@ Targ_FindList(Lst *names, int flags)
Error("\"%s\" -- target unknown.", name);
}
}
- Lst_Close(names);
return (nodes);
}
OpenPOWER on IntegriCloud