diff options
author | Marc Espie <espie@cvs.openbsd.org> | 2000-06-17 14:38:23 +0000 |
---|---|---|
committer | Marc Espie <espie@cvs.openbsd.org> | 2000-06-17 14:38:23 +0000 |
commit | ecbebb6e3cb3428095eb28e7e03e6872e5d24a68 (patch) | |
tree | 25a3cb92a8ac766285ba464991f3a7d4d6f10cf4 /usr.bin | |
parent | 93fa2e228c8792a5468e8d398b5bb6c290eecb73 (diff) |
This patch introduces a distinction between
Lst_Init (constructor) and Lst_New (allocation + construction)
Lst_Destroy (destructor) and Lst_Delete (deallocation + destruction),
and uses that to turn most dynamic allocation of lists (Lst pointers)
into static structures (LIST).
Most of this is mundane, except for allGNs in targ.c, where the code must
be checked to verify that Targ_Init is called soon enough.
Lst_New is a temporary addition. All lists will soon be static.
Reviewed by millert@, like the previous patch.
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/make/arch.c | 39 | ||||
-rw-r--r-- | usr.bin/make/compat.c | 24 | ||||
-rw-r--r-- | usr.bin/make/cond.c | 8 | ||||
-rw-r--r-- | usr.bin/make/dir.c | 57 | ||||
-rw-r--r-- | usr.bin/make/for.c | 14 | ||||
-rw-r--r-- | usr.bin/make/job.c | 93 | ||||
-rw-r--r-- | usr.bin/make/job.h | 6 | ||||
-rw-r--r-- | usr.bin/make/lst.h | 12 | ||||
-rw-r--r-- | usr.bin/make/lst.lib/lstDestroy.c | 22 | ||||
-rw-r--r-- | usr.bin/make/lst.lib/lstDupl.c | 13 | ||||
-rw-r--r-- | usr.bin/make/lst.lib/lstInit.c | 36 | ||||
-rw-r--r-- | usr.bin/make/main.c | 72 | ||||
-rw-r--r-- | usr.bin/make/make.c | 72 | ||||
-rw-r--r-- | usr.bin/make/make.h | 24 | ||||
-rw-r--r-- | usr.bin/make/parse.c | 190 | ||||
-rw-r--r-- | usr.bin/make/suff.c | 279 | ||||
-rw-r--r-- | usr.bin/make/targ.c | 85 | ||||
-rw-r--r-- | usr.bin/make/var.c | 41 |
18 files changed, 536 insertions, 551 deletions
diff --git a/usr.bin/make/arch.c b/usr.bin/make/arch.c index fdea6a5b913..dac5f708781 100644 --- a/usr.bin/make/arch.c +++ b/usr.bin/make/arch.c @@ -1,4 +1,4 @@ -/* $OpenBSD: arch.c,v 1.27 2000/06/10 01:41:05 espie Exp $ */ +/* $OpenBSD: arch.c,v 1.28 2000/06/17 14:38:13 espie Exp $ */ /* $NetBSD: arch.c,v 1.17 1996/11/06 17:58:59 christos Exp $ */ /* @@ -43,7 +43,7 @@ #if 0 static char sccsid[] = "@(#)arch.c 8.2 (Berkeley) 1/2/94"; #else -static char rcsid[] = "$OpenBSD: arch.c,v 1.27 2000/06/10 01:41:05 espie Exp $"; +static char rcsid[] = "$OpenBSD: arch.c,v 1.28 2000/06/17 14:38:13 espie Exp $"; #endif #endif /* not lint */ @@ -119,7 +119,7 @@ static char rcsid[] = "$OpenBSD: arch.c,v 1.27 2000/06/10 01:41:05 espie Exp $"; #define MACHINE_ARCH TARGET_MACHINE_ARCH #endif -static Lst archives; /* Lst of archives we've already examined */ +static LIST archives; /* Lst of archives we've already examined */ typedef struct Arch { char *name; /* Name of archive */ @@ -359,18 +359,19 @@ Arch_ParseArchive (linePtr, nodeLst, ctxt) */ free(buf); } else if (Dir_HasWildcards(memName)) { - Lst members = Lst_Init(); + LIST members; char *member; - Dir_Expand(memName, dirSearchPath, members); - while ((member = (char *)Lst_DeQueue(members)) != NULL) { + Lst_Init(&members); + Dir_Expand(memName, &dirSearchPath, &members); + while ((member = (char *)Lst_DeQueue(&members)) != NULL) { sprintf(nameBuf, "%s(%s)", libName, member); free(member); - gn = Targ_FindNode (nameBuf, TARG_CREATE); - if (gn == NULL) { + gn = Targ_FindNode(nameBuf, TARG_CREATE); + if (gn == NULL) return (FAILURE); - } else { + else { /* * We've found the node, but have to make sure the rest of * the world knows it's an archive member, without having @@ -382,7 +383,7 @@ Arch_ParseArchive (linePtr, nodeLst, ctxt) Lst_AtEnd(nodeLst, gn); } } - Lst_Destroy(members, NOFREE); + Lst_Destroy(&members, NOFREE); } else { sprintf(nameBuf, "%s(%s)", libName, memName); gn = Targ_FindNode (nameBuf, TARG_CREATE); @@ -496,7 +497,7 @@ ArchStatMember (archive, member, hash) if (cp != NULL) member = cp + 1; - ln = Lst_Find(archives, ArchFindArchive, archive); + ln = Lst_Find(&archives, ArchFindArchive, archive); if (ln != NULL) { ar = (Arch *) Lst_Datum (ln); @@ -643,7 +644,7 @@ ArchStatMember (archive, member, hash) fclose (arch); - Lst_AtEnd(archives, ar); + Lst_AtEnd(&archives, ar); /* * Now that the archive has been read and cached, we can look into @@ -1044,11 +1045,11 @@ Arch_MemMTime (gn) char *nameStart, *nameEnd; - if (Lst_Open (gn->parents) != SUCCESS) { + if (Lst_Open(&gn->parents) != SUCCESS) { gn->mtime = OUT_OF_DATE; return FALSE; } - while ((ln = Lst_Next (gn->parents)) != NULL) { + while ((ln = Lst_Next(&gn->parents)) != NULL) { pgn = (GNode *) Lst_Datum (ln); if (pgn->type & OP_ARCHV) { @@ -1083,7 +1084,7 @@ Arch_MemMTime (gn) } } - Lst_Close (gn->parents); + Lst_Close(&gn->parents); return gn->mtime == OUT_OF_DATE; } @@ -1171,7 +1172,7 @@ Arch_LibOODate (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 || gn->mtime == OUT_OF_DATE) { @@ -1220,9 +1221,9 @@ Arch_LibOODate (gn) *----------------------------------------------------------------------- */ void -Arch_Init () +Arch_Init() { - archives = Lst_Init(); + Lst_Init(&archives); } @@ -1244,7 +1245,7 @@ void Arch_End () { #ifdef CLEANUP - Lst_Destroy(archives, ArchFree); + Lst_Destroy(&archives, ArchFree); #endif } diff --git a/usr.bin/make/compat.c b/usr.bin/make/compat.c index 73745dc2024..279de0b99ff 100644 --- a/usr.bin/make/compat.c +++ b/usr.bin/make/compat.c @@ -1,4 +1,4 @@ -/* $OpenBSD: compat.c,v 1.27 2000/06/10 01:41:05 espie Exp $ */ +/* $OpenBSD: compat.c,v 1.28 2000/06/17 14:38:14 espie Exp $ */ /* $NetBSD: compat.c,v 1.14 1996/11/06 17:59:01 christos Exp $ */ /* @@ -43,7 +43,7 @@ #if 0 static char sccsid[] = "@(#)compat.c 8.2 (Berkeley) 3/19/94"; #else -static char rcsid[] = "$OpenBSD: compat.c,v 1.27 2000/06/10 01:41:05 espie Exp $"; +static char rcsid[] = "$OpenBSD: compat.c,v 1.28 2000/06/17 14:38:14 espie Exp $"; #endif #endif /* not lint */ @@ -122,7 +122,7 @@ CompatInterrupt (signo) if (signo == SIGINT) { gn = Targ_FindNode(".INTERRUPT", TARG_NOCREATE); if (gn != NULL) { - Lst_Find(gn->commands, CompatRunCommand, gn); + Lst_Find(&gn->commands, CompatRunCommand, gn); } } @@ -232,7 +232,7 @@ CompatRunCommand (cmdp, gnp) silent = gn->type & OP_SILENT; errCheck = !(gn->type & OP_IGNORE); - cmdNode = Lst_Member(gn->commands, cmd); + cmdNode = Lst_Member(&gn->commands, cmd); cmdStart = Var_Subst(cmd, gn, FALSE); /* @@ -252,7 +252,7 @@ CompatRunCommand (cmdp, gnp) Lst_Replace(cmdNode, cmdStart); if ((gn->type & OP_SAVE_CMDS) && (gn != ENDNode)) { - Lst_AtEnd(ENDNode->commands, cmdStart); + Lst_AtEnd(&ENDNode->commands, cmdStart); return 1; } else if (strcmp(cmdStart, "...") == 0) { gn->type |= OP_SAVE_CMDS; @@ -455,14 +455,14 @@ CompatMake(gnp, 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; } - if (Lst_Member (gn->iParents, pgn) != NULL) { + if (Lst_Member(&gn->iParents, pgn) != NULL) { Var_Set(IMPSRC, Var_Value(TARGET, gn), pgn); } @@ -518,7 +518,7 @@ CompatMake(gnp, pgnp) */ if (!touchFlag) { curTarg = gn; - Lst_Find(gn->commands, CompatRunCommand, gn); + Lst_Find(&gn->commands, CompatRunCommand, gn); curTarg = NULL; } else { Job_Touch (gn, gn->type & OP_SILENT); @@ -562,7 +562,7 @@ CompatMake(gnp, 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 @@ -616,7 +616,7 @@ CompatMake(gnp, pgnp) */ pgn->make = FALSE; } else { - if (Lst_Member (gn->iParents, pgn) != NULL) + if (Lst_Member(&gn->iParents, pgn) != NULL) Var_Set (IMPSRC, Var_Value(TARGET, gn), pgn); switch(gn->made) { case BEINGMADE: @@ -691,7 +691,7 @@ Compat_Run(targs) if (!queryFlag) { gn = Targ_FindNode(".BEGIN", TARG_NOCREATE); if (gn != NULL) { - Lst_Find(gn->commands, CompatRunCommand, gn); + Lst_Find(&gn->commands, CompatRunCommand, gn); if (gn->made == ERROR) { printf("\n\nStop.\n"); exit(1); @@ -725,6 +725,6 @@ Compat_Run(targs) * If the user has defined a .END target, run its commands. */ if (errors == 0) { - Lst_Find(ENDNode->commands, CompatRunCommand, gn); + Lst_Find(&ENDNode->commands, CompatRunCommand, gn); } } diff --git a/usr.bin/make/cond.c b/usr.bin/make/cond.c index 082a57a1c70..94c789ebb91 100644 --- a/usr.bin/make/cond.c +++ b/usr.bin/make/cond.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cond.c,v 1.17 2000/06/10 01:41:05 espie Exp $ */ +/* $OpenBSD: cond.c,v 1.18 2000/06/17 14:38:14 espie Exp $ */ /* $NetBSD: cond.c,v 1.7 1996/11/06 17:59:02 christos Exp $ */ /* @@ -43,7 +43,7 @@ #if 0 static char sccsid[] = "@(#)cond.c 8.2 (Berkeley) 1/2/94"; #else -static char rcsid[] = "$OpenBSD: cond.c,v 1.17 2000/06/10 01:41:05 espie Exp $"; +static char rcsid[] = "$OpenBSD: cond.c,v 1.18 2000/06/17 14:38:14 espie Exp $"; #endif #endif /* not lint */ @@ -339,7 +339,7 @@ CondDoMake (argLen, arg) Boolean result; arg[argLen] = '\0'; - if (Lst_Find(create, CondStrMatch, arg) == NULL) { + if (Lst_Find(&create, CondStrMatch, arg) == NULL) { result = FALSE; } else { result = TRUE; @@ -371,7 +371,7 @@ CondDoExists (argLen, arg) char *path; arg[argLen] = '\0'; - path = Dir_FindFile(arg, dirSearchPath); + path = Dir_FindFile(arg, &dirSearchPath); if (path != (char *)NULL) { result = TRUE; free(path); diff --git a/usr.bin/make/dir.c b/usr.bin/make/dir.c index ee7dd6f1a31..a401fe4a5ad 100644 --- a/usr.bin/make/dir.c +++ b/usr.bin/make/dir.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dir.c,v 1.19 2000/06/10 01:41:05 espie Exp $ */ +/* $OpenBSD: dir.c,v 1.20 2000/06/17 14:38:14 espie Exp $ */ /* $NetBSD: dir.c,v 1.14 1997/03/29 16:51:26 christos Exp $ */ /* @@ -43,7 +43,7 @@ #if 0 static char sccsid[] = "@(#)dir.c 8.2 (Berkeley) 1/2/94"; #else -static char rcsid[] = "$OpenBSD: dir.c,v 1.19 2000/06/10 01:41:05 espie Exp $"; +static char rcsid[] = "$OpenBSD: dir.c,v 1.20 2000/06/17 14:38:14 espie Exp $"; #endif #endif /* not lint */ @@ -168,9 +168,9 @@ static char rcsid[] = "$OpenBSD: dir.c,v 1.19 2000/06/10 01:41:05 espie Exp $"; * in a cache for when Dir_MTime was actually called. */ -Lst dirSearchPath; /* main search path */ +LIST dirSearchPath; /* main search path */ -static Lst openDirectories; /* the list of all open directories */ +static LIST openDirectories; /* the list of all open directories */ /* * Variables for gathering statistics on the efficiency of the hashing @@ -213,10 +213,10 @@ static void DirPrintDir __P((void *)); *----------------------------------------------------------------------- */ void -Dir_Init () +Dir_Init() { - dirSearchPath = Lst_Init(); - openDirectories = Lst_Init(); + Lst_Init(&dirSearchPath); + Lst_Init(&openDirectories); Hash_InitTable(&mtimes, 0); /* @@ -225,8 +225,8 @@ Dir_Init () * we need to remove "." from openDirectories and what better time to * do it than when we have to fetch the thing anyway? */ - Dir_AddDir (openDirectories, "."); - dot = (Path *) Lst_DeQueue (openDirectories); + Dir_AddDir(&openDirectories, "."); + dot = (Path *)Lst_DeQueue(&openDirectories); /* * We always need to have dot around, so we increment its reference count @@ -253,10 +253,10 @@ Dir_End() #ifdef CLEANUP 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); #endif } @@ -623,10 +623,10 @@ Dir_Expand (word, path, expansions) char *dp = &dirpath[strlen(dirpath) - 1]; if (*dp == '/') *dp = '\0'; - path = Lst_Init(); + path = Lst_New(); Dir_AddDir(path, dirpath); DirExpandInt(cp+1, path, expansions); - Lst_Destroy(path, NOFREE); + Lst_Delete(path, NOFREE); } } else { /* @@ -978,7 +978,7 @@ Dir_FindFile (name, path) *----------------------------------------------------------------------- */ Boolean -Dir_MTime (gn) +Dir_MTime(gn) GNode *gn; /* the file whose modification time is * desired */ { @@ -987,13 +987,12 @@ Dir_MTime (gn) Hash_Entry *entry; Boolean exists; - if (gn->type & OP_ARCHV) { - return Arch_MTime (gn); - } else if (gn->path == (char *)NULL) { - fullName = Dir_FindFile (gn->name, dirSearchPath); - } else { + if (gn->type & OP_ARCHV) + return Arch_MTime(gn); + else if (gn->path == NULL) + fullName = Dir_FindFile(gn->name, &dirSearchPath); + else fullName = gn->path; - } if (fullName == (char *)NULL) { fullName = estrdup(gn->name); @@ -1063,7 +1062,7 @@ Dir_AddDir (path, name) DIR *d; /* for reading directory */ register struct dirent *dp; /* entry in directory */ - ln = Lst_Find(openDirectories, DirFindName, name); + ln = Lst_Find(&openDirectories, DirFindName, name); if (ln != NULL) { p = (Path *)Lst_Datum (ln); if (Lst_Member(path, p) == NULL) { @@ -1103,7 +1102,7 @@ Dir_AddDir (path, name) (void)Hash_CreateEntry(&p->files, dp->d_name, (Boolean *)NULL); } (void) closedir (d); - Lst_AtEnd(openDirectories, p); + Lst_AtEnd(&openDirectories, p); Lst_AtEnd(path, p); } if (DEBUG(DIR)) { @@ -1201,8 +1200,8 @@ Dir_Destroy (pp) if (p->refCount == 0) { LstNode ln; - ln = Lst_Member(openDirectories, p); - Lst_Remove(openDirectories, ln); + ln = Lst_Member(&openDirectories, p); + Lst_Remove(&openDirectories, ln); Hash_DeleteTable (&p->files); free(p->name); @@ -1278,12 +1277,12 @@ Dir_PrintDirectories() (hits+bigmisses+nearmisses ? hits * 100 / (hits + bigmisses + nearmisses) : 0)); printf ("# %-20s referenced\thits\n", "directory"); - if (Lst_Open (openDirectories) == SUCCESS) { - while ((ln = Lst_Next (openDirectories)) != NULL) { + if (Lst_Open(&openDirectories) == SUCCESS) { + while ((ln = Lst_Next(&openDirectories)) != NULL) { p = (Path *) Lst_Datum (ln); printf ("# %-20s %10d\t%4d\n", p->name, p->refCount, p->hits); } - Lst_Close (openDirectories); + Lst_Close(&openDirectories); } } diff --git a/usr.bin/make/for.c b/usr.bin/make/for.c index 846ac63553e..98cc8e74bd0 100644 --- a/usr.bin/make/for.c +++ b/usr.bin/make/for.c @@ -1,4 +1,4 @@ -/* $OpenBSD: for.c,v 1.17 2000/06/10 01:41:05 espie Exp $ */ +/* $OpenBSD: for.c,v 1.18 2000/06/17 14:38:15 espie Exp $ */ /* $NetBSD: for.c,v 1.4 1996/11/06 17:59:05 christos Exp $ */ /* @@ -82,7 +82,7 @@ #if 0 static char sccsid[] = "@(#)for.c 8.1 (Berkeley) 6/6/93"; #else -static char rcsid[] = "$OpenBSD: for.c,v 1.17 2000/06/10 01:41:05 espie Exp $"; +static char rcsid[] = "$OpenBSD: for.c,v 1.18 2000/06/17 14:38:15 espie Exp $"; #endif #endif /* not lint */ @@ -104,7 +104,7 @@ static char rcsid[] = "$OpenBSD: for.c,v 1.17 2000/06/10 01:41:05 espie Exp $"; struct For_ { char *text; /* unexpanded text */ char *var; /* Index name */ - Lst lst; /* List of items */ + LIST lst; /* List of items */ size_t guess; /* Estimated expansion size */ BUFFER buf; /* Accumulating text */ unsigned long lineno; /* Line number at start of loop */ @@ -202,8 +202,8 @@ For_Eval(line) if (DEBUG(FOR)) (void)fprintf(stderr, "For: Iterator %s List %s\n", arg->var, sub); - arg->lst = Lst_Init(); - build_words_list(arg->lst, sub); + Lst_Init(&arg->lst); + build_words_list(&arg->lst, sub); free(sub); arg->lineno = Parse_Getlineno(); arg->level = 1; @@ -303,9 +303,9 @@ For_Run(arg) arg->text = Buf_Retrieve(&arg->buf); arg->guess = Buf_Size(&arg->buf) + GUESS_EXPANSION; - Lst_ForEach(arg->lst, ForExec, arg); + Lst_ForEach(&arg->lst, ForExec, arg); free(arg->var); free(arg->text); - Lst_Destroy(arg->lst, (SimpleProc)free); + Lst_Destroy(&arg->lst, (SimpleProc)free); free(arg); } diff --git a/usr.bin/make/job.c b/usr.bin/make/job.c index db174089b7b..0b78264af54 100644 --- a/usr.bin/make/job.c +++ b/usr.bin/make/job.c @@ -1,4 +1,4 @@ -/* $OpenBSD: job.c,v 1.28 2000/06/10 01:41:05 espie Exp $ */ +/* $OpenBSD: job.c,v 1.29 2000/06/17 14:38:15 espie Exp $ */ /* $NetBSD: job.c,v 1.16 1996/11/06 17:59:08 christos Exp $ */ /* @@ -43,7 +43,7 @@ #if 0 static char sccsid[] = "@(#)job.c 8.2 (Berkeley) 3/19/94"; #else -static char rcsid[] = "$OpenBSD: job.c,v 1.28 2000/06/10 01:41:05 espie Exp $"; +static char rcsid[] = "$OpenBSD: job.c,v 1.29 2000/06/17 14:38:15 espie Exp $"; #endif #endif /* not lint */ @@ -223,7 +223,7 @@ static int maxJobs; /* The most children we can run at once */ static int maxLocal; /* The most local ones we can have */ STATIC int nJobs; /* The number of children currently running */ STATIC int nLocal; /* The number of local children */ -STATIC Lst jobs; /* The structures that describe them */ +STATIC LIST jobs; /* The structures that describe them */ 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 or @@ -257,7 +257,7 @@ STATIC char *targFmt; /* Format string to use to head output from a * been migrated home, the job is placed on the stoppedJobs queue to be run * when the next job finishes. */ -STATIC Lst stoppedJobs; /* Lst of Job structures describing +STATIC LIST stoppedJobs; /* Lst of Job structures describing * jobs that were stopped due to concurrency * limits or migration home */ @@ -380,7 +380,7 @@ JobPassSig(signo) (void) fprintf(stdout, "JobPassSig(%d) called.\n", signo); (void) fflush(stdout); } - Lst_ForEach(jobs, JobCondPassSig, &signo); + Lst_ForEach(&jobs, JobCondPassSig, &signo); /* * Deal with proper cleanup based on the signal received. We only run @@ -426,7 +426,7 @@ JobPassSig(signo) (void) KILL(getpid(), signo); signo = SIGCONT; - Lst_ForEach(jobs, JobCondPassSig, &signo); + Lst_ForEach(&jobs, JobCondPassSig, &signo); (void) sigprocmask(SIG_SETMASK, &omask, NULL); sigprocmask(SIG_SETMASK, &omask, NULL); @@ -531,8 +531,7 @@ JobPrintCommand(cmdp, 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 0; } return 1; @@ -551,7 +550,7 @@ JobPrintCommand(cmdp, 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(cmd, job->node, FALSE); Lst_Replace(cmdNode, cmdStart); @@ -672,7 +671,7 @@ JobSaveCommand(cmd, gn) char *result; result = Var_Subst((char *)cmd, (GNode *)gn, FALSE); - Lst_AtEnd(postCommands->commands, result); + Lst_AtEnd(&postCommands->commands, result); } @@ -848,7 +847,7 @@ JobFinish(job, status) WSTOPSIG(*status)); } job->flags |= JOB_RESUME; - Lst_AtEnd(stoppedJobs, job); + Lst_AtEnd(&stoppedJobs, job); #ifdef REMOTE if (job->flags & JOB_REMIGRATE) JobRestart(job); @@ -886,7 +885,7 @@ JobFinish(job, status) #endif } job->flags &= ~JOB_CONTINUING; - Lst_AtEnd(jobs, job); + Lst_AtEnd(&jobs, job); nJobs += 1; if (!(job->flags & JOB_REMOTE)) { if (DEBUG(JOB)) { @@ -923,7 +922,7 @@ JobFinish(job, status) * ok, it's ok. If there's an error, this puppy is done. */ if (compatMake && (WIFEXITED(*status) && - !Lst_IsAtEnd(job->node->commands))) { + !Lst_IsAtEnd(&job->node->commands))) { switch (JobStart(job->node, job->flags & JOB_IGNDOTS, job)) { case JOB_RUNNING: done = FALSE; @@ -1081,13 +1080,13 @@ Job_CheckCommands(gn, abortProc) void (*abortProc) __P((char *, ...)); /* Function to abort with message */ { - 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)) { /* * Make only looks for a .DEFAULT if the node was never the * target of an operator, so that's what we do too. If @@ -1325,7 +1324,7 @@ jobExecFinish: * 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; } @@ -1460,7 +1459,7 @@ JobRestart(job) (void) fprintf(stdout, "*** holding\n"); (void) fflush(stdout); } - Lst_AtFront(stoppedJobs, job); + Lst_AtFront(&stoppedJobs, job); jobFull = TRUE; if (DEBUG(JOB)) { (void) fprintf(stdout, "Job queue is full.\n"); @@ -1481,7 +1480,7 @@ JobRestart(job) } #endif - Lst_AtEnd(jobs, job); + Lst_AtEnd(&jobs, job); nJobs += 1; if (nJobs == maxJobs) { jobFull = TRUE; @@ -1526,7 +1525,7 @@ JobRestart(job) (void) fprintf(stdout, "holding\n"); (void) fflush(stdout); } - Lst_AtFront(stoppedJobs, job); + Lst_AtFront(&stoppedJobs, job); jobFull = TRUE; if (DEBUG(JOB)) { (void) fprintf(stdout, "Job queue is full.\n"); @@ -1625,7 +1624,7 @@ JobRestart(job) (void) fprintf(stdout, "table full\n"); (void) fflush(stdout); } - Lst_AtFront(stoppedJobs, job); + Lst_AtFront(&stoppedJobs, job); jobFull = TRUE; if (DEBUG(JOB)) { (void) fprintf(stdout, "Job queue is full.\n"); @@ -1748,14 +1747,14 @@ JobStart(gn, flags, previous) * and print it to the command file. If the command was an * ellipsis, note that there's nothing more to execute. */ - if ((job->flags&JOB_FIRST) && (Lst_Open(gn->commands) != SUCCESS)){ + if ((job->flags&JOB_FIRST) && (Lst_Open(&gn->commands) != SUCCESS)){ cmdsOK = FALSE; } else { - LstNode ln = Lst_Next(gn->commands); + LstNode ln = Lst_Next(&gn->commands); if ((ln == NULL) || !JobPrintCommand(Lst_Datum(ln), job)) { noExec = TRUE; - Lst_Close(gn->commands); + Lst_Close(&gn->commands); } if (noExec && !(job->flags & JOB_FIRST)) { /* @@ -1777,7 +1776,7 @@ JobStart(gn, flags, previous) * We can do all the commands at once. hooray for sanity */ numCommands = 0; - Lst_Find(gn->commands, JobPrintCommand, job); + Lst_Find(&gn->commands, JobPrintCommand, job); /* * If we didn't print out any commands to the shell script, @@ -1803,7 +1802,7 @@ JobStart(gn, flags, previous) * doesn't do any harm in this case and may do some good. */ if (cmdsOK) - Lst_Find(gn->commands, JobPrintCommand, job); + Lst_Find(&gn->commands, JobPrintCommand, job); /* * Don't execute the shell, thank you. */ @@ -1922,7 +1921,7 @@ JobStart(gn, flags, previous) (void) fflush(stdout); } job->flags |= JOB_RESTART; - Lst_AtEnd(stoppedJobs, job); + Lst_AtEnd(&stoppedJobs, job); } else { if ((nLocal >= maxLocal) && local) { /* @@ -2234,24 +2233,24 @@ Job_CatchChildren(block) } - jnode = Lst_Find(jobs, JobCmpPid, &pid); + jnode = Lst_Find(&jobs, JobCmpPid, &pid); if (jnode == NULL) { if (WIFSIGNALED(status) && (WTERMSIG(status) == SIGCONT)) { - jnode = Lst_Find(stoppedJobs, JobCmpPid, &pid); + jnode = Lst_Find(&stoppedJobs, JobCmpPid, &pid); if (jnode == NULL) { Error("Resumed child (%d) not in table", pid); continue; } job = (Job *)Lst_Datum(jnode); - (void) Lst_Remove(stoppedJobs, jnode); + Lst_Remove(&stoppedJobs, jnode); } else { Error("Child (%d) not in table?", pid); continue; } } else { job = (Job *) Lst_Datum(jnode); - Lst_Remove(jobs, jnode); + Lst_Remove(&jobs, jnode); nJobs -= 1; if (jobFull && DEBUG(JOB)) { (void) fprintf(stdout, "Job queue is no longer full.\n"); @@ -2342,18 +2341,18 @@ Job_CatchOutput() free(readfdsp); return; } else { - if (Lst_Open(jobs) == FAILURE) { + if (Lst_Open(&jobs) == FAILURE) { free(readfdsp); Punt("Cannot open job table"); } - while (nfds && (ln = Lst_Next(jobs)) != NULL) { + while (nfds && (ln = Lst_Next(&jobs)) != NULL) { job = (Job *) Lst_Datum(ln); if (FD_ISSET(job->inPipe, readfdsp)) { JobDoOutput(job, FALSE); nfds -= 1; } } - Lst_Close(jobs); + Lst_Close(&jobs); } free(readfdsp); } @@ -2402,8 +2401,8 @@ Job_Init(maxproc, maxlocal) { GNode *begin; /* node for commands to do at the very start */ - jobs = Lst_Init(); - stoppedJobs = Lst_Init(); + Lst_Init(&jobs); + Lst_Init(&stoppedJobs); maxJobs = maxproc; maxLocal = maxlocal; nJobs = 0; @@ -2539,7 +2538,7 @@ Boolean Job_Empty() { 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. @@ -2790,8 +2789,8 @@ JobInterrupt(runINTERRUPT, signo) aborting = ABORT_INTERRUPT; - (void) Lst_Open(jobs); - while ((ln = Lst_Next(jobs)) != NULL) { + (void) Lst_Open(&jobs); + while ((ln = Lst_Next(&jobs)) != NULL) { job = (Job *) Lst_Datum(ln); if (!Targ_Precious(job->node)) { @@ -2835,8 +2834,8 @@ JobInterrupt(runINTERRUPT, signo) } #ifdef REMOTE - (void)Lst_Open(stoppedJobs); - while ((ln = Lst_Next(stoppedJobs)) != NULL) { + (void)Lst_Open(&stoppedJobs); + while ((ln = Lst_Next(&stoppedJobs)) != NULL) { job = (Job *) Lst_Datum(ln); if (job->flags & JOB_RESTART) { @@ -2893,7 +2892,7 @@ JobInterrupt(runINTERRUPT, signo) #endif /* RMT_WANTS_SIGNALS */ } #endif - Lst_Close(stoppedJobs); + Lst_Close(&stoppedJobs); if (runINTERRUPT && !touchFlag) { interrupt = Targ_FindNode(".INTERRUPT", TARG_NOCREATE); @@ -2925,7 +2924,7 @@ JobInterrupt(runINTERRUPT, signo) int Job_Finish() { - if (postCommands != NULL && !Lst_IsEmpty(postCommands->commands)) { + if (postCommands != NULL && !Lst_IsEmpty(&postCommands->commands)) { if (errors) { Error("Errors reported so .END ignored"); } else { @@ -3014,8 +3013,8 @@ Job_AbortAll() if (nJobs) { - (void) Lst_Open(jobs); - while ((ln = Lst_Next(jobs)) != NULL) { + (void) Lst_Open(&jobs); + while ((ln = Lst_Next(&jobs)) != NULL) { job = (Job *) Lst_Datum(ln); /* @@ -3070,10 +3069,10 @@ JobFlagForMigration(hostID) (void) fprintf(stdout, "JobFlagForMigration(%d) called.\n", hostID); (void) fflush(stdout); } - jnode = Lst_Find(jobs, JobCmpRmtID, &hostID); + jnode = Lst_Find(&jobs, JobCmpRmtID, &hostID); if (jnode == NULL) { - jnode = Lst_Find(stoppedJobs, JobCmpRmtID, &hostID); + jnode = Lst_Find(&stoppedJobs, JobCmpRmtID, &hostID); if (jnode == NULL) { if (DEBUG(JOB)) { Error("Evicting host(%d) not in table", hostID); @@ -3117,7 +3116,7 @@ JobRestartJobs() { Job *job; - while (!jobFull && (job = (Job *)Lst_DeQueue(stoppedJobs)) != NULL) { + while (!jobFull && (job = (Job *)Lst_DeQueue(&stoppedJobs)) != NULL) { if (DEBUG(JOB)) { (void) fprintf(stdout, "Job queue is not full. Restarting a stopped job.\n"); diff --git a/usr.bin/make/job.h b/usr.bin/make/job.h index 9fe3af337e3..07955d14492 100644 --- a/usr.bin/make/job.h +++ b/usr.bin/make/job.h @@ -1,4 +1,4 @@ -/* $OpenBSD: job.h,v 1.6 1999/12/18 21:53:32 espie Exp $ */ +/* $OpenBSD: job.h,v 1.7 2000/06/17 14:38:17 espie Exp $ */ /* $NetBSD: job.h,v 1.5 1996/11/06 17:59:10 christos Exp $ */ /* @@ -213,8 +213,8 @@ extern GNode *lastNode; /* Last node for which a banner was printed. * for which the banner was printed */ extern int nJobs; /* Number of jobs running (local and remote) */ extern int nLocal; /* Number of jobs running locally */ -extern Lst jobs; /* List of active job descriptors */ -extern Lst stoppedJobs; /* List of jobs that are stopped or didn't +extern LIST jobs; /* List of active job descriptors */ +extern LIST stoppedJobs; /* List of jobs that are stopped or didn't * quite get started */ extern Boolean jobFull; /* Non-zero if no more jobs should/will start*/ diff --git a/usr.bin/make/lst.h b/usr.bin/make/lst.h index 4dd6613d4f3..f914452de58 100644 --- a/usr.bin/make/lst.h +++ b/usr.bin/make/lst.h @@ -1,4 +1,4 @@ -/* $OpenBSD: lst.h,v 1.14 2000/06/17 14:34:04 espie Exp $ */ +/* $OpenBSD: lst.h,v 1.15 2000/06/17 14:38:17 espie Exp $ */ /* $NetBSD: lst.h,v 1.7 1996/11/06 17:59:12 christos Exp $ */ /* @@ -109,12 +109,16 @@ typedef void * (*DuplicateProc) __P((void *)); /* * Creation/destruction functions */ +/* CTOR/DTOR, ala C++ */ +void Lst_Init __P((Lst)); +void Lst_Destroy __P((Lst, SimpleProc)); + /* Create a new list */ -Lst Lst_Init __P((void)); +Lst Lst_New __P((void)); +/* Destroy an old one */ +void Lst_Delete __P((Lst, SimpleProc)); /* Duplicate an existing list */ Lst Lst_Duplicate __P((Lst, DuplicateProc)); -/* Destroy an old one */ -void Lst_Destroy __P((Lst, SimpleProc)); /* True if list is empty */ Boolean Lst_IsEmpty __P((Lst)); diff --git a/usr.bin/make/lst.lib/lstDestroy.c b/usr.bin/make/lst.lib/lstDestroy.c index 74f285ea40e..e584fb16834 100644 --- a/usr.bin/make/lst.lib/lstDestroy.c +++ b/usr.bin/make/lst.lib/lstDestroy.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lstDestroy.c,v 1.8 2000/06/17 14:34:07 espie Exp $ */ +/* $OpenBSD: lstDestroy.c,v 1.9 2000/06/17 14:38:21 espie Exp $ */ /* $NetBSD: lstDestroy.c,v 1.6 1996/11/06 17:59:37 christos Exp $ */ /* @@ -41,7 +41,7 @@ #if 0 static char sccsid[] = "@(#)lstDestroy.c 8.1 (Berkeley) 6/6/93"; #else -static char rcsid[] = "$OpenBSD: lstDestroy.c,v 1.8 2000/06/17 14:34:07 espie Exp $"; +static char rcsid[] = "$OpenBSD: lstDestroy.c,v 1.9 2000/06/17 14:38:21 espie Exp $"; #endif #endif /* not lint */ @@ -52,6 +52,16 @@ static char rcsid[] = "$OpenBSD: lstDestroy.c,v 1.8 2000/06/17 14:34:07 espie Ex #include "lstInt.h" +void +Lst_Delete(l, freeProc) + Lst l; + SimpleProc freeProc; +{ + if (l != NULL) + Lst_Destroy(l, freeProc); + free(l); +} + /*- *----------------------------------------------------------------------- * Lst_Destroy -- @@ -59,9 +69,6 @@ static char rcsid[] = "$OpenBSD: lstDestroy.c,v 1.8 2000/06/17 14:34:07 espie Ex * given, it is called with the datum from each node in turn before * the node is freed. * - * Results: - * None. - * * Side Effects: * The given list is freed in its entirety. * @@ -75,9 +82,6 @@ Lst_Destroy(l, freeProc) LstNode ln; LstNode tln; - if (l == NULL) - return; - if (freeProc) { for (ln = l->firstPtr; ln != NULL; ln = tln) { tln = ln->nextPtr; @@ -90,6 +94,4 @@ Lst_Destroy(l, freeProc) free(ln); } } - - free(l); } diff --git a/usr.bin/make/lst.lib/lstDupl.c b/usr.bin/make/lst.lib/lstDupl.c index 30a1e135d89..349c8657226 100644 --- a/usr.bin/make/lst.lib/lstDupl.c +++ b/usr.bin/make/lst.lib/lstDupl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lstDupl.c,v 1.10 2000/06/17 14:34:07 espie Exp $ */ +/* $OpenBSD: lstDupl.c,v 1.11 2000/06/17 14:38:22 espie Exp $ */ /* $NetBSD: lstDupl.c,v 1.6 1996/11/06 17:59:37 christos Exp $ */ /* @@ -41,7 +41,7 @@ #if 0 static char sccsid[] = "@(#)lstDupl.c 8.1 (Berkeley) 6/6/93"; #else -static char rcsid[] = "$OpenBSD: lstDupl.c,v 1.10 2000/06/17 14:34:07 espie Exp $"; +static char rcsid[] = "$OpenBSD: lstDupl.c,v 1.11 2000/06/17 14:38:22 espie Exp $"; #endif #endif /* not lint */ @@ -74,11 +74,10 @@ Lst_Duplicate(l, copyProc) Lst nl; LstNode ln; - if (!LstValid (l)) { - return (NULL); - } + if (!LstValid(l)) + return NULL; - nl = Lst_Init(); + nl = Lst_New(); if (nl == NULL) return NULL; @@ -89,5 +88,5 @@ Lst_Duplicate(l, copyProc) Lst_AtEnd(nl, ln->datum); } - return (nl); + return nl; } diff --git a/usr.bin/make/lst.lib/lstInit.c b/usr.bin/make/lst.lib/lstInit.c index 8c5ddbac253..1497be9b03d 100644 --- a/usr.bin/make/lst.lib/lstInit.c +++ b/usr.bin/make/lst.lib/lstInit.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lstInit.c,v 1.7 2000/06/17 14:34:08 espie Exp $ */ +/* $OpenBSD: lstInit.c,v 1.8 2000/06/17 14:38:22 espie Exp $ */ /* $NetBSD: lstInit.c,v 1.5 1996/11/06 17:59:43 christos Exp $ */ /* @@ -41,7 +41,7 @@ #if 0 static char sccsid[] = "@(#)lstInit.c 8.1 (Berkeley) 6/6/93"; #else -static char rcsid[] = "$OpenBSD: lstInit.c,v 1.7 2000/06/17 14:34:08 espie Exp $"; +static char rcsid[] = "$OpenBSD: lstInit.c,v 1.8 2000/06/17 14:38:22 espie Exp $"; #endif #endif /* not lint */ @@ -54,28 +54,32 @@ static char rcsid[] = "$OpenBSD: lstInit.c,v 1.7 2000/06/17 14:34:08 espie Exp $ /*- *----------------------------------------------------------------------- - * Lst_Init -- + * Lst_New -- * Create and initialize a new list. - * - * Results: - * The created list. - * - * Side Effects: - * A list is created, what else? - * *----------------------------------------------------------------------- */ Lst -Lst_Init() +Lst_New() { register Lst nList; PAlloc(nList, Lst); - - nList->firstPtr = NULL; - nList->lastPtr = NULL; - nList->isOpen = FALSE; - nList->atEnd = Unknown; + Lst_Init(nList); return nList; } +/*- + *----------------------------------------------------------------------- + * Lst_Init -- + * Initialize a new list. + *----------------------------------------------------------------------- + */ +void +Lst_Init(l) + Lst l; +{ + l->firstPtr = NULL; + l->lastPtr = NULL; + l->isOpen = FALSE; + l->atEnd = Unknown; +} diff --git a/usr.bin/make/main.c b/usr.bin/make/main.c index 25745f2e59f..6ef4c6da020 100644 --- a/usr.bin/make/main.c +++ b/usr.bin/make/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.32 2000/06/10 01:41:05 espie Exp $ */ +/* $OpenBSD: main.c,v 1.33 2000/06/17 14:38:18 espie Exp $ */ /* $NetBSD: main.c,v 1.34 1997/03/24 20:56:36 gwr Exp $ */ /* @@ -49,7 +49,7 @@ static char copyright[] = #if 0 static char sccsid[] = "@(#)main.c 8.3 (Berkeley) 3/19/94"; #else -static char rcsid[] = "$OpenBSD: main.c,v 1.32 2000/06/10 01:41:05 espie Exp $"; +static char rcsid[] = "$OpenBSD: main.c,v 1.33 2000/06/17 14:38:18 espie Exp $"; #endif #endif /* not lint */ @@ -112,15 +112,15 @@ static char rcsid[] = "$OpenBSD: main.c,v 1.32 2000/06/10 01:41:05 espie Exp $"; #define MAKEFLAGS ".MAKEFLAGS" -Lst create; /* Targets to be made */ +LIST create; /* Targets to be made */ time_t now = OUT_OF_DATE;/* 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 */ +static LIST makefiles; /* ordered list of makefiles to read */ static Boolean printVars; /* print value of one or more vars */ -static Lst variables; /* list of variables to print */ +static LIST variables; /* list of variables to print */ int maxJobs; /* -j argument */ static int maxLocal; /* -L argument */ Boolean compatMake; /* -B argument */ @@ -189,7 +189,7 @@ rearg: while((c = getopt(argc, argv, OPTFLAGS)) != -1) { break; case 'V': printVars = TRUE; - Lst_AtEnd(variables, optarg); + Lst_AtEnd(&variables, optarg); Var_Append(MAKEFLAGS, "-V", VAR_GLOBAL); Var_Append(MAKEFLAGS, optarg, VAR_GLOBAL); break; @@ -280,7 +280,7 @@ rearg: while((c = getopt(argc, argv, OPTFLAGS)) != -1) { Var_Append(MAKEFLAGS, "-e", VAR_GLOBAL); break; case 'f': - Lst_AtEnd(makefiles, optarg); + Lst_AtEnd(&makefiles, optarg); break; case 'i': ignoreErrors = TRUE; @@ -310,7 +310,7 @@ rearg: while((c = getopt(argc, argv, OPTFLAGS)) != -1) { Var_Append(MAKEFLAGS, "-k", VAR_GLOBAL); break; case 'm': - Dir_AddDir(sysIncPath, optarg); + Dir_AddDir(&sysIncPath, optarg); Var_Append(MAKEFLAGS, "-m", VAR_GLOBAL); Var_Append(MAKEFLAGS, optarg, VAR_GLOBAL); break; @@ -371,7 +371,7 @@ rearg: while((c = getopt(argc, argv, OPTFLAGS)) != -1) { optind = 1; /* - */ goto rearg; } - Lst_AtEnd(create, estrdup(*argv)); + Lst_AtEnd(&create, estrdup(*argv)); } } @@ -477,7 +477,6 @@ main(argc, argv) char cdpath[MAXPATHLEN + 1]; char *machine = getenv("MACHINE"); char *machine_arch = getenv("MACHINE_ARCH"); - Lst sysMkPath; /* Path of sys.mk */ char *cp = NULL, *start; /* avoid faults on read-only strings */ static char syspath[] = _PATH_DEFSYSPATH; @@ -588,10 +587,10 @@ main(argc, argv) setenv("PWD", objdir, 1); unsetenv("CDPATH"); - create = Lst_Init(); - makefiles = Lst_Init(); + Lst_Init(&create); + Lst_Init(&makefiles); printVars = FALSE; - variables = Lst_Init(); + Lst_Init(&variables); beSilent = FALSE; /* Print commands as executed */ ignoreErrors = FALSE; /* Pay attention to non-zero returns */ noExecute = FALSE; /* Execute all commands */ @@ -625,7 +624,7 @@ main(argc, argv) Var_Init(); /* As well as the lists of variables for * parsing arguments */ if (objdir != curdir) - Dir_AddDir(dirSearchPath, curdir); + Dir_AddDir(&dirSearchPath, curdir); Var_Set(".CURDIR", curdir, VAR_GLOBAL); Var_Set(".OBJDIR", objdir, VAR_GLOBAL); @@ -672,10 +671,10 @@ main(argc, 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; + for (ln = Lst_First(&create); ln != NULL; ln = Lst_Succ(ln)) { char *name = (char *)Lst_Datum(ln); @@ -690,15 +689,15 @@ main(argc, 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); } } } @@ -710,20 +709,21 @@ main(argc, argv) */ if (!noBuiltins) { LstNode ln; + LIST sysMkPath; /* Path of sys.mk */ - sysMkPath = Lst_Init(); - Dir_Expand (_PATH_DEFSYSMK, sysIncPath, sysMkPath); - if (Lst_IsEmpty(sysMkPath)) + Lst_Init(&sysMkPath); + Dir_Expand(_PATH_DEFSYSMK, &sysIncPath, &sysMkPath); + if (Lst_IsEmpty(&sysMkPath)) Fatal("make: no system rules (%s).", _PATH_DEFSYSMK); - ln = Lst_Find(sysMkPath, ReadMakefile, NULL); + ln = Lst_Find(&sysMkPath, ReadMakefile, NULL); if (ln != NULL) Fatal("make: cannot open %s.", (char *)Lst_Datum(ln)); } - if (!Lst_IsEmpty(makefiles)) { + if (!Lst_IsEmpty(&makefiles)) { LstNode ln; - ln = Lst_Find(makefiles, ReadMakefile, NULL); + ln = Lst_Find(&makefiles, ReadMakefile, NULL); if (ln != NULL) Fatal("make: cannot open %s.", (char *)Lst_Datum(ln)); } else if (!ReadMakefile("BSDmakefile", NULL)) @@ -767,7 +767,7 @@ main(argc, 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 == ':'); @@ -788,7 +788,7 @@ main(argc, argv) if (printVars) { LstNode ln; - for (ln = Lst_First(variables); ln != NULL; + for (ln = Lst_First(&variables); ln != NULL; ln = Lst_Succ(ln)) { char *value = Var_Value((char *)Lst_Datum(ln), VAR_GLOBAL); @@ -802,10 +802,10 @@ main(argc, 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)) + if (Lst_IsEmpty(&create)) targs = Parse_MainName(); else - targs = Targ_FindList(create, TARG_CREATE); + targs = Targ_FindList(&create, TARG_CREATE); if (!compatMake && !printVars) { /* @@ -831,10 +831,10 @@ main(argc, argv) Compat_Run(targs); } - Lst_Destroy(targs, NOFREE); - Lst_Destroy(variables, NOFREE); - Lst_Destroy(makefiles, NOFREE); - Lst_Destroy(create, (SimpleProc)free); + Lst_Delete(targs, NOFREE); + Lst_Destroy(&variables, NOFREE); + Lst_Destroy(&makefiles, NOFREE); + Lst_Destroy(&create, (SimpleProc)free); /* print the graph now it's been processed if the user requested it */ if (DEBUG(GRAPH2)) @@ -870,7 +870,7 @@ ReadMakefile(p, q) void *q; { char *fname = p; /* makefile to read */ - extern Lst parseIncPath; + extern LIST parseIncPath; FILE *stream; char *name, path[MAXPATHLEN + 1]; @@ -889,9 +889,9 @@ ReadMakefile(p, q) } } /* 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); fname = name; diff --git a/usr.bin/make/make.c b/usr.bin/make/make.c index fd8bfec8ddb..ca8032f76af 100644 --- a/usr.bin/make/make.c +++ b/usr.bin/make/make.c @@ -1,4 +1,4 @@ -/* $OpenBSD: make.c,v 1.16 2000/06/10 01:41:05 espie Exp $ */ +/* $OpenBSD: make.c,v 1.17 2000/06/17 14:38:18 espie Exp $ */ /* $NetBSD: make.c,v 1.10 1996/11/06 17:59:15 christos Exp $ */ /* @@ -43,7 +43,7 @@ #if 0 static char sccsid[] = "@(#)make.c 8.1 (Berkeley) 6/6/93"; #else -static char rcsid[] = "$OpenBSD: make.c,v 1.16 2000/06/10 01:41:05 espie Exp $"; +static char rcsid[] = "$OpenBSD: make.c,v 1.17 2000/06/17 14:38:18 espie Exp $"; #endif #endif /* not lint */ @@ -84,7 +84,7 @@ static char rcsid[] = "$OpenBSD: make.c,v 1.16 2000/06/10 01:41:05 espie Exp $"; #include "dir.h" #include "job.h" -static Lst toBeMade; /* The current fringe of the graph. These +static LIST 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 @@ -268,7 +268,7 @@ Make_OODate (gn) * thinking they're out-of-date. */ if (!oodate) - Lst_ForEach(gn->parents, MakeTimeStamp, gn); + Lst_ForEach(&gn->parents, MakeTimeStamp, gn); return (oodate); } @@ -324,25 +324,25 @@ Make_HandleUse(cgn, 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); } - if (Lst_Open (cgn->children) == SUCCESS) { - while ((ln = Lst_Next (cgn->children)) != NULL) { + if (Lst_Open(&cgn->children) == SUCCESS) { + while ((ln = Lst_Next(&cgn->children)) != NULL) { gn = (GNode *)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; } } - Lst_Close (cgn->children); + Lst_Close(&cgn->children); } pgn->type |= cgn->type & ~(OP_OPMASK|OP_USE|OP_TRANSFORM); @@ -433,7 +433,7 @@ Make_Update (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 @@ -469,8 +469,8 @@ Make_Update (cgn) #endif } - if (Lst_Open (cgn->parents) == SUCCESS) { - while ((ln = Lst_Next (cgn->parents)) != NULL) { + if (Lst_Open(&cgn->parents) == SUCCESS) { + while ((ln = Lst_Next(&cgn->parents)) != NULL) { pgn = (GNode *)Lst_Datum (ln); if (pgn->make) { pgn->unmade -= 1; @@ -490,13 +490,13 @@ Make_Update (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); } } } - Lst_Close (cgn->parents); + Lst_Close(&cgn->parents); } /* * Deal with successor nodes. If any is marked for making and has an unmade @@ -504,31 +504,29 @@ Make_Update (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 = (GNode *)Lst_Datum(ln); if (succ->make && succ->unmade == 0 && succ->made == UNMADE && - Lst_Member(toBeMade, succ) == NULL) - { - Lst_EnQueue(toBeMade, succ); - } + Lst_Member(&toBeMade, succ) == NULL) + Lst_EnQueue(&toBeMade, succ); } /* * Set the .PREFIX and .IMPSRC variables for all the implied parents * of this node. */ - if (Lst_Open (cgn->iParents) == SUCCESS) { + if (Lst_Open(&cgn->iParents) == SUCCESS) { char *cpref = Var_Value(PREFIX, cgn); - while ((ln = Lst_Next (cgn->iParents)) != NULL) { + while ((ln = Lst_Next(&cgn->iParents)) != NULL) { pgn = (GNode *)Lst_Datum (ln); if (pgn->make) { Var_Set (IMPSRC, cname, pgn); Var_Set (PREFIX, cpref, pgn); } } - Lst_Close (cgn->iParents); + Lst_Close(&cgn->iParents); } } @@ -623,7 +621,7 @@ void Make_DoAllVar (gn) GNode *gn; { - Lst_ForEach(gn->children, MakeAddAllSrc, gn); + Lst_ForEach(&gn->children, MakeAddAllSrc, gn); if (!Var_Exists (OODATE, gn)) { Var_Set (OODATE, "", gn); @@ -657,7 +655,7 @@ MakeStartJobs () { register GNode *gn; - while (!Job_Full() && (gn = (GNode *)Lst_DeQueue(toBeMade)) != NULL) { + while (!Job_Full() && (gn = (GNode *)Lst_DeQueue(&toBeMade)) != NULL) { if (DEBUG(MAKE)) { printf ("Examining %s...", gn->name); } @@ -665,10 +663,10 @@ MakeStartJobs () * 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 = (GNode *)Lst_Datum(ln); if (pgn->make && pgn->made == UNMADE) { @@ -755,11 +753,11 @@ MakePrintStatus(gnp, 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); @@ -790,14 +788,14 @@ MakePrintStatus(gnp, cyclep) *----------------------------------------------------------------------- */ Boolean -Make_Run (targs) +Make_Run(targs) Lst targs; /* the initial list of targets */ { register GNode *gn; /* a temporary pointer */ register Lst examine; /* List of targets to examine */ int errors; /* Number of errors the Job module reports */ - toBeMade = Lst_Init(); + Lst_Init(&toBeMade); examine = Lst_Duplicate(targs, NOCOPY); numNodes = 0; @@ -820,18 +818,18 @@ Make_Run (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); + Lst_Delete(examine, NOFREE); if (queryFlag) { /* diff --git a/usr.bin/make/make.h b/usr.bin/make/make.h index c7e3e82d5f1..097ebbf5f37 100644 --- a/usr.bin/make/make.h +++ b/usr.bin/make/make.h @@ -1,4 +1,4 @@ -/* $OpenBSD: make.h,v 1.18 2000/04/17 23:54:47 espie Exp $ */ +/* $OpenBSD: make.h,v 1.19 2000/06/17 14:38:18 espie Exp $ */ /* $NetBSD: make.h,v 1.15 1997/03/10 21:20:00 christos Exp $ */ /* @@ -152,18 +152,18 @@ typedef struct GNode { time_t cmtime; /* The modification time of its youngest * child */ - Lst iParents; /* Links to parents for which this is an + LIST 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 */ + LIST cohorts; /* Other nodes for the :: operator */ + LIST parents; /* Nodes that depend on this one */ + LIST children; /* Nodes on which this one depends */ + LIST successors; /* Nodes that must be made after this one */ + LIST preds; /* Nodes that must be made before this one */ - Lst context; /* The local variables */ + LIST context; /* The local variables */ unsigned long lineno; /* First line number of commands. */ const char * fname; /* File name of commands. */ - Lst commands; /* Creation commands */ + LIST commands; /* Creation commands */ struct _Suff *suffix; /* Suffix for the node (determined by * Suff_FindDeps and opaque to everyone @@ -306,10 +306,10 @@ typedef struct GNode { /* * Global Variables */ -extern Lst create; /* The list of target names specified on the +extern LIST 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 +extern LIST dirSearchPath; /* The list of directories to search when * looking for targets */ extern Boolean compatMake; /* True if we are make compatible */ @@ -348,7 +348,7 @@ 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. */ +extern LIST sysIncPath; /* The system include path. */ /* * debug control: diff --git a/usr.bin/make/parse.c b/usr.bin/make/parse.c index e471f28574a..339bb4ea157 100644 --- a/usr.bin/make/parse.c +++ b/usr.bin/make/parse.c @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.c,v 1.42 2000/06/10 01:41:06 espie Exp $ */ +/* $OpenBSD: parse.c,v 1.43 2000/06/17 14:38:18 espie Exp $ */ /* $NetBSD: parse.c,v 1.29 1997/03/10 21:20:04 christos Exp $ */ /* @@ -43,7 +43,7 @@ #if 0 static char sccsid[] = "@(#)parse.c 8.3 (Berkeley) 3/19/94"; #else -static char rcsid[] = "$OpenBSD: parse.c,v 1.42 2000/06/10 01:41:06 espie Exp $"; +static char rcsid[] = "$OpenBSD: parse.c,v 1.43 2000/06/17 14:38:18 espie Exp $"; #endif #endif /* not lint */ @@ -105,7 +105,7 @@ static char rcsid[] = "$OpenBSD: parse.c,v 1.42 2000/06/10 01:41:06 espie Exp $" #include "pathnames.h" #ifdef CLEANUP -static Lst fileNames; /* file names to free at end */ +static LIST fileNames; /* file names to free at end */ #endif /* @@ -117,7 +117,7 @@ static Lst fileNames; /* file names to free at end */ #define DONE 0 static Lst targets; /* targets we're working on */ #ifdef CLEANUP -static Lst targCmds; /* command lines for targets */ +static LIST targCmds; /* command lines for targets */ #endif static Boolean inLine; /* true if currently in a dependency * line or its commands */ @@ -147,10 +147,10 @@ typedef struct IFile { PTR *p; /* the char pointer */ } IFile; -static Lst includes; /* stack of IFiles generated by +static LIST includes; /* stack of IFiles generated by * #includes */ -Lst parseIncPath; /* list of directories for "..." includes */ -Lst sysIncPath; /* list of directories for <...> includes */ +LIST parseIncPath; /* list of directories for "..." includes */ +LIST sysIncPath; /* list of directories for <...> includes */ /*- * specType contains the SPECial TYPE of the current target. It is @@ -435,10 +435,10 @@ ParseLinkSrc(pgnp, cgnp) { GNode *pgn = (GNode *)pgnp; GNode *cgn = (GNode *)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; } } @@ -500,9 +500,9 @@ ParseDoOp (gnp, 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 @@ -550,8 +550,8 @@ ParseAddDep(pp, 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 1; } else @@ -610,7 +610,7 @@ ParseDoSrc (tOp, src, 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. @@ -625,8 +625,8 @@ ParseDoSrc (tOp, src, 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. @@ -656,7 +656,7 @@ ParseDoSrc (tOp, src, allsrc) register GNode *cohort; register 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 = (GNode *)Lst_Datum(ln); if (tOp) { cohort->type |= tOp; @@ -784,11 +784,9 @@ ParseDoDependency (line) Lst paths; /* List of 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 + LIST curTargs; /* list of target names to be found and added * to the targets list */ - Lst curSrcs; /* list of sources in order */ + LIST curSrcs; /* list of sources in order */ tOp = 0; @@ -796,8 +794,8 @@ ParseDoDependency (line) waiting = 0; paths = (Lst)NULL; - curTargs = Lst_Init(); - curSrcs = Lst_Init(); + Lst_Init(&curTargs); + Lst_Init(&curSrcs); do { for (cp = line; @@ -929,13 +927,12 @@ ParseDoDependency (line) */ switch (specType) { case ExPath: - if (paths == NULL) { - paths = Lst_Init(); - } - Lst_AtEnd(paths, dirSearchPath); + if (paths == NULL) + paths = Lst_New(); + Lst_AtEnd(paths, &dirSearchPath); break; case Main: - if (!Lst_IsEmpty(create)) { + if (!Lst_IsEmpty(&create)) { specType = Not; } break; @@ -984,9 +981,8 @@ ParseDoDependency (line) &line[5]); return; } else { - if (paths == NULL) { - paths = Lst_Init(); - } + if (paths == NULL) + paths = Lst_New(); Lst_AtEnd(paths, path); } } @@ -1006,20 +1002,22 @@ ParseDoDependency (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(); + LIST emptyPath; + + Lst_Init(&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((targName = (char *)Lst_DeQueue(curTargs)) != NULL) { + while((targName = (char *)Lst_DeQueue(&curTargs)) != NULL) { if (!Suff_IsTransform (targName)) { gn = Targ_FindNode (targName, TARG_CREATE); } else { @@ -1058,10 +1056,8 @@ ParseDoDependency (line) line = cp; } while ((*line != '!') && (*line != ':') && *line); - /* - * Don't need the list of target names anymore... - */ - Lst_Destroy(curTargs, NOFREE); + /* Don't need the list of target names any more */ + Lst_Destroy(&curTargs, NOFREE); if (!Lst_IsEmpty(targets)) { switch(specType) { @@ -1227,9 +1223,8 @@ ParseDoDependency (line) } line = cp; } - if (paths) { - Lst_Destroy(paths, NOFREE); - } + if (paths) + Lst_Delete(paths, NOFREE); } else { while (*line) { /* @@ -1253,17 +1248,19 @@ ParseDoDependency (line) if (*cp == '(') { GNode *gn; + LIST sources; /* list of archive source names after + * expansion */ - sources = Lst_Init(); - if (Arch_ParseArchive (&line, sources, VAR_CMD) != SUCCESS) { + Lst_Init(&sources); + if (Arch_ParseArchive(&line, &sources, VAR_CMD) != SUCCESS) { Parse_Error (PARSE_FATAL, "Error in source archive spec \"%s\"", line); return; } - while ((gn = (GNode *)Lst_DeQueue(sources)) != NULL) - ParseDoSrc(tOp, gn->name, curSrcs); - Lst_Destroy(sources, NOFREE); + while ((gn = (GNode *)Lst_DeQueue(&sources)) != NULL) + ParseDoSrc(tOp, gn->name, &curSrcs); + Lst_Destroy(&sources, NOFREE); cp = line; } else { if (*cp) { @@ -1271,7 +1268,7 @@ ParseDoDependency (line) cp += 1; } - ParseDoSrc (tOp, line, curSrcs); + ParseDoSrc(tOp, line, &curSrcs); } while (*cp && isspace (*cp)) { cp++; @@ -1290,10 +1287,8 @@ ParseDoDependency (line) Lst_Find(targets, ParseFindMain, NULL); } - /* - * Finally, destroy the list of sources - */ - Lst_Destroy(curSrcs, NOFREE); + /* Finally, destroy the list of sources. */ + Lst_Destroy(&curSrcs, NOFREE); } /*- @@ -1574,7 +1569,7 @@ ParseAddCmd(gnp, cmd) GNode *gn = (GNode *)gnp; /* if target already supplied, ignore commands */ if (!(gn->type & OP_HAS_COMMANDS)) { - Lst_AtEnd(gn->commands, cmd); + Lst_AtEnd(&gn->commands, cmd); if (!gn->lineno) { gn->lineno = Parse_Getlineno(); gn->fname = Parse_Getfilename(); @@ -1603,7 +1598,7 @@ ParseHasCommands(gnp) void *gnp; /* Node to examine */ { GNode *gn = (GNode *) gnp; - if (!Lst_IsEmpty(gn->commands)) { + if (!Lst_IsEmpty(&gn->commands)) { gn->type |= OP_HAS_COMMANDS; } } @@ -1623,10 +1618,10 @@ ParseHasCommands(gnp) *----------------------------------------------------------------------- */ void -Parse_AddIncludeDir (dir) +Parse_AddIncludeDir(dir) char *dir; /* The name of the directory to add */ { - Dir_AddDir (parseIncPath, dir); + Dir_AddDir(&parseIncPath, dir); } /*- @@ -1731,9 +1726,9 @@ ParseDoInclude (file) newName = estrdup(file); else newName = str_concat (Fname, file, STR_ADDSLASH); - fullname = Dir_FindFile (newName, parseIncPath); + fullname = Dir_FindFile(newName, &parseIncPath); if (fullname == (char *)NULL) { - fullname = Dir_FindFile(newName, dirSearchPath); + fullname = Dir_FindFile(newName, &dirSearchPath); } free (newName); *prefEnd = '/'; @@ -1752,9 +1747,9 @@ ParseDoInclude (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 == (char *)NULL) { - fullname = Dir_FindFile(file, dirSearchPath); + fullname = Dir_FindFile(file, &dirSearchPath); } } @@ -1763,7 +1758,7 @@ ParseDoInclude (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 == (char *) NULL) { @@ -1788,7 +1783,7 @@ ParseDoInclude (file) oldFile->p = curPTR; oldFile->lineno = lineno; - Lst_AtFront(includes, oldFile); + Lst_AtFront(&includes, oldFile); /* * Once the previous state has been saved, we can get down to reading @@ -1798,7 +1793,7 @@ ParseDoInclude (file) */ fname = fullname; #ifdef CLEANUP - Lst_AtEnd(fileNames, fname); + Lst_AtEnd(&fileNames, fname); #endif lineno = 0; @@ -1843,7 +1838,7 @@ Parse_FromString(str, newlineno) oldFile->F = curFILE; oldFile->p = curPTR; - Lst_AtFront(includes, oldFile); + Lst_AtFront(&includes, oldFile); curFILE = NULL; curPTR = (PTR *) emalloc (sizeof (PTR)); @@ -1923,10 +1918,9 @@ ParseTraditionalInclude (file) *prefEnd = '\0'; newName = str_concat (fname, file, STR_ADDSLASH); - fullname = Dir_FindFile (newName, parseIncPath); - if (fullname == (char *)NULL) { - fullname = Dir_FindFile(newName, dirSearchPath); - } + fullname = Dir_FindFile(newName, &parseIncPath); + if (fullname == NULL) + fullname = Dir_FindFile(newName, &dirSearchPath); free (newName); *prefEnd = '/'; } else { @@ -1940,10 +1934,9 @@ ParseTraditionalInclude (file) * then on the .PATH search path, if not found in a -I directory. * XXX: Suffix specific? */ - fullname = Dir_FindFile (file, parseIncPath); - if (fullname == (char *)NULL) { - fullname = Dir_FindFile(file, dirSearchPath); - } + fullname = Dir_FindFile(file, &parseIncPath); + if (fullname == NULL) + fullname = Dir_FindFile(file, &dirSearchPath); } if (fullname == (char *)NULL) { @@ -1951,7 +1944,7 @@ ParseTraditionalInclude (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 == (char *) NULL) { @@ -1973,7 +1966,7 @@ ParseTraditionalInclude (file) oldFile->p = curPTR; oldFile->lineno = lineno; - Lst_AtFront(includes, oldFile); + Lst_AtFront(&includes, oldFile); /* * Once the previous state has been saved, we can get down to reading @@ -1983,7 +1976,7 @@ ParseTraditionalInclude (file) */ fname = fullname; #ifdef CLEANUP - lst_AtEnd(fileNames, fname); + Lst_AtEnd(&fileNames, fname); #endif lineno = 0; @@ -2020,7 +2013,7 @@ ParseEOF (opened) { IFile *ifile; /* the state on the top of the includes stack */ - if ((ifile = (IFile *)Lst_DeQueue(includes)) == NULL) + if ((ifile = (IFile *)Lst_DeQueue(&includes)) == NULL) return DONE; fname = ifile->fname; lineno = ifile->lineno; @@ -2414,7 +2407,7 @@ ParseFinishLine() { if (inLine) { Lst_Every(targets, Suff_EndTransform); - Lst_Destroy(targets, ParseHasCommands); + Lst_Delete(targets, ParseHasCommands); targets = NULL; inLine = FALSE; } @@ -2447,7 +2440,7 @@ Parse_File(name, stream) inLine = FALSE; fname = estrdup(name); #ifdef CLEANUP - Lst_AtEnd(fileNames, fname); + Lst_AtEnd(&fileNames, fname); #endif curFILE = stream; lineno = 0; @@ -2508,7 +2501,7 @@ Parse_File(name, stream) */ Lst_ForEach(targets, ParseAddCmd, cp); #ifdef CLEANUP - Lst_AtEnd(targCmds, line); + Lst_AtEnd(&targCmds, line); #endif continue; } else { @@ -2582,9 +2575,9 @@ Parse_File(name, stream) * Need a non-circular list for the target nodes */ if (targets) - Lst_Destroy(targets, NOFREE); + Lst_Delete(targets, NOFREE); - targets = Lst_Init(); + targets = Lst_New(); inLine = TRUE; ParseDoDependency (line); @@ -2618,23 +2611,20 @@ Parse_File(name, stream) * Parse_Init -- * initialize the parsing module * - * Results: - * none - * * Side Effects: * the parseIncPath list is initialized... *--------------------------------------------------------------------- */ void -Parse_Init () +Parse_Init() { mainNode = NULL; - parseIncPath = Lst_Init(); - sysIncPath = Lst_Init(); - includes = Lst_Init(); + Lst_Init(&parseIncPath); + Lst_Init(&sysIncPath); + Lst_Init(&includes); #ifdef CLEANUP - targCmds = Lst_Init(); - fileNames = Lst_Init(); + Lst_Init(&targCmds); + Lst_Init(&fileNames); #endif } @@ -2642,13 +2632,13 @@ void Parse_End() { #ifdef CLEANUP - Lst_Destroy(targCmds, (SimpleProc)free); - Lst_Destroy(fileNames, (void (*) __P((ClientData))) free); + Lst_Destroy(&targCmds, (SimpleProc)free); + Lst_Destroy(&fileNames, (void (*) __P((ClientData))) free); 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_Delete(targets, NOFREE); + Lst_Destroy(&sysIncPath, Dir_Destroy); + Lst_Destroy(&parseIncPath, Dir_Destroy); + Lst_Destroy(&includes, NOFREE); /* Should be empty now */ #endif } @@ -2672,14 +2662,14 @@ Parse_MainName() { Lst listmain; /* result list */ - listmain = Lst_Init(); + listmain = Lst_New(); 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); diff --git a/usr.bin/make/suff.c b/usr.bin/make/suff.c index 96315279702..d494fe96c4d 100644 --- a/usr.bin/make/suff.c +++ b/usr.bin/make/suff.c @@ -1,4 +1,4 @@ -/* $OpenBSD: suff.c,v 1.28 2000/06/10 01:41:06 espie Exp $ */ +/* $OpenBSD: suff.c,v 1.29 2000/06/17 14:38:19 espie Exp $ */ /* $NetBSD: suff.c,v 1.13 1996/11/06 17:59:25 christos Exp $ */ /* @@ -43,7 +43,7 @@ #if 0 static char sccsid[] = "@(#)suff.c 8.4 (Berkeley) 3/21/94"; #else -static char rcsid[] = "$OpenBSD: suff.c,v 1.28 2000/06/10 01:41:06 espie Exp $"; +static char rcsid[] = "$OpenBSD: suff.c,v 1.29 2000/06/17 14:38:19 espie Exp $"; #endif #endif /* not lint */ @@ -105,10 +105,10 @@ static char rcsid[] = "$OpenBSD: suff.c,v 1.28 2000/06/10 01:41:06 espie Exp $"; static Lst sufflist; /* Lst of suffixes */ #ifdef CLEANUP -static Lst suffClean; /* Lst of suffixes to be cleaned */ +static LIST suffClean; /* Lst of suffixes to be cleaned */ #endif -static Lst srclist; /* Lst of sources */ -static Lst transforms; /* Lst of transformation rules */ +static LIST srclist; /* Lst of sources */ +static LIST transforms; /* Lst of transformation rules */ static int sNum = 0; /* Counter for assigning suffix numbers */ @@ -125,9 +125,9 @@ typedef struct _Suff { Lst searchPath; /* The path along which files of this suffix * may be found */ int sNum; /* The suffix number */ - 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 */ + LIST parents; /* Suffixes we have a transformation to */ + LIST children; /* Suffixes we have a transformation from */ + LIST ref; /* List of lists this suffix is referenced */ } Suff; /* @@ -142,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 */ + LIST cp; /* Debug; children list */ #endif } Src; @@ -369,10 +369,10 @@ SuffFree(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_Delete(s->searchPath, Dir_Destroy); free(s->name); free(s); @@ -432,13 +432,13 @@ SuffInsert (l, s) printf("at end of list\n"); } Lst_AtEnd(l, s); - Lst_AtEnd(s->ref, l); + Lst_AtEnd(&s->ref, l); } else if (s2->sNum != s->sNum) { if (DEBUG(SUFF)) { printf("before %s(%d)\n", s2->name, s2->sNum); } Lst_Insert(l, ln, s); - Lst_AtEnd(s->ref, l); + Lst_AtEnd(&s->ref, l); } else if (DEBUG(SUFF)) { printf("already there\n"); } @@ -465,9 +465,9 @@ void Suff_ClearSuffixes () { #ifdef CLEANUP - Lst_Concat(suffClean, sufflist, LST_CONCLINK); + Lst_Concat(&suffClean, sufflist, LST_CONCLINK); #endif - sufflist = Lst_Init(); + sufflist = Lst_New(); sNum = 0; suffNull = emptySuff; } @@ -598,14 +598,14 @@ Suff_AddTransform (line) *t; /* target suffix */ LstNode ln; /* Node for existing transformation */ - ln = Lst_Find(transforms, SuffGNHasNameP, line); + ln = Lst_Find(&transforms, SuffGNHasNameP, line); 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 @@ -614,10 +614,10 @@ Suff_AddTransform (line) * attached to several different transformations. */ gn = (GNode *) 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); + Lst_Init(&gn->commands); + Lst_Init(&gn->children); } gn->type = OP_TRANSFORM; @@ -631,8 +631,8 @@ Suff_AddTransform (line) printf("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); } @@ -657,8 +657,8 @@ Suff_EndTransform(gnp) { 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; @@ -675,12 +675,12 @@ Suff_EndTransform(gnp) * 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) && DEBUG(SUFF)) { printf("transformation %s complete\n", gn->name); } @@ -725,8 +725,8 @@ SuffRebuildGraph(transformp, sp) * else. */ s2 = (Suff *)Lst_Datum(ln); - SuffInsert(s2->children, s); - SuffInsert(s->parents, s2); + SuffInsert(&s2->children, s); + SuffInsert(&s->parents, s2); return; } } @@ -750,8 +750,8 @@ SuffRebuildGraph(transformp, sp) * Found it -- establish the proper relationship */ s2 = (Suff *)Lst_Datum(ln); - SuffInsert(s->children, s2); - SuffInsert(s2->parents, s); + SuffInsert(&s->children, s2); + SuffInsert(&s2->parents, s); } } } @@ -783,10 +783,10 @@ Suff_AddSuffix (str) 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(); + s->searchPath = Lst_New(); + Lst_Init(&s->children); + Lst_Init(&s->parents); + Lst_Init(&s->ref); s->sNum = sNum++; s->flags = 0; @@ -795,7 +795,7 @@ Suff_AddSuffix (str) * 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); } } @@ -852,43 +852,43 @@ Suff_DoPaths() register Suff *s; register LstNode ln; char *ptr; - Lst inIncludes; /* Cumulative .INCLUDES path */ - Lst inLibs; /* Cumulative .LIBS path */ + LIST inIncludes; /* Cumulative .INCLUDES path */ + LIST inLibs; /* Cumulative .LIBS path */ if (Lst_Open (sufflist) == FAILURE) { return; } - inIncludes = Lst_Init(); - inLibs = Lst_Init(); + Lst_Init(&inIncludes); + Lst_Init(&inLibs); while ((ln = Lst_Next (sufflist)) != NULL) { s = (Suff *) Lst_Datum (ln); 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_Delete(s->searchPath, Dir_Destroy); + s->searchPath = Lst_Duplicate(&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); Lst_Close (sufflist); } @@ -993,8 +993,8 @@ SuffAddSrc(sp, lsp) targ->children += 1; Lst_AtEnd(ls->l, s2); #ifdef DEBUG_SRC - s2->cp = Lst_Init(); - Lst_AtEnd(targ->cp, s2); + Lst_Init(&s2->cp); + Lst_AtEnd(&targ->cp, s2); printf("1 add %x %x to %x:", targ, s2, ls->l); Lst_Every(ls->l, PrintAddr); printf("\n"); @@ -1010,8 +1010,8 @@ SuffAddSrc(sp, lsp) targ->children += 1; Lst_AtEnd(ls->l, s2); #ifdef DEBUG_SRC - s2->cp = Lst_Init(); - Lst_AtEnd(targ->cp, s2); + Lst_Init(&s2->cp); + Lst_AtEnd(&targ->cp, s2); printf("2 add %x %x to %x:", targ, s2, ls->l); Lst_Every(ls->l, PrintAddr); printf("\n"); @@ -1040,7 +1040,7 @@ SuffAddLevel (l, targ) ls.s = targ; ls.l = l; - Lst_ForEach(targ->suff->children, SuffAddSrc, &ls); + Lst_ForEach(&targ->suff->children, SuffAddSrc, &ls); } /*- @@ -1081,15 +1081,15 @@ SuffRemoveSrc (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); + Lst_Destroy(&s->cp, NOFREE); #endif Lst_Remove(l, ln); free(s); @@ -1100,7 +1100,7 @@ SuffRemoveSrc (l) #ifdef DEBUG_SRC else { printf("keep: [l=%x] p=%x %d: ", l, s, s->children); - Lst_Every(s->cp, PrintAddr); + Lst_Every(&s->cp, PrintAddr); printf("\n"); } #endif @@ -1203,10 +1203,10 @@ SuffFindCmds (targ, slst) char *cp; t = targ->node; - (void) Lst_Open (t->children); + (void) Lst_Open(&t->children); prefLen = strlen (targ->pref); - while ((ln = Lst_Next (t->children)) != NULL) { + while ((ln = Lst_Next(&t->children)) != NULL) { s = (GNode *)Lst_Datum (ln); cp = strrchr (s->name, '/'); @@ -1230,7 +1230,7 @@ SuffFindCmds (targ, slst) */ suff = (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 @@ -1247,9 +1247,9 @@ SuffFindCmds (targ, slst) ret->children = 0; targ->children += 1; #ifdef DEBUG_SRC - ret->cp = Lst_Init(); + Lst_Init(&ret->cp); printf("3 add %x %x\n", targ, ret); - Lst_AtEnd(targ->cp, ret); + Lst_AtEnd(&targ->cp, ret); #endif Lst_AtEnd(slst, ret); if (DEBUG(SUFF)) { @@ -1260,7 +1260,7 @@ SuffFindCmds (targ, slst) } } } - Lst_Close (t->children); + Lst_Close(&t->children); return ((Src *)NULL); } @@ -1293,7 +1293,7 @@ SuffExpandChildren(cgnp, 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 @@ -1307,8 +1307,9 @@ SuffExpandChildren(cgnp, pgnp) cp = Var_Subst(cgn->name, pgn, TRUE); if (cp != NULL) { - Lst members = Lst_Init(); + LIST members; + Lst_Init(&members); if (cgn->type & OP_ARCHV) { /* * Node was an archive(member) target, so we want to call @@ -1317,7 +1318,7 @@ SuffExpandChildren(cgnp, pgnp) */ char *sacrifice = cp; - (void)Arch_ParseArchive(&sacrifice, members, pgn); + (void)Arch_ParseArchive(&sacrifice, &members, pgn); } else { /* * Break the result into a vector of strings whose nodes @@ -1339,7 +1340,7 @@ SuffExpandChildren(cgnp, pgnp) */ *cp++ = '\0'; gn = Targ_FindNode(start, TARG_CREATE); - Lst_AtEnd(members, gn); + Lst_AtEnd(&members, gn); while (*cp == ' ' || *cp == '\t') { cp++; } @@ -1376,7 +1377,7 @@ SuffExpandChildren(cgnp, 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 @@ -1384,36 +1385,32 @@ SuffExpandChildren(cgnp, pgnp) */ cp = initcp; } - /* - * Add all elements of the members list to the parent node. - */ - while((gn = (GNode *)Lst_DeQueue(members)) != NULL) { + /* Add all elements of the members list to the parent node. */ + while((gn = (GNode *)Lst_DeQueue(&members)) != NULL) { if (DEBUG(SUFF)) printf("%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 - */ + Lst_Destroy(&members, NOFREE); + /* Free the result */ free(cp); } /* * 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); if (DEBUG(SUFF)) printf("\n"); } else if (Dir_HasWildcards(cgn->name)) { - Lst exp; /* List of expansions */ + LIST exp; /* List of expansions */ Lst path; /* Search path along which to expand */ /* @@ -1440,17 +1437,15 @@ SuffExpandChildren(cgnp, pgnp) /* * Use default search path */ - path = dirSearchPath; + path = &dirSearchPath; } - /* - * Expand the word along the chosen path - */ - exp = Lst_Init(); - Dir_Expand(cgn->name, path, exp); + /* Expand the word along the chosen path */ + Lst_Init(&exp); + Dir_Expand(cgn->name, path, &exp); /* Fetch next expansion off the list and find its GNode. */ - while ((cp = (char *)Lst_DeQueue(exp)) != NULL) { + while ((cp = (char *)Lst_DeQueue(&exp)) != NULL) { if (DEBUG(SUFF)) printf("%s...", cp); gn = Targ_FindNode(cp, TARG_CREATE); @@ -1459,26 +1454,24 @@ SuffExpandChildren(cgnp, 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); + /* 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); if (DEBUG(SUFF)) printf("\n"); } @@ -1513,13 +1506,13 @@ SuffApplyTransform(tGn, sGn, t, 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; } @@ -1530,16 +1523,16 @@ SuffApplyTransform(tGn, sGn, t, 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 = (GNode *)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; } } @@ -1548,7 +1541,7 @@ SuffApplyTransform(tGn, sGn, t, s) * Locate the transformation rule itself */ tname = str_concat(s->name, t->name, 0); - ln = Lst_Find(transforms, SuffGNHasNameP, tname); + ln = Lst_Find(&transforms, SuffGNHasNameP, tname); free(tname); if (ln == NULL) { @@ -1569,7 +1562,7 @@ SuffApplyTransform(tGn, sGn, t, 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 @@ -1586,7 +1579,7 @@ SuffApplyTransform(tGn, sGn, t, s) * 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); } @@ -1648,9 +1641,9 @@ SuffFindArchiveDeps(gn, 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; } @@ -1692,7 +1685,7 @@ SuffFindArchiveDeps(gn, slst) /* * Use first matching suffix... */ - ln = Lst_Find(ms->parents, SuffSuffIsSuffixP, eoarch); + ln = Lst_Find(&ms->parents, SuffSuffIsSuffixP, eoarch); if (ln != NULL) { /* @@ -1768,8 +1761,8 @@ SuffFindNormalDeps(gn, slst) * Begin at the beginning... */ ln = Lst_First(sufflist); - srcs = Lst_Init(); - targs = Lst_Init(); + srcs = Lst_New(); + targs = Lst_New(); /* * We're caught in a catch-22 here. On the one hand, we want to use any @@ -1810,7 +1803,7 @@ SuffFindNormalDeps(gn, slst) targ->parent = (Src *)NULL; targ->children = 0; #ifdef DEBUG_SRC - targ->cp = Lst_Init(); + Lst_Init(&targ->cp); #endif /* @@ -1855,14 +1848,14 @@ SuffFindNormalDeps(gn, 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)) + if (Lst_IsEmpty(&gn->commands) && Lst_IsEmpty(&gn->children)) SuffAddLevel(srcs, targ); else { if (DEBUG(SUFF)) @@ -1915,7 +1908,7 @@ SuffFindNormalDeps(gn, 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, gn); + Lst_ForEach(&gn->children, SuffExpandChildren, gn); if (targ == NULL) { if (DEBUG(SUFF)) { @@ -1929,10 +1922,10 @@ 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 == NULL ? &dirSearchPath : targ->suff->searchPath)); if (gn->path != NULL) { char *ptr; @@ -1999,7 +1992,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 != (Src *)NULL) { @@ -2128,8 +2121,8 @@ Suff_FindDeps(gn) GNode *gn; { - SuffFindDeps(gn, srclist); - while (SuffRemoveSrc(srclist)) + SuffFindDeps(gn, &srclist); + while (SuffRemoveSrc(&srclist)) continue; } @@ -2241,12 +2234,12 @@ Suff_SetNull(name) void Suff_Init () { - sufflist = Lst_Init(); + sufflist = Lst_New(); #ifdef CLEANUP - suffClean = Lst_Init(); + Lst_Init(&suffClean); #endif - srclist = Lst_Init(); - transforms = Lst_Init(); + Lst_Init(&srclist); + Lst_Init(&transforms); sNum = 0; /* @@ -2258,11 +2251,11 @@ Suff_Init () 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(); + suffNull->searchPath = Lst_New(); + Dir_Concat(suffNull->searchPath, &dirSearchPath); + Lst_Init(&suffNull->children); + Lst_Init(&suffNull->parents); + Lst_Init(&suffNull->ref); suffNull->sNum = sNum++; suffNull->flags = SUFF_NULL; @@ -2286,12 +2279,12 @@ void Suff_End() { #ifdef CLEANUP - Lst_Destroy(sufflist, SuffFree); - Lst_Destroy(suffClean, SuffFree); + Lst_Delete(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); #endif } @@ -2335,9 +2328,9 @@ SuffPrintSuff(sp) } } printf("\n#\tTo: "); - Lst_Every(s->parents, SuffPrintName); + Lst_Every(&s->parents, SuffPrintName); printf("\n#\tFrom: "); - Lst_Every(s->children, SuffPrintName); + Lst_Every(&s->children, SuffPrintName); printf("\n#\tSearch Path: "); Dir_PrintPath(s->searchPath); fputc('\n', stdout); @@ -2352,7 +2345,7 @@ SuffPrintTrans(tp) printf("%-16s: ", t->name); Targ_PrintType(t->type); fputc('\n', stdout); - Lst_Every(t->commands, Targ_PrintCmd); + Lst_Every(&t->commands, Targ_PrintCmd); fputc('\n', stdout); } @@ -2363,5 +2356,5 @@ Suff_PrintAll() Lst_Every(sufflist, SuffPrintSuff); printf("#*** Transformations:\n"); - Lst_Every(transforms, SuffPrintTrans); + Lst_Every(&transforms, SuffPrintTrans); } diff --git a/usr.bin/make/targ.c b/usr.bin/make/targ.c index 16c9656b8e7..9b1c24d79d7 100644 --- a/usr.bin/make/targ.c +++ b/usr.bin/make/targ.c @@ -1,4 +1,4 @@ -/* $OpenBSD: targ.c,v 1.18 2000/06/10 01:41:06 espie Exp $ */ +/* $OpenBSD: targ.c,v 1.19 2000/06/17 14:38:20 espie Exp $ */ /* $NetBSD: targ.c,v 1.11 1997/02/20 16:51:50 christos Exp $ */ /* @@ -43,7 +43,7 @@ #if 0 static char sccsid[] = "@(#)targ.c 8.2 (Berkeley) 3/19/94"; #else -static char *rcsid = "$OpenBSD: targ.c,v 1.18 2000/06/10 01:41:06 espie Exp $"; +static char *rcsid = "$OpenBSD: targ.c,v 1.19 2000/06/17 14:38:20 espie Exp $"; #endif #endif /* not lint */ @@ -94,9 +94,9 @@ static char *rcsid = "$OpenBSD: targ.c,v 1.18 2000/06/10 01:41:06 espie Exp $"; #include "hash.h" #include "dir.h" -static Lst allTargets; /* the list of all targets found so far */ +static LIST allTargets; /* the list of all targets found so far */ #ifdef CLEANUP -static Lst allGNs; /* List of all the GNodes */ +static LIST allGNs; /* List of all the GNodes */ #endif static Hash_Table targets; /* a hash table of same */ @@ -122,10 +122,13 @@ static void TargFreeGN __P((void *)); *----------------------------------------------------------------------- */ void -Targ_Init () +Targ_Init() { - allTargets = Lst_Init(); - Hash_InitTable (&targets, HTSIZE); +#ifdef CLEANUP + Lst_Init(&allGNs); +#endif + Lst_Init(&allTargets); + Hash_InitTable(&targets, HTSIZE); } /*- @@ -144,9 +147,8 @@ void Targ_End () { #ifdef CLEANUP - Lst_Destroy(allTargets, NOFREE); - if (allGNs) - Lst_Destroy(allGNs, TargFreeGN); + Lst_Destroy(&allTargets, NOFREE); + Lst_Destroy(&allGNs, TargFreeGN); Hash_DeleteTable(&targets); #endif } @@ -184,22 +186,20 @@ Targ_NewGN (name) gn->childMade = FALSE; gn->order = 0; gn->mtime = gn->cmtime = OUT_OF_DATE; - 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(); + 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); gn->lineno = 0; gn->fname = NULL; - gn->commands = Lst_Init(); + Lst_Init(&gn->commands); gn->suffix = NULL; #ifdef CLEANUP - if (allGNs == NULL) - allGNs = Lst_Init(); - Lst_AtEnd(allGNs, gn); + Lst_AtEnd(&allGNs, gn); #endif return (gn); @@ -227,15 +227,14 @@ TargFreeGN(gnp) free(gn->name); efree(gn->path); - - Lst_Destroy(gn->iParents, NOFREE); - Lst_Destroy(gn->cohorts, NOFREE); - Lst_Destroy(gn->parents, NOFREE); - Lst_Destroy(gn->children, NOFREE); - Lst_Destroy(gn->successors, NOFREE); - Lst_Destroy(gn->preds, NOFREE); - Lst_Destroy(gn->context, NOFREE); - Lst_Destroy(gn->commands, NOFREE); + Lst_Destroy(&gn->iParents, NOFRE); + Lst_Destroy(&gn->cohorts, NOFRE); + Lst_Destroy(&gn->parents, NOFRE); + Lst_Destroy(&gn->children, NOFRE); + Lst_Destroy(&gn->successors, NOFRE); + Lst_Destroy(&gn->preds, NOFRE); + Lst_Destroy(&gn->context, NOFRE); + Lst_Destroy(&gn->commands, NOFRE); free(gn); } #endif @@ -272,7 +271,7 @@ Targ_FindNode (name, 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); @@ -301,7 +300,7 @@ Targ_FindNode (name, flags) * ----------------------------------------------------------------------- */ Lst -Targ_FindList (names, flags) +Targ_FindList(names, flags) Lst names; /* list of names to find */ int flags; /* flags used if no node is found for a given * name */ @@ -311,7 +310,7 @@ Targ_FindList (names, flags) register GNode *gn; /* node in tLn */ char *name; - nodes = Lst_Init(); + nodes = Lst_New(); if (Lst_Open (names) == FAILURE) { return (nodes); @@ -327,7 +326,7 @@ Targ_FindList (names, 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); @@ -563,15 +562,15 @@ TargPrintNode(gnp, passp) else printf("# unmade\n"); } - if (!Lst_IsEmpty (gn->iParents)) { + if (!Lst_IsEmpty(&gn->iParents)) { printf("# implicit parents: "); - Lst_Every(gn->iParents, TargPrintName); + Lst_Every(&gn->iParents, TargPrintName); fputc('\n', stdout); } } - if (!Lst_IsEmpty (gn->parents)) { + if (!Lst_IsEmpty(&gn->parents)) { printf("# parents: "); - Lst_Every(gn->parents, TargPrintName); + Lst_Every(&gn->parents, TargPrintName); fputc ('\n', stdout); } @@ -585,12 +584,12 @@ TargPrintNode(gnp, passp) printf(":: "); break; } Targ_PrintType(gn->type); - Lst_Every(gn->children, TargPrintName); + Lst_Every(&gn->children, TargPrintName); fputc('\n', stdout); - Lst_Every(gn->commands, Targ_PrintCmd); + Lst_Every(&gn->commands, Targ_PrintCmd); printf("\n\n"); if (gn->type & OP_DOUBLEDEP) - Lst_ForEach(gn->cohorts, TargPrintNode, &pass); + Lst_ForEach(&gn->cohorts, TargPrintNode, &pass); } } @@ -632,10 +631,10 @@ Targ_PrintGraph (pass) * 2 => processing done */ { 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_Every(allTargets, TargPrintOnlySrc); + Lst_Every(&allTargets, TargPrintOnlySrc); 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 71f0b191565..d13aa3cf980 100644 --- a/usr.bin/make/var.c +++ b/usr.bin/make/var.c @@ -1,4 +1,4 @@ -/* $OpenBSD: var.c,v 1.32 2000/06/10 01:41:06 espie Exp $ */ +/* $OpenBSD: var.c,v 1.33 2000/06/17 14:38:20 espie Exp $ */ /* $NetBSD: var.c,v 1.18 1997/03/18 19:24:46 christos Exp $ */ /* @@ -70,7 +70,7 @@ #if 0 static char sccsid[] = "@(#)var.c 8.3 (Berkeley) 3/19/94"; #else -static char rcsid[] = "$OpenBSD: var.c,v 1.32 2000/06/10 01:41:06 espie Exp $"; +static char rcsid[] = "$OpenBSD: var.c,v 1.33 2000/06/17 14:38:20 espie Exp $"; #endif #endif /* not lint */ @@ -159,7 +159,7 @@ GNode *VAR_GLOBAL; /* variables from the makefile */ GNode *VAR_CMD; /* variables defined on the command-line */ static GNode *VAR_ENV; /* variables read from env */ -static Lst allVars; /* List of all variables */ +static LIST allVars; /* List of all variables */ #define FIND_CMD 0x1 /* look in VAR_CMD when searching */ #define FIND_GLOBAL 0x2 /* look in VAR_GLOBAL as well */ @@ -318,16 +318,16 @@ VarFind (name, ctxt, 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, VarCmp, name); + var = Lst_Find(&ctxt->context, VarCmp, name); if ((var == NULL) && (flags & FIND_CMD) && (ctxt != VAR_CMD)) - var = Lst_Find(VAR_CMD->context, VarCmp, name); + var = Lst_Find(&VAR_CMD->context, VarCmp, name); if (!checkEnvFirst && (var == NULL) && (flags & FIND_GLOBAL) && (ctxt != VAR_GLOBAL)) { - var = Lst_Find(VAR_GLOBAL->context, VarCmp, name); + var = Lst_Find(&VAR_GLOBAL->context, VarCmp, name); } if ((var == NULL) && (flags & FIND_ENV)) { - var = Lst_Find(VAR_ENV->context, VarCmp, name); + var = Lst_Find(&VAR_ENV->context, VarCmp, name); if (var == NULL) { char *env; @@ -337,7 +337,7 @@ VarFind (name, ctxt, flags) } if (var == NULL && checkEnvFirst && (flags & FIND_GLOBAL) && (ctxt != VAR_GLOBAL)) - var = Lst_Find(VAR_GLOBAL->context, VarCmp, name); + var = Lst_Find(&VAR_GLOBAL->context, VarCmp, name); if (var == NULL) return NULL; else @@ -377,8 +377,8 @@ VarAdd(name, val, ctxt) v->flags = 0; - Lst_AtFront(ctxt->context, v); - Lst_AtEnd(allVars, v); + Lst_AtFront(&ctxt->context, v); + Lst_AtEnd(&allVars, v); if (DEBUG(VAR)) { printf("%s:%s = %s\n", ctxt->name, name, val); } @@ -433,14 +433,14 @@ Var_Delete(name, ctxt) if (DEBUG(VAR)) { printf("%s:delete %s\n", ctxt->name, name); } - ln = Lst_Find(ctxt->context, VarCmp, name); + ln = Lst_Find(&ctxt->context, VarCmp, name); if (ln != NULL) { register Var *v; v = (Var *)Lst_Datum(ln); - Lst_Remove(ctxt->context, ln); - ln = Lst_Member(allVars, v); - Lst_Remove(allVars, ln); + Lst_Remove(&ctxt->context, ln); + ln = Lst_Member(&allVars, v); + Lst_Remove(&allVars, ln); VarDelete(v); } } @@ -2302,28 +2302,25 @@ Var_GetHead(file) * Var_Init -- * Initialize the module * - * Results: - * None - * * Side Effects: * The VAR_CMD and VAR_GLOBAL contexts are created *----------------------------------------------------------------------- */ void -Var_Init () +Var_Init() { VAR_GLOBAL = Targ_NewGN("Global"); VAR_CMD = Targ_NewGN("Command"); VAR_ENV = Targ_NewGN("Environment"); - allVars = Lst_Init(); + Lst_Init(&allVars); } void -Var_End () +Var_End() { - Lst_Destroy(allVars, VarDelete); + Lst_Destroy(&allVars, VarDelete); } @@ -2347,5 +2344,5 @@ void Var_Dump (ctxt) GNode *ctxt; { - Lst_Every(ctxt->context, VarPrintVar); + Lst_Every(&ctxt->context, VarPrintVar); } |