summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorharti <harti@FreeBSD.org>2004-12-16 16:14:16 +0000
committerharti <harti@FreeBSD.org>2004-12-16 16:14:16 +0000
commitce24622080c0eb3be79451dd08003d8e95ce7e29 (patch)
treefdf4034c35002c2f5a941b3dae513d763e63ce80
parentc9d76864dd7b7d31e691edce2d40a35711cc3f7c (diff)
downloadFreeBSD-src-ce24622080c0eb3be79451dd08003d8e95ce7e29.zip
FreeBSD-src-ce24622080c0eb3be79451dd08003d8e95ce7e29.tar.gz
Instead of dynamically allocating list heads allocated them statically
now that their size is only two pointers. This eliminates a lot of calls to Lst_Init and from there to malloc together with many calls to Lst_Destroy (in places where the list is obviously empty). This also reduces the chance to leave a list uninitilized so we can remove more NULL pointer checks and probably eliminates a couple of memory leaks.
-rw-r--r--usr.bin/make/Makefile2
-rw-r--r--usr.bin/make/arch.c28
-rw-r--r--usr.bin/make/compat.c20
-rw-r--r--usr.bin/make/cond.c4
-rw-r--r--usr.bin/make/dir.c42
-rw-r--r--usr.bin/make/for.c21
-rw-r--r--usr.bin/make/job.c72
-rw-r--r--usr.bin/make/lst.h14
-rw-r--r--usr.bin/make/lst.lib/lstConcat.c1
-rw-r--r--usr.bin/make/lst.lib/lstDestroy.c16
-rw-r--r--usr.bin/make/lst.lib/lstDupl.c30
-rw-r--r--usr.bin/make/lst.lib/lstInit.c76
-rw-r--r--usr.bin/make/main.c91
-rw-r--r--usr.bin/make/make.c73
-rw-r--r--usr.bin/make/make.h43
-rw-r--r--usr.bin/make/nonints.h4
-rw-r--r--usr.bin/make/parse.c206
-rw-r--r--usr.bin/make/suff.c365
-rw-r--r--usr.bin/make/targ.c53
-rw-r--r--usr.bin/make/var.c20
20 files changed, 530 insertions, 651 deletions
diff --git a/usr.bin/make/Makefile b/usr.bin/make/Makefile
index d3e5f56..953bb3e 100644
--- a/usr.bin/make/Makefile
+++ b/usr.bin/make/Makefile
@@ -7,7 +7,7 @@ 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 lstConcat.c lstDeQueue.c lstDestroy.c \
- lstDupl.c lstFindFrom.c lstForEachFrom.c lstInit.c lstInsert.c \
+ lstDupl.c lstFindFrom.c lstForEachFrom.c lstInsert.c \
lstMember.c lstRemove.c
.PATH: ${.CURDIR}/lst.lib
diff --git a/usr.bin/make/arch.c b/usr.bin/make/arch.c
index a74713d..6947acc 100644
--- a/usr.bin/make/arch.c
+++ b/usr.bin/make/arch.c
@@ -103,7 +103,8 @@ __FBSDID("$FreeBSD$");
#include "dir.h"
#include "config.h"
-static Lst *archives; /* Lst of archives we've already examined */
+/* Lst of archives we've already examined */
+static Lst archives = Lst_Initializer(archives);
typedef struct Arch {
char *name; /* Name of archive */
@@ -335,16 +336,16 @@ Arch_ParseArchive(char **linePtr, Lst *nodeLst, GNode *ctxt)
*/
free(buf);
} else if (Dir_HasWildcards(memName)) {
- Lst *members = Lst_Init();
+ Lst members = Lst_Initializer(members);
char *member;
size_t sz = MAXPATHLEN;
size_t nsz;
nameBuf = emalloc(sz);
- Dir_Expand(memName, dirSearchPath, members);
- while (!Lst_IsEmpty(members)) {
- member = Lst_DeQueue(members);
+ Dir_Expand(memName, &dirSearchPath, &members);
+ while (!Lst_IsEmpty(&members)) {
+ member = Lst_DeQueue(&members);
nsz = strlen(libName) + strlen(member) + 3;
if (nsz > sz) {
sz = nsz * 2;
@@ -356,6 +357,7 @@ Arch_ParseArchive(char **linePtr, Lst *nodeLst, GNode *ctxt)
gn = Targ_FindNode(nameBuf, TARG_CREATE);
if (gn == NULL) {
free(nameBuf);
+ /* XXXHB Lst_Destroy(&members) */
return (FAILURE);
} else {
/*
@@ -369,7 +371,6 @@ Arch_ParseArchive(char **linePtr, Lst *nodeLst, GNode *ctxt)
Lst_AtEnd(nodeLst, (void *)gn);
}
}
- Lst_Destroy(members, NOFREE);
free(nameBuf);
} else {
size_t sz = strlen(libName) + strlen(memName) + 3;
@@ -483,7 +484,7 @@ ArchStatMember(char *archive, char *member, Boolean hash)
if ((cp != NULL) && (strcmp(member, RANLIBMAG) != 0))
member = cp + 1;
- ln = Lst_Find(archives, archive, ArchFindArchive);
+ ln = Lst_Find(&archives, archive, ArchFindArchive);
if (ln != NULL) {
ar = Lst_Datum(ln);
@@ -633,7 +634,7 @@ ArchStatMember(char *archive, char *member, Boolean hash)
fclose(arch);
- Lst_AtEnd(archives, ar);
+ Lst_AtEnd(&archives, ar);
/*
* Now that the archive has been read and cached, we can look into
@@ -1021,7 +1022,7 @@ Arch_MemMTime(GNode *gn)
char *nameStart,
*nameEnd;
- for (ln = Lst_First(gn->parents); ln != NULL; ln = Lst_Succ(ln)) {
+ for (ln = Lst_First(&gn->parents); ln != NULL; ln = Lst_Succ(ln)) {
pgn = Lst_Datum(ln);
if (pgn->type & OP_ARCHV) {
@@ -1134,7 +1135,7 @@ Arch_LibOODate(GNode *gn)
{
Boolean oodate;
- if (OP_NOP(gn->type) && Lst_IsEmpty(gn->children)) {
+ if (OP_NOP(gn->type) && Lst_IsEmpty(&gn->children)) {
oodate = FALSE;
} else if ((gn->mtime > now) || (gn->mtime < gn->cmtime)) {
oodate = TRUE;
@@ -1177,16 +1178,11 @@ Arch_LibOODate(GNode *gn)
* Results:
* None.
*
- * Side Effects:
- * The 'archives' list is initialized.
- *
*-----------------------------------------------------------------------
*/
void
Arch_Init(void)
{
-
- archives = Lst_Init();
}
/*-
@@ -1206,5 +1202,5 @@ void
Arch_End(void)
{
- Lst_Destroy(archives, ArchFree);
+ Lst_Destroy(&archives, ArchFree);
}
diff --git a/usr.bin/make/compat.c b/usr.bin/make/compat.c
index 1645ff1..646a2b0 100644
--- a/usr.bin/make/compat.c
+++ b/usr.bin/make/compat.c
@@ -160,7 +160,7 @@ CompatInterrupt (int signo)
if (signo == SIGINT) {
gn = Targ_FindNode(".INTERRUPT", TARG_NOCREATE);
if (gn != NULL) {
- Lst_ForEach(gn->commands, Compat_RunCommand, (void *)gn);
+ Lst_ForEach(&gn->commands, Compat_RunCommand, (void *)gn);
}
}
@@ -245,7 +245,7 @@ Compat_RunCommand(void *cmdp, void *gnp)
errCheck = !(gn->type & OP_IGNORE);
doit = FALSE;
- cmdNode = Lst_Member(gn->commands, cmd);
+ cmdNode = Lst_Member(&gn->commands, cmd);
cmdStart = Var_Subst(NULL, cmd, gn, FALSE);
/*
@@ -265,7 +265,7 @@ Compat_RunCommand(void *cmdp, void *gnp)
Lst_Replace (cmdNode, cmdStart);
if ((gn->type & OP_SAVE_CMDS) && (gn != ENDNode)) {
- Lst_AtEnd(ENDNode->commands, cmdStart);
+ Lst_AtEnd(&ENDNode->commands, cmdStart);
return (0);
} else if (strcmp(cmdStart, "...") == 0) {
gn->type |= OP_SAVE_CMDS;
@@ -481,14 +481,14 @@ CompatMake(void *gnp, void *pgnp)
gn->make = TRUE;
gn->made = BEINGMADE;
Suff_FindDeps(gn);
- Lst_ForEach(gn->children, CompatMake, gn);
+ Lst_ForEach(&gn->children, CompatMake, gn);
if (!gn->make) {
gn->made = ABORTED;
pgn->make = FALSE;
return (0);
}
- if (Lst_Member(gn->iParents, pgn) != NULL) {
+ if (Lst_Member(&gn->iParents, pgn) != NULL) {
char *p1;
Var_Set(IMPSRC, Var_Value(TARGET, gn, &p1), pgn);
free(p1);
@@ -542,7 +542,7 @@ CompatMake(void *gnp, void *pgnp)
*/
if (!touchFlag) {
curTarg = gn;
- Lst_ForEach(gn->commands, Compat_RunCommand, (void *)gn);
+ Lst_ForEach(&gn->commands, Compat_RunCommand, (void *)gn);
curTarg = NULL;
} else {
Job_Touch(gn, gn->type & OP_SILENT);
@@ -586,7 +586,7 @@ CompatMake(void *gnp, void *pgnp)
* To force things that depend on FRC to be made, so we have to
* check for gn->children being empty as well...
*/
- if (!Lst_IsEmpty(gn->commands) || Lst_IsEmpty(gn->children)) {
+ if (!Lst_IsEmpty(&gn->commands) || Lst_IsEmpty(gn->children)) {
gn->mtime = now;
}
#else
@@ -635,7 +635,7 @@ CompatMake(void *gnp, void *pgnp)
*/
pgn->make = FALSE;
} else {
- if (Lst_Member(gn->iParents, pgn) != NULL) {
+ if (Lst_Member(&gn->iParents, pgn) != NULL) {
char *p1;
Var_Set(IMPSRC, Var_Value(TARGET, gn, &p1), pgn);
free(p1);
@@ -708,7 +708,7 @@ Compat_Run(Lst *targs)
if (!queryFlag) {
gn = Targ_FindNode(".BEGIN", TARG_NOCREATE);
if (gn != NULL) {
- Lst_ForEach(gn->commands, Compat_RunCommand, gn);
+ Lst_ForEach(&gn->commands, Compat_RunCommand, gn);
if (gn->made == ERROR) {
printf("\n\nStop.\n");
exit(1);
@@ -743,6 +743,6 @@ Compat_Run(Lst *targs)
* If the user has defined a .END target, run its commands.
*/
if (errors == 0) {
- Lst_ForEach(ENDNode->commands, Compat_RunCommand, gn);
+ Lst_ForEach(&ENDNode->commands, Compat_RunCommand, gn);
}
}
diff --git a/usr.bin/make/cond.c b/usr.bin/make/cond.c
index dad3869..ad70a3e 100644
--- a/usr.bin/make/cond.c
+++ b/usr.bin/make/cond.c
@@ -332,7 +332,7 @@ CondDoMake(int argLen, char *arg)
Boolean result;
arg[argLen] = '\0';
- if (Lst_Find(create, arg, CondStrMatch) == NULL) {
+ if (Lst_Find(&create, arg, CondStrMatch) == NULL) {
result = FALSE;
} else {
result = TRUE;
@@ -362,7 +362,7 @@ CondDoExists(int argLen, char *arg)
char *path;
arg[argLen] = '\0';
- path = Dir_FindFile(arg, dirSearchPath);
+ path = Dir_FindFile(arg, &dirSearchPath);
if (path != NULL) {
result = TRUE;
free(path);
diff --git a/usr.bin/make/dir.c b/usr.bin/make/dir.c
index f269196..c353629 100644
--- a/usr.bin/make/dir.c
+++ b/usr.bin/make/dir.c
@@ -164,9 +164,11 @@ __FBSDID("$FreeBSD$");
* in a cache for when Dir_MTime was actually called.
*/
-Lst *dirSearchPath; /* main search path */
+/* main search path */
+Lst dirSearchPath = Lst_Initializer(dirSearchPath);
-static Lst *openDirectories; /* the list of all open directories */
+/* the list of all open directories */
+static Lst openDirectories = Lst_Initializer(openDirectories);
/*
* Variables for gathering statistics on the efficiency of the hashing
@@ -208,8 +210,6 @@ void
Dir_Init(void)
{
- dirSearchPath = Lst_Init();
- openDirectories = Lst_Init();
Hash_InitTable(&mtimes, 0);
}
@@ -230,8 +230,8 @@ Dir_InitDot(void)
{
LstNode *ln;
- Dir_AddDir(openDirectories, ".");
- if ((ln = Lst_Last(openDirectories)) == NULL)
+ Dir_AddDir(&openDirectories, ".");
+ if ((ln = Lst_Last(&openDirectories)) == NULL)
err(1, "cannot open current directory");
dot = Lst_Datum(ln);
@@ -260,10 +260,10 @@ Dir_End(void)
dot->refCount -= 1;
Dir_Destroy(dot);
- Dir_ClearPath(dirSearchPath);
- Lst_Destroy(dirSearchPath, NOFREE);
- Dir_ClearPath(openDirectories);
- Lst_Destroy(openDirectories, NOFREE);
+ Dir_ClearPath(&dirSearchPath);
+ Lst_Destroy(&dirSearchPath, NOFREE);
+ Dir_ClearPath(&openDirectories);
+ Lst_Destroy(&openDirectories, NOFREE);
Hash_DeleteTable(&mtimes);
}
@@ -611,14 +611,14 @@ Dir_Expand(char *word, Lst *path, Lst *expansions)
char *dp =
&dirpath[strlen(dirpath)
- 1];
+ Lst tp = Lst_Initializer(tp);
if (*dp == '/')
*dp = '\0';
- path = Lst_Init();
- Dir_AddDir(path, dirpath);
- DirExpandInt(cp + 1, path,
+ Dir_AddDir(&tp, dirpath);
+ DirExpandInt(cp + 1, &tp,
expansions);
- Lst_Destroy(path, NOFREE);
+ Lst_Destroy(&tp, NOFREE);
}
} else {
/*
@@ -942,7 +942,7 @@ Dir_MTime(GNode *gn)
return (Arch_MTime(gn));
else if (gn->path == NULL)
- fullName = Dir_FindFile(gn->name, dirSearchPath);
+ fullName = Dir_FindFile(gn->name, &dirSearchPath);
else
fullName = gn->path;
@@ -1000,7 +1000,7 @@ Dir_AddDir(Lst *path, char *name)
DIR *d; /* for reading directory */
struct dirent *dp; /* entry in directory */
- ln = Lst_Find(openDirectories, name, DirFindName);
+ ln = Lst_Find(&openDirectories, name, DirFindName);
if (ln != NULL) {
p = Lst_Datum(ln);
if (Lst_Member(path, p) == NULL) {
@@ -1043,8 +1043,8 @@ Dir_AddDir(Lst *path, char *name)
(Boolean *)NULL);
}
closedir(d);
- Lst_AtEnd(openDirectories, p);
- if (path != openDirectories)
+ Lst_AtEnd(&openDirectories, p);
+ if (path != &openDirectories)
Lst_AtEnd(path, p);
}
DEBUGF(DIR, ("done\n"));
@@ -1139,8 +1139,8 @@ Dir_Destroy(void *pp)
if (p->refCount == 0) {
LstNode *ln;
- if ((ln = Lst_Member(openDirectories, p)) != NULL)
- Lst_Remove(openDirectories, ln);
+ if ((ln = Lst_Member(&openDirectories, p)) != NULL)
+ Lst_Remove(&openDirectories, ln);
Hash_DeleteTable(&p->files);
free(p->name);
@@ -1216,7 +1216,7 @@ Dir_PrintDirectories(void)
(hits + bigmisses + nearmisses ?
hits * 100 / (hits + bigmisses + nearmisses) : 0));
printf("# %-20s referenced\thits\n", "directory");
- for (ln = Lst_First(openDirectories); ln != NULL; ln = Lst_Succ(ln)) {
+ 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/for.c b/usr.bin/make/for.c
index e2df76c..a083630 100644
--- a/usr.bin/make/for.c
+++ b/usr.bin/make/for.c
@@ -72,7 +72,7 @@ __FBSDID("$FreeBSD$");
static int forLevel = 0; /* Nesting level */
static char *forVar; /* Iteration variable */
static Buffer forBuf; /* Commands in loop */
-static Lst *forLst; /* List of items */
+static Lst forLst; /* List of items */
/*
* State of a for loop.
@@ -80,7 +80,7 @@ static Lst *forLst; /* List of items */
typedef struct _For {
Buffer buf; /* Unexpanded buffer */
char* var; /* Index name */
- Lst *lst; /* List of variables */
+ Lst lst; /* List of variables */
int lineno; /* Line # */
} For;
@@ -168,14 +168,14 @@ For_Eval(char *line)
/*
* Make a list with the remaining words
*/
- forLst = Lst_Init();
+ Lst_Init(&forLst);
buf = Buf_Init(0);
sub = Var_Subst(NULL, ptr, VAR_CMD, FALSE);
#define ADDWORD() \
Buf_AddBytes(buf, ptr - wrd, (Byte *)wrd), \
Buf_AddByte(buf, (Byte)'\0'), \
- Lst_AtFront(forLst, Buf_GetAll(buf, &varlen)), \
+ Lst_AtFront(&forLst, Buf_GetAll(buf, &varlen)), \
Buf_Destroy(buf, FALSE)
for (ptr = sub; *ptr && isspace((unsigned char)*ptr); ptr++)
@@ -277,19 +277,22 @@ For_Run(int lineno)
{
For arg;
- if (forVar == NULL || forBuf == NULL || forLst == NULL)
+ if (forVar == NULL || forBuf == NULL)
return;
arg.var = forVar;
arg.buf = forBuf;
- arg.lst = forLst;
+
+ /* move the forLst to the arg to get it free for nested for's */
+ Lst_Init(&arg.lst);
+ Lst_Concat(&arg.lst, &forLst, LST_CONCLINK);
+
arg.lineno = lineno;
forVar = NULL;
forBuf = NULL;
- forLst = NULL;
- Lst_ForEach(arg.lst, ForExec, &arg);
+ Lst_ForEach(&arg.lst, ForExec, &arg);
free(arg.var);
- Lst_Destroy(arg.lst, free);
+ Lst_Destroy(&arg.lst, free);
Buf_Destroy(arg.buf, TRUE);
}
diff --git a/usr.bin/make/job.c b/usr.bin/make/job.c
index 7a598f2..76ebe75 100644
--- a/usr.bin/make/job.c
+++ b/usr.bin/make/job.c
@@ -214,7 +214,10 @@ char *shellPath = NULL, /* full pathname of executable image */
static int maxJobs; /* The most children we can run at once */
STATIC int nJobs; /* The number of children currently running */
-STATIC Lst *jobs; /* The structures that describe them */
+
+/* The structures that describe them */
+STATIC Lst jobs = Lst_Initializer(jobs);
+
STATIC Boolean jobFull; /* Flag to tell when the job table is full. It
* is set TRUE when (1) the total number of
* running jobs equals the maximum allowed */
@@ -240,10 +243,11 @@ STATIC char *targFmt; /* Format string to use to head output from a
* or when Job_CatchChildren detects a job that has
* been stopped somehow, the job is placed on the stoppedJobs queue to be run
* when the next job finishes.
+ *
+ * Lst of Job structures describing jobs that were stopped due to
+ * concurrency limits or externally
*/
-STATIC Lst *stoppedJobs; /* Lst of Job structures describing
- * jobs that were stopped due to concurrency
- * limits or externally */
+STATIC Lst stoppedJobs = Lst_Initializer(stoppedJobs);
STATIC int fifoFd; /* Fd of our job fifo */
STATIC char fifoName[] = "/tmp/make_fifo_XXXXXXXXX";
@@ -361,7 +365,7 @@ JobPassSig(int signo)
sigprocmask(SIG_SETMASK, &nmask, &omask);
DEBUGF(JOB, ("JobPassSig(%d) called.\n", signo));
- Lst_ForEach(jobs, JobCondPassSig, &signo);
+ Lst_ForEach(&jobs, JobCondPassSig, &signo);
/*
* Deal with proper cleanup based on the signal received. We only run
@@ -400,7 +404,7 @@ JobPassSig(int signo)
KILL(getpid(), signo);
signo = SIGCONT;
- Lst_ForEach(jobs, JobCondPassSig, &signo);
+ Lst_ForEach(&jobs, JobCondPassSig, &signo);
sigprocmask(SIG_SETMASK, &omask, NULL);
sigprocmask(SIG_SETMASK, &omask, NULL);
@@ -479,7 +483,7 @@ JobPrintCommand(void *cmdp, void *jobp)
if (strcmp(cmd, "...") == 0) {
job->node->type |= OP_SAVE_CMDS;
if ((job->flags & JOB_IGNDOTS) == 0) {
- job->tailCmds = Lst_Succ(Lst_Member(job->node->commands, cmd));
+ job->tailCmds = Lst_Succ(Lst_Member(&job->node->commands, cmd));
return (1);
}
return (0);
@@ -496,7 +500,7 @@ JobPrintCommand(void *cmdp, void *jobp)
* For debugging, we replace each command with the result of expanding
* the variables in the command.
*/
- cmdNode = Lst_Member(job->node->commands, cmd);
+ cmdNode = Lst_Member(&job->node->commands, cmd);
cmdStart = cmd = Var_Subst(NULL, cmd, job->node, FALSE);
Lst_Replace(cmdNode, cmdStart);
@@ -634,7 +638,7 @@ JobSaveCommand(void *cmd, void *gn)
{
cmd = Var_Subst(NULL, cmd, gn, FALSE);
- Lst_AtEnd(postCommands->commands, cmd);
+ Lst_AtEnd(&postCommands->commands, cmd);
return (0);
}
@@ -790,7 +794,7 @@ JobFinish(Job *job, int *status)
fprintf(out, "*** Stopped -- signal %d\n",
WSTOPSIG(*status));
job->flags |= JOB_RESUME;
- Lst_AtEnd(stoppedJobs, job);
+ Lst_AtEnd(&stoppedJobs, job);
fflush(out);
return;
} else if (WTERMSIG(*status) == SIGCONT) {
@@ -819,7 +823,7 @@ JobFinish(Job *job, int *status)
#endif
}
job->flags &= ~JOB_CONTINUING;
- Lst_AtEnd(jobs, job);
+ Lst_AtEnd(&jobs, job);
nJobs += 1;
DEBUGF(JOB, ("Process %d is continuing locally.\n", job->pid));
if (nJobs == maxJobs) {
@@ -884,7 +888,7 @@ JobFinish(Job *job, int *status)
* on the .END target.
*/
if (job->tailCmds != NULL) {
- Lst_ForEachFrom(job->node->commands, job->tailCmds,
+ Lst_ForEachFrom(&job->node->commands, job->tailCmds,
JobSaveCommand, job->node);
}
job->node->made = MADE;
@@ -1003,13 +1007,13 @@ Boolean
Job_CheckCommands(GNode *gn, void (*abortProc)(const char *, ...))
{
- if (OP_NOP(gn->type) && Lst_IsEmpty(gn->commands) &&
+ if (OP_NOP(gn->type) && Lst_IsEmpty(&gn->commands) &&
(gn->type & OP_LIB) == 0) {
/*
* No commands. Look for .DEFAULT rule from which we might infer
* commands
*/
- if ((DEFAULT != NULL) && !Lst_IsEmpty(DEFAULT->commands)) {
+ if ((DEFAULT != NULL) && !Lst_IsEmpty(&DEFAULT->commands)) {
char *p1;
/*
* Make only looks for a .DEFAULT if the node was never the
@@ -1195,7 +1199,7 @@ JobExec(Job *job, char **argv)
* Now the job is actually running, add it to the table.
*/
nJobs += 1;
- Lst_AtEnd(jobs, job);
+ Lst_AtEnd(&jobs, job);
if (nJobs == maxJobs) {
jobFull = TRUE;
}
@@ -1291,7 +1295,7 @@ JobRestart(Job *job)
* back on the hold queue and mark the table full
*/
DEBUGF(JOB, ("holding\n"));
- Lst_AtFront(stoppedJobs, (void *)job);
+ Lst_AtFront(&stoppedJobs, (void *)job);
jobFull = TRUE;
DEBUGF(JOB, ("Job queue is full.\n"));
return;
@@ -1346,7 +1350,7 @@ JobRestart(Job *job)
* place the job back on the list of stopped jobs.
*/
DEBUGF(JOB, ("table full\n"));
- Lst_AtFront(stoppedJobs, (void *)job);
+ Lst_AtFront(&stoppedJobs, (void *)job);
jobFull = TRUE;
DEBUGF(JOB, ("Job queue is full.\n"));
}
@@ -1462,7 +1466,7 @@ JobStart(GNode *gn, int flags, Job *previous)
* ellipsis, note that there's nothing more to execute.
*/
if (job->flags & JOB_FIRST)
- gn->compat_command = Lst_First(gn->commands);
+ gn->compat_command = Lst_First(&gn->commands);
else
gn->compat_command = Lst_Succ(gn->compat_command);
@@ -1489,7 +1493,7 @@ JobStart(GNode *gn, int flags, Job *previous)
* We can do all the commands at once. hooray for sanity
*/
numCommands = 0;
- Lst_ForEach(gn->commands, JobPrintCommand, job);
+ Lst_ForEach(&gn->commands, JobPrintCommand, job);
/*
* If we didn't print out any commands to the shell script,
@@ -1515,7 +1519,7 @@ JobStart(GNode *gn, int flags, Job *previous)
* doesn't do any harm in this case and may do some good.
*/
if (cmdsOK) {
- Lst_ForEach(gn->commands, JobPrintCommand, job);
+ Lst_ForEach(&gn->commands, JobPrintCommand, job);
}
/*
* Don't execute the shell, thank you.
@@ -1554,7 +1558,7 @@ JobStart(GNode *gn, int flags, Job *previous)
if (cmdsOK) {
if (aborting == 0) {
if (job->tailCmds != NULL) {
- Lst_ForEachFrom(job->node->commands, job->tailCmds,
+ Lst_ForEachFrom(&job->node->commands, job->tailCmds,
JobSaveCommand, job->node);
}
job->node->made = MADE;
@@ -1612,7 +1616,7 @@ JobStart(GNode *gn, int flags, Job *previous)
DEBUGF(JOB, ("Can only run job locally.\n"));
job->flags |= JOB_RESTART;
- Lst_AtEnd(stoppedJobs, job);
+ Lst_AtEnd(&stoppedJobs, job);
} else {
if (nJobs >= maxJobs) {
/*
@@ -1916,24 +1920,24 @@ Job_CatchChildren(Boolean block)
break;
DEBUGF(JOB, ("Process %d exited or stopped.\n", pid));
- jnode = Lst_Find(jobs, &pid, JobCmpPid);
+ jnode = Lst_Find(&jobs, &pid, JobCmpPid);
if (jnode == NULL) {
if (WIFSIGNALED(status) && (WTERMSIG(status) == SIGCONT)) {
- jnode = Lst_Find(stoppedJobs, &pid, JobCmpPid);
+ jnode = Lst_Find(&stoppedJobs, &pid, JobCmpPid);
if (jnode == NULL) {
Error("Resumed child (%d) not in table", pid);
continue;
}
job = Lst_Datum(jnode);
- Lst_Remove(stoppedJobs, jnode);
+ Lst_Remove(&stoppedJobs, jnode);
} else {
Error("Child (%d) not in table?", pid);
continue;
}
} else {
job = Lst_Datum(jnode);
- Lst_Remove(jobs, jnode);
+ Lst_Remove(&jobs, jnode);
nJobs -= 1;
if (fifoFd >= 0 && maxJobs > 1) {
write(fifoFd, "+", 1);
@@ -2029,7 +2033,7 @@ Job_CatchOutput(int flag)
if (--nfds <= 0)
return;
}
- for (ln = Lst_First(jobs); nfds != 0 && ln != NULL; ln = Lst_Succ(ln)) {
+ 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);
@@ -2178,8 +2182,6 @@ Job_Init(int maxproc)
struct sigaction sa;
fifoFd = -1;
- jobs = Lst_Init();
- stoppedJobs = Lst_Init();
env = getenv("MAKE_JOBS_FIFO");
if (env == NULL && maxproc > 1) {
@@ -2359,7 +2361,7 @@ Boolean
Job_Empty(void)
{
if (nJobs == 0) {
- if (!Lst_IsEmpty(stoppedJobs) && !aborting) {
+ if (!Lst_IsEmpty(&stoppedJobs) && !aborting) {
/*
* The job table is obviously not full if it has no jobs in
* it...Try and restart the stopped jobs.
@@ -2613,7 +2615,7 @@ JobInterrupt(int runINTERRUPT, int signo)
aborting = ABORT_INTERRUPT;
- for (ln = Lst_First(jobs); ln != NULL; ln = Lst_Succ(ln)) {
+ for (ln = Lst_First(&jobs); ln != NULL; ln = Lst_Succ(ln)) {
job = Lst_Datum(ln);
if (!Targ_Precious(job->node)) {
@@ -2663,7 +2665,7 @@ int
Job_Finish(void)
{
- if (postCommands != NULL && !Lst_IsEmpty(postCommands->commands)) {
+ if (postCommands != NULL && !Lst_IsEmpty(&postCommands->commands)) {
if (errors) {
Error("Errors reported so .END ignored");
} else {
@@ -2734,7 +2736,7 @@ Job_AbortAll(void)
aborting = ABORT_ERROR;
if (nJobs) {
- for (ln = Lst_First(jobs); ln != NULL; ln = Lst_Succ(ln)) {
+ for (ln = Lst_First(&jobs); ln != NULL; ln = Lst_Succ(ln)) {
job = Lst_Datum(ln);
/*
@@ -2771,8 +2773,8 @@ Job_AbortAll(void)
static void
JobRestartJobs(void)
{
- while (!jobFull && !Lst_IsEmpty(stoppedJobs)) {
+ while (!jobFull && !Lst_IsEmpty(&stoppedJobs)) {
DEBUGF(JOB, ("Job queue is not full. Restarting a stopped job.\n"));
- JobRestart(Lst_DeQueue(stoppedJobs));
+ JobRestart(Lst_DeQueue(&stoppedJobs));
}
}
diff --git a/usr.bin/make/lst.h b/usr.bin/make/lst.h
index f78d523..4aa55c0 100644
--- a/usr.bin/make/lst.h
+++ b/usr.bin/make/lst.h
@@ -102,11 +102,17 @@ typedef void FreeProc(void *);
* Creation/destruction functions
*/
/* Create a new list */
-Lst *Lst_Init(void);
+#define Lst_Init(LST) do { \
+ (LST)->firstPtr = NULL; \
+ (LST)->lastPtr = NULL; \
+ } while (0)
+#define Lst_Initializer(NAME) { NULL, NULL }
+
/* Duplicate an existing list */
-Lst *Lst_Duplicate(Lst *, DuplicateProc *);
+void Lst_Duplicate(Lst *, Lst *, DuplicateProc *);
+
/* Destroy an old one */
-void Lst_Destroy(Lst *, FreeProc *);
+void Lst_Destroy(Lst *, FreeProc *);
/*
* Functions to modify a list
@@ -125,7 +131,7 @@ void Lst_Remove(Lst *, LstNode *);
#define Lst_Replace(NODE, D) (((NODE) == NULL) ? FAILURE : \
(((NODE)->datum = (D)), SUCCESS))
/* Concatenate two lists */
-void Lst_Concat(Lst *, Lst *, int);
+void Lst_Concat(Lst *, Lst *, int);
/*
* Node-specific functions
diff --git a/usr.bin/make/lst.lib/lstConcat.c b/usr.bin/make/lst.lib/lstConcat.c
index a997fcb..e6bf54a 100644
--- a/usr.bin/make/lst.lib/lstConcat.c
+++ b/usr.bin/make/lst.lib/lstConcat.c
@@ -96,6 +96,7 @@ Lst_Concat(Lst *list1, Lst *list2, int flags)
list1->firstPtr = list2->firstPtr;
list1->lastPtr = list2->lastPtr;
+ Lst_Init(list2);
} else {
/*
* The loop simply goes through the entire
diff --git a/usr.bin/make/lst.lib/lstDestroy.c b/usr.bin/make/lst.lib/lstDestroy.c
index 15bac2d..39d5239 100644
--- a/usr.bin/make/lst.lib/lstDestroy.c
+++ b/usr.bin/make/lst.lib/lstDestroy.c
@@ -69,18 +69,9 @@ Lst_Destroy(Lst *list, FreeProc *freeProc)
{
LstNode *ln;
- if (!Lst_Valid(list)) {
- /*
- * Note the check to catch uninitialized static Lst's.
- * Gross, but useful.
- */
+ if (list->firstPtr == NULL)
return;
- }
- if (list->firstPtr == NULL) {
- free(list);
- return;
- }
if (freeProc != NOFREE) {
while ((ln = list->firstPtr) != NULL) {
list->firstPtr = ln->nextPtr;
@@ -90,9 +81,8 @@ Lst_Destroy(Lst *list, FreeProc *freeProc)
} else {
while ((ln = list->firstPtr) != NULL) {
list->firstPtr = ln->nextPtr;
- free(ln);
+ free(ln);
}
}
-
- free(list);
+ list->lastPtr = NULL;
}
diff --git a/usr.bin/make/lst.lib/lstDupl.c b/usr.bin/make/lst.lib/lstDupl.c
index 2596816..807cc19 100644
--- a/usr.bin/make/lst.lib/lstDupl.c
+++ b/usr.bin/make/lst.lib/lstDupl.c
@@ -56,40 +56,24 @@ __FBSDID("$FreeBSD$");
* Duplicate an entire list. If a function to copy a void * is
* given, the individual client elements will be duplicated as well.
*
- * Results:
- * The new Lst structure or NULL if failure.
- *
* Arguments:
- * l the list to duplicate
+ * dst the destination list (initialized)
+ * src the list to duplicate
* copyProc A function to duplicate each void
*
- * Side Effects:
- * A new list is created.
*-----------------------------------------------------------------------
*/
-Lst *
-Lst_Duplicate(Lst *list, DuplicateProc *copyProc)
+void
+Lst_Duplicate(Lst *dst, Lst *src, DuplicateProc *copyProc)
{
- Lst *nl;
LstNode *ln;
- if (!Lst_Valid(list)) {
- return (NULL);
- }
-
- nl = Lst_Init();
- if (nl == NULL) {
- return (NULL);
- }
-
- ln = list->firstPtr;
+ ln = src->firstPtr;
while (ln != NULL) {
if (copyProc != NOCOPY)
- Lst_AtEnd(nl, (*copyProc)(ln->datum));
+ Lst_AtEnd(dst, (*copyProc)(ln->datum));
else
- Lst_AtEnd(nl, ln->datum);
+ Lst_AtEnd(dst, ln->datum);
ln = ln->nextPtr;
}
-
- return (nl);
}
diff --git a/usr.bin/make/lst.lib/lstInit.c b/usr.bin/make/lst.lib/lstInit.c
deleted file mode 100644
index 7fc775d..0000000
--- a/usr.bin/make/lst.lib/lstInit.c
+++ /dev/null
@@ -1,76 +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.
- *
- * @(#)lstInit.c 8.1 (Berkeley) 6/6/93
- */
-
-#ifndef lint
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-#endif /* not lint */
-
-/*-
- * init.c --
- * Initialize a new linked list.
- */
-
-#include "make.h"
-#include "lst.h"
-
-/*-
- *-----------------------------------------------------------------------
- * Lst_Init --
- * Create and initialize a new list.
- *
- * Results:
- * The created list.
- *
- * Side Effects:
- * A list is created, what else?
- *
- *-----------------------------------------------------------------------
- */
-Lst *
-Lst_Init(void)
-{
- Lst *nList;
-
- nList = emalloc(sizeof(*nList));
-
- nList->firstPtr = NULL;
- nList->lastPtr = NULL;
-
- return (nList);
-}
diff --git a/usr.bin/make/main.c b/usr.bin/make/main.c
index 6ec5a66..ad114a4 100644
--- a/usr.bin/make/main.c
+++ b/usr.bin/make/main.c
@@ -93,15 +93,23 @@ __FBSDID("$FreeBSD$");
#define MAKEFLAGS ".MAKEFLAGS"
-Lst *create; /* Targets to be made */
+/* Targets to be made */
+Lst create = Lst_Initializer(create);
+
time_t now; /* Time at start of make */
GNode *DEFAULT; /* .DEFAULT node */
Boolean allPrecious; /* .PRECIOUS given on line by itself */
static Boolean noBuiltins; /* -r flag */
-static Lst *makefiles; /* ordered list of makefiles to read */
+
+/* ordered list of makefiles to read */
+static Lst makefiles = Lst_Initializer(makefiles);
+
static Boolean expandVars; /* fully expand printed variables */
-static Lst *variables; /* list of variables to print */
+
+/* list of variables to print */
+static Lst variables = Lst_Initializer(variables);
+
int maxJobs; /* -j argument */
static Boolean forceJobs; /* -j argument given */
Boolean compatMake; /* -B argument */
@@ -116,7 +124,10 @@ Boolean beSilent; /* -s flag */
Boolean beVerbose; /* -v flag */
Boolean oldVars; /* variable substitution style */
Boolean checkEnvFirst; /* -e flag */
-Lst *envFirstVars; /* (-E) vars to override from env */
+
+/* (-E) vars to override from env */
+Lst envFirstVars = Lst_Initializer(envFirstVars);
+
Boolean jobsRunning; /* TRUE if the jobs might be running */
static void MainParseArgs(int, char **);
@@ -180,7 +191,7 @@ rearg: while((c = getopt(argc, argv, OPTFLAGS)) != -1) {
MFLAGS_append("-I", optarg);
break;
case 'V':
- (void)Lst_AtEnd(variables, (void *)optarg);
+ Lst_AtEnd(&variables, (void *)optarg);
MFLAGS_append("-V", optarg);
break;
case 'X':
@@ -257,7 +268,7 @@ rearg: while((c = getopt(argc, argv, OPTFLAGS)) != -1) {
case 'E':
p = emalloc(strlen(optarg) + 1);
strcpy(p, optarg);
- Lst_AtEnd(envFirstVars, p);
+ Lst_AtEnd(&envFirstVars, p);
MFLAGS_append("-E", optarg);
break;
case 'e':
@@ -265,7 +276,7 @@ rearg: while((c = getopt(argc, argv, OPTFLAGS)) != -1) {
MFLAGS_append("-e", NULL);
break;
case 'f':
- Lst_AtEnd(makefiles, optarg);
+ Lst_AtEnd(&makefiles, optarg);
break;
case 'i':
ignoreErrors = TRUE;
@@ -289,7 +300,7 @@ rearg: while((c = getopt(argc, argv, OPTFLAGS)) != -1) {
MFLAGS_append("-k", NULL);
break;
case 'm':
- Dir_AddDir(sysIncPath, optarg);
+ Dir_AddDir(&sysIncPath, optarg);
MFLAGS_append("-m", optarg);
break;
case 'n':
@@ -348,7 +359,7 @@ rearg: while((c = getopt(argc, argv, OPTFLAGS)) != -1) {
optind = 1; /* - */
goto rearg;
}
- Lst_AtEnd(create, estrdup(*argv));
+ Lst_AtEnd(&create, estrdup(*argv));
}
}
@@ -450,7 +461,6 @@ check_make_level(void)
int
main(int argc, char **argv)
{
- Lst *targs; /* target nodes to create -- passed to Make_Init */
Boolean outOfDate = TRUE; /* FALSE if all targets up to date */
struct stat sa;
char *p, *p1, *path, *pathp;
@@ -460,7 +470,6 @@ main(int argc, char **argv)
char *machine = getenv("MACHINE");
char *machine_arch = getenv("MACHINE_ARCH");
char *machine_cpu = getenv("MACHINE_CPU");
- Lst *sysMkPath; /* Path of sys.mk */
char *cp = NULL, *start;
/* avoid faults on read-only strings */
static char syspath[] = _PATH_DEFSYSPATH;
@@ -565,11 +574,7 @@ main(int argc, char **argv)
machine_cpu = "unknown";
}
- create = Lst_Init();
- makefiles = Lst_Init();
- envFirstVars = Lst_Init();
expandVars = TRUE;
- variables = Lst_Init();
beSilent = FALSE; /* Print commands as executed */
ignoreErrors = FALSE; /* Pay attention to non-zero returns */
noExecute = FALSE; /* Execute all commands */
@@ -679,7 +684,7 @@ main(int argc, char **argv)
}
Dir_InitDot(); /* Initialize the "." directory */
if (objdir != curdir)
- Dir_AddDir(dirSearchPath, curdir);
+ Dir_AddDir(&dirSearchPath, curdir);
Var_Set(".CURDIR", curdir, VAR_GLOBAL);
Var_Set(".OBJDIR", objdir, VAR_GLOBAL);
@@ -708,10 +713,10 @@ main(int argc, char **argv)
* created. If none specified, make the variable empty -- the parser
* will fill the thing in with the default or .MAIN target.
*/
- if (!Lst_IsEmpty(create)) {
+ if (!Lst_IsEmpty(&create)) {
LstNode *ln;
- for (ln = Lst_First(create); ln != NULL; ln = Lst_Succ(ln)) {
+ for (ln = Lst_First(&create); ln != NULL; ln = Lst_Succ(ln)) {
char *name = Lst_Datum(ln);
Var_Append(".TARGETS", name, VAR_GLOBAL);
@@ -725,15 +730,15 @@ main(int argc, char **argv)
* add the directories from the DEFSYSPATH (more than one may be given
* as dir1:...:dirn) to the system include path.
*/
- if (Lst_IsEmpty(sysIncPath)) {
+ if (Lst_IsEmpty(&sysIncPath)) {
for (start = syspath; *start != '\0'; start = cp) {
for (cp = start; *cp != '\0' && *cp != ':'; cp++)
continue;
if (*cp == '\0') {
- Dir_AddDir(sysIncPath, start);
+ Dir_AddDir(&sysIncPath, start);
} else {
*cp++ = '\0';
- Dir_AddDir(sysIncPath, start);
+ Dir_AddDir(&sysIncPath, start);
}
}
}
@@ -744,21 +749,23 @@ main(int argc, char **argv)
* Makefile and makefile, in that order, if it wasn't.
*/
if (!noBuiltins) {
+ /* Path of sys.mk */
+ Lst sysMkPath = Lst_Initializer(sysMkPath);
LstNode *ln;
- sysMkPath = Lst_Init();
- Dir_Expand(_PATH_DEFSYSMK, sysIncPath, sysMkPath);
- if (Lst_IsEmpty(sysMkPath))
+ Dir_Expand(_PATH_DEFSYSMK, &sysIncPath, &sysMkPath);
+ if (Lst_IsEmpty(&sysMkPath))
Fatal("make: no system rules (%s).", _PATH_DEFSYSMK);
- ln = Lst_Find(sysMkPath, NULL, ReadMakefile);
+ ln = Lst_Find(&sysMkPath, NULL, ReadMakefile);
if (ln != NULL)
Fatal("make: cannot open %s.", (char *)Lst_Datum(ln));
+ Lst_Destroy(&sysMkPath, free);
}
- if (!Lst_IsEmpty(makefiles)) {
+ if (!Lst_IsEmpty(&makefiles)) {
LstNode *ln;
- ln = Lst_Find(makefiles, NULL, ReadMakefile);
+ ln = Lst_Find(&makefiles, NULL, ReadMakefile);
if (ln != NULL)
Fatal("make: cannot open %s.", (char *)Lst_Datum(ln));
} else if (!ReadMakefile("BSDmakefile", NULL))
@@ -797,7 +804,7 @@ main(int argc, char **argv)
savec = *cp;
*cp = '\0';
/* Add directory to search path */
- Dir_AddDir(dirSearchPath, path);
+ Dir_AddDir(&dirSearchPath, path);
*cp = savec;
path = cp + 1;
} while (savec == ':');
@@ -815,10 +822,10 @@ main(int argc, char **argv)
Targ_PrintGraph(1);
/* print the values of any variables requested by the user */
- if (!Lst_IsEmpty(variables)) {
+ if (!Lst_IsEmpty(&variables)) {
LstNode *ln;
- for (ln = Lst_First(variables); ln != NULL;
+ for (ln = Lst_First(&variables); ln != NULL;
ln = Lst_Succ(ln)) {
char *value;
if (expandVars) {
@@ -841,10 +848,12 @@ main(int argc, char **argv)
* to create. If none was given on the command line, we consult the
* parsing module to find the main target(s) to create.
*/
- if (Lst_IsEmpty(create))
- targs = Parse_MainName();
+ Lst targs = Lst_Initializer(targs);
+
+ if (Lst_IsEmpty(&create))
+ Parse_MainName(&targs);
else
- targs = Targ_FindList(create, TARG_CREATE);
+ Targ_FindList(&targs, &create, TARG_CREATE);
if (!compatMake) {
/*
@@ -859,21 +868,21 @@ main(int argc, char **argv)
}
/* Traverse the graph, checking on all the targets */
- outOfDate = Make_Run(targs);
+ outOfDate = Make_Run(&targs);
} else {
/*
* Compat_Init will take care of creating all the targets as
* well as initializing the module.
*/
- Compat_Run(targs);
+ Compat_Run(&targs);
outOfDate = 0;
}
- Lst_Destroy(targs, NOFREE);
+ Lst_Destroy(&targs, NOFREE);
}
- Lst_Destroy(variables, NOFREE);
- Lst_Destroy(makefiles, NOFREE);
- Lst_Destroy(create, free);
+ Lst_Destroy(&variables, NOFREE);
+ Lst_Destroy(&makefiles, NOFREE);
+ Lst_Destroy(&create, free);
/* print the graph now it's been processed if the user requested it */
if (DEBUG(GRAPH2))
@@ -965,9 +974,9 @@ ReadMakefile(const void *p, const void *q __unused)
}
#endif
/* look in -I and system include directories. */
- name = Dir_FindFile(fname, parseIncPath);
+ name = Dir_FindFile(fname, &parseIncPath);
if (!name)
- name = Dir_FindFile(fname, sysIncPath);
+ name = Dir_FindFile(fname, &sysIncPath);
if (!name || !(stream = fopen(name, "r")))
return (FALSE);
MAKEFILE = fname = name;
diff --git a/usr.bin/make/make.c b/usr.bin/make/make.c
index f064348..fb4040d 100644
--- a/usr.bin/make/make.c
+++ b/usr.bin/make/make.c
@@ -78,11 +78,11 @@ __FBSDID("$FreeBSD$");
#include "dir.h"
#include "job.h"
-static Lst *toBeMade; /* The current fringe of the graph. These
- * are nodes which await examination by
- * MakeOODate. It is added to by
- * Make_Update and subtracted from by
- * MakeStartJobs */
+/* The current fringe of the graph. These are nodes which await examination
+ * by MakeOODate. It is added to by Make_Update and subtracted from by
+ * MakeStartJobs */
+static Lst toBeMade = Lst_Initializer(toBeMade);
+
static int numNodes; /* Number of nodes to be processed. If this
* is non-zero when Job_Empty() returns
* TRUE, there's a cycle in the graph */
@@ -241,7 +241,7 @@ Make_OODate(GNode *gn)
* thinking they're out-of-date.
*/
if (!oodate) {
- Lst_ForEach(gn->parents, MakeTimeStamp, gn);
+ Lst_ForEach(&gn->parents, MakeTimeStamp, gn);
}
return (oodate);
@@ -302,20 +302,20 @@ Make_HandleUse(GNode *cgn, GNode *pgn)
LstNode *ln; /* An element in the children list */
if (cgn->type & (OP_USE | OP_TRANSFORM)) {
- if ((cgn->type & OP_USE) || Lst_IsEmpty(pgn->commands)) {
+ if ((cgn->type & OP_USE) || Lst_IsEmpty(&pgn->commands)) {
/*
* .USE or transformation and target has no commands -- append
* the child's commands to the parent.
*/
- Lst_Concat(pgn->commands, cgn->commands, LST_CONCNEW);
+ Lst_Concat(&pgn->commands, &cgn->commands, LST_CONCNEW);
}
- for (ln = Lst_First(cgn->children); ln != NULL; ln = Lst_Succ(ln)) {
+ 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);
+ if (Lst_Member(&pgn->children, gn) == NULL) {
+ Lst_AtEnd(&pgn->children, gn);
+ Lst_AtEnd(&gn->parents, pgn);
pgn->unmade += 1;
}
}
@@ -412,7 +412,7 @@ Make_Update(GNode *cgn)
* To force things that depend on FRC to be made, so we have to
* check for gn->children being empty as well...
*/
- if (!Lst_IsEmpty(cgn->commands) || Lst_IsEmpty(cgn->children)) {
+ if (!Lst_IsEmpty(&cgn->commands) || Lst_IsEmpty(&cgn->children)) {
cgn->mtime = now;
}
#else
@@ -446,7 +446,7 @@ Make_Update(GNode *cgn)
#endif
}
- for (ln = Lst_First(cgn->parents); ln != NULL; ln = Lst_Succ(ln)) {
+ for (ln = Lst_First(&cgn->parents); ln != NULL; ln = Lst_Succ(ln)) {
pgn = Lst_Datum(ln);
if (pgn->make) {
pgn->unmade -= 1;
@@ -466,7 +466,7 @@ Make_Update(GNode *cgn)
* Queue the node up -- any unmade predecessors will
* be dealt with in MakeStartJobs.
*/
- Lst_EnQueue(toBeMade, pgn);
+ Lst_EnQueue(&toBeMade, pgn);
} else if (pgn->unmade < 0) {
Error("Graph cycles through %s", pgn->name);
}
@@ -479,13 +479,13 @@ Make_Update(GNode *cgn)
* it means we need to place it in the queue as it restrained itself
* before.
*/
- for (ln = Lst_First(cgn->successors); ln != NULL; ln = Lst_Succ(ln)) {
+ for (ln = Lst_First(&cgn->successors); ln != NULL; ln = Lst_Succ(ln)) {
GNode *succ = Lst_Datum(ln);
if (succ->make && succ->unmade == 0 && succ->made == UNMADE &&
- Lst_Member(toBeMade, succ) == NULL)
+ Lst_Member(&toBeMade, succ) == NULL)
{
- Lst_EnQueue(toBeMade, succ);
+ Lst_EnQueue(&toBeMade, succ);
}
}
@@ -494,7 +494,7 @@ Make_Update(GNode *cgn)
* of this node.
*/
cpref = Var_Value(PREFIX, cgn, &ptr);
- for (ln = Lst_First(cgn->iParents); ln != NULL; ln = Lst_Succ(ln)) {
+ for (ln = Lst_First(&cgn->iParents); ln != NULL; ln = Lst_Succ(ln)) {
pgn = Lst_Datum (ln);
if (pgn->make) {
Var_Set(IMPSRC, cname, pgn);
@@ -599,7 +599,7 @@ void
Make_DoAllVar(GNode *gn)
{
- Lst_ForEach(gn->children, MakeAddAllSrc, gn);
+ Lst_ForEach(&gn->children, MakeAddAllSrc, gn);
if (!Var_Exists (OODATE, gn)) {
Var_Set(OODATE, "", gn);
@@ -637,17 +637,17 @@ MakeStartJobs(void)
{
GNode *gn;
- while (!Lst_IsEmpty(toBeMade) && !Job_Full()) {
- gn = Lst_DeQueue(toBeMade);
+ while (!Lst_IsEmpty(&toBeMade) && !Job_Full()) {
+ gn = Lst_DeQueue(&toBeMade);
DEBUGF(MAKE, ("Examining %s...", gn->name));
/*
* Make sure any and all predecessors that are going to be made,
* have been.
*/
- if (!Lst_IsEmpty(gn->preds)) {
+ if (!Lst_IsEmpty(&gn->preds)) {
LstNode *ln;
- for (ln = Lst_First(gn->preds); ln != NULL; ln = Lst_Succ(ln)){
+ for (ln = Lst_First(&gn->preds); ln != NULL; ln = Lst_Succ(ln)){
GNode *pgn = Lst_Datum(ln);
if (pgn->make && pgn->made == UNMADE) {
@@ -734,11 +734,11 @@ MakePrintStatus(void *gnp, void *cyclep)
if (gn->made == CYCLE) {
Error("Graph cycles through `%s'", gn->name);
gn->made = ENDCYCLE;
- Lst_ForEach(gn->children, MakePrintStatus, &t);
+ Lst_ForEach(&gn->children, MakePrintStatus, &t);
gn->made = UNMADE;
} else if (gn->made != ENDCYCLE) {
gn->made = CYCLE;
- Lst_ForEach(gn->children, MakePrintStatus, &t);
+ Lst_ForEach(&gn->children, MakePrintStatus, &t);
}
} else {
printf("`%s' not remade because of errors.\n", gn->name);
@@ -772,12 +772,11 @@ Boolean
Make_Run(Lst *targs)
{
GNode *gn; /* a temporary pointer */
- Lst *examine; /* List of targets to examine */
+ Lst examine; /* List of targets to examine */
int errors; /* Number of errors the Job module reports */
- toBeMade = Lst_Init();
-
- examine = Lst_Duplicate(targs, NOCOPY);
+ Lst_Init(&examine);
+ Lst_Duplicate(&examine, targs, NOCOPY);
numNodes = 0;
/*
@@ -788,8 +787,8 @@ Make_Run(Lst *targs)
* be looked at in a minute, otherwise we add its children to our queue
* and go on about our business.
*/
- while (!Lst_IsEmpty(examine)) {
- gn = Lst_DeQueue(examine);
+ while (!Lst_IsEmpty(&examine)) {
+ gn = Lst_DeQueue(&examine);
if (!gn->make) {
gn->make = TRUE;
@@ -799,19 +798,17 @@ Make_Run(Lst *targs)
* Apply any .USE rules before looking for implicit dependencies
* to make sure everything has commands that should...
*/
- Lst_ForEach(gn->children, MakeHandleUse, gn);
+ Lst_ForEach(&gn->children, MakeHandleUse, gn);
Suff_FindDeps(gn);
if (gn->unmade != 0) {
- Lst_ForEach(gn->children, MakeAddChild, examine);
+ Lst_ForEach(&gn->children, MakeAddChild, &examine);
} else {
- Lst_EnQueue(toBeMade, gn);
+ Lst_EnQueue(&toBeMade, gn);
}
}
}
- Lst_Destroy(examine, NOFREE);
-
if (queryFlag) {
/*
* We wouldn't do any work unless we could start some jobs in the
@@ -841,7 +838,7 @@ Make_Run(Lst *targs)
* keepgoing flag was given.
*/
while (!Job_Empty ()) {
- Job_CatchOutput(!Lst_IsEmpty(toBeMade));
+ Job_CatchOutput(!Lst_IsEmpty(&toBeMade));
Job_CatchChildren(!usePipes);
MakeStartJobs();
}
diff --git a/usr.bin/make/make.h b/usr.bin/make/make.h
index a6a3b71..19438a3 100644
--- a/usr.bin/make/make.h
+++ b/usr.bin/make/make.h
@@ -125,16 +125,16 @@ typedef struct GNode {
int cmtime; /* The modification time of its youngest
* child */
- Lst *iParents; /* Links to parents for which this is an
+ Lst iParents; /* Links to parents for which this is an
* implied source, if any */
- Lst *cohorts; /* Other nodes for the :: operator */
- Lst *parents; /* Nodes that depend on this one */
- Lst *children; /* Nodes on which this one depends */
- Lst *successors;/* Nodes that must be made after this one */
- Lst *preds; /* Nodes that must be made before this one */
+ Lst cohorts; /* Other nodes for the :: operator */
+ Lst parents; /* Nodes that depend on this one */
+ Lst children; /* Nodes on which this one depends */
+ Lst successors; /* Nodes that must be made after this one */
+ Lst preds; /* Nodes that must be made before this one */
- Lst *context; /* The local variables */
- Lst *commands; /* Creation commands */
+ Lst context; /* The local variables */
+ Lst commands; /* Creation commands */
/* current command executing in compat mode */
LstNode *compat_command;
@@ -283,14 +283,17 @@ typedef struct IFile {
/*
* Global Variables
*/
-extern Lst *create; /* The list of target names specified on the
- * command line. used to resolve #if
- * make(...) statements */
-extern Lst *dirSearchPath; /* The list of directories to search when
- * looking for targets */
+/* The list of target names specified on the command line.
+ * Used to resolve #if make(...) statements */
+extern Lst create;
+
+/* The list of directories to search when looking for targets */
+extern Lst dirSearchPath;
+
extern IFile curFile; /* current makefile */
-extern Lst *parseIncPath; /* The list of directories to search when
- * looking for includes */
+
+/* The list of directories to search when looking for includes */
+extern Lst parseIncPath;
extern Boolean jobsRunning; /* True if jobs are running */
extern Boolean compatMake; /* True if we are make compatible */
@@ -314,9 +317,10 @@ extern Boolean queryFlag; /* TRUE if we aren't supposed to really make
extern Boolean checkEnvFirst; /* TRUE if environment should be searched for
* all variables before the global context */
-extern Lst *envFirstVars; /* List of specific variables for which the
- * environment should be searched before the
- * global context */
+
+/* List of specific variables for which the environment should be
+ * searched before the global context */
+extern Lst envFirstVars;
extern GNode *DEFAULT; /* .DEFAULT rule */
@@ -333,7 +337,8 @@ extern time_t now; /* The time at the start of this whole
extern Boolean oldVars; /* Do old-style variable substitution */
-extern Lst *sysIncPath; /* The system include path. */
+/* The system include path. */
+extern Lst sysIncPath;
/*
* debug control:
diff --git a/usr.bin/make/nonints.h b/usr.bin/make/nonints.h
index c622d4b..aa73f6a 100644
--- a/usr.bin/make/nonints.h
+++ b/usr.bin/make/nonints.h
@@ -88,7 +88,7 @@ void Parse_File(char *, FILE *);
void Parse_Init(void);
void Parse_End(void);
void Parse_FromString(char *, int);
-Lst *Parse_MainName(void);
+void Parse_MainName(Lst *);
/* str.c */
void str_init(void);
@@ -120,7 +120,7 @@ void Targ_Init(void);
void Targ_End(void);
GNode *Targ_NewGN(char *);
GNode *Targ_FindNode(char *, int);
-Lst *Targ_FindList(Lst *, int);
+void Targ_FindList(Lst *, Lst *, int);
Boolean Targ_Ignore(GNode *);
Boolean Targ_Silent(GNode *);
Boolean Targ_Precious(GNode *);
diff --git a/usr.bin/make/parse.c b/usr.bin/make/parse.c
index a945571..4aa3313 100644
--- a/usr.bin/make/parse.c
+++ b/usr.bin/make/parse.c
@@ -101,7 +101,10 @@ __FBSDID("$FreeBSD$");
*/
#define CONTINUE 1
#define DONE 0
-static Lst *targets; /* targets we're working on */
+
+/* targets we're working on */
+static Lst targets = Lst_Initializer(targets);
+
static Boolean inLine; /* true if currently in a dependency
* line or its commands */
static int fatals = 0;
@@ -112,10 +115,14 @@ static GNode *mainNode; /* The main target to create. This is the
IFile curFile; /* current makefile */
-static Lst *includes; /* stack of IFiles generated by
- * #includes */
-Lst *parseIncPath; /* list of directories for "..." includes */
-Lst *sysIncPath; /* list of directories for <...> includes */
+/* stack of IFiles generated by * #includes */
+static Lst includes = Lst_Initializer(includes);
+
+/* list of directories for "..." includes */
+Lst parseIncPath = Lst_Initializer(parseIncPath);
+
+/* list of directories for <...> includes */
+Lst sysIncPath = Lst_Initializer(sysIncPath);
/*-
* specType contains the SPECial TYPE of the current target. It is
@@ -322,10 +329,10 @@ ParseLinkSrc(void *pgnp, void *cgnp)
GNode *pgn = pgnp;
GNode *cgn = cgnp;
- if (Lst_Member(pgn->children, cgn) == NULL) {
- Lst_AtEnd(pgn->children, cgn);
+ if (Lst_Member(&pgn->children, cgn) == NULL) {
+ Lst_AtEnd(&pgn->children, cgn);
if (specType == Not) {
- Lst_AtEnd(cgn->parents, pgn);
+ Lst_AtEnd(&cgn->parents, pgn);
}
pgn->unmade += 1;
}
@@ -388,14 +395,14 @@ ParseDoOp(void *gnp, void *opp)
* anything with their local variables, but better safe than
* sorry.
*/
- Lst_ForEach(gn->parents, ParseLinkSrc, cohort);
+ Lst_ForEach(&gn->parents, ParseLinkSrc, cohort);
cohort->type = OP_DOUBLEDEP|OP_INVISIBLE;
- Lst_AtEnd(gn->cohorts, cohort);
+ Lst_AtEnd(&gn->cohorts, cohort);
/*
* Replace the node in the targets list with the new copy
*/
- ln = Lst_Member(targets, gn);
+ ln = Lst_Member(&targets, gn);
Lst_Replace(ln, cohort);
gn = cohort;
}
@@ -436,8 +443,8 @@ ParseAddDep(void *pp, void *sp)
* but checking is tedious, and the debugging output can show the
* problem
*/
- Lst_AtEnd(p->successors, s);
- Lst_AtEnd(s->preds, p);
+ Lst_AtEnd(&p->successors, s);
+ Lst_AtEnd(&s->preds, p);
return (0);
}
else
@@ -472,7 +479,7 @@ ParseDoSrc(int tOp, char *src, Lst *allsrc)
if (keywd != -1) {
int op = parseKeywords[keywd].op;
if (op != 0) {
- Lst_ForEach(targets, ParseDoOp, &op);
+ Lst_ForEach(&targets, ParseDoOp, &op);
return;
}
if (parseKeywords[keywd].spec == Wait) {
@@ -492,7 +499,7 @@ ParseDoSrc(int tOp, char *src, Lst *allsrc)
* invoked if the user didn't specify a target on the command
* line. This is to allow #ifmake's to succeed, or something...
*/
- Lst_AtEnd(create, estrdup(src));
+ Lst_AtEnd(&create, estrdup(src));
/*
* Add the name to the .TARGETS variable as well, so the user cna
* employ that, if desired.
@@ -507,8 +514,8 @@ ParseDoSrc(int tOp, char *src, Lst *allsrc)
*/
gn = Targ_FindNode(src, TARG_CREATE);
if (predecessor != NULL) {
- Lst_AtEnd(predecessor->successors, gn);
- Lst_AtEnd(gn->preds, predecessor);
+ Lst_AtEnd(&predecessor->successors, gn);
+ Lst_AtEnd(&gn->preds, predecessor);
}
/*
* The current source now becomes the predecessor for the next one.
@@ -532,18 +539,18 @@ ParseDoSrc(int tOp, char *src, Lst *allsrc)
if (tOp) {
gn->type |= tOp;
} else {
- Lst_ForEach(targets, ParseLinkSrc, gn);
+ Lst_ForEach(&targets, ParseLinkSrc, gn);
}
if ((gn->type & OP_OPMASK) == OP_DOUBLEDEP) {
GNode *cohort;
LstNode *ln;
- for (ln=Lst_First(gn->cohorts); ln != NULL; ln = Lst_Succ(ln)){
+ for (ln = Lst_First(&gn->cohorts); ln != NULL; ln = Lst_Succ(ln)) {
cohort = Lst_Datum(ln);
if (tOp) {
cohort->type |= tOp;
} else {
- Lst_ForEach(targets, ParseLinkSrc, cohort);
+ Lst_ForEach(&targets, ParseLinkSrc, cohort);
}
}
}
@@ -669,23 +676,14 @@ ParseDoDependency (char *line)
GNode *gn; /* a general purpose temporary node */
int op; /* the operator on the line */
char savec; /* a place to save a character */
- Lst *paths; /* List of search paths to alter when parsing
- * a list of .PATH targets */
+ Lst paths; /* Search paths to alter when parsing a list of .PATH targets */
int tOp; /* operator from special target */
- Lst *sources; /* list of archive source names after
- * expansion */
- Lst *curTargs; /* list of target names to be found and added
- * to the targets list */
- Lst *curSrcs; /* list of sources in order */
tOp = 0;
specType = Not;
waiting = 0;
- paths = NULL;
-
- curTargs = Lst_Init();
- curSrcs = Lst_Init();
+ Lst_Init(&paths);
do {
for (cp = line;
@@ -751,7 +749,7 @@ ParseDoDependency (char *line)
* went well and FAILURE if there was an error in the
* specification. On error, line should remain untouched.
*/
- if (Arch_ParseArchive(&line, targets, VAR_CMD) != SUCCESS) {
+ if (Arch_ParseArchive(&line, &targets, VAR_CMD) != SUCCESS) {
Parse_Error(PARSE_FATAL,
"Error in archive specification: \"%s\"", line);
return;
@@ -826,13 +824,10 @@ ParseDoDependency (char *line)
*/
switch (specType) {
case ExPath:
- if (paths == NULL) {
- paths = Lst_Init();
- }
- Lst_AtEnd(paths, dirSearchPath);
+ Lst_AtEnd(&paths, &dirSearchPath);
break;
case Main:
- if (!Lst_IsEmpty(create)) {
+ if (!Lst_IsEmpty(&create)) {
specType = Not;
}
break;
@@ -841,12 +836,12 @@ ParseDoDependency (char *line)
case Interrupt:
gn = Targ_FindNode(line, TARG_CREATE);
gn->type |= OP_NOTMAIN;
- Lst_AtEnd(targets, gn);
+ Lst_AtEnd(&targets, gn);
break;
case Default:
gn = Targ_NewGN(".DEFAULT");
gn->type |= (OP_NOTMAIN|OP_TRANSFORM);
- Lst_AtEnd(targets, gn);
+ Lst_AtEnd(&targets, gn);
DEFAULT = gn;
break;
case NotParallel:
@@ -878,12 +873,8 @@ ParseDoDependency (char *line)
"Suffix '%s' not defined (yet)",
&line[5]);
return;
- } else {
- if (paths == NULL) {
- paths = Lst_Init();
- }
- Lst_AtEnd(paths, path);
- }
+ } else
+ Lst_AtEnd(&paths, path);
}
}
@@ -892,6 +883,9 @@ ParseDoDependency (char *line)
* the end of the targets list
*/
if ((specType == Not) && (*line != '\0')) {
+ /* target names to be found and added to targets list */
+ Lst curTargs = Lst_Initializer(curTargs);
+
if (Dir_HasWildcards(line)) {
/*
* Targets are to be sought only in the current directory,
@@ -899,21 +893,21 @@ ParseDoDependency (char *line)
* use Dir_Destroy in the destruction of the path as the
* Dir module could have added a directory to the path...
*/
- Lst *emptyPath = Lst_Init();
+ Lst emptyPath = Lst_Initializer(emptyPath);
- Dir_Expand(line, emptyPath, curTargs);
+ Dir_Expand(line, &emptyPath, &curTargs);
- Lst_Destroy(emptyPath, Dir_Destroy);
+ Lst_Destroy(&emptyPath, Dir_Destroy);
} else {
/*
* No wildcards, but we want to avoid code duplication,
* so create a list with the word on it.
*/
- Lst_AtEnd(curTargs, line);
+ Lst_AtEnd(&curTargs, line);
}
- while(!Lst_IsEmpty(curTargs)) {
- char *targName = Lst_DeQueue(curTargs);
+ while (!Lst_IsEmpty(&curTargs)) {
+ char *targName = Lst_DeQueue(&curTargs);
if (!Suff_IsTransform (targName)) {
gn = Targ_FindNode(targName, TARG_CREATE);
@@ -921,7 +915,7 @@ ParseDoDependency (char *line)
gn = Suff_AddTransform(targName);
}
- Lst_AtEnd(targets, gn);
+ Lst_AtEnd(&targets, gn);
}
} else if (specType == ExPath && *line != '.' && *line != '\0') {
Parse_Error(PARSE_WARNING, "Extra target (%s) ignored", line);
@@ -952,12 +946,7 @@ ParseDoDependency (char *line)
line = cp;
} while ((*line != '!') && (*line != ':') && *line);
- /*
- * Don't need the list of target names anymore...
- */
- Lst_Destroy(curTargs, NOFREE);
-
- if (!Lst_IsEmpty(targets)) {
+ if (!Lst_IsEmpty(&targets)) {
switch (specType) {
default:
Parse_Error(PARSE_WARNING, "Special and mundane targets don't mix. Mundane ones ignored");
@@ -998,7 +987,7 @@ ParseDoDependency (char *line)
cp++; /* Advance beyond operator */
- Lst_ForEach(targets, ParseDoOp, &op);
+ Lst_ForEach(&targets, ParseDoOp, &op);
/*
* Get to the first source
@@ -1032,7 +1021,7 @@ ParseDoDependency (char *line)
beSilent = TRUE;
break;
case ExPath:
- Lst_ForEach(paths, ParseClearPath, NULL);
+ Lst_ForEach(&paths, ParseClearPath, NULL);
break;
case Posix:
Var_Set("%POSIX", "1003.2", VAR_GLOBAL);
@@ -1101,7 +1090,7 @@ ParseDoDependency (char *line)
Suff_AddSuffix(line);
break;
case ExPath:
- Lst_ForEach(paths, ParseAddDir, line);
+ Lst_ForEach(&paths, ParseAddDir, line);
break;
case Includes:
Suff_AddInclude(line);
@@ -1124,10 +1113,11 @@ ParseDoDependency (char *line)
}
line = cp;
}
- if (paths) {
- Lst_Destroy(paths, NOFREE);
- }
+ Lst_Destroy(&paths, NOFREE);
+
} else {
+ Lst curSrcs = Lst_Initializer(curSrc); /* list of sources in order */
+
while (*line) {
/*
* The targets take real sources, so we must beware of archive
@@ -1150,19 +1140,19 @@ ParseDoDependency (char *line)
if (*cp == '(') {
GNode *gnp;
+ /* list of archive source names after expansion */
+ Lst sources = Lst_Initializer(sources);
- sources = Lst_Init();
- if (Arch_ParseArchive(&line, sources, VAR_CMD) != SUCCESS) {
+ if (Arch_ParseArchive(&line, &sources, VAR_CMD) != SUCCESS) {
Parse_Error(PARSE_FATAL,
"Error in source archive spec \"%s\"", line);
return;
}
- while (!Lst_IsEmpty (sources)) {
- gnp = Lst_DeQueue(sources);
- ParseDoSrc(tOp, gnp->name, curSrcs);
+ while (!Lst_IsEmpty(&sources)) {
+ gnp = Lst_DeQueue(&sources);
+ ParseDoSrc(tOp, gnp->name, &curSrcs);
}
- Lst_Destroy(sources, NOFREE);
cp = line;
} else {
if (*cp) {
@@ -1170,13 +1160,14 @@ ParseDoDependency (char *line)
cp += 1;
}
- ParseDoSrc(tOp, line, curSrcs);
+ ParseDoSrc(tOp, line, &curSrcs);
}
while (*cp && isspace((unsigned char)*cp)) {
cp++;
}
line = cp;
}
+ Lst_Destroy(&curSrcs, NOFREE);
}
if (mainNode == NULL) {
@@ -1186,13 +1177,8 @@ ParseDoDependency (char *line)
* the first dependency line that is actually a real target
* (i.e. isn't a .USE or .EXEC rule) to be made.
*/
- Lst_ForEach(targets, ParseFindMain, NULL);
+ Lst_ForEach(&targets, ParseFindMain, NULL);
}
-
- /*
- * Finally, destroy the list of sources
- */
- Lst_Destroy(curSrcs, NOFREE);
}
/*-
@@ -1481,7 +1467,7 @@ ParseAddCmd(void *gnp, void *cmd)
/* if target already supplied, ignore commands */
if (!(gn->type & OP_HAS_COMMANDS))
- Lst_AtEnd(gn->commands, cmd);
+ Lst_AtEnd(&gn->commands, cmd);
else
Parse_Error(PARSE_WARNING,
"duplicate script for target \"%s\" ignored",
@@ -1510,7 +1496,7 @@ ParseHasCommands(void *gnp)
{
GNode *gn = gnp;
- if (!Lst_IsEmpty(gn->commands)) {
+ if (!Lst_IsEmpty(&gn->commands)) {
gn->type |= OP_HAS_COMMANDS;
}
}
@@ -1533,7 +1519,7 @@ void
Parse_AddIncludeDir(char *dir)
{
- Dir_AddDir(parseIncPath, dir);
+ Dir_AddDir(&parseIncPath, dir);
}
/*---------------------------------------------------------------------
@@ -1694,9 +1680,9 @@ ParseDoInclude (char *file)
newName = estrdup(file);
else
newName = str_concat(Fname, file, STR_ADDSLASH);
- fullname = Dir_FindFile(newName, parseIncPath);
+ fullname = Dir_FindFile(newName, &parseIncPath);
if (fullname == NULL) {
- fullname = Dir_FindFile(newName, dirSearchPath);
+ fullname = Dir_FindFile(newName, &dirSearchPath);
}
free(newName);
*prefEnd = '/';
@@ -1715,9 +1701,9 @@ ParseDoInclude (char *file)
* then on the .PATH search path, if not found in a -I directory.
* XXX: Suffix specific?
*/
- fullname = Dir_FindFile(file, parseIncPath);
+ fullname = Dir_FindFile(file, &parseIncPath);
if (fullname == NULL) {
- fullname = Dir_FindFile(file, dirSearchPath);
+ fullname = Dir_FindFile(file, &dirSearchPath);
}
}
@@ -1726,7 +1712,7 @@ ParseDoInclude (char *file)
* Still haven't found the makefile. Look for it on the system
* path as a last resort.
*/
- fullname = Dir_FindFile(file, sysIncPath);
+ fullname = Dir_FindFile(file, &sysIncPath);
}
if (fullname == NULL) {
@@ -1747,7 +1733,7 @@ ParseDoInclude (char *file)
oldFile = emalloc(sizeof (IFile));
memcpy(oldFile, &curFile, sizeof(IFile));
- Lst_AtFront(includes, oldFile);
+ Lst_AtFront(&includes, oldFile);
/*
* Once the previous state has been saved, we can get down to reading
@@ -1794,7 +1780,7 @@ Parse_FromString(char *str, int lineno)
oldFile = emalloc(sizeof(IFile));
memcpy(oldFile, &curFile, sizeof(IFile));
- Lst_AtFront(includes, oldFile);
+ Lst_AtFront(&includes, oldFile);
curFile.F = NULL;
curFile.p = emalloc(sizeof (PTR));
@@ -1860,9 +1846,9 @@ ParseTraditionalInclude (char *file)
* Search for it first on the -I search path, then on the .PATH
* search path, if not found in a -I directory.
*/
- fullname = Dir_FindFile(file, parseIncPath);
+ fullname = Dir_FindFile(file, &parseIncPath);
if (fullname == NULL) {
- fullname = Dir_FindFile(file, dirSearchPath);
+ fullname = Dir_FindFile(file, &dirSearchPath);
}
if (fullname == NULL) {
@@ -1870,7 +1856,7 @@ ParseTraditionalInclude (char *file)
* Still haven't found the makefile. Look for it on the system
* path as a last resort.
*/
- fullname = Dir_FindFile(file, sysIncPath);
+ fullname = Dir_FindFile(file, &sysIncPath);
}
if (fullname == NULL) {
@@ -1888,7 +1874,7 @@ ParseTraditionalInclude (char *file)
oldFile = emalloc(sizeof(IFile));
memcpy(oldFile, &curFile, sizeof(IFile));
- Lst_AtFront(includes, oldFile);
+ Lst_AtFront(&includes, oldFile);
/*
* Once the previous state has been saved, we can get down to reading
@@ -1934,12 +1920,12 @@ ParseEOF(int opened)
{
IFile *ifile; /* the state on the top of the includes stack */
- if (Lst_IsEmpty (includes)) {
+ if (Lst_IsEmpty(&includes)) {
Var_Append(".MAKEFILE_LIST", "..", VAR_GLOBAL);
return (DONE);
}
- ifile = Lst_DeQueue(includes);
+ ifile = Lst_DeQueue(&includes);
free(curFile.fname);
if (opened && curFile.F) {
fclose(curFile.F);
@@ -2349,9 +2335,8 @@ ParseFinishLine(void)
{
if (inLine) {
- Lst_ForEach(targets, Suff_EndTransform, NULL);
- Lst_Destroy(targets, ParseHasCommands);
- targets = NULL;
+ Lst_ForEach(&targets, Suff_EndTransform, NULL);
+ Lst_Destroy(&targets, ParseHasCommands);
inLine = FALSE;
}
}
@@ -2443,7 +2428,7 @@ Parse_File(char *name, FILE *stream)
* in a dependency spec, add the command to the list of
* commands of all targets in the dependency spec
*/
- Lst_ForEach(targets, ParseAddCmd, cp);
+ Lst_ForEach(&targets, ParseAddCmd, cp);
continue;
} else {
Parse_Error(PARSE_FATAL,
@@ -2494,10 +2479,7 @@ Parse_File(char *name, FILE *stream)
/*
* Need a non-circular list for the target nodes
*/
- if (targets)
- Lst_Destroy(targets, NOFREE);
-
- targets = Lst_Init();
+ Lst_Destroy(&targets, NOFREE);
inLine = TRUE;
ParseDoDependency (line);
@@ -2538,20 +2520,16 @@ Parse_Init(void)
{
mainNode = NULL;
- parseIncPath = Lst_Init();
- sysIncPath = Lst_Init();
- includes = Lst_Init();
}
void
Parse_End(void)
{
- if (targets)
- Lst_Destroy(targets, NOFREE);
- Lst_Destroy(sysIncPath, Dir_Destroy);
- Lst_Destroy(parseIncPath, Dir_Destroy);
- Lst_Destroy(includes, NOFREE); /* Should be empty now */
+ Lst_Destroy(&targets, NOFREE);
+ Lst_Destroy(&sysIncPath, Dir_Destroy);
+ Lst_Destroy(&parseIncPath, Dir_Destroy);
+ Lst_Destroy(&includes, NOFREE); /* Should be empty now */
}
@@ -2569,21 +2547,17 @@ Parse_End(void)
*
*-----------------------------------------------------------------------
*/
-Lst *
-Parse_MainName(void)
+void
+Parse_MainName(Lst *listmain)
{
- Lst *listmain; /* result list */
-
- listmain = Lst_Init();
if (mainNode == NULL) {
Punt("no target to make.");
/*NOTREACHED*/
} else if (mainNode->type & OP_DOUBLEDEP) {
Lst_AtEnd(listmain, mainNode);
- Lst_Concat(listmain, mainNode->cohorts, LST_CONCNEW);
+ Lst_Concat(listmain, &mainNode->cohorts, LST_CONCNEW);
}
else
Lst_AtEnd(listmain, mainNode);
- return (listmain);
}
diff --git a/usr.bin/make/suff.c b/usr.bin/make/suff.c
index b08bc10..25b6dbf 100644
--- a/usr.bin/make/suff.c
+++ b/usr.bin/make/suff.c
@@ -97,10 +97,17 @@ __FBSDID("$FreeBSD$");
#include "hash.h"
#include "dir.h"
-static Lst *sufflist; /* Lst of suffixes */
-static Lst *suffClean; /* Lst of suffixes to be cleaned */
-static Lst *srclist; /* Lst of sources */
-static Lst *transforms; /* Lst of transformation rules */
+/* Lst of suffixes */
+static Lst sufflist = Lst_Initializer(sufflist);
+
+/* Lst of suffixes to be cleaned */
+static Lst suffClean = Lst_Initializer(suffClean);
+
+/* Lst of sources */
+static Lst srclist = Lst_Initializer(srclist);
+
+/* Lst of transformation rules */
+static Lst transforms = Lst_Initializer(transforms);
static int sNum = 0; /* Counter for assigning suffix numbers */
@@ -114,13 +121,13 @@ typedef struct _Suff {
#define SUFF_INCLUDE 0x01 /* One which is #include'd */
#define SUFF_LIBRARY 0x02 /* One which contains a library */
#define SUFF_NULL 0x04 /* The empty suffix */
- Lst *searchPath; /* The path along which files of this suffix
+ Lst searchPath; /* The path along which files of this suffix
* may be found */
int sNum; /* The suffix number */
int refCount; /* Reference count of list membership */
- Lst *parents; /* Suffixes we have a transformation to */
- Lst *children; /* Suffixes we have a transformation from */
- Lst *ref; /* List of lists this suffix is referenced */
+ Lst parents; /* Suffixes we have a transformation to */
+ Lst children; /* Suffixes we have a transformation from */
+ Lst ref; /* List of lists this suffix is referenced */
} Suff;
/*
@@ -135,7 +142,7 @@ typedef struct _Src {
int children; /* Count of existing children (so we don't free
* this thing too early or never nuke it) */
#ifdef DEBUG_SRC
- Lst *cp; /* Debug; children list */
+ Lst cp; /* Debug; children list */
#endif
} Src;
@@ -355,10 +362,10 @@ SuffFree(void *sp)
if (s == emptySuff)
emptySuff = NULL;
- Lst_Destroy(s->ref, NOFREE);
- Lst_Destroy(s->children, NOFREE);
- Lst_Destroy(s->parents, NOFREE);
- Lst_Destroy(s->searchPath, Dir_Destroy);
+ Lst_Destroy(&s->ref, NOFREE);
+ Lst_Destroy(&s->children, NOFREE);
+ Lst_Destroy(&s->parents, NOFREE);
+ Lst_Destroy(&s->searchPath, Dir_Destroy);
free(s->name);
free(s);
@@ -421,12 +428,12 @@ SuffInsert(Lst *l, Suff *s)
DEBUGF(SUFF, ("at end of list\n"));
Lst_AtEnd (l, s);
s->refCount++;
- Lst_AtEnd(s->ref, l);
+ Lst_AtEnd(&s->ref, l);
} else if (s2->sNum != s->sNum) {
DEBUGF(SUFF, ("before %s(%d)\n", s2->name, s2->sNum));
Lst_Insert(l, ln, s);
s->refCount++;
- Lst_AtEnd(s->ref, l);
+ Lst_AtEnd(&s->ref, l);
} else {
DEBUGF(SUFF, ("already there\n"));
}
@@ -453,9 +460,8 @@ void
Suff_ClearSuffixes(void)
{
- Lst_Concat(suffClean, sufflist, LST_CONCLINK);
- free(sufflist);
- sufflist = Lst_Init();
+ Lst_Concat(&suffClean, &sufflist, LST_CONCLINK);
+
sNum = 1;
suffNull = emptySuff;
/*
@@ -464,8 +470,7 @@ Suff_ClearSuffixes(void)
* NOFREE is used because all suffixes are are on the suffClean list.
* suffNull should not have parents.
*/
- Lst_Destroy(suffNull->children, NOFREE);
- suffNull->children = Lst_Init();
+ Lst_Destroy(&suffNull->children, NOFREE);
}
/*-
@@ -504,9 +509,9 @@ SuffParseTransform(char *str, Suff **srcPtr, Suff **targPtr)
*/
for (;;) {
if (srcLn == NULL) {
- srcLn = Lst_Find(sufflist, str, SuffSuffIsPrefix);
+ srcLn = Lst_Find(&sufflist, str, SuffSuffIsPrefix);
} else {
- srcLn = Lst_FindFrom(sufflist, Lst_Succ(srcLn), str,
+ srcLn = Lst_FindFrom(&sufflist, Lst_Succ(srcLn), str,
SuffSuffIsPrefix);
}
if (srcLn == NULL) {
@@ -535,7 +540,7 @@ SuffParseTransform(char *str, Suff **srcPtr, Suff **targPtr)
single = src;
singleLn = srcLn;
} else {
- targLn = Lst_Find(sufflist, str2, SuffSuffHasNameP);
+ targLn = Lst_Find(&sufflist, str2, SuffSuffHasNameP);
if (targLn != NULL) {
*srcPtr = src;
*targPtr = Lst_Datum(targLn);
@@ -589,14 +594,14 @@ Suff_AddTransform(char *line)
*t; /* target suffix */
LstNode *ln; /* Node for existing transformation */
- ln = Lst_Find(transforms, line, SuffGNHasNameP);
+ ln = Lst_Find(&transforms, line, SuffGNHasNameP);
if (ln == NULL) {
/*
* Make a new graph node for the transformation. It will be filled in
* by the Parse module.
*/
gn = Targ_NewGN(line);
- Lst_AtEnd(transforms, gn);
+ Lst_AtEnd(&transforms, gn);
} else {
/*
* New specification for transformation rule. Just nuke the old list
@@ -605,10 +610,8 @@ Suff_AddTransform(char *line)
* attached to several different transformations.
*/
gn = Lst_Datum(ln);
- Lst_Destroy(gn->commands, NOFREE);
- Lst_Destroy(gn->children, NOFREE);
- gn->commands = Lst_Init();
- gn->children = Lst_Init();
+ Lst_Destroy(&gn->commands, NOFREE);
+ Lst_Destroy(&gn->children, NOFREE);
}
gn->type = OP_TRANSFORM;
@@ -620,8 +623,8 @@ Suff_AddTransform(char *line)
*/
DEBUGF(SUFF, ("defining transformation from `%s' to `%s'\n",
s->name, t->name));
- SuffInsert(t->children, s);
- SuffInsert(s->parents, t);
+ SuffInsert(&t->children, s);
+ SuffInsert(&s->parents, t);
return (gn);
}
@@ -648,8 +651,8 @@ Suff_EndTransform(void *gnp, void *dummy __unused)
{
GNode *gn = (GNode *)gnp;
- if ((gn->type & OP_TRANSFORM) && Lst_IsEmpty(gn->commands) &&
- Lst_IsEmpty(gn->children))
+ if ((gn->type & OP_TRANSFORM) && Lst_IsEmpty(&gn->commands) &&
+ Lst_IsEmpty(&gn->children))
{
Suff *s, *t;
@@ -671,12 +674,12 @@ Suff_EndTransform(void *gnp, void *dummy __unused)
* We'll be called twice when the next target is seen, but .c and .o
* are only linked once...
*/
- SuffRemove(t->children, s);
+ SuffRemove(&t->children, s);
/*
* Remove the target from the source's parents list
*/
- SuffRemove(s->parents, t);
+ SuffRemove(&s->parents, t);
} else if (gn->type & OP_TRANSFORM) {
DEBUGF(SUFF, ("transformation %s complete\n", gn->name));
}
@@ -720,7 +723,7 @@ SuffRebuildGraph(void *transformp, void *sp)
if (cp[0] == '\0') /* null rule */
s2 = suffNull;
else {
- ln = Lst_Find(sufflist, cp, SuffSuffHasNameP);
+ ln = Lst_Find(&sufflist, cp, SuffSuffHasNameP);
if (ln != NULL)
s2 = Lst_Datum(ln);
}
@@ -729,8 +732,8 @@ SuffRebuildGraph(void *transformp, void *sp)
* Found target. Link in and return, since it can't be anything
* else.
*/
- SuffInsert(s2->children, s);
- SuffInsert(s->parents, s2);
+ SuffInsert(&s2->children, s);
+ SuffInsert(&s->parents, s2);
return (0);
}
}
@@ -744,7 +747,7 @@ SuffRebuildGraph(void *transformp, void *sp)
* Null-terminate the source suffix in order to find it.
*/
cp[1] = '\0';
- ln = Lst_Find(sufflist, transform->name, SuffSuffHasNameP);
+ ln = Lst_Find(&sufflist, transform->name, SuffSuffHasNameP);
/*
* Replace the start of the target suffix
*/
@@ -754,8 +757,8 @@ SuffRebuildGraph(void *transformp, void *sp)
* Found it -- establish the proper relationship
*/
s2 = Lst_Datum(ln);
- SuffInsert(s->children, s2);
- SuffInsert(s2->parents, s);
+ SuffInsert(&s->children, s2);
+ SuffInsert(&s2->parents, s);
}
}
return (0);
@@ -781,27 +784,27 @@ Suff_AddSuffix(char *str)
Suff *s; /* new suffix descriptor */
LstNode *ln;
- ln = Lst_Find(sufflist, str, SuffSuffHasNameP);
+ ln = Lst_Find(&sufflist, str, SuffSuffHasNameP);
if (ln == NULL) {
s = emalloc(sizeof(Suff));
s->name = estrdup(str);
s->nameLen = strlen (s->name);
- s->searchPath = Lst_Init();
- s->children = Lst_Init();
- s->parents = Lst_Init();
- s->ref = Lst_Init();
+ Lst_Init(&s->searchPath);
+ Lst_Init(&s->children);
+ Lst_Init(&s->parents);
+ Lst_Init(&s->ref);
s->sNum = sNum++;
s->flags = 0;
s->refCount = 0;
- Lst_AtEnd(sufflist, s);
+ Lst_AtEnd(&sufflist, s);
/*
* Look for any existing transformations from or to this suffix.
* XXX: Only do this after a Suff_ClearSuffixes?
*/
- Lst_ForEach(transforms, SuffRebuildGraph, s);
+ Lst_ForEach(&transforms, SuffRebuildGraph, s);
}
}
@@ -824,12 +827,12 @@ Suff_GetPath(char *sname)
LstNode *ln;
Suff *s;
- ln = Lst_Find(sufflist, sname, SuffSuffHasNameP);
+ ln = Lst_Find(&sufflist, sname, SuffSuffHasNameP);
if (ln == NULL) {
return (NULL);
} else {
s = Lst_Datum(ln);
- return (s->searchPath);
+ return (&s->searchPath);
}
}
@@ -857,39 +860,39 @@ Suff_DoPaths(void)
Suff *s;
LstNode *ln;
char *ptr;
- Lst *inIncludes; /* Cumulative .INCLUDES path */
- Lst *inLibs; /* Cumulative .LIBS path */
+ Lst inIncludes; /* Cumulative .INCLUDES path */
+ Lst inLibs; /* Cumulative .LIBS path */
- inIncludes = Lst_Init();
- inLibs = Lst_Init();
+ Lst_Init(&inIncludes);
+ Lst_Init(&inLibs);
- for (ln = Lst_First(sufflist); ln != NULL; ln = Lst_Succ(ln)) {
+ for (ln = Lst_First(&sufflist); ln != NULL; ln = Lst_Succ(ln)) {
s = Lst_Datum(ln);
- if (!Lst_IsEmpty(s->searchPath)) {
+ if (!Lst_IsEmpty(&s->searchPath)) {
#ifdef INCLUDES
if (s->flags & SUFF_INCLUDE) {
- Dir_Concat(inIncludes, s->searchPath);
+ Dir_Concat(&inIncludes, &s->searchPath);
}
#endif /* INCLUDES */
#ifdef LIBRARIES
if (s->flags & SUFF_LIBRARY) {
- Dir_Concat(inLibs, s->searchPath);
+ Dir_Concat(&inLibs, &s->searchPath);
}
#endif /* LIBRARIES */
- Dir_Concat(s->searchPath, dirSearchPath);
+ Dir_Concat(&s->searchPath, &dirSearchPath);
} else {
- Lst_Destroy(s->searchPath, Dir_Destroy);
- s->searchPath = Lst_Duplicate(dirSearchPath, Dir_CopyDir);
+ Lst_Destroy(&s->searchPath, Dir_Destroy);
+ Lst_Duplicate(&s->searchPath, &dirSearchPath, Dir_CopyDir);
}
}
- Var_Set(".INCLUDES", ptr = Dir_MakeFlags("-I", inIncludes), VAR_GLOBAL);
+ Var_Set(".INCLUDES", ptr = Dir_MakeFlags("-I", &inIncludes), VAR_GLOBAL);
free(ptr);
- Var_Set(".LIBS", ptr = Dir_MakeFlags("-L", inLibs), VAR_GLOBAL);
+ Var_Set(".LIBS", ptr = Dir_MakeFlags("-L", &inLibs), VAR_GLOBAL);
free(ptr);
- Lst_Destroy(inIncludes, Dir_Destroy);
- Lst_Destroy(inLibs, Dir_Destroy);
+ Lst_Destroy(&inIncludes, Dir_Destroy);
+ Lst_Destroy(&inLibs, Dir_Destroy);
}
/*-
@@ -913,7 +916,7 @@ Suff_AddInclude(char *sname)
LstNode *ln;
Suff *s;
- ln = Lst_Find(sufflist, sname, SuffSuffHasNameP);
+ ln = Lst_Find(&sufflist, sname, SuffSuffHasNameP);
if (ln != NULL) {
s = Lst_Datum(ln);
s->flags |= SUFF_INCLUDE;
@@ -942,7 +945,7 @@ Suff_AddLib(char *sname)
LstNode *ln;
Suff *s;
- ln = Lst_Find(sufflist, sname, SuffSuffHasNameP);
+ ln = Lst_Find(&sufflist, sname, SuffSuffHasNameP);
if (ln != NULL) {
s = Lst_Datum(ln);
s->flags |= SUFF_LIBRARY;
@@ -992,9 +995,9 @@ SuffAddSrc(void *sp, void *lsp)
targ->children += 1;
Lst_AtEnd(ls->l, s2);
#ifdef DEBUG_SRC
- s2->cp = Lst_Init();
- Lst_AtEnd(targ->cp, s2);
- printf("1 add %x %x to %x:", targ, s2, ls->l);
+ Lst_Init(&s2->cp);
+ Lst_AtEnd(&targ->cp, s2);
+ printf("1 add %p %p to %p:", targ, s2, ls->l);
Lst_ForEach(ls->l, PrintAddr, (void *)NULL);
printf("\n");
#endif
@@ -1010,9 +1013,9 @@ SuffAddSrc(void *sp, void *lsp)
targ->children += 1;
Lst_AtEnd(ls->l, s2);
#ifdef DEBUG_SRC
- s2->cp = Lst_Init();
- Lst_AtEnd(targ->cp, s2);
- printf("2 add %x %x to %x:", targ, s2, ls->l);
+ Lst_Init(&s2->cp);
+ Lst_AtEnd(&targ->cp, s2);
+ printf("2 add %p %p to %p:", targ, s2, ls->l);
Lst_ForEach(ls->l, PrintAddr, (void *)NULL);
printf("\n");
#endif
@@ -1040,7 +1043,7 @@ SuffAddLevel(Lst *l, Src *targ)
ls.s = targ;
ls.l = l;
- Lst_ForEach(targ->suff->children, SuffAddSrc, &ls);
+ Lst_ForEach(&targ->suff->children, SuffAddSrc, &ls);
}
/*-
@@ -1079,15 +1082,15 @@ SuffRemoveSrc(Lst *l)
free(s->pref);
else {
#ifdef DEBUG_SRC
- LstNode *ln = Lst_Member(s->parent->cp, s);
+ LstNode *ln = Lst_Member(&s->parent->cp, s);
if (ln != NULL)
- Lst_Remove(s->parent->cp, ln);
+ Lst_Remove(&s->parent->cp, ln);
#endif
--s->parent->children;
}
#ifdef DEBUG_SRC
- printf("free: [l=%x] p=%x %d\n", l, s, s->children);
- Lst_Destroy(s->cp, NOFREE);
+ printf("free: [l=%p] p=%p %d\n", l, s, s->children);
+ Lst_Destroy(&s->cp, NOFREE);
#endif
Lst_Remove(l, ln);
free(s);
@@ -1096,8 +1099,8 @@ SuffRemoveSrc(Lst *l)
}
#ifdef DEBUG_SRC
else {
- printf("keep: [l=%x] p=%x %d: ", l, s, s->children);
- Lst_ForEach(s->cp, PrintAddr, (void *)NULL);
+ printf("keep: [l=%p] p=%p %d: ", l, s, s->children);
+ Lst_ForEach(&s->cp, PrintAddr, (void *)NULL);
printf("\n");
}
#endif
@@ -1138,16 +1141,16 @@ SuffFindThem(Lst *srcs, Lst *slst)
*/
if (Targ_FindNode(s->file, TARG_NOCREATE) != NULL) {
#ifdef DEBUG_SRC
- printf("remove %x from %x\n", s, srcs);
+ printf("remove %p from %p\n", s, srcs);
#endif
rs = s;
break;
}
- if ((ptr = Dir_FindFile(s->file, s->suff->searchPath)) != NULL) {
+ if ((ptr = Dir_FindFile(s->file, &s->suff->searchPath)) != NULL) {
rs = s;
#ifdef DEBUG_SRC
- printf("remove %x from %x\n", s, srcs);
+ printf("remove %p from %p\n", s, srcs);
#endif
free(ptr);
break;
@@ -1194,7 +1197,7 @@ SuffFindCmds (Src *targ, Lst *slst)
t = targ->node;
prefLen = strlen(targ->pref);
- for (ln = Lst_First(t->children); ln != NULL; ln = Lst_Succ(ln)) {
+ for (ln = Lst_First(&t->children); ln != NULL; ln = Lst_Succ(ln)) {
s = Lst_Datum(ln);
cp = strrchr(s->name, '/');
@@ -1208,7 +1211,7 @@ SuffFindCmds (Src *targ, Lst *slst)
* The node matches the prefix ok, see if it has a known
* suffix.
*/
- ln = Lst_Find(sufflist, &cp[prefLen], SuffSuffHasNameP);
+ ln = Lst_Find(&sufflist, &cp[prefLen], SuffSuffHasNameP);
if (ln != NULL) {
/*
* It even has a known suffix, see if there's a transformation
@@ -1218,7 +1221,7 @@ SuffFindCmds (Src *targ, Lst *slst)
*/
suff = Lst_Datum(ln);
- if (Lst_Member(suff->parents, targ->suff) != NULL) {
+ if (Lst_Member(&suff->parents, targ->suff) != NULL) {
/*
* Hot Damn! Create a new Src structure to describe
* this transformation (making sure to duplicate the
@@ -1235,9 +1238,9 @@ SuffFindCmds (Src *targ, Lst *slst)
ret->children = 0;
targ->children += 1;
#ifdef DEBUG_SRC
- ret->cp = Lst_Init();
- printf("3 add %x %x\n", targ, ret);
- Lst_AtEnd(targ->cp, ret);
+ Lst_Init(&ret->cp);
+ printf("3 add %p %p\n", &targ, ret);
+ Lst_AtEnd(&targ->cp, ret);
#endif
Lst_AtEnd(slst, ret);
DEBUGF(SUFF, ("\tusing existing source %s\n", s->name));
@@ -1279,7 +1282,7 @@ SuffExpandChildren(void *cgnp, void *pgnp)
* New nodes effectively take the place of the child, so place them
* after the child
*/
- prevLN = Lst_Member(pgn->children, cgn);
+ prevLN = Lst_Member(&pgn->children, cgn);
/*
* First do variable expansion -- this takes precedence over
@@ -1292,7 +1295,7 @@ SuffExpandChildren(void *cgnp, void *pgnp)
cp = Var_Subst(NULL, cgn->name, pgn, TRUE);
if (cp != NULL) {
- Lst *members = Lst_Init();
+ Lst members = Lst_Initializer(members);
if (cgn->type & OP_ARCHV) {
/*
@@ -1302,7 +1305,7 @@ SuffExpandChildren(void *cgnp, void *pgnp)
*/
char *sacrifice = cp;
- Arch_ParseArchive(&sacrifice, members, pgn);
+ Arch_ParseArchive(&sacrifice, &members, pgn);
} else {
/*
* Break the result into a vector of strings whose nodes
@@ -1324,7 +1327,7 @@ SuffExpandChildren(void *cgnp, void *pgnp)
*/
*cp++ = '\0';
gn = Targ_FindNode(start, TARG_CREATE);
- Lst_AtEnd(members, gn);
+ Lst_AtEnd(&members, gn);
while (*cp == ' ' || *cp == '\t') {
cp++;
}
@@ -1363,7 +1366,7 @@ SuffExpandChildren(void *cgnp, void *pgnp)
* Stuff left over -- add it to the list too
*/
gn = Targ_FindNode(start, TARG_CREATE);
- Lst_AtEnd(members, gn);
+ Lst_AtEnd(&members, gn);
}
/*
* Point cp back at the beginning again so the variable value
@@ -1374,18 +1377,18 @@ SuffExpandChildren(void *cgnp, void *pgnp)
/*
* Add all elements of the members list to the parent node.
*/
- while(!Lst_IsEmpty(members)) {
- gn = Lst_DeQueue(members);
+ while(!Lst_IsEmpty(&members)) {
+ gn = Lst_DeQueue(&members);
DEBUGF(SUFF, ("%s...", gn->name));
- if (Lst_Member(pgn->children, gn) == NULL) {
- Lst_Append(pgn->children, prevLN, gn);
+ if (Lst_Member(&pgn->children, gn) == NULL) {
+ Lst_Append(&pgn->children, prevLN, gn);
prevLN = Lst_Succ(prevLN);
- Lst_AtEnd(gn->parents, pgn);
+ Lst_AtEnd(&gn->parents, pgn);
pgn->unmade++;
}
}
- Lst_Destroy(members, NOFREE);
+
/*
* Free the result
*/
@@ -1395,12 +1398,12 @@ SuffExpandChildren(void *cgnp, void *pgnp)
* Now the source is expanded, remove it from the list of children to
* keep it from being processed.
*/
- ln = Lst_Member(pgn->children, cgn);
+ ln = Lst_Member(&pgn->children, cgn);
pgn->unmade--;
- Lst_Remove(pgn->children, ln);
+ Lst_Remove(&pgn->children, ln);
DEBUGF(SUFF, ("\n"));
} else if (Dir_HasWildcards(cgn->name)) {
- Lst *exp; /* List of expansions */
+ Lst exp; /* List of expansions */
Lst *path; /* Search path along which to expand */
/*
@@ -1412,7 +1415,7 @@ SuffExpandChildren(void *cgnp, void *pgnp)
* Else use the default system search path.
*/
cp = cgn->name + strlen(cgn->name);
- ln = Lst_Find(sufflist, cp, SuffSuffIsSuffixP);
+ ln = Lst_Find(&sufflist, cp, SuffSuffIsSuffixP);
DEBUGF(SUFF, ("Wildcard expanding \"%s\"...", cgn->name));
@@ -1420,25 +1423,25 @@ SuffExpandChildren(void *cgnp, void *pgnp)
Suff *s = Lst_Datum(ln);
DEBUGF(SUFF, ("suffix is \"%s\"...", s->name));
- path = s->searchPath;
+ path = &s->searchPath;
} else {
/*
* Use default search path
*/
- path = dirSearchPath;
+ path = &dirSearchPath;
}
/*
* Expand the word along the chosen path
*/
- exp = Lst_Init();
- Dir_Expand(cgn->name, path, exp);
+ Lst_Init(&exp);
+ Dir_Expand(cgn->name, path, &exp);
- while (!Lst_IsEmpty(exp)) {
+ while (!Lst_IsEmpty(&exp)) {
/*
* Fetch next expansion off the list and find its GNode
*/
- cp = Lst_DeQueue(exp);
+ cp = Lst_DeQueue(&exp);
DEBUGF(SUFF, ("%s...", cp));
gn = Targ_FindNode(cp, TARG_CREATE);
@@ -1447,26 +1450,21 @@ SuffExpandChildren(void *cgnp, void *pgnp)
* If gn isn't already a child of the parent, make it so and
* up the parent's count of unmade children.
*/
- if (Lst_Member(pgn->children, gn) == NULL) {
- Lst_Append(pgn->children, prevLN, gn);
+ if (Lst_Member(&pgn->children, gn) == NULL) {
+ Lst_Append(&pgn->children, prevLN, gn);
prevLN = Lst_Succ(prevLN);
- Lst_AtEnd(gn->parents, pgn);
+ Lst_AtEnd(&gn->parents, pgn);
pgn->unmade++;
}
}
/*
- * Nuke what's left of the list
- */
- Lst_Destroy(exp, NOFREE);
-
- /*
* Now the source is expanded, remove it from the list of children to
* keep it from being processed.
*/
- ln = Lst_Member(pgn->children, cgn);
+ ln = Lst_Member(&pgn->children, cgn);
pgn->unmade--;
- Lst_Remove(pgn->children, ln);
+ Lst_Remove(&pgn->children, ln);
DEBUGF(SUFF, ("\n"));
}
@@ -1498,13 +1496,13 @@ SuffApplyTransform(GNode *tGn, GNode *sGn, Suff *t, Suff *s)
char *tname; /* Name of transformation rule */
GNode *gn; /* Node for same */
- if (Lst_Member(tGn->children, sGn) == NULL) {
+ if (Lst_Member(&tGn->children, sGn) == NULL) {
/*
* Not already linked, so form the proper links between the
* target and source.
*/
- Lst_AtEnd(tGn->children, sGn);
- Lst_AtEnd(sGn->parents, tGn);
+ Lst_AtEnd(&tGn->children, sGn);
+ Lst_AtEnd(&sGn->parents, tGn);
tGn->unmade += 1;
}
@@ -1515,16 +1513,16 @@ SuffApplyTransform(GNode *tGn, GNode *sGn, Suff *t, Suff *s)
* sGn gets the target in its iParents list, however, as that
* will be sufficient to get the .IMPSRC variable set for tGn
*/
- for (ln = Lst_First(sGn->cohorts); ln != NULL; ln = Lst_Succ(ln)) {
+ for (ln = Lst_First(&sGn->cohorts); ln != NULL; ln = Lst_Succ(ln)) {
gn = Lst_Datum(ln);
- if (Lst_Member(tGn->children, gn) == NULL) {
+ if (Lst_Member(&tGn->children, gn) == NULL) {
/*
* Not already linked, so form the proper links between the
* target and source.
*/
- Lst_AtEnd(tGn->children, gn);
- Lst_AtEnd(gn->parents, tGn);
+ Lst_AtEnd(&tGn->children, gn);
+ Lst_AtEnd(&gn->parents, tGn);
tGn->unmade += 1;
}
}
@@ -1533,7 +1531,7 @@ SuffApplyTransform(GNode *tGn, GNode *sGn, Suff *t, Suff *s)
* Locate the transformation rule itself
*/
tname = str_concat(s->name, t->name, 0);
- ln = Lst_Find(transforms, tname, SuffGNHasNameP);
+ ln = Lst_Find(&transforms, tname, SuffGNHasNameP);
free(tname);
if (ln == NULL) {
@@ -1552,7 +1550,7 @@ SuffApplyTransform(GNode *tGn, GNode *sGn, Suff *t, Suff *s)
/*
* Record last child for expansion purposes
*/
- ln = Lst_Last(tGn->children);
+ ln = Lst_Last(&tGn->children);
/*
* Pass the buck to Make_HandleUse to apply the rule
@@ -1564,14 +1562,14 @@ SuffApplyTransform(GNode *tGn, GNode *sGn, Suff *t, Suff *s)
*/
ln = Lst_Succ(ln);
if (ln != NULL) {
- Lst_ForEachFrom(tGn->children, ln, SuffExpandChildren, tGn);
+ Lst_ForEachFrom(&tGn->children, ln, SuffExpandChildren, tGn);
}
/*
* Keep track of another parent to which this beast is transformed so
* the .IMPSRC variable can be set correctly for the parent.
*/
- Lst_AtEnd(sGn->iParents, tGn);
+ Lst_AtEnd(&sGn->iParents, tGn);
return (TRUE);
}
@@ -1629,9 +1627,9 @@ SuffFindArchiveDeps(GNode *gn, Lst *slst)
/*
* Create the link between the two nodes right off
*/
- if (Lst_Member(gn->children, mem) == NULL) {
- Lst_AtEnd(gn->children, mem);
- Lst_AtEnd(mem->parents, gn);
+ if (Lst_Member(&gn->children, mem) == NULL) {
+ Lst_AtEnd(&gn->children, mem);
+ Lst_AtEnd(&mem->parents, gn);
gn->unmade += 1;
}
@@ -1673,7 +1671,7 @@ SuffFindArchiveDeps(GNode *gn, Lst *slst)
/*
* Use first matching suffix...
*/
- ln = Lst_Find(ms->parents, eoarch, SuffSuffIsSuffixP);
+ ln = Lst_Find(&ms->parents, eoarch, SuffSuffIsSuffixP);
if (ln != NULL) {
/*
@@ -1727,8 +1725,8 @@ SuffFindNormalDeps(GNode *gn, Lst *slst)
char *eoname; /* End of name */
char *sopref; /* Start of prefix */
LstNode *ln; /* Next suffix node to check */
- Lst *srcs; /* List of sources at which to look */
- Lst *targs; /* List of targets to which things can be
+ Lst srcs; /* List of sources at which to look */
+ Lst targs; /* List of targets to which things can be
* transformed. They all have the same file,
* but different suff and pref fields */
Src *bottom; /* Start of found transformation path */
@@ -1744,9 +1742,9 @@ SuffFindNormalDeps(GNode *gn, Lst *slst)
/*
* Begin at the beginning...
*/
- ln = Lst_First(sufflist);
- srcs = Lst_Init();
- targs = Lst_Init();
+ ln = Lst_First(&sufflist);
+ Lst_Init(&srcs);
+ Lst_Init(&targs);
/*
* We're caught in a catch-22 here. On the one hand, we want to use any
@@ -1771,7 +1769,7 @@ SuffFindNormalDeps(GNode *gn, Lst *slst)
/*
* Look for next possible suffix...
*/
- ln = Lst_FindFrom(sufflist, ln, eoname, SuffSuffIsSuffixP);
+ ln = Lst_FindFrom(&sufflist, ln, eoname, SuffSuffIsSuffixP);
if (ln != NULL) {
int prefLen; /* Length of the prefix */
@@ -1788,7 +1786,7 @@ SuffFindNormalDeps(GNode *gn, Lst *slst)
target->parent = NULL;
target->children = 0;
#ifdef DEBUG_SRC
- target->cp = Lst_Init();
+ Lst_Init(&target->cp);
#endif
/*
@@ -1803,12 +1801,12 @@ SuffFindNormalDeps(GNode *gn, Lst *slst)
/*
* Add nodes from which the target can be made
*/
- SuffAddLevel(srcs, target);
+ SuffAddLevel(&srcs, target);
/*
* Record the target so we can nuke it
*/
- Lst_AtEnd(targs, target);
+ Lst_AtEnd(&targs, target);
/*
* Search from this suffix's successor...
@@ -1820,7 +1818,7 @@ SuffFindNormalDeps(GNode *gn, Lst *slst)
/*
* Handle target of unknown suffix...
*/
- if (Lst_IsEmpty(targs) && suffNull != NULL) {
+ if (Lst_IsEmpty(&targs) && suffNull != NULL) {
DEBUGF(SUFF, ("\tNo known suffix on %s. Using .NULL suffix\n", gn->name));
targ = emalloc(sizeof(Src));
@@ -1832,37 +1830,37 @@ SuffFindNormalDeps(GNode *gn, Lst *slst)
targ->children = 0;
targ->pref = estrdup(sopref);
#ifdef DEBUG_SRC
- targ->cp = Lst_Init();
+ Lst_Init(&targ->cp);
#endif
/*
* Only use the default suffix rules if we don't have commands
* or dependencies defined for this gnode
*/
- if (Lst_IsEmpty(gn->commands) && Lst_IsEmpty(gn->children))
- SuffAddLevel(srcs, targ);
+ if (Lst_IsEmpty(&gn->commands) && Lst_IsEmpty(&gn->children))
+ SuffAddLevel(&srcs, targ);
else {
DEBUGF(SUFF, ("not "));
}
DEBUGF(SUFF, ("adding suffix rules\n"));
- Lst_AtEnd(targs, targ);
+ Lst_AtEnd(&targs, targ);
}
/*
* Using the list of possible sources built up from the target suffix(es),
* try and find an existing file/target that matches.
*/
- bottom = SuffFindThem(srcs, slst);
+ bottom = SuffFindThem(&srcs, slst);
if (bottom == NULL) {
/*
* No known transformations -- use the first suffix found for setting
* the local variables.
*/
- if (!Lst_IsEmpty(targs)) {
- targ = Lst_Datum(Lst_First(targs));
+ if (!Lst_IsEmpty(&targs)) {
+ targ = Lst_Datum(Lst_First(&targs));
} else {
targ = NULL;
}
@@ -1890,7 +1888,7 @@ SuffFindNormalDeps(GNode *gn, Lst *slst)
* Now we've got the important local variables set, expand any sources
* that still contain variables or wildcards in their names.
*/
- Lst_ForEach(gn->children, SuffExpandChildren, (void *)gn);
+ Lst_ForEach(&gn->children, SuffExpandChildren, (void *)gn);
if (targ == NULL) {
DEBUGF(SUFF, ("\tNo valid suffix on %s\n", gn->name));
@@ -1902,11 +1900,11 @@ sfnd_abort:
* or [XXX] it has neither children or commands).
*/
if (OP_NOP(gn->type) ||
- (Lst_IsEmpty(gn->children) && Lst_IsEmpty(gn->commands)))
+ (Lst_IsEmpty(&gn->children) && Lst_IsEmpty(&gn->commands)))
{
gn->path = Dir_FindFile(gn->name,
- (targ == NULL ? dirSearchPath :
- targ->suff->searchPath));
+ (targ == NULL ? &dirSearchPath :
+ &targ->suff->searchPath));
if (gn->path != NULL) {
char *ptr;
Var_Set(TARGET, gn->path, gn);
@@ -1981,7 +1979,7 @@ sfnd_abort:
/*
* Check for overriding transformation rule implied by sources
*/
- if (!Lst_IsEmpty(gn->children)) {
+ if (!Lst_IsEmpty(&gn->children)) {
src = SuffFindCmds(targ, slst);
if (src != NULL) {
@@ -2075,13 +2073,11 @@ sfnd_return:
if (Lst_Member(slst, bottom) == NULL)
Lst_AtEnd(slst, bottom);
- while (SuffRemoveSrc(srcs) || SuffRemoveSrc(targs))
+ while (SuffRemoveSrc(&srcs) || SuffRemoveSrc(&targs))
continue;
- Lst_Concat(slst, srcs, LST_CONCLINK);
- Lst_Concat(slst, targs, LST_CONCLINK);
- free(srcs);
- free(targs);
+ Lst_Concat(slst, &srcs, LST_CONCLINK);
+ Lst_Concat(slst, &targs, LST_CONCLINK);
}
/*-
@@ -2115,8 +2111,8 @@ void
Suff_FindDeps(GNode *gn)
{
- SuffFindDeps(gn, srclist);
- while (SuffRemoveSrc(srclist))
+ SuffFindDeps(gn, &srclist);
+ while (SuffRemoveSrc(&srclist))
continue;
}
@@ -2150,13 +2146,13 @@ SuffFindDeps(GNode *gn, Lst *slst)
LstNode *ln;
Suff *s;
- ln = Lst_Find(sufflist, LIBSUFF, SuffSuffHasNameP);
+ ln = Lst_Find(&sufflist, LIBSUFF, SuffSuffHasNameP);
if (gn->suffix)
gn->suffix->refCount--;
if (ln != NULL) {
gn->suffix = s = Lst_Datum (ln);
gn->suffix->refCount++;
- Arch_FindLib(gn, s->searchPath);
+ Arch_FindLib(gn, &s->searchPath);
} else {
gn->suffix = NULL;
Var_Set(TARGET, gn->name, gn);
@@ -2195,7 +2191,7 @@ Suff_SetNull(char *name)
Suff *s;
LstNode *ln;
- ln = Lst_Find(sufflist, name, SuffSuffHasNameP);
+ ln = Lst_Find(&sufflist, name, SuffSuffHasNameP);
if (ln != NULL) {
s = Lst_Datum(ln);
if (suffNull != NULL) {
@@ -2228,11 +2224,6 @@ void
Suff_Init(void)
{
- sufflist = Lst_Init();
- suffClean = Lst_Init();
- srclist = Lst_Init();
- transforms = Lst_Init();
-
sNum = 0;
/*
* Create null suffix for single-suffix rules (POSIX). The thing doesn't
@@ -2243,11 +2234,11 @@ Suff_Init(void)
suffNull->name = estrdup("");
suffNull->nameLen = 0;
- suffNull->searchPath = Lst_Init();
- Dir_Concat(suffNull->searchPath, dirSearchPath);
- suffNull->children = Lst_Init();
- suffNull->parents = Lst_Init();
- suffNull->ref = Lst_Init();
+ Lst_Init(&suffNull->searchPath);
+ Dir_Concat(&suffNull->searchPath, &dirSearchPath);
+ Lst_Init(&suffNull->children);
+ Lst_Init(&suffNull->parents);
+ Lst_Init(&suffNull->ref);
suffNull->sNum = sNum++;
suffNull->flags = SUFF_NULL;
suffNull->refCount = 1;
@@ -2270,12 +2261,12 @@ void
Suff_End(void)
{
- Lst_Destroy(sufflist, SuffFree);
- Lst_Destroy(suffClean, SuffFree);
+ Lst_Destroy(&sufflist, SuffFree);
+ Lst_Destroy(&suffClean, SuffFree);
if (suffNull)
SuffFree(suffNull);
- Lst_Destroy(srclist, NOFREE);
- Lst_Destroy(transforms, NOFREE);
+ Lst_Destroy(&srclist, NOFREE);
+ Lst_Destroy(&transforms, NOFREE);
}
/********************* DEBUGGING FUNCTIONS **********************/
@@ -2321,13 +2312,13 @@ SuffPrintSuff(void *sp, void *dummy __unused)
}
fputc('\n', stdout);
printf("#\tTo: ");
- Lst_ForEach(s->parents, SuffPrintName, (void *)NULL);
+ Lst_ForEach(&s->parents, SuffPrintName, (void *)NULL);
fputc('\n', stdout);
printf("#\tFrom: ");
- Lst_ForEach(s->children, SuffPrintName, (void *)NULL);
+ Lst_ForEach(&s->children, SuffPrintName, (void *)NULL);
fputc('\n', stdout);
printf("#\tSearch Path: ");
- Dir_PrintPath(s->searchPath);
+ Dir_PrintPath(&s->searchPath);
fputc('\n', stdout);
return (0);
}
@@ -2340,7 +2331,7 @@ SuffPrintTrans(void *tp, void *dummy __unused)
printf("%-16s: ", t->name);
Targ_PrintType(t->type);
fputc('\n', stdout);
- Lst_ForEach(t->commands, Targ_PrintCmd, (void *)NULL);
+ Lst_ForEach(&t->commands, Targ_PrintCmd, (void *)NULL);
fputc('\n', stdout);
return (0);
}
@@ -2350,8 +2341,8 @@ Suff_PrintAll(void)
{
printf("#*** Suffixes:\n");
- Lst_ForEach(sufflist, SuffPrintSuff, (void *)NULL);
+ Lst_ForEach(&sufflist, SuffPrintSuff, (void *)NULL);
printf("#*** Transformations:\n");
- Lst_ForEach(transforms, SuffPrintTrans, (void *)NULL);
+ Lst_ForEach(&transforms, SuffPrintTrans, (void *)NULL);
}
diff --git a/usr.bin/make/targ.c b/usr.bin/make/targ.c
index 358399b..eff08ee 100644
--- a/usr.bin/make/targ.c
+++ b/usr.bin/make/targ.c
@@ -88,7 +88,9 @@ __FBSDID("$FreeBSD$");
#include "hash.h"
#include "dir.h"
-static Lst *allTargets; /* the list of all targets found so far */
+/* the list of all targets found so far */
+static Lst allTargets = Lst_Initializer(allTargets);
+
static Hash_Table targets; /* a hash table of same */
#define HTSIZE 191 /* initial size of hash table */
@@ -113,7 +115,6 @@ void
Targ_Init(void)
{
- allTargets = Lst_Init();
Hash_InitTable(&targets, HTSIZE);
}
@@ -133,7 +134,7 @@ void
Targ_End(void)
{
- Lst_Destroy(allTargets, NOFREE);
+ Lst_Destroy(&allTargets, NOFREE);
Hash_DeleteTable(&targets);
}
@@ -169,14 +170,14 @@ Targ_NewGN(char *name)
gn->childMade = FALSE;
gn->order = 0;
gn->mtime = gn->cmtime = 0;
- gn->iParents = Lst_Init();
- gn->cohorts = Lst_Init();
- gn->parents = Lst_Init();
- gn->children = Lst_Init();
- gn->successors = Lst_Init();
- gn->preds = Lst_Init();
- gn->context = Lst_Init();
- gn->commands = Lst_Init();
+ Lst_Init(&gn->iParents);
+ Lst_Init(&gn->cohorts);
+ Lst_Init(&gn->parents);
+ Lst_Init(&gn->children);
+ Lst_Init(&gn->successors);
+ Lst_Init(&gn->preds);
+ Lst_Init(&gn->context);
+ Lst_Init(&gn->commands);
gn->suffix = NULL;
return (gn);
@@ -209,7 +210,7 @@ Targ_FindNode(char *name, int flags)
if (isNew) {
gn = Targ_NewGN(name);
Hash_SetValue (he, gn);
- Lst_AtEnd(allTargets, gn);
+ Lst_AtEnd(&allTargets, gn);
}
} else {
he = Hash_FindEntry(&targets, name);
@@ -237,16 +238,13 @@ Targ_FindNode(char *name, int flags)
* an error message will be printed for each name which can't be found.
* -----------------------------------------------------------------------
*/
-Lst *
-Targ_FindList(Lst *names, int flags)
+void
+Targ_FindList(Lst *nodes, Lst *names, int flags)
{
- Lst *nodes; /* result list */
LstNode *ln; /* name list element */
GNode *gn; /* node in tLn */
char *name;
- nodes = Lst_Init();
-
for (ln = Lst_First(names); ln != NULL; ln = Lst_Succ(ln)) {
name = Lst_Datum(ln);
gn = Targ_FindNode(name, flags);
@@ -258,13 +256,12 @@ Targ_FindList(Lst *names, int flags)
*/
Lst_AtEnd(nodes, gn);
if (gn->type & OP_DOUBLEDEP) {
- Lst_Concat(nodes, gn->cohorts, LST_CONCNEW);
+ Lst_Concat(nodes, &gn->cohorts, LST_CONCNEW);
}
} else if (flags == TARG_NOCREATE) {
Error("\"%s\" -- target unknown.", name);
}
}
- return (nodes);
}
/*-
@@ -501,15 +498,15 @@ TargPrintNode(void *gnp, void *passp)
printf("# unmade\n");
}
}
- if (!Lst_IsEmpty (gn->iParents)) {
+ if (!Lst_IsEmpty(&gn->iParents)) {
printf("# implicit parents: ");
- Lst_ForEach(gn->iParents, TargPrintName, (void *)NULL);
+ Lst_ForEach(&gn->iParents, TargPrintName, (void *)NULL);
fputc('\n', stdout);
}
}
- if (!Lst_IsEmpty (gn->parents)) {
+ if (!Lst_IsEmpty(&gn->parents)) {
printf("# parents: ");
- Lst_ForEach(gn->parents, TargPrintName, (void *)NULL);
+ Lst_ForEach(&gn->parents, TargPrintName, (void *)NULL);
fputc('\n', stdout);
}
@@ -525,12 +522,12 @@ TargPrintNode(void *gnp, void *passp)
break;
}
Targ_PrintType(gn->type);
- Lst_ForEach(gn->children, TargPrintName, (void *)NULL);
+ Lst_ForEach(&gn->children, TargPrintName, (void *)NULL);
fputc('\n', stdout);
- Lst_ForEach(gn->commands, Targ_PrintCmd, (void *)NULL);
+ Lst_ForEach(&gn->commands, Targ_PrintCmd, (void *)NULL);
printf("\n\n");
if (gn->type & OP_DOUBLEDEP) {
- Lst_ForEach(gn->cohorts, TargPrintNode, &pass);
+ Lst_ForEach(&gn->cohorts, TargPrintNode, &pass);
}
}
return (0);
@@ -577,10 +574,10 @@ Targ_PrintGraph(int pass)
{
printf("#*** Input graph:\n");
- Lst_ForEach(allTargets, TargPrintNode, &pass);
+ Lst_ForEach(&allTargets, TargPrintNode, &pass);
printf("\n\n");
printf("#\n# Files that are only sources:\n");
- Lst_ForEach(allTargets, TargPrintOnlySrc, (void *)NULL);
+ Lst_ForEach(&allTargets, TargPrintOnlySrc, (void *)NULL);
printf("#*** Global Variables:\n");
Var_Dump(VAR_GLOBAL);
printf("#*** Command-line Variables:\n");
diff --git a/usr.bin/make/var.c b/usr.bin/make/var.c
index 7ac597b..d0eb74a 100644
--- a/usr.bin/make/var.c
+++ b/usr.bin/make/var.c
@@ -247,7 +247,7 @@ VarFind(char *name, GNode *ctxt, int flags)
* Note whether this is one of the specific variables we were told through
* the -E flag to use environment-variable-override for.
*/
- if (Lst_Find(envFirstVars, name, (CompareProc *)strcmp) != NULL) {
+ if (Lst_Find(&envFirstVars, name, (CompareProc *)strcmp) != NULL) {
localCheckEnvFirst = TRUE;
} else {
localCheckEnvFirst = FALSE;
@@ -258,15 +258,15 @@ VarFind(char *name, GNode *ctxt, int flags)
* look for it in VAR_CMD, VAR_GLOBAL and the environment, in that order,
* depending on the FIND_* flags in 'flags'
*/
- var = Lst_Find(ctxt->context, name, VarCmp);
+ var = Lst_Find(&ctxt->context, name, VarCmp);
if ((var == NULL) && (flags & FIND_CMD) && (ctxt != VAR_CMD)) {
- var = Lst_Find(VAR_CMD->context, name, VarCmp);
+ var = Lst_Find(&VAR_CMD->context, name, VarCmp);
}
if ((var == NULL) && (flags & FIND_GLOBAL) && (ctxt != VAR_GLOBAL) &&
!checkEnvFirst && !localCheckEnvFirst)
{
- var = Lst_Find(VAR_GLOBAL->context, name, VarCmp);
+ var = Lst_Find(&VAR_GLOBAL->context, name, VarCmp);
}
if ((var == NULL) && (flags & FIND_ENV)) {
char *env;
@@ -287,7 +287,7 @@ VarFind(char *name, GNode *ctxt, int flags)
} else if ((checkEnvFirst || localCheckEnvFirst) &&
(flags & FIND_GLOBAL) && (ctxt != VAR_GLOBAL))
{
- var = Lst_Find(VAR_GLOBAL->context, name, VarCmp);
+ var = Lst_Find(&VAR_GLOBAL->context, name, VarCmp);
if (var == NULL) {
return (NULL);
} else {
@@ -333,7 +333,7 @@ VarAdd(char *name, char *val, GNode *ctxt)
v->flags = 0;
- Lst_AtFront(ctxt->context, v);
+ Lst_AtFront(&ctxt->context, v);
DEBUGF(VAR, ("%s:%s = %s\n", ctxt->name, name, val));
}
@@ -378,10 +378,10 @@ Var_Delete(char *name, GNode *ctxt)
LstNode *ln;
DEBUGF(VAR, ("%s:delete %s\n", ctxt->name, name));
- ln = Lst_Find(ctxt->context, name, VarCmp);
+ ln = Lst_Find(&ctxt->context, name, VarCmp);
if (ln != NULL) {
VarDelete(Lst_Datum(ln));
- Lst_Remove(ctxt->context, ln);
+ Lst_Remove(&ctxt->context, ln);
}
}
@@ -483,7 +483,7 @@ Var_Append(char *name, char *val, GNode *ctxt)
* export other variables...)
*/
v->flags &= ~VAR_FROM_ENV;
- Lst_AtFront(ctxt->context, v);
+ Lst_AtFront(&ctxt->context, v);
}
}
free(name);
@@ -1949,5 +1949,5 @@ void
Var_Dump(GNode *ctxt)
{
- Lst_ForEach (ctxt->context, VarPrintVar, (void *)NULL);
+ Lst_ForEach(&ctxt->context, VarPrintVar, (void *)NULL);
}
OpenPOWER on IntegriCloud