From d0f862960eef69fdd7801239999a637a2b2d5021 Mon Sep 17 00:00:00 2001 From: Marc Espie Date: Sat, 17 Jun 2000 14:43:41 +0000 Subject: This removes the few instances of Lst_New left. - replaces Lst_Duplicate with Lst_Clone, which does not allocate storage - split Lst_Concat into Lst_Concat/Lst_ConcatDestroy Thus, all the LstValid checks are gone, since we always invoke list functions with valid pointers. Note that dynamic list allocation accounted for roughly 20% of all calls to malloc. The extraneous calls to malloc left are now mostly in parse.c, which makes some wasteful usage of temporary buffers. With those few patches, the code is sturdier, and easier to maintain. Reviewed by millert@ --- usr.bin/make/Makefile | 3 +- usr.bin/make/lst.h | 21 +++-- usr.bin/make/lst.lib/Makefile | 5 +- usr.bin/make/lst.lib/lstAppend.c | 10 +-- usr.bin/make/lst.lib/lstClose.c | 10 +-- usr.bin/make/lst.lib/lstConcat.c | 48 ++--------- usr.bin/make/lst.lib/lstDestroy.c | 14 +--- usr.bin/make/lst.lib/lstDupl.c | 21 ++--- usr.bin/make/lst.lib/lstEnQueue.c | 7 +- usr.bin/make/lst.lib/lstFirst.c | 9 +-- usr.bin/make/lst.lib/lstInit.c | 20 +---- usr.bin/make/lst.lib/lstInsert.c | 8 +- usr.bin/make/lst.lib/lstInt.h | 8 +- usr.bin/make/lst.lib/lstIsAtEnd.c | 6 +- usr.bin/make/lst.lib/lstIsEmpty.c | 17 +--- usr.bin/make/lst.lib/lstLast.c | 9 +-- usr.bin/make/lst.lib/lstNext.c | 6 +- usr.bin/make/lst.lib/lstOpen.c | 10 +-- usr.bin/make/lst.lib/lstRemove.c | 6 +- usr.bin/make/make.c | 16 ++-- usr.bin/make/parse.c | 84 +++++++++----------- usr.bin/make/suff.c | 163 ++++++++++++++++++-------------------- usr.bin/make/targ.c | 6 +- 23 files changed, 191 insertions(+), 316 deletions(-) diff --git a/usr.bin/make/Makefile b/usr.bin/make/Makefile index 47e1383621f..abee82e219e 100644 --- a/usr.bin/make/Makefile +++ b/usr.bin/make/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.14 2000/06/10 01:32:22 espie Exp $ +# $OpenBSD: Makefile,v 1.15 2000/06/17 14:43:35 espie Exp $ PROG= make CFLAGS+= -I${.CURDIR} -Wall -Wno-char-subscripts -Wno-unused -Wstrict-prototypes#-Wmissing-prototypes -Wstrict-prototypes @@ -10,6 +10,7 @@ CFLAGS+=-O0 SRCS= arch.c buf.c compat.c cond.c dir.c error.c for.c hash.c job.c main.c \ make.c parse.c str.c suff.c targ.c var.c #util.c SRCS+= lstAppend.c lstAtEnd.c lstAtFront.c lstClose.c lstConcat.c \ + lstConcatDestroy.c \ lstDatum.c lstDeQueue.c lstDestroy.c lstDupl.c lstEnQueue.c \ lstFindFrom.c lstFirst.c lstForEachFrom.c \ lstInit.c lstInsert.c lstIsAtEnd.c lstIsEmpty.c lstLast.c \ diff --git a/usr.bin/make/lst.h b/usr.bin/make/lst.h index f914452de58..7ed98129a65 100644 --- a/usr.bin/make/lst.h +++ b/usr.bin/make/lst.h @@ -1,4 +1,4 @@ -/* $OpenBSD: lst.h,v 1.15 2000/06/17 14:38:17 espie Exp $ */ +/* $OpenBSD: lst.h,v 1.16 2000/06/17 14:43:36 espie Exp $ */ /* $NetBSD: lst.h,v 1.7 1996/11/06 17:59:12 christos Exp $ */ /* @@ -98,27 +98,22 @@ typedef void * (*DuplicateProc) __P((void *)); /* * NOFREE can be used as the freeProc to Lst_Destroy when the elements are * not to be freed. - * NOCOPY performs similarly when given as the copyProc to Lst_Duplicate. + * NOCOPY performs similarly when given as the copyProc to Lst_Clone. */ #define NOFREE ((SimpleProc)0) #define NOCOPY ((DuplicateProc)0) -#define LST_CONCNEW 0 /* create new LstNode's when using Lst_Concat */ -#define LST_CONCLINK 1 /* relink LstNode's when using Lst_Concat */ - /* * Creation/destruction functions */ /* CTOR/DTOR, ala C++ */ +/* Create a new list */ void Lst_Init __P((Lst)); +/* Destroy an old one */ void Lst_Destroy __P((Lst, SimpleProc)); -/* Create a new list */ -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)); +Lst Lst_Clone __P((Lst, Lst, DuplicateProc)); /* True if list is empty */ Boolean Lst_IsEmpty __P((Lst)); @@ -137,8 +132,10 @@ void Lst_AtEnd __P((Lst, void *)); void Lst_Remove __P((Lst, LstNode)); /* Replace a node with a new value */ void Lst_Replace __P((LstNode, void *)); -/* Concatenate two lists */ -void Lst_Concat __P((Lst, Lst, int)); +/* Concatenate two lists, destructive. */ +void Lst_ConcatDestroy __P((Lst, Lst)); +/* Concatenate two lists, non destructive */ +void Lst_Concat __P((Lst, Lst)); /* * Node-specific functions diff --git a/usr.bin/make/lst.lib/Makefile b/usr.bin/make/lst.lib/Makefile index c101a0e8698..1ea96b2ada0 100644 --- a/usr.bin/make/lst.lib/Makefile +++ b/usr.bin/make/lst.lib/Makefile @@ -1,9 +1,10 @@ -# $OpenBSD: Makefile,v 1.7 2000/06/10 01:32:23 espie Exp $ +# $OpenBSD: Makefile,v 1.8 2000/06/17 14:43:37 espie Exp $ # $NetBSD: Makefile,v 1.4 1996/11/06 17:59:31 christos Exp $ OBJ=lstAppend.o lstDupl.o lstInit.o lstOpen.o lstAtEnd.o lstEnQueue.o \ lstInsert.o lstAtFront.o lstIsAtEnd.o lstClose.o lstIsEmpty.o \ - lstRemove.o lstConcat.o lstFindFrom.o lstLast.o lstReplace.o lstFirst.o \ + lstRemove.o lstConcat.o lstConcatDestroy.o lstFindFrom.o lstLast.o \ + lstReplace.o lstFirst.o \ lstDatum.o lstMember.o lstSucc.o lstDeQueue.o lstForEachFrom.o \ lstDestroy.o lstNext.o diff --git a/usr.bin/make/lst.lib/lstAppend.c b/usr.bin/make/lst.lib/lstAppend.c index 414118c3f6a..cc4a494fcb3 100644 --- a/usr.bin/make/lst.lib/lstAppend.c +++ b/usr.bin/make/lst.lib/lstAppend.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lstAppend.c,v 1.9 2000/06/17 14:34:05 espie Exp $ */ +/* $OpenBSD: lstAppend.c,v 1.10 2000/06/17 14:43:38 espie Exp $ */ /* $NetBSD: lstAppend.c,v 1.5 1996/11/06 17:59:31 christos Exp $ */ /* @@ -41,7 +41,7 @@ #if 0 static char sccsid[] = "@(#)lstAppend.c 8.1 (Berkeley) 6/6/93"; #else -static char rcsid[] = "$OpenBSD: lstAppend.c,v 1.9 2000/06/17 14:34:05 espie Exp $"; +static char rcsid[] = "$OpenBSD: lstAppend.c,v 1.10 2000/06/17 14:43:38 espie Exp $"; #endif #endif /* not lint */ @@ -76,13 +76,11 @@ Lst_Append(l, ln, d) { LstNode nLNode; - if (LstValid(l) && (ln == NULL && LstIsEmpty(l))) { + if (ln == NULL && LstIsEmpty(l)) goto ok; - } - if (!LstValid(l) || LstIsEmpty(l) || ! LstNodeValid(ln, l)) { + if (LstIsEmpty(l) || ! LstNodeValid(ln, l)) return; - } ok: PAlloc(nLNode, LstNode); diff --git a/usr.bin/make/lst.lib/lstClose.c b/usr.bin/make/lst.lib/lstClose.c index 9778c1c3403..9c804260a88 100644 --- a/usr.bin/make/lst.lib/lstClose.c +++ b/usr.bin/make/lst.lib/lstClose.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lstClose.c,v 1.5 2000/06/17 14:34:06 espie Exp $ */ +/* $OpenBSD: lstClose.c,v 1.6 2000/06/17 14:43:38 espie Exp $ */ /* $NetBSD: lstClose.c,v 1.5 1996/11/06 17:59:34 christos Exp $ */ /* @@ -41,7 +41,7 @@ #if 0 static char sccsid[] = "@(#)lstClose.c 8.1 (Berkeley) 6/6/93"; #else -static char rcsid[] = "$OpenBSD: lstClose.c,v 1.5 2000/06/17 14:34:06 espie Exp $"; +static char rcsid[] = "$OpenBSD: lstClose.c,v 1.6 2000/06/17 14:43:38 espie Exp $"; #endif #endif /* not lint */ @@ -74,9 +74,7 @@ void Lst_Close(l) Lst l; /* The list to close */ { - if (LstValid(l) == TRUE) { - l->isOpen = FALSE; - l->atEnd = Unknown; - } + l->isOpen = FALSE; + l->atEnd = Unknown; } diff --git a/usr.bin/make/lst.lib/lstConcat.c b/usr.bin/make/lst.lib/lstConcat.c index fb0d867ba58..bde8253bc84 100644 --- a/usr.bin/make/lst.lib/lstConcat.c +++ b/usr.bin/make/lst.lib/lstConcat.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lstConcat.c,v 1.9 2000/06/17 14:34:06 espie Exp $ */ +/* $OpenBSD: lstConcat.c,v 1.10 2000/06/17 14:43:38 espie Exp $ */ /* $NetBSD: lstConcat.c,v 1.6 1996/11/06 17:59:34 christos Exp $ */ /* @@ -41,7 +41,7 @@ #if 0 static char sccsid[] = "@(#)lstConcat.c 8.1 (Berkeley) 6/6/93"; #else -static char rcsid[] = "$OpenBSD: lstConcat.c,v 1.9 2000/06/17 14:34:06 espie Exp $"; +static char rcsid[] = "$OpenBSD: lstConcat.c,v 1.10 2000/06/17 14:43:38 espie Exp $"; #endif #endif /* not lint */ @@ -56,64 +56,28 @@ static char rcsid[] = "$OpenBSD: lstConcat.c,v 1.9 2000/06/17 14:34:06 espie Exp *----------------------------------------------------------------------- * Lst_Concat -- * Concatenate two lists. New elements are created to hold the data - * elements, if specified, but the elements themselves are not copied. + * elements, but the elements themselves are not copied. * If the elements should be duplicated to avoid confusion with another * list, the Lst_Duplicate function should be called first. - * If LST_CONCLINK is specified, the second list is destroyed since - * its pointers have been corrupted and the list is no longer useable. * * Results: * SUCCESS if all went well. FAILURE otherwise. * * Side Effects: - * New elements are created and appended the the first list. + * New elements are created and appended to the first list. *----------------------------------------------------------------------- */ void -Lst_Concat(l1, l2, flags) +Lst_Concat(l1, l2) Lst l1; /* The list to which l2 is to be appended */ Lst l2; /* The list to append to l1 */ - int flags; /* LST_CONCNEW if LstNode's should be duplicated - * LST_CONCLINK if should just be relinked */ { LstNode ln; /* original LstNode */ LstNode nln; /* new LstNode */ LstNode last; /* the last element in the list. Keeps * bookkeeping until the end */ - if (!LstValid(l1) || !LstValid(l2)) { - return; - } - - if (flags == LST_CONCLINK) { - if (l2->firstPtr != NULL) { - /* - * We set the nextPtr of the - * last element of list two to be NULL to make the loop easier and - * so we don't need an extra case should the first list turn - * out to be non-circular -- the final element will already point - * to NULL space and the first element will be untouched if it - * existed before and will also point to NULL space if it didn't. - */ - l2->lastPtr->nextPtr = NULL; - /* - * So long as the second list isn't empty, we just link the - * first element of the second list to the last element of the - * first list. If the first list isn't empty, we then link the - * last element of the list to the first element of the second list - * The last element of the second list, if it exists, then becomes - * the last element of the first list. - */ - l2->firstPtr->prevPtr = l1->lastPtr; - if (l1->lastPtr != NULL) { - l1->lastPtr->nextPtr = l2->firstPtr; - } else { - l1->firstPtr = l2->firstPtr; - } - l1->lastPtr = l2->lastPtr; - } - free(l2); - } else if (l2->firstPtr != NULL) { + if (l2->firstPtr != NULL) { /* * We set the nextPtr of the last element of list 2 to be NULL to make * the loop less difficult. 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 e584fb16834..d7fea7f449f 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.9 2000/06/17 14:38:21 espie Exp $ */ +/* $OpenBSD: lstDestroy.c,v 1.10 2000/06/17 14:43:38 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.9 2000/06/17 14:38:21 espie Exp $"; +static char rcsid[] = "$OpenBSD: lstDestroy.c,v 1.10 2000/06/17 14:43:38 espie Exp $"; #endif #endif /* not lint */ @@ -52,16 +52,6 @@ static char rcsid[] = "$OpenBSD: lstDestroy.c,v 1.9 2000/06/17 14:38:21 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 -- diff --git a/usr.bin/make/lst.lib/lstDupl.c b/usr.bin/make/lst.lib/lstDupl.c index 349c8657226..049354662f0 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.11 2000/06/17 14:38:22 espie Exp $ */ +/* $OpenBSD: lstDupl.c,v 1.12 2000/06/17 14:43:39 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.11 2000/06/17 14:38:22 espie Exp $"; +static char rcsid[] = "$OpenBSD: lstDupl.c,v 1.12 2000/06/17 14:43:39 espie Exp $"; #endif #endif /* not lint */ @@ -55,31 +55,26 @@ static char rcsid[] = "$OpenBSD: lstDupl.c,v 1.11 2000/06/17 14:38:22 espie Exp /*- *----------------------------------------------------------------------- - * Lst_Duplicate -- + * Lst_Clone -- * 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. + * Returns the new list. * * Side Effects: - * A new list is created. + * The new list is created. *----------------------------------------------------------------------- */ Lst -Lst_Duplicate(l, copyProc) +Lst_Clone(nl, l, copyProc) + Lst nl; Lst l; DuplicateProc copyProc; { - Lst nl; LstNode ln; - if (!LstValid(l)) - return NULL; - - nl = Lst_New(); - if (nl == NULL) - return NULL; + Lst_Init(nl); for (ln = l->firstPtr; ln != NULL; ln = ln->nextPtr) { if (copyProc != NOCOPY) diff --git a/usr.bin/make/lst.lib/lstEnQueue.c b/usr.bin/make/lst.lib/lstEnQueue.c index 6a26bfba7ca..6432c9b76ca 100644 --- a/usr.bin/make/lst.lib/lstEnQueue.c +++ b/usr.bin/make/lst.lib/lstEnQueue.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lstEnQueue.c,v 1.6 2000/06/10 01:41:07 espie Exp $ */ +/* $OpenBSD: lstEnQueue.c,v 1.7 2000/06/17 14:43:39 espie Exp $ */ /* $NetBSD: lstEnQueue.c,v 1.5 1996/11/06 17:59:38 christos Exp $ */ /* @@ -41,7 +41,7 @@ #if 0 static char sccsid[] = "@(#)lstEnQueue.c 8.1 (Berkeley) 6/6/93"; #else -static char rcsid[] = "$OpenBSD: lstEnQueue.c,v 1.6 2000/06/10 01:41:07 espie Exp $"; +static char rcsid[] = "$OpenBSD: lstEnQueue.c,v 1.7 2000/06/17 14:43:39 espie Exp $"; #endif #endif /* not lint */ @@ -68,9 +68,6 @@ Lst_EnQueue(l, d) Lst l; void *d; { - if (LstValid(l) == FALSE) - return; - Lst_AtEnd(l, d); } diff --git a/usr.bin/make/lst.lib/lstFirst.c b/usr.bin/make/lst.lib/lstFirst.c index 19d515f1c5e..c37717fd728 100644 --- a/usr.bin/make/lst.lib/lstFirst.c +++ b/usr.bin/make/lst.lib/lstFirst.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lstFirst.c,v 1.6 2000/06/17 14:34:08 espie Exp $ */ +/* $OpenBSD: lstFirst.c,v 1.7 2000/06/17 14:43:39 espie Exp $ */ /* $NetBSD: lstFirst.c,v 1.5 1996/11/06 17:59:41 christos Exp $ */ /* @@ -41,7 +41,7 @@ #if 0 static char sccsid[] = "@(#)lstFirst.c 8.1 (Berkeley) 6/6/93"; #else -static char rcsid[] = "$OpenBSD: lstFirst.c,v 1.6 2000/06/17 14:34:08 espie Exp $"; +static char rcsid[] = "$OpenBSD: lstFirst.c,v 1.7 2000/06/17 14:43:39 espie Exp $"; #endif #endif /* not lint */ @@ -69,9 +69,6 @@ LstNode Lst_First(l) Lst l; { - if (!LstValid(l) || LstIsEmpty(l)) - return NULL; - else - return l->firstPtr; + return l->firstPtr; } diff --git a/usr.bin/make/lst.lib/lstInit.c b/usr.bin/make/lst.lib/lstInit.c index 1497be9b03d..8e393363924 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.8 2000/06/17 14:38:22 espie Exp $ */ +/* $OpenBSD: lstInit.c,v 1.9 2000/06/17 14:43:39 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.8 2000/06/17 14:38:22 espie Exp $"; +static char rcsid[] = "$OpenBSD: lstInit.c,v 1.9 2000/06/17 14:43:39 espie Exp $"; #endif #endif /* not lint */ @@ -52,22 +52,6 @@ static char rcsid[] = "$OpenBSD: lstInit.c,v 1.8 2000/06/17 14:38:22 espie Exp $ #include "lstInt.h" -/*- - *----------------------------------------------------------------------- - * Lst_New -- - * Create and initialize a new list. - *----------------------------------------------------------------------- - */ -Lst -Lst_New() -{ - register Lst nList; - - PAlloc(nList, Lst); - Lst_Init(nList); - - return nList; -} /*- *----------------------------------------------------------------------- * Lst_Init -- diff --git a/usr.bin/make/lst.lib/lstInsert.c b/usr.bin/make/lst.lib/lstInsert.c index 67afdd5d452..50c3af30689 100644 --- a/usr.bin/make/lst.lib/lstInsert.c +++ b/usr.bin/make/lst.lib/lstInsert.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lstInsert.c,v 1.9 2000/06/17 14:34:09 espie Exp $ */ +/* $OpenBSD: lstInsert.c,v 1.10 2000/06/17 14:43:39 espie Exp $ */ /* $NetBSD: lstInsert.c,v 1.5 1996/11/06 17:59:44 christos Exp $ */ /* @@ -41,7 +41,7 @@ #if 0 static char sccsid[] = "@(#)lstInsert.c 8.1 (Berkeley) 6/6/93"; #else -static char rcsid[] = "$OpenBSD: lstInsert.c,v 1.9 2000/06/17 14:34:09 espie Exp $"; +static char rcsid[] = "$OpenBSD: lstInsert.c,v 1.10 2000/06/17 14:43:39 espie Exp $"; #endif #endif /* not lint */ @@ -76,10 +76,10 @@ Lst_Insert(l, ln, d) /* * check validity of arguments */ - if (LstValid(l) && (LstIsEmpty(l) && ln == NULL)) + if (LstIsEmpty(l) && ln == NULL) goto ok; - if (!LstValid(l) || LstIsEmpty(l) || !LstNodeValid(ln, l)) + if (LstIsEmpty(l) || !LstNodeValid(ln, l)) return; ok: diff --git a/usr.bin/make/lst.lib/lstInt.h b/usr.bin/make/lst.lib/lstInt.h index f44f58a38c9..78c5db8d65f 100644 --- a/usr.bin/make/lst.lib/lstInt.h +++ b/usr.bin/make/lst.lib/lstInt.h @@ -1,4 +1,4 @@ -/* $OpenBSD: lstInt.h,v 1.10 2000/06/17 14:34:09 espie Exp $ */ +/* $OpenBSD: lstInt.h,v 1.11 2000/06/17 14:43:40 espie Exp $ */ /* $NetBSD: lstInt.h,v 1.7 1996/11/06 17:59:44 christos Exp $ */ /* @@ -61,12 +61,6 @@ */ #define PAlloc(var,ptype) var = (ptype) emalloc (sizeof (*var)) -/* - * LstValid (l) -- - * Return TRUE if the list l is valid - */ -#define LstValid(l) ((l) == NULL ? FALSE : TRUE) - /* * LstNodeValid (ln, l) -- * Return TRUE if the LstNode ln is valid with respect to l diff --git a/usr.bin/make/lst.lib/lstIsAtEnd.c b/usr.bin/make/lst.lib/lstIsAtEnd.c index 880795d01fb..6e640433da8 100644 --- a/usr.bin/make/lst.lib/lstIsAtEnd.c +++ b/usr.bin/make/lst.lib/lstIsAtEnd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lstIsAtEnd.c,v 1.5 2000/06/17 14:34:09 espie Exp $ */ +/* $OpenBSD: lstIsAtEnd.c,v 1.6 2000/06/17 14:43:40 espie Exp $ */ /* $NetBSD: lstIsAtEnd.c,v 1.5 1996/11/06 17:59:45 christos Exp $ */ /* @@ -41,7 +41,7 @@ #if 0 static char sccsid[] = "@(#)lstIsAtEnd.c 8.1 (Berkeley) 6/6/93"; #else -static char rcsid[] = "$OpenBSD: lstIsAtEnd.c,v 1.5 2000/06/17 14:34:09 espie Exp $"; +static char rcsid[] = "$OpenBSD: lstIsAtEnd.c,v 1.6 2000/06/17 14:43:40 espie Exp $"; #endif #endif /* not lint */ @@ -76,6 +76,6 @@ Boolean Lst_IsAtEnd(l) Lst l; { - return !LstValid(l) || !l->isOpen || l->atEnd == Head || l->atEnd == Tail; + return !l->isOpen || l->atEnd == Head || l->atEnd == Tail; } diff --git a/usr.bin/make/lst.lib/lstIsEmpty.c b/usr.bin/make/lst.lib/lstIsEmpty.c index 2ff56351ee2..b98ca563a19 100644 --- a/usr.bin/make/lst.lib/lstIsEmpty.c +++ b/usr.bin/make/lst.lib/lstIsEmpty.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lstIsEmpty.c,v 1.5 1999/12/18 21:53:34 espie Exp $ */ +/* $OpenBSD: lstIsEmpty.c,v 1.6 2000/06/17 14:43:40 espie Exp $ */ /* $NetBSD: lstIsEmpty.c,v 1.5 1996/11/06 17:59:47 christos Exp $ */ /* @@ -41,7 +41,7 @@ #if 0 static char sccsid[] = "@(#)lstIsEmpty.c 8.1 (Berkeley) 6/6/93"; #else -static char rcsid[] = "$OpenBSD: lstIsEmpty.c,v 1.5 1999/12/18 21:53:34 espie Exp $"; +static char rcsid[] = "$OpenBSD: lstIsEmpty.c,v 1.6 2000/06/17 14:43:40 espie Exp $"; #endif #endif /* not lint */ @@ -56,21 +56,12 @@ static char rcsid[] = "$OpenBSD: lstIsEmpty.c,v 1.5 1999/12/18 21:53:34 espie Ex *----------------------------------------------------------------------- * Lst_IsEmpty -- * Return TRUE if the given list is empty. - * - * Results: - * TRUE if the list is empty, FALSE otherwise. - * - * Side Effects: - * None. - * - * A list is considered empty if its firstPtr == NULL (or if - * the list itself is NULL). *----------------------------------------------------------------------- */ Boolean -Lst_IsEmpty (l) +Lst_IsEmpty(l) Lst l; { - return ( ! LstValid (l) || LstIsEmpty(l)); + return LstIsEmpty(l); } diff --git a/usr.bin/make/lst.lib/lstLast.c b/usr.bin/make/lst.lib/lstLast.c index 65a3128821e..3117ce856cc 100644 --- a/usr.bin/make/lst.lib/lstLast.c +++ b/usr.bin/make/lst.lib/lstLast.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lstLast.c,v 1.6 2000/06/17 14:34:09 espie Exp $ */ +/* $OpenBSD: lstLast.c,v 1.7 2000/06/17 14:43:40 espie Exp $ */ /* $NetBSD: lstLast.c,v 1.5 1996/11/06 17:59:48 christos Exp $ */ /* @@ -41,7 +41,7 @@ #if 0 static char sccsid[] = "@(#)lstLast.c 8.1 (Berkeley) 6/6/93"; #else -static char rcsid[] = "$OpenBSD: lstLast.c,v 1.6 2000/06/17 14:34:09 espie Exp $"; +static char rcsid[] = "$OpenBSD: lstLast.c,v 1.7 2000/06/17 14:43:40 espie Exp $"; #endif #endif /* not lint */ @@ -65,9 +65,6 @@ LstNode Lst_Last(l) Lst l; { - if (!LstValid(l) || LstIsEmpty(l)) - return NULL; - else - return (LstNode)(l->lastPtr); + return l->lastPtr; } diff --git a/usr.bin/make/lst.lib/lstNext.c b/usr.bin/make/lst.lib/lstNext.c index 3de2a6f81c7..fd4c4cf7b4d 100644 --- a/usr.bin/make/lst.lib/lstNext.c +++ b/usr.bin/make/lst.lib/lstNext.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lstNext.c,v 1.6 2000/06/17 14:34:10 espie Exp $ */ +/* $OpenBSD: lstNext.c,v 1.7 2000/06/17 14:43:40 espie Exp $ */ /* $NetBSD: lstNext.c,v 1.5 1996/11/06 17:59:49 christos Exp $ */ /* @@ -41,7 +41,7 @@ #if 0 static char sccsid[] = "@(#)lstNext.c 8.1 (Berkeley) 6/6/93"; #else -static char rcsid[] = "$OpenBSD: lstNext.c,v 1.6 2000/06/17 14:34:10 espie Exp $"; +static char rcsid[] = "$OpenBSD: lstNext.c,v 1.7 2000/06/17 14:43:40 espie Exp $"; #endif #endif /* not lint */ @@ -78,7 +78,7 @@ Lst_Next(l) { LstNode tln; - if (LstValid(l) == FALSE || l->isOpen == FALSE) + if (l->isOpen == FALSE) return NULL; l->prevPtr = l->curPtr; diff --git a/usr.bin/make/lst.lib/lstOpen.c b/usr.bin/make/lst.lib/lstOpen.c index 04f7721fda1..e525358a150 100644 --- a/usr.bin/make/lst.lib/lstOpen.c +++ b/usr.bin/make/lst.lib/lstOpen.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lstOpen.c,v 1.6 2000/06/17 14:34:10 espie Exp $ */ +/* $OpenBSD: lstOpen.c,v 1.7 2000/06/17 14:43:40 espie Exp $ */ /* $NetBSD: lstOpen.c,v 1.5 1996/11/06 17:59:50 christos Exp $ */ /* @@ -41,7 +41,7 @@ #if 0 static char sccsid[] = "@(#)lstOpen.c 8.1 (Berkeley) 6/6/93"; #else -static char rcsid[] = "$OpenBSD: lstOpen.c,v 1.6 2000/06/17 14:34:10 espie Exp $"; +static char rcsid[] = "$OpenBSD: lstOpen.c,v 1.7 2000/06/17 14:43:40 espie Exp $"; #endif #endif /* not lint */ @@ -62,9 +62,6 @@ static char rcsid[] = "$OpenBSD: lstOpen.c,v 1.6 2000/06/17 14:34:10 espie Exp $ * Open a list for sequential access. A list can still be searched, * etc., without confusing these functions. * - * Results: - * SUCCESS or FAILURE. - * * Side Effects: * isOpen is set TRUE and curPtr is set to NULL so the * other sequential functions no it was just opened and can choose @@ -76,12 +73,9 @@ ReturnStatus Lst_Open(l) Lst l; { - if (LstValid(l) == FALSE) - return FAILURE; l->isOpen = TRUE; l->atEnd = LstIsEmpty(l) ? Head : Unknown; l->curPtr = NULL; - return SUCCESS; } diff --git a/usr.bin/make/lst.lib/lstRemove.c b/usr.bin/make/lst.lib/lstRemove.c index 6bcb2a42fd3..e6be2a8eff2 100644 --- a/usr.bin/make/lst.lib/lstRemove.c +++ b/usr.bin/make/lst.lib/lstRemove.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lstRemove.c,v 1.8 2000/06/17 14:34:10 espie Exp $ */ +/* $OpenBSD: lstRemove.c,v 1.9 2000/06/17 14:43:40 espie Exp $ */ /* $NetBSD: lstRemove.c,v 1.5 1996/11/06 17:59:50 christos Exp $ */ /* @@ -41,7 +41,7 @@ #if 0 static char sccsid[] = "@(#)lstRemove.c 8.1 (Berkeley) 6/6/93"; #else -static char rcsid[] = "$OpenBSD: lstRemove.c,v 1.8 2000/06/17 14:34:10 espie Exp $"; +static char rcsid[] = "$OpenBSD: lstRemove.c,v 1.9 2000/06/17 14:43:40 espie Exp $"; #endif #endif /* not lint */ @@ -72,7 +72,7 @@ Lst_Remove(l, ln) Lst l; LstNode ln; { - if (!LstValid(l) || !LstNodeValid(ln, l)) + if (!LstNodeValid(ln, l)) return; /* unlink it from the list */ diff --git a/usr.bin/make/make.c b/usr.bin/make/make.c index ca8032f76af..33a86775d71 100644 --- a/usr.bin/make/make.c +++ b/usr.bin/make/make.c @@ -1,4 +1,4 @@ -/* $OpenBSD: make.c,v 1.17 2000/06/17 14:38:18 espie Exp $ */ +/* $OpenBSD: make.c,v 1.18 2000/06/17 14:43:36 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.17 2000/06/17 14:38:18 espie Exp $"; +static char rcsid[] = "$OpenBSD: make.c,v 1.18 2000/06/17 14:43:36 espie Exp $"; #endif #endif /* not lint */ @@ -329,7 +329,7 @@ Make_HandleUse(cgn, pgn) * .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); } if (Lst_Open(&cgn->children) == SUCCESS) { @@ -792,12 +792,12 @@ Make_Run(targs) Lst targs; /* the initial list of targets */ { register GNode *gn; /* a temporary pointer */ - register Lst examine; /* List of targets to examine */ + LIST examine; /* List of targets to examine */ int errors; /* Number of errors the Job module reports */ Lst_Init(&toBeMade); - examine = Lst_Duplicate(targs, NOCOPY); + Lst_Clone(&examine, targs, NOCOPY); numNodes = 0; /* @@ -808,7 +808,7 @@ Make_Run(targs) * be looked at in a minute, otherwise we add its children to our queue * and go on about our business. */ - while ((gn = (GNode *)Lst_DeQueue(examine)) != NULL) { + while ((gn = (GNode *)Lst_DeQueue(&examine)) != NULL) { if (!gn->make) { gn->make = TRUE; @@ -822,14 +822,14 @@ Make_Run(targs) 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_Delete(examine, NOFREE); + Lst_Destroy(&examine, NOFREE); if (queryFlag) { /* diff --git a/usr.bin/make/parse.c b/usr.bin/make/parse.c index 35267238c32..001c55c2f31 100644 --- a/usr.bin/make/parse.c +++ b/usr.bin/make/parse.c @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.c,v 1.44 2000/06/17 14:40:29 espie Exp $ */ +/* $OpenBSD: parse.c,v 1.45 2000/06/17 14:43:36 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.44 2000/06/17 14:40:29 espie Exp $"; +static char rcsid[] = "$OpenBSD: parse.c,v 1.45 2000/06/17 14:43:36 espie Exp $"; #endif #endif /* not lint */ @@ -115,12 +115,12 @@ static LIST fileNames; /* file names to free at end */ */ #define CONTINUE 1 #define DONE 0 -static Lst targets; /* targets we're working on */ +static LIST targets; /* targets we're working on */ #ifdef CLEANUP -static LIST 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 */ +static Boolean inLine; /* true if currently in a dependency + * line or its commands */ typedef struct { char *str; char *ptr; @@ -507,7 +507,7 @@ ParseDoOp (gnp, opp) /* * 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; } @@ -590,7 +590,7 @@ ParseDoSrc (tOp, src, allsrc) if (keywd != -1) { int op = parseKeywords[keywd].op; if (op != 0) { - Lst_Find(targets, ParseDoOp, &op); + Lst_Find(&targets, ParseDoOp, &op); return; } if (parseKeywords[keywd].spec == Wait) { @@ -650,7 +650,7 @@ ParseDoSrc (tOp, src, allsrc) if (tOp) { gn->type |= tOp; } else { - Lst_ForEach(targets, ParseLinkSrc, gn); + Lst_ForEach(&targets, ParseLinkSrc, gn); } if ((gn->type & OP_OPMASK) == OP_DOUBLEDEP) { register GNode *cohort; @@ -661,7 +661,7 @@ ParseDoSrc (tOp, src, allsrc) if (tOp) { cohort->type |= tOp; } else { - Lst_ForEach(targets, ParseLinkSrc, cohort); + Lst_ForEach(&targets, ParseLinkSrc, cohort); } } } @@ -781,7 +781,7 @@ ParseDoDependency (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 + LIST paths; /* List of search paths to alter when parsing * a list of .PATH targets */ int tOp; /* operator from special target */ LIST curTargs; /* list of target names to be found and added @@ -792,7 +792,7 @@ ParseDoDependency (line) specType = Not; waiting = 0; - paths = (Lst)NULL; + Lst_Init(&paths); Lst_Init(&curTargs); Lst_Init(&curSrcs); @@ -858,7 +858,7 @@ ParseDoDependency (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; @@ -927,9 +927,7 @@ ParseDoDependency (line) */ switch (specType) { case ExPath: - if (paths == NULL) - paths = Lst_New(); - Lst_AtEnd(paths, &dirSearchPath); + Lst_AtEnd(&paths, &dirSearchPath); break; case Main: if (!Lst_IsEmpty(&create)) { @@ -941,12 +939,12 @@ ParseDoDependency (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: @@ -974,17 +972,14 @@ ParseDoDependency (line) Lst path; specType = ExPath; - path = Suff_GetPath (&line[5]); + path = Suff_GetPath(&line[5]); if (path == NULL) { - Parse_Error (PARSE_FATAL, + Parse_Error(PARSE_FATAL, "Suffix '%s' not defined (yet)", &line[5]); return; - } else { - if (paths == NULL) - paths = Lst_New(); - Lst_AtEnd(paths, path); - } + } else + Lst_AtEnd(&paths, path); } } @@ -1025,7 +1020,7 @@ ParseDoDependency (line) } if (gn != NULL) - Lst_AtEnd(targets, gn); + Lst_AtEnd(&targets, gn); } } else if (specType == ExPath && *line != '.' && *line != '\0') { Parse_Error(PARSE_WARNING, "Extra target (%s) ignored", line); @@ -1059,7 +1054,7 @@ ParseDoDependency (line) /* Don't need the list of target names any more */ 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"); @@ -1100,7 +1095,7 @@ ParseDoDependency (line) cp++; /* Advance beyond operator */ - Lst_Find(targets, ParseDoOp, &op); + Lst_Find(&targets, ParseDoOp, &op); /* * Get to the first source @@ -1134,7 +1129,7 @@ ParseDoDependency (line) beSilent = TRUE; break; case ExPath: - Lst_Every(paths, ParseClearPath); + Lst_Every(&paths, ParseClearPath); break; default: break; @@ -1200,7 +1195,7 @@ ParseDoDependency (line) Suff_AddSuffix (line); break; case ExPath: - Lst_ForEach(paths, ParseAddDir, line); + Lst_ForEach(&paths, ParseAddDir, line); break; case Includes: Suff_AddInclude (line); @@ -1223,8 +1218,7 @@ ParseDoDependency (line) } line = cp; } - if (paths) - Lst_Delete(paths, NOFREE); + Lst_Destroy(&paths, NOFREE); } else { while (*line) { /* @@ -1284,7 +1278,7 @@ ParseDoDependency (line) * the first dependency line that is actually a real target * (i.e. isn't a .USE or .EXEC rule) to be made. */ - Lst_Find(targets, ParseFindMain, NULL); + Lst_Find(&targets, ParseFindMain, NULL); } /* Finally, destroy the list of sources. */ @@ -2406,9 +2400,9 @@ static void ParseFinishLine() { if (inLine) { - Lst_Every(targets, Suff_EndTransform); - Lst_Delete(targets, ParseHasCommands); - targets = NULL; + Lst_Every(&targets, Suff_EndTransform); + Lst_Destroy(&targets, ParseHasCommands); + Lst_Init(&targets); inLine = FALSE; } } @@ -2499,7 +2493,7 @@ Parse_File(name, 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); #ifdef CLEANUP Lst_AtEnd(&targCmds, line); #endif @@ -2571,13 +2565,9 @@ Parse_File(name, stream) free (line); line = cp; - /* - * Need a non-circular list for the target nodes - */ - if (targets) - Lst_Delete(targets, NOFREE); - - targets = Lst_New(); + /* Need a new list for the target nodes */ + Lst_Destroy(&targets, NOFREE); + Lst_Init(&targets); inLine = TRUE; ParseDoDependency (line); @@ -2622,6 +2612,7 @@ Parse_Init() Lst_Init(&parseIncPath); Lst_Init(&sysIncPath); Lst_Init(&includes); + Lst_Init(&targets); #ifdef CLEANUP Lst_Init(&targCmds); Lst_Init(&fileNames); @@ -2634,8 +2625,7 @@ Parse_End() #ifdef CLEANUP Lst_Destroy(&targCmds, (SimpleProc)free); Lst_Destroy(&fileNames, (void (*) __P((ClientData))) free); - if (targets) - Lst_Delete(targets, NOFREE); + Lst_Delete(&targets, NOFREE); Lst_Destroy(&sysIncPath, Dir_Destroy); Lst_Destroy(&parseIncPath, Dir_Destroy); Lst_Destroy(&includes, NOFREE); /* Should be empty now */ @@ -2664,7 +2654,7 @@ Parse_MainName(listmain) /*NOTREACHED*/ else if (mainNode->type & OP_DOUBLEDEP) { Lst_AtEnd(listmain, mainNode); - Lst_Concat(listmain, &mainNode->cohorts, LST_CONCNEW); + Lst_Concat(listmain, &mainNode->cohorts); } else Lst_AtEnd(listmain, mainNode); diff --git a/usr.bin/make/suff.c b/usr.bin/make/suff.c index d494fe96c4d..0d49e746beb 100644 --- a/usr.bin/make/suff.c +++ b/usr.bin/make/suff.c @@ -1,4 +1,4 @@ -/* $OpenBSD: suff.c,v 1.29 2000/06/17 14:38:19 espie Exp $ */ +/* $OpenBSD: suff.c,v 1.30 2000/06/17 14:43:36 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.29 2000/06/17 14:38:19 espie Exp $"; +static char rcsid[] = "$OpenBSD: suff.c,v 1.30 2000/06/17 14:43:36 espie Exp $"; #endif #endif /* not lint */ @@ -103,7 +103,7 @@ static char rcsid[] = "$OpenBSD: suff.c,v 1.29 2000/06/17 14:38:19 espie Exp $"; #include "hash.h" #include "dir.h" -static Lst sufflist; /* Lst of suffixes */ +static LIST sufflist; /* Lst of suffixes */ #ifdef CLEANUP static LIST suffClean; /* Lst of suffixes to be cleaned */ #endif @@ -122,7 +122,7 @@ 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 + LIST searchPath; /* The path along which files of this suffix * may be found */ int sNum; /* The suffix number */ LIST parents; /* Suffixes we have a transformation to */ @@ -166,7 +166,7 @@ static int SuffSuffIsSuffixP __P((void *, void *)); static int SuffSuffHasNameP __P((void *, void *)); static int SuffSuffIsPrefix __P((void *, void *)); static int SuffGNHasNameP __P((void *, void *)); -static void SuffUnRef __P((void *, void *)); +static void SuffUnRef __P((Lst, Suff *)); static void SuffFree __P((void *)); static void SuffInsert __P((Lst, Suff *)); static void SuffRemove __P((Lst, Suff *)); @@ -334,13 +334,11 @@ SuffGNHasNameP(gn, name) /*********** Maintenance Functions ************/ static void -SuffUnRef(lp, sp) - void *lp; - void *sp; +SuffUnRef(l, s) + Lst l; + Suff *s; { - Lst l = (Lst) lp; - - LstNode ln = Lst_Member(l, sp); + LstNode ln = Lst_Member(l, s); if (ln != NULL) Lst_Remove(l, ln); } @@ -372,7 +370,7 @@ SuffFree(sp) Lst_Destroy(&s->ref, NOFREE); Lst_Destroy(&s->children, NOFREE); Lst_Destroy(&s->parents, NOFREE); - Lst_Delete(s->searchPath, Dir_Destroy); + Lst_Destroy(&s->searchPath, Dir_Destroy); free(s->name); free(s); @@ -465,9 +463,9 @@ void Suff_ClearSuffixes () { #ifdef CLEANUP - Lst_Concat(&suffClean, sufflist, LST_CONCLINK); + Lst_ConcatDestroy(&suffClean, &sufflist); #endif - sufflist = Lst_New(); + Lst_Init(&sufflist); sNum = 0; suffNull = emptySuff; } @@ -511,7 +509,7 @@ SuffParseTransform(str, srcPtr, targPtr) */ for (;;) { if (srcLn == NULL) { - srcLn = Lst_Find(sufflist, SuffSuffIsPrefix, str); + srcLn = Lst_Find(&sufflist, SuffSuffIsPrefix, str); } else { srcLn = Lst_FindFrom(Lst_Succ(srcLn), SuffSuffIsPrefix, str); @@ -542,7 +540,7 @@ SuffParseTransform(str, srcPtr, targPtr) single = src; singleLn = srcLn; } else { - targLn = Lst_Find(sufflist, SuffSuffHasNameP, str2); + targLn = Lst_Find(&sufflist, SuffSuffHasNameP, str2); if (targLn != NULL) { *srcPtr = src; *targPtr = (Suff *)Lst_Datum(targLn); @@ -718,7 +716,7 @@ SuffRebuildGraph(transformp, sp) */ cp = SuffStrIsPrefix(s->name, transform->name); if (cp != NULL) { - ln = Lst_Find(sufflist, SuffSuffHasNameP, cp); + ln = Lst_Find(&sufflist, SuffSuffHasNameP, cp); if (ln != NULL) { /* * Found target. Link in and return, since it can't be anything @@ -740,7 +738,7 @@ SuffRebuildGraph(transformp, sp) * Null-terminate the source suffix in order to find it. */ cp[1] = '\0'; - ln = Lst_Find(sufflist, SuffSuffHasNameP, transform->name); + ln = Lst_Find(&sufflist, SuffSuffHasNameP, transform->name); /* * Replace the start of the target suffix */ @@ -777,20 +775,20 @@ Suff_AddSuffix (str) Suff *s; /* new suffix descriptor */ LstNode ln; - ln = Lst_Find(sufflist, SuffSuffHasNameP, str); + ln = Lst_Find(&sufflist, SuffSuffHasNameP, str); if (ln == NULL) { s = (Suff *) emalloc (sizeof (Suff)); - s->name = estrdup (str); - s->nameLen = strlen (s->name); - s->searchPath = Lst_New(); + s->name = estrdup(str); + s->nameLen = strlen(s->name); + Lst_Init(&s->searchPath); Lst_Init(&s->children); Lst_Init(&s->parents); Lst_Init(&s->ref); s->sNum = sNum++; s->flags = 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? @@ -807,24 +805,21 @@ Suff_AddSuffix (str) * Results: * The searchPath for the desired suffix or NULL if the suffix isn't * defined. - * - * Side Effects: - * None *----------------------------------------------------------------------- */ Lst -Suff_GetPath (sname) +Suff_GetPath(sname) char *sname; { LstNode ln; Suff *s; - ln = Lst_Find(sufflist, SuffSuffHasNameP, sname); - if (ln == NULL) { - return (NULL); - } else { - s = (Suff *) Lst_Datum (ln); - return (s->searchPath); + ln = Lst_Find(&sufflist, SuffSuffHasNameP, sname); + if (ln == NULL) + return NULL; + else { + s = (Suff *)Lst_Datum(ln); + return &s->searchPath; } } @@ -855,30 +850,29 @@ Suff_DoPaths() LIST inIncludes; /* Cumulative .INCLUDES path */ LIST inLibs; /* Cumulative .LIBS path */ - if (Lst_Open (sufflist) == FAILURE) { + if (Lst_Open(&sufflist) == FAILURE) return; - } Lst_Init(&inIncludes); Lst_Init(&inLibs); - while ((ln = Lst_Next (sufflist)) != NULL) { + while ((ln = Lst_Next(&sufflist)) != NULL) { s = (Suff *) 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_Delete(s->searchPath, Dir_Destroy); - s->searchPath = Lst_Duplicate(&dirSearchPath, Dir_CopyDir); + Lst_Destroy(&s->searchPath, Dir_Destroy); + Lst_Clone(&s->searchPath, &dirSearchPath, Dir_CopyDir); } } @@ -890,7 +884,7 @@ Suff_DoPaths() Lst_Destroy(&inIncludes, Dir_Destroy); Lst_Destroy(&inLibs, Dir_Destroy); - Lst_Close (sufflist); + Lst_Close(&sufflist); } /*- @@ -915,7 +909,7 @@ Suff_AddInclude (sname) LstNode ln; Suff *s; - ln = Lst_Find(sufflist, SuffSuffHasNameP, sname); + ln = Lst_Find(&sufflist, SuffSuffHasNameP, sname); if (ln != NULL) { s = (Suff *) Lst_Datum (ln); s->flags |= SUFF_INCLUDE; @@ -945,7 +939,7 @@ Suff_AddLib (sname) LstNode ln; Suff *s; - ln = Lst_Find(sufflist, SuffSuffHasNameP, sname); + ln = Lst_Find(&sufflist, SuffSuffHasNameP, sname); if (ln != NULL) { s = (Suff *) Lst_Datum (ln); s->flags |= SUFF_LIBRARY; @@ -1151,7 +1145,7 @@ SuffFindThem (srcs, slst) 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); @@ -1220,7 +1214,7 @@ SuffFindCmds (targ, slst) * The node matches the prefix ok, see if it has a known * suffix. */ - ln = Lst_Find(sufflist, SuffSuffHasNameP, &cp[prefLen]); + ln = Lst_Find(&sufflist, SuffSuffHasNameP, &cp[prefLen]); if (ln != NULL) { /* * It even has a known suffix, see if there's a transformation @@ -1422,7 +1416,7 @@ SuffExpandChildren(cgnp, pgnp) * Else use the default system search path. */ cp = cgn->name + strlen(cgn->name); - ln = Lst_Find(sufflist, SuffSuffIsSuffixP, cp); + ln = Lst_Find(&sufflist, SuffSuffIsSuffixP, cp); if (DEBUG(SUFF)) printf("Wildcard expanding \"%s\"...", cgn->name); @@ -1432,7 +1426,7 @@ SuffExpandChildren(cgnp, pgnp) if (DEBUG(SUFF)) printf("suffix is \"%s\"...", s->name); - path = s->searchPath; + path = &s->searchPath; } else { /* * Use default search path @@ -1743,8 +1737,8 @@ SuffFindNormalDeps(gn, 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 + LIST srcs; /* List of sources at which to look */ + LIST 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 */ @@ -1760,9 +1754,9 @@ SuffFindNormalDeps(gn, slst) /* * Begin at the beginning... */ - ln = Lst_First(sufflist); - srcs = Lst_New(); - targs = Lst_New(); + 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 @@ -1815,19 +1809,13 @@ SuffFindNormalDeps(gn, slst) memcpy(targ->pref, sopref, prefLen); targ->pref[prefLen] = '\0'; - /* - * Add nodes from which the target can be made - */ - SuffAddLevel(srcs, targ); + /* Add nodes from which the target can be made. */ + SuffAddLevel(&srcs, targ); - /* - * Record the target so we can nuke it - */ - Lst_AtEnd(targs, targ); + /* Record the target so we can nuke it. */ + Lst_AtEnd(&targs, targ); - /* - * Search from this suffix's successor... - */ + /* Search from this suffix's successor... */ ln = Lst_Succ(ln); } } @@ -1835,7 +1823,7 @@ SuffFindNormalDeps(gn, slst) /* * Handle target of unknown suffix... */ - if (Lst_IsEmpty(targs) && suffNull != NULL) { + if (Lst_IsEmpty(&targs) && suffNull != NULL) { if (DEBUG(SUFF)) { printf("\tNo known suffix on %s. Using .NULL suffix\n", gn->name); } @@ -1856,7 +1844,7 @@ SuffFindNormalDeps(gn, slst) * or dependencies defined for this gnode */ if (Lst_IsEmpty(&gn->commands) && Lst_IsEmpty(&gn->children)) - SuffAddLevel(srcs, targ); + SuffAddLevel(&srcs, targ); else { if (DEBUG(SUFF)) printf("not "); @@ -1865,25 +1853,24 @@ SuffFindNormalDeps(gn, slst) if (DEBUG(SUFF)) printf("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 == (Src *)NULL) { + if (bottom == NULL) { /* * No known transformations -- use the first suffix found for setting * the local variables. */ - if (!Lst_IsEmpty(targs)) { - targ = (Src *)Lst_Datum(Lst_First(targs)); - } else { - targ = (Src *)NULL; - } + if (!Lst_IsEmpty(&targs)) + targ = (Src *)Lst_Datum(Lst_First(&targs)); + else + targ = NULL; } else { /* * Work up the transformation path to find the suffix of the @@ -1926,7 +1913,7 @@ sfnd_abort: { gn->path = Dir_FindFile(gn->name, (targ == NULL ? &dirSearchPath : - targ->suff->searchPath)); + &targ->suff->searchPath)); if (gn->path != NULL) { char *ptr; Var_Set(TARGET, gn->path, gn); @@ -2080,11 +2067,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); + Lst_ConcatDestroy(slst, &srcs); + Lst_ConcatDestroy(slst, &targs); } @@ -2159,10 +2146,10 @@ SuffFindDeps (gn, slst) LstNode ln; Suff *s; - ln = Lst_Find(sufflist, SuffSuffHasNameP, LIBSUFF); + ln = Lst_Find(&sufflist, SuffSuffHasNameP, LIBSUFF); if (ln != NULL) { gn->suffix = s = (Suff *) Lst_Datum (ln); - Arch_FindLib (gn, s->searchPath); + Arch_FindLib(gn, &s->searchPath); } else { gn->suffix = NULL; Var_Set (TARGET, gn->name, gn); @@ -2202,7 +2189,7 @@ Suff_SetNull(name) Suff *s; LstNode ln; - ln = Lst_Find(sufflist, SuffSuffHasNameP, name); + ln = Lst_Find(&sufflist, SuffSuffHasNameP, name); if (ln != NULL) { s = (Suff *)Lst_Datum(ln); if (suffNull != (Suff *)NULL) { @@ -2234,7 +2221,7 @@ Suff_SetNull(name) void Suff_Init () { - sufflist = Lst_New(); + Lst_Init(&sufflist); #ifdef CLEANUP Lst_Init(&suffClean); #endif @@ -2251,8 +2238,8 @@ Suff_Init () suffNull->name = estrdup (""); suffNull->nameLen = 0; - suffNull->searchPath = Lst_New(); - Dir_Concat(suffNull->searchPath, &dirSearchPath); + Lst_Init(&suffNull->searchPath); + Dir_Concat(&suffNull->searchPath, &dirSearchPath); Lst_Init(&suffNull->children); Lst_Init(&suffNull->parents); Lst_Init(&suffNull->ref); @@ -2279,7 +2266,7 @@ void Suff_End() { #ifdef CLEANUP - Lst_Delete(sufflist, SuffFree); + Lst_Destroy(&sufflist, SuffFree); Lst_Destroy(&suffClean, SuffFree); if (suffNull) SuffFree(suffNull); @@ -2332,7 +2319,7 @@ SuffPrintSuff(sp) printf("\n#\tFrom: "); Lst_Every(&s->children, SuffPrintName); printf("\n#\tSearch Path: "); - Dir_PrintPath(s->searchPath); + Dir_PrintPath(&s->searchPath); fputc('\n', stdout); } @@ -2353,7 +2340,7 @@ void Suff_PrintAll() { printf("#*** Suffixes:\n"); - Lst_Every(sufflist, SuffPrintSuff); + Lst_Every(&sufflist, SuffPrintSuff); printf("#*** Transformations:\n"); Lst_Every(&transforms, SuffPrintTrans); diff --git a/usr.bin/make/targ.c b/usr.bin/make/targ.c index 0e1420752be..5ecc7c26967 100644 --- a/usr.bin/make/targ.c +++ b/usr.bin/make/targ.c @@ -1,4 +1,4 @@ -/* $OpenBSD: targ.c,v 1.20 2000/06/17 14:40:30 espie Exp $ */ +/* $OpenBSD: targ.c,v 1.21 2000/06/17 14:43:37 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.20 2000/06/17 14:40:30 espie Exp $"; +static char *rcsid = "$OpenBSD: targ.c,v 1.21 2000/06/17 14:43:37 espie Exp $"; #endif #endif /* not lint */ @@ -313,7 +313,7 @@ Targ_FindList(nodes, names) */ Lst_AtEnd(nodes, gn); if (gn->type & OP_DOUBLEDEP) - Lst_Concat(nodes, &gn->cohorts, LST_CONCNEW); + Lst_Concat(nodes, &gn->cohorts); } } -- cgit v1.2.3