diff options
Diffstat (limited to 'usr.bin/make/lst.lib/lstInsert.c')
-rw-r--r-- | usr.bin/make/lst.lib/lstInsert.c | 47 |
1 files changed, 32 insertions, 15 deletions
diff --git a/usr.bin/make/lst.lib/lstInsert.c b/usr.bin/make/lst.lib/lstInsert.c index 356393f7d92..6337f4e17e2 100644 --- a/usr.bin/make/lst.lib/lstInsert.c +++ b/usr.bin/make/lst.lib/lstInsert.c @@ -1,4 +1,5 @@ -/* $OpenBSD: lstInsert.c,v 1.11 2000/09/14 13:32:09 espie Exp $ */ +/* $OpenPackages$ */ +/* $OpenBSD: lstInsert.c,v 1.12 2001/05/03 13:41:21 espie Exp $ */ /* $NetBSD: lstInsert.c,v 1.5 1996/11/06 17:59:44 christos Exp $ */ /* @@ -43,22 +44,25 @@ */ #include "lstInt.h" + #ifndef lint #if 0 -static char sccsid[] = "@(#)lstInsert.c 8.1 (Berkeley) 6/6/93"; +static char sccsid[] = "@(#)lstInsert.c 8.1 (Berkeley) 6/6/93"; #else UNUSED -static char rcsid[] = "$OpenBSD: lstInsert.c,v 1.11 2000/09/14 13:32:09 espie Exp $"; +static char rcsid[] = "$OpenBSD: lstInsert.c,v 1.12 2001/05/03 13:41:21 espie Exp $"; #endif #endif /* not lint */ - /*- *----------------------------------------------------------------------- * Lst_Insert -- * Insert a new node with the given piece of data before the given * node in the given list. * + * Results: + * SUCCESS or FAILURE. + * * Side Effects: * the firstPtr field will be changed if ln is the first node in the * list. @@ -67,27 +71,22 @@ static char rcsid[] = "$OpenBSD: lstInsert.c,v 1.11 2000/09/14 13:32:09 espie Ex */ void Lst_Insert(l, ln, d) - Lst l; /* list to manipulate */ - LstNode ln; /* node before which to insert d */ + Lst l; /* list to manipulate */ + LstNode ln; /* node before which to insert d */ void *d; /* datum to be inserted */ { - LstNode nLNode; /* new lnode for d */ + LstNode nLNode; /* new lnode for d */ - /* - * check validity of arguments - */ - if (LstIsEmpty(l) && ln == NULL) - goto ok; + if (ln == NULL && !Lst_IsEmpty(l)) + return; - if (LstIsEmpty(l) || !LstNodeValid(ln, l)) + if (ln != NULL && Lst_IsEmpty(l)) return; - ok: PAlloc(nLNode, LstNode); nLNode->datum = d; - nLNode->useCount = nLNode->flags = 0; if (ln == NULL) { nLNode->prevPtr = nLNode->nextPtr = NULL; @@ -105,3 +104,21 @@ Lst_Insert(l, ln, d) } } +void +Lst_AtFront(l, d) + Lst l; + void *d; +{ + LstNode ln; + + PAlloc(ln, LstNode); + ln->datum = d; + + ln->nextPtr = l->firstPtr; + ln->prevPtr = NULL; + if (l->firstPtr == NULL) + l->lastPtr = ln; + else + l->firstPtr->prevPtr = ln; + l->firstPtr = ln; +} |