diff options
author | Marc Espie <espie@cvs.openbsd.org> | 2001-05-03 13:41:28 +0000 |
---|---|---|
committer | Marc Espie <espie@cvs.openbsd.org> | 2001-05-03 13:41:28 +0000 |
commit | 32d5cfe8f4f4bd9647d36fc0f609479f02311103 (patch) | |
tree | 06bd5d3e7a2a46bf77a1da707955bfdc16acf068 /usr.bin/make/lst.lib/lstInsert.c | |
parent | a50fea6f0032902e640160d4c42a8c9ce003fc2d (diff) |
Synch with my current work.
Numerous changes:
- generate can build several tables
- style cleanup
- statistics code
- use variable names throughout (struct Name)
- recursive variables everywhere
- faster parser (pass buffer along instead of allocating multiple copies)
- correct parser. Handles comments everywhere, and ; correctly
- more string intervals
- simplified dir.c, less recursion.
- extended for loops
- sinclude()
- finished removing extra junk from Lst_*
- handles ${@D} and friends in a simpler way
- cleaned up and modular VarModifiers handling.
- recognizes some gnu Makefile usages and errors out about them.
Additionally, some extra functionality is defined by FEATURES. The set of
functionalities is currently hardcoded to OpenBSD defaults, but this may
include support for some NetBSD extensions, like ODE modifiers.
Backed by miod@ and millert@, who finally got sick of my endless patches...
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; +} |