summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2000-06-17 14:34:12 +0000
committerMarc Espie <espie@cvs.openbsd.org>2000-06-17 14:34:12 +0000
commit93fa2e228c8792a5468e8d398b5bb6c290eecb73 (patch)
treec0ea5557fc5eeb30f54bbf940c06762e68e76895
parent73501d656ca05164437c542734297118885750b9 (diff)
This patch moves the definition of lists and list nodes to lst.h.
C is not well-suited for opaque data structures. Then it proceeds by removing a lot of non-sensical casts and white space. There are two motivations behind this change: * small functions like Lst_First can now be redefined as macros safely (otherwise, the cast would mean that you might write Lst_First(5) and find out about it rather late) * the size of the Lst data structure is exposed to user code. This will be used to allocate lists statically, instead of malloc/free them like crazy.
-rw-r--r--usr.bin/make/lst.h36
-rw-r--r--usr.bin/make/lst.lib/lstAppend.c35
-rw-r--r--usr.bin/make/lst.lib/lstClose.c12
-rw-r--r--usr.bin/make/lst.lib/lstConcat.c53
-rw-r--r--usr.bin/make/lst.lib/lstDatum.c6
-rw-r--r--usr.bin/make/lst.lib/lstDeQueue.c6
-rw-r--r--usr.bin/make/lst.lib/lstDestroy.c30
-rw-r--r--usr.bin/make/lst.lib/lstDupl.c16
-rw-r--r--usr.bin/make/lst.lib/lstFindFrom.c10
-rw-r--r--usr.bin/make/lst.lib/lstFirst.c15
-rw-r--r--usr.bin/make/lst.lib/lstForEachFrom.c12
-rw-r--r--usr.bin/make/lst.lib/lstInit.c10
-rw-r--r--usr.bin/make/lst.lib/lstInsert.c31
-rw-r--r--usr.bin/make/lst.lib/lstInt.h30
-rw-r--r--usr.bin/make/lst.lib/lstIsAtEnd.c15
-rw-r--r--usr.bin/make/lst.lib/lstLast.c19
-rw-r--r--usr.bin/make/lst.lib/lstMember.c22
-rw-r--r--usr.bin/make/lst.lib/lstNext.c42
-rw-r--r--usr.bin/make/lst.lib/lstOpen.c21
-rw-r--r--usr.bin/make/lst.lib/lstRemove.c58
-rw-r--r--usr.bin/make/lst.lib/lstReplace.c6
-rw-r--r--usr.bin/make/lst.lib/lstSucc.c19
22 files changed, 213 insertions, 291 deletions
diff --git a/usr.bin/make/lst.h b/usr.bin/make/lst.h
index e91ba25d9ea..4dd6613d4f3 100644
--- a/usr.bin/make/lst.h
+++ b/usr.bin/make/lst.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: lst.h,v 1.13 2000/06/10 01:41:05 espie Exp $ */
+/* $OpenBSD: lst.h,v 1.14 2000/06/17 14:34:04 espie Exp $ */
/* $NetBSD: lst.h,v 1.7 1996/11/06 17:59:12 christos Exp $ */
/*
@@ -54,12 +54,42 @@
#include <stdlib.h>
#endif
+/* These data structures are PRIVATE !!!
+ * Here for efficiency, so that some functions can be recoded as inlines,
+ * and so that lst headers don't need dynamic allocation most of the time. */
+typedef struct ListNode_ {
+ struct ListNode_ *prevPtr; /* previous element in list */
+ struct ListNode_ *nextPtr; /* next in list */
+ short useCount:8, /* Count of functions using the node.
+ * node may not be deleted until count
+ * goes to 0 */
+ flags:8; /* Node status flags */
+ void *datum; /* datum associated with this element */
+} *LstNode;
+
+typedef enum {
+ Head, Middle, Tail, Unknown
+} Where;
+
+typedef struct {
+ LstNode firstPtr; /* first node in list */
+ LstNode lastPtr; /* last node in list */
+/*
+ * fields for sequential access
+ */
+ Where atEnd; /* Where in the list the last access was */
+ Boolean isOpen; /* true if list has been Lst_Open'ed */
+ LstNode curPtr; /* current node, if open. NULL if
+ * *just* opened */
+ LstNode prevPtr; /* Previous node, if open. Used by
+ * Lst_Remove */
+} LIST;
+
+typedef LIST *Lst;
/*
* basic typedef. This is what the Lst_ functions handle
*/
-typedef struct Lst *Lst;
-typedef struct LstNode *LstNode;
typedef int (*FindProc) __P((void *, void *));
typedef void (*SimpleProc) __P((void *));
typedef void (*ForEachProc) __P((void *, void *));
diff --git a/usr.bin/make/lst.lib/lstAppend.c b/usr.bin/make/lst.lib/lstAppend.c
index fbc4d8daaab..414118c3f6a 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.8 2000/06/10 01:41:06 espie Exp $ */
+/* $OpenBSD: lstAppend.c,v 1.9 2000/06/17 14:34:05 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.8 2000/06/10 01:41:06 espie Exp $";
+static char rcsid[] = "$OpenBSD: lstAppend.c,v 1.9 2000/06/17 14:34:05 espie Exp $";
#endif
#endif /* not lint */
@@ -74,41 +74,34 @@ Lst_Append(l, ln, d)
LstNode ln; /* node after which to append the datum */
void *d; /* said datum */
{
- register List list;
- register ListNode lNode;
- register ListNode nLNode;
+ LstNode nLNode;
- if (LstValid (l) && (ln == NULL && LstIsEmpty (l))) {
+ if (LstValid(l) && (ln == NULL && LstIsEmpty(l))) {
goto ok;
}
- if (!LstValid (l) || LstIsEmpty (l) || ! LstNodeValid (ln, l)) {
+ if (!LstValid(l) || LstIsEmpty(l) || ! LstNodeValid(ln, l)) {
return;
}
ok:
- list = (List)l;
- lNode = (ListNode)ln;
-
- PAlloc (nLNode, ListNode);
+ PAlloc(nLNode, LstNode);
nLNode->datum = d;
nLNode->useCount = nLNode->flags = 0;
- if (lNode == NULL) {
+ if (ln == NULL) {
nLNode->nextPtr = nLNode->prevPtr = NULL;
- list->firstPtr = list->lastPtr = nLNode;
+ l->firstPtr = l->lastPtr = nLNode;
} else {
- nLNode->prevPtr = lNode;
- nLNode->nextPtr = lNode->nextPtr;
+ nLNode->prevPtr = ln;
+ nLNode->nextPtr = ln->nextPtr;
- lNode->nextPtr = nLNode;
- if (nLNode->nextPtr != NULL) {
+ ln->nextPtr = nLNode;
+ if (nLNode->nextPtr != NULL)
nLNode->nextPtr->prevPtr = nLNode;
- }
- if (lNode == list->lastPtr) {
- list->lastPtr = nLNode;
- }
+ if (ln == l->lastPtr)
+ l->lastPtr = nLNode;
}
}
diff --git a/usr.bin/make/lst.lib/lstClose.c b/usr.bin/make/lst.lib/lstClose.c
index ce517f83cc4..9778c1c3403 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.4 1998/12/05 00:06:31 espie Exp $ */
+/* $OpenBSD: lstClose.c,v 1.5 2000/06/17 14:34:06 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.4 1998/12/05 00:06:31 espie Exp $";
+static char rcsid[] = "$OpenBSD: lstClose.c,v 1.5 2000/06/17 14:34:06 espie Exp $";
#endif
#endif /* not lint */
@@ -71,14 +71,12 @@ static char rcsid[] = "$OpenBSD: lstClose.c,v 1.4 1998/12/05 00:06:31 espie Exp
*-----------------------------------------------------------------------
*/
void
-Lst_Close (l)
+Lst_Close(l)
Lst l; /* The list to close */
{
- register List list = (List) l;
-
if (LstValid(l) == TRUE) {
- list->isOpen = FALSE;
- list->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 9eb3847f05d..fb0d867ba58 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.8 2000/06/10 01:41:06 espie Exp $ */
+/* $OpenBSD: lstConcat.c,v 1.9 2000/06/17 14:34:06 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.8 2000/06/10 01:41:06 espie Exp $";
+static char rcsid[] = "$OpenBSD: lstConcat.c,v 1.9 2000/06/17 14:34:06 espie Exp $";
#endif
#endif /* not lint */
@@ -70,25 +70,23 @@ static char rcsid[] = "$OpenBSD: lstConcat.c,v 1.8 2000/06/10 01:41:06 espie Exp
*-----------------------------------------------------------------------
*/
void
-Lst_Concat (l1, l2, flags)
+Lst_Concat(l1, l2, flags)
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 */
{
- register ListNode ln; /* original LstNode */
- register ListNode nln; /* new LstNode */
- register ListNode last; /* the last element in the list. Keeps
+ LstNode ln; /* original LstNode */
+ LstNode nln; /* new LstNode */
+ LstNode last; /* the last element in the list. Keeps
* bookkeeping until the end */
- register List list1 = (List)l1;
- register List list2 = (List)l2;
- if (!LstValid (l1) || !LstValid (l2)) {
+ if (!LstValid(l1) || !LstValid(l2)) {
return;
}
if (flags == LST_CONCLINK) {
- if (list2->firstPtr != NULL) {
+ if (l2->firstPtr != NULL) {
/*
* We set the nextPtr of the
* last element of list two to be NULL to make the loop easier and
@@ -97,7 +95,7 @@ Lst_Concat (l1, l2, flags)
* 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.
*/
- list2->lastPtr->nextPtr = NULL;
+ 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
@@ -106,16 +104,16 @@ Lst_Concat (l1, l2, flags)
* The last element of the second list, if it exists, then becomes
* the last element of the first list.
*/
- list2->firstPtr->prevPtr = list1->lastPtr;
- if (list1->lastPtr != NULL) {
- list1->lastPtr->nextPtr = list2->firstPtr;
+ l2->firstPtr->prevPtr = l1->lastPtr;
+ if (l1->lastPtr != NULL) {
+ l1->lastPtr->nextPtr = l2->firstPtr;
} else {
- list1->firstPtr = list2->firstPtr;
+ l1->firstPtr = l2->firstPtr;
}
- list1->lastPtr = list2->lastPtr;
+ l1->lastPtr = l2->lastPtr;
}
free(l2);
- } else if (list2->firstPtr != NULL) {
+ } else 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
@@ -128,18 +126,15 @@ Lst_Concat (l1, l2, flags)
* the first list must have been empty so the newly-created node is
* made the first node of the list.
*/
- list2->lastPtr->nextPtr = NULL;
- for (last = list1->lastPtr, ln = list2->firstPtr;
- ln != NULL;
- ln = ln->nextPtr)
- {
- PAlloc (nln, ListNode);
+ l2->lastPtr->nextPtr = NULL;
+ for (last = l1->lastPtr, ln = l2->firstPtr; ln != NULL;
+ ln = ln->nextPtr) {
+ PAlloc(nln, LstNode);
nln->datum = ln->datum;
- if (last != NULL) {
+ if (last != NULL)
last->nextPtr = nln;
- } else {
- list1->firstPtr = nln;
- }
+ else
+ l1->firstPtr = nln;
nln->prevPtr = last;
nln->flags = nln->useCount = 0;
last = nln;
@@ -149,11 +144,11 @@ Lst_Concat (l1, l2, flags)
* Finish bookkeeping. The last new element becomes the last element
* of list one.
*/
- list1->lastPtr = last;
+ l1->lastPtr = last;
last->nextPtr = NULL;
- list2->lastPtr->nextPtr = list2->firstPtr;
+ l2->lastPtr->nextPtr = l2->firstPtr;
}
}
diff --git a/usr.bin/make/lst.lib/lstDatum.c b/usr.bin/make/lst.lib/lstDatum.c
index 5b11cd8eddb..95044a2acce 100644
--- a/usr.bin/make/lst.lib/lstDatum.c
+++ b/usr.bin/make/lst.lib/lstDatum.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lstDatum.c,v 1.7 2000/06/10 01:41:06 espie Exp $ */
+/* $OpenBSD: lstDatum.c,v 1.8 2000/06/17 14:34:06 espie Exp $ */
/* $NetBSD: lstDatum.c,v 1.5 1996/11/06 17:59:35 christos Exp $ */
/*
@@ -41,7 +41,7 @@
#if 0
static char sccsid[] = "@(#)lstDatum.c 8.1 (Berkeley) 6/6/93";
#else
-static char rcsid[] = "$OpenBSD: lstDatum.c,v 1.7 2000/06/10 01:41:06 espie Exp $";
+static char rcsid[] = "$OpenBSD: lstDatum.c,v 1.8 2000/06/17 14:34:06 espie Exp $";
#endif
#endif /* not lint */
@@ -70,7 +70,7 @@ Lst_Datum(ln)
LstNode ln;
{
if (ln != NULL)
- return ((ListNode)ln)->datum;
+ return ln->datum;
else
return NULL;
}
diff --git a/usr.bin/make/lst.lib/lstDeQueue.c b/usr.bin/make/lst.lib/lstDeQueue.c
index a0f87b25e2f..1389c411bb6 100644
--- a/usr.bin/make/lst.lib/lstDeQueue.c
+++ b/usr.bin/make/lst.lib/lstDeQueue.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lstDeQueue.c,v 1.8 2000/06/10 01:41:06 espie Exp $ */
+/* $OpenBSD: lstDeQueue.c,v 1.9 2000/06/17 14:34:07 espie Exp $ */
/* $NetBSD: lstDeQueue.c,v 1.5 1996/11/06 17:59:36 christos Exp $ */
/*
@@ -41,7 +41,7 @@
#if 0
static char sccsid[] = "@(#)lstDeQueue.c 8.1 (Berkeley) 6/6/93";
#else
-static char rcsid[] = "$OpenBSD: lstDeQueue.c,v 1.8 2000/06/10 01:41:06 espie Exp $";
+static char rcsid[] = "$OpenBSD: lstDeQueue.c,v 1.9 2000/06/17 14:34:07 espie Exp $";
#endif
#endif /* not lint */
@@ -77,7 +77,7 @@ Lst_DeQueue(l)
if (tln == NULL)
return NULL;
- rd = ((ListNode)tln)->datum;
+ rd = tln->datum;
Lst_Remove(l, tln);
return rd;
}
diff --git a/usr.bin/make/lst.lib/lstDestroy.c b/usr.bin/make/lst.lib/lstDestroy.c
index 229621f01af..74f285ea40e 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.7 2000/06/10 01:41:06 espie Exp $ */
+/* $OpenBSD: lstDestroy.c,v 1.8 2000/06/17 14:34:07 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.7 2000/06/10 01:41:06 espie Exp $";
+static char rcsid[] = "$OpenBSD: lstDestroy.c,v 1.8 2000/06/17 14:34:07 espie Exp $";
#endif
#endif /* not lint */
@@ -72,34 +72,20 @@ Lst_Destroy(l, freeProc)
Lst l;
SimpleProc freeProc;
{
- register ListNode ln;
- register ListNode tln = NULL;
- register List list = (List)l;
+ LstNode ln;
+ LstNode tln;
- if (l == NULL) {
- /*
- * Note the check for l == (Lst)0 to catch uninitialized static Lst's.
- * Gross, but useful.
- */
+ if (l == NULL)
return;
- }
-
- /* To ease scanning */
- if (list->lastPtr != NULL)
- list->lastPtr->nextPtr = NULL;
- else {
- free(l);
- return;
- }
if (freeProc) {
- for (ln = list->firstPtr; ln != NULL; ln = tln) {
+ for (ln = l->firstPtr; ln != NULL; ln = tln) {
tln = ln->nextPtr;
- (*freeProc) (ln->datum);
+ (*freeProc)(ln->datum);
free(ln);
}
} else {
- for (ln = list->firstPtr; ln != NULL; ln = tln) {
+ for (ln = l->firstPtr; ln != NULL; ln = tln) {
tln = ln->nextPtr;
free(ln);
}
diff --git a/usr.bin/make/lst.lib/lstDupl.c b/usr.bin/make/lst.lib/lstDupl.c
index c826050e28d..30a1e135d89 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.9 2000/06/10 01:41:06 espie Exp $ */
+/* $OpenBSD: lstDupl.c,v 1.10 2000/06/17 14:34:07 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.9 2000/06/10 01:41:06 espie Exp $";
+static char rcsid[] = "$OpenBSD: lstDupl.c,v 1.10 2000/06/17 14:34:07 espie Exp $";
#endif
#endif /* not lint */
@@ -71,20 +71,18 @@ Lst_Duplicate(l, copyProc)
Lst l;
DuplicateProc copyProc;
{
- register Lst nl;
- register ListNode ln;
- register List list = (List)l;
+ Lst nl;
+ LstNode ln;
if (!LstValid (l)) {
return (NULL);
}
nl = Lst_Init();
- if (nl == NULL) {
- return (NULL);
- }
+ if (nl == NULL)
+ return NULL;
- for (ln = list->firstPtr; ln != NULL; ln = ln->nextPtr) {
+ for (ln = l->firstPtr; ln != NULL; ln = ln->nextPtr) {
if (copyProc != NOCOPY)
Lst_AtEnd(nl, (*copyProc)(ln->datum));
else
diff --git a/usr.bin/make/lst.lib/lstFindFrom.c b/usr.bin/make/lst.lib/lstFindFrom.c
index dc416e89340..e54c46ae6ce 100644
--- a/usr.bin/make/lst.lib/lstFindFrom.c
+++ b/usr.bin/make/lst.lib/lstFindFrom.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lstFindFrom.c,v 1.7 2000/06/10 01:41:07 espie Exp $ */
+/* $OpenBSD: lstFindFrom.c,v 1.8 2000/06/17 14:34:07 espie Exp $ */
/* $NetBSD: lstFindFrom.c,v 1.6 1996/11/06 17:59:40 christos Exp $ */
/*
@@ -41,7 +41,7 @@
#if 0
static char sccsid[] = "@(#)lstFindFrom.c 8.1 (Berkeley) 6/6/93";
#else
-static char *rcsid = "$OpenBSD: lstFindFrom.c,v 1.7 2000/06/10 01:41:07 espie Exp $";
+static char *rcsid = "$OpenBSD: lstFindFrom.c,v 1.8 2000/06/17 14:34:07 espie Exp $";
#endif
#endif /* not lint */
@@ -72,10 +72,10 @@ Lst_FindFrom(ln, cProc, d)
FindProc cProc;
void *d;
{
- ListNode tln;
+ LstNode tln;
- for (tln = (ListNode)ln; tln != NULL; tln = tln->nextPtr)
+ for (tln = ln; tln != NULL; tln = tln->nextPtr)
if ((*cProc)(tln->datum, d) == 0)
- return (LstNode)tln;
+ return tln;
return NULL;
}
diff --git a/usr.bin/make/lst.lib/lstFirst.c b/usr.bin/make/lst.lib/lstFirst.c
index c0d6a4611d0..19d515f1c5e 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.5 1999/12/18 21:53:33 espie Exp $ */
+/* $OpenBSD: lstFirst.c,v 1.6 2000/06/17 14:34:08 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.5 1999/12/18 21:53:33 espie Exp $";
+static char rcsid[] = "$OpenBSD: lstFirst.c,v 1.6 2000/06/17 14:34:08 espie Exp $";
#endif
#endif /* not lint */
@@ -66,13 +66,12 @@ static char rcsid[] = "$OpenBSD: lstFirst.c,v 1.5 1999/12/18 21:53:33 espie Exp
*-----------------------------------------------------------------------
*/
LstNode
-Lst_First (l)
+Lst_First(l)
Lst l;
{
- if (!LstValid (l) || LstIsEmpty (l)) {
- return (NULL);
- } else {
- return ((LstNode)((List)l)->firstPtr);
- }
+ if (!LstValid(l) || LstIsEmpty(l))
+ return NULL;
+ else
+ return l->firstPtr;
}
diff --git a/usr.bin/make/lst.lib/lstForEachFrom.c b/usr.bin/make/lst.lib/lstForEachFrom.c
index 238e0f7e8a5..c7700b61f2b 100644
--- a/usr.bin/make/lst.lib/lstForEachFrom.c
+++ b/usr.bin/make/lst.lib/lstForEachFrom.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lstForEachFrom.c,v 1.7 2000/06/10 01:41:07 espie Exp $ */
+/* $OpenBSD: lstForEachFrom.c,v 1.8 2000/06/17 14:34:08 espie Exp $ */
/* $NetBSD: lstForEachFrom.c,v 1.5 1996/11/06 17:59:42 christos Exp $ */
/*
@@ -41,7 +41,7 @@
#if 0
static char sccsid[] = "@(#)lstForEachFrom.c 8.1 (Berkeley) 6/6/93";
#else
-static char rcsid[] = "$OpenBSD: lstForEachFrom.c,v 1.7 2000/06/10 01:41:07 espie Exp $";
+static char rcsid[] = "$OpenBSD: lstForEachFrom.c,v 1.8 2000/06/17 14:34:08 espie Exp $";
#endif
#endif /* not lint */
@@ -69,9 +69,9 @@ Lst_ForEachFrom(ln, proc, d)
ForEachProc proc;
void *d;
{
- ListNode tln;
+ LstNode tln;
- for (tln = (ListNode)ln; tln != NULL; tln = tln->nextPtr)
+ for (tln = ln; tln != NULL; tln = tln->nextPtr)
(*proc)(tln->datum, d);
}
@@ -80,8 +80,8 @@ Lst_Every(l, proc)
Lst l;
SimpleProc proc;
{
- ListNode tln;
+ LstNode tln;
- for (tln = (ListNode)Lst_First(l); tln != NULL; tln = tln->nextPtr)
+ for (tln = Lst_First(l); tln != NULL; tln = tln->nextPtr)
(*proc)(tln->datum);
}
diff --git a/usr.bin/make/lst.lib/lstInit.c b/usr.bin/make/lst.lib/lstInit.c
index 89ac9b3d6d5..8c5ddbac253 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.6 1999/12/18 21:53:33 espie Exp $ */
+/* $OpenBSD: lstInit.c,v 1.7 2000/06/17 14:34:08 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.6 1999/12/18 21:53:33 espie Exp $";
+static char rcsid[] = "$OpenBSD: lstInit.c,v 1.7 2000/06/17 14:34:08 espie Exp $";
#endif
#endif /* not lint */
@@ -68,14 +68,14 @@ static char rcsid[] = "$OpenBSD: lstInit.c,v 1.6 1999/12/18 21:53:33 espie Exp $
Lst
Lst_Init()
{
- register List nList;
+ register Lst nList;
- PAlloc (nList, List);
+ PAlloc(nList, Lst);
nList->firstPtr = NULL;
nList->lastPtr = NULL;
nList->isOpen = FALSE;
nList->atEnd = Unknown;
- return ((Lst)nList);
+ return nList;
}
diff --git a/usr.bin/make/lst.lib/lstInsert.c b/usr.bin/make/lst.lib/lstInsert.c
index e6d1fbf6e9a..67afdd5d452 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.8 2000/06/10 01:41:07 espie Exp $ */
+/* $OpenBSD: lstInsert.c,v 1.9 2000/06/17 14:34:09 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.8 2000/06/10 01:41:07 espie Exp $";
+static char rcsid[] = "$OpenBSD: lstInsert.c,v 1.9 2000/06/17 14:34:09 espie Exp $";
#endif
#endif /* not lint */
@@ -70,42 +70,37 @@ Lst_Insert(l, ln, d)
LstNode ln; /* node before which to insert d */
void *d; /* datum to be inserted */
{
- register ListNode nLNode; /* new lnode for d */
- register ListNode lNode = (ListNode)ln;
- register List list = (List)l;
+ LstNode nLNode; /* new lnode for d */
/*
* check validity of arguments
*/
- if (LstValid (l) && (LstIsEmpty (l) && ln == NULL))
+ if (LstValid(l) && (LstIsEmpty(l) && ln == NULL))
goto ok;
- if (!LstValid (l) || LstIsEmpty (l) || !LstNodeValid (ln, l)) {
+ if (!LstValid(l) || LstIsEmpty(l) || !LstNodeValid(ln, l))
return;
- }
ok:
- PAlloc (nLNode, ListNode);
+ PAlloc(nLNode, LstNode);
nLNode->datum = d;
nLNode->useCount = nLNode->flags = 0;
if (ln == NULL) {
nLNode->prevPtr = nLNode->nextPtr = NULL;
- list->firstPtr = list->lastPtr = nLNode;
+ l->firstPtr = l->lastPtr = nLNode;
} else {
- nLNode->prevPtr = lNode->prevPtr;
- nLNode->nextPtr = lNode;
+ nLNode->prevPtr = ln->prevPtr;
+ nLNode->nextPtr = ln;
- if (nLNode->prevPtr != NULL) {
+ if (nLNode->prevPtr != NULL)
nLNode->prevPtr->nextPtr = nLNode;
- }
- lNode->prevPtr = nLNode;
+ ln->prevPtr = nLNode;
- if (lNode == list->firstPtr) {
- list->firstPtr = nLNode;
- }
+ if (ln == l->firstPtr)
+ l->firstPtr = nLNode;
}
}
diff --git a/usr.bin/make/lst.lib/lstInt.h b/usr.bin/make/lst.lib/lstInt.h
index be021cbe175..f44f58a38c9 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.9 2000/06/10 01:41:07 espie Exp $ */
+/* $OpenBSD: lstInt.h,v 1.10 2000/06/17 14:34:09 espie Exp $ */
/* $NetBSD: lstInt.h,v 1.7 1996/11/06 17:59:44 christos Exp $ */
/*
@@ -49,37 +49,11 @@
#include "make.h"
#include "lst.h"
-typedef struct ListNode {
- struct ListNode *prevPtr; /* previous element in list */
- struct ListNode *nextPtr; /* next in list */
- short useCount:8, /* Count of functions using the node.
- * node may not be deleted until count
- * goes to 0 */
- flags:8; /* Node status flags */
- void *datum; /* datum associated with this element */
-} *ListNode;
/*
* Flags required for synchronization
*/
#define LN_DELETED 0x0001 /* List node should be removed when done */
-typedef enum {
- Head, Middle, Tail, Unknown
-} Where;
-
-typedef struct {
- ListNode firstPtr; /* first node in list */
- ListNode lastPtr; /* last node in list */
-/*
- * fields for sequential access
- */
- Where atEnd; /* Where in the list the last access was */
- Boolean isOpen; /* true if list has been Lst_Open'ed */
- ListNode curPtr; /* current node, if open. NULL if
- * *just* opened */
- ListNode prevPtr; /* Previous node, if open. Used by
- * Lst_Remove */
-} *List;
/*
* PAlloc (var, ptype) --
@@ -103,6 +77,6 @@ typedef struct {
* LstIsEmpty (l) --
* TRUE if the list l is empty.
*/
-#define LstIsEmpty(l) (((List)l)->firstPtr == NULL)
+#define LstIsEmpty(l) ((l)->firstPtr == NULL)
#endif /* _LSTINT_H_ */
diff --git a/usr.bin/make/lst.lib/lstIsAtEnd.c b/usr.bin/make/lst.lib/lstIsAtEnd.c
index 87cf6ad0416..880795d01fb 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.4 1998/12/05 00:06:32 espie Exp $ */
+/* $OpenBSD: lstIsAtEnd.c,v 1.5 2000/06/17 14:34:09 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.4 1998/12/05 00:06:32 espie Exp $";
+static char rcsid[] = "$OpenBSD: lstIsAtEnd.c,v 1.5 2000/06/17 14:34:09 espie Exp $";
#endif
#endif /* not lint */
@@ -70,19 +70,12 @@ static char rcsid[] = "$OpenBSD: lstIsAtEnd.c,v 1.4 1998/12/05 00:06:32 espie Ex
* while (!Lst_IsAtEnd (l)) {
* ...
* }
- *
- * Side Effects:
- * None.
- *
*-----------------------------------------------------------------------
*/
Boolean
-Lst_IsAtEnd (l)
+Lst_IsAtEnd(l)
Lst l;
{
- register List list = (List) l;
-
- return (!LstValid (l) || !list->isOpen ||
- (list->atEnd == Head) || (list->atEnd == Tail));
+ return !LstValid(l) || !l->isOpen || l->atEnd == Head || l->atEnd == Tail;
}
diff --git a/usr.bin/make/lst.lib/lstLast.c b/usr.bin/make/lst.lib/lstLast.c
index e824fdf7399..65a3128821e 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.5 1999/12/18 21:53:34 espie Exp $ */
+/* $OpenBSD: lstLast.c,v 1.6 2000/06/17 14:34:09 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.5 1999/12/18 21:53:34 espie Exp $";
+static char rcsid[] = "$OpenBSD: lstLast.c,v 1.6 2000/06/17 14:34:09 espie Exp $";
#endif
#endif /* not lint */
@@ -59,20 +59,15 @@ static char rcsid[] = "$OpenBSD: lstLast.c,v 1.5 1999/12/18 21:53:34 espie Exp $
*
* Results:
* The requested node or NULL if the list is empty.
- *
- * Side Effects:
- * None.
- *
*-----------------------------------------------------------------------
*/
LstNode
-Lst_Last (l)
+Lst_Last(l)
Lst l;
{
- if (!LstValid(l) || LstIsEmpty (l)) {
- return (NULL);
- } else {
- return ((LstNode)((List)l)->lastPtr);
- }
+ if (!LstValid(l) || LstIsEmpty(l))
+ return NULL;
+ else
+ return (LstNode)(l->lastPtr);
}
diff --git a/usr.bin/make/lst.lib/lstMember.c b/usr.bin/make/lst.lib/lstMember.c
index 6cbaeed47bc..b799ea7287c 100644
--- a/usr.bin/make/lst.lib/lstMember.c
+++ b/usr.bin/make/lst.lib/lstMember.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lstMember.c,v 1.6 2000/06/10 01:41:07 espie Exp $ */
+/* $OpenBSD: lstMember.c,v 1.7 2000/06/17 14:34:09 espie Exp $ */
/* $NetBSD: lstMember.c,v 1.5 1996/11/06 17:59:48 christos Exp $ */
/*
@@ -41,7 +41,7 @@
#if 0
static char sccsid[] = "@(#)lstMember.c 8.1 (Berkeley) 6/6/93";
#else
-static char rcsid[] = "$OpenBSD: lstMember.c,v 1.6 2000/06/10 01:41:07 espie Exp $";
+static char rcsid[] = "$OpenBSD: lstMember.c,v 1.7 2000/06/17 14:34:09 espie Exp $";
#endif
#endif /* not lint */
@@ -57,20 +57,10 @@ Lst_Member(l, d)
Lst l;
void *d;
{
- List list = (List) l;
- register ListNode lNode;
-
- lNode = list->firstPtr;
- if (lNode == NULL) {
- return NULL;
- }
-
- do {
- if (lNode->datum == d) {
- return (LstNode)lNode;
- }
- lNode = lNode->nextPtr;
- } while (lNode != NULL && lNode != list->firstPtr);
+ LstNode lNode;
+ for (lNode = l->firstPtr; lNode != NULL; lNode = lNode->nextPtr)
+ if (lNode->datum == d)
+ return lNode;
return NULL;
}
diff --git a/usr.bin/make/lst.lib/lstNext.c b/usr.bin/make/lst.lib/lstNext.c
index 52d76636659..3de2a6f81c7 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.5 1999/12/18 21:53:34 espie Exp $ */
+/* $OpenBSD: lstNext.c,v 1.6 2000/06/17 14:34:10 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.5 1999/12/18 21:53:34 espie Exp $";
+static char rcsid[] = "$OpenBSD: lstNext.c,v 1.6 2000/06/17 14:34:10 espie Exp $";
#endif
#endif /* not lint */
@@ -73,49 +73,45 @@ static char rcsid[] = "$OpenBSD: lstNext.c,v 1.5 1999/12/18 21:53:34 espie Exp $
*-----------------------------------------------------------------------
*/
LstNode
-Lst_Next (l)
+Lst_Next(l)
Lst l;
{
- register ListNode tln;
- register List list = (List)l;
+ LstNode tln;
- if ((LstValid (l) == FALSE) ||
- (list->isOpen == FALSE)) {
- return (NULL);
- }
+ if (LstValid(l) == FALSE || l->isOpen == FALSE)
+ return NULL;
- list->prevPtr = list->curPtr;
+ l->prevPtr = l->curPtr;
- if (list->curPtr == NULL) {
- if (list->atEnd == Unknown) {
+ if (l->curPtr == NULL) {
+ if (l->atEnd == Unknown) {
/*
* If we're just starting out, atEnd will be Unknown.
* Then we want to start this thing off in the right
* direction -- at the start with atEnd being Middle.
*/
- list->curPtr = tln = list->firstPtr;
- list->atEnd = Middle;
+ l->curPtr = tln = l->firstPtr;
+ l->atEnd = Middle;
} else {
tln = NULL;
- list->atEnd = Tail;
+ l->atEnd = Tail;
}
} else {
- tln = list->curPtr->nextPtr;
- list->curPtr = tln;
+ tln = l->curPtr->nextPtr;
+ l->curPtr = tln;
- if (tln == list->firstPtr || tln == NULL) {
+ if (tln == l->firstPtr || tln == NULL)
/*
* If back at the front, then we've hit the end...
*/
- list->atEnd = Tail;
- } else {
+ l->atEnd = Tail;
+ else
/*
* Reset to Middle if gone past first.
*/
- list->atEnd = Middle;
- }
+ l->atEnd = Middle;
}
- return ((LstNode)tln);
+ return tln;
}
diff --git a/usr.bin/make/lst.lib/lstOpen.c b/usr.bin/make/lst.lib/lstOpen.c
index 6434f4ace48..04f7721fda1 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.5 1999/12/18 21:53:34 espie Exp $ */
+/* $OpenBSD: lstOpen.c,v 1.6 2000/06/17 14:34:10 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.5 1999/12/18 21:53:34 espie Exp $";
+static char rcsid[] = "$OpenBSD: lstOpen.c,v 1.6 2000/06/17 14:34:10 espie Exp $";
#endif
#endif /* not lint */
@@ -73,16 +73,15 @@ static char rcsid[] = "$OpenBSD: lstOpen.c,v 1.5 1999/12/18 21:53:34 espie Exp $
*-----------------------------------------------------------------------
*/
ReturnStatus
-Lst_Open (l)
- register Lst l;
+Lst_Open(l)
+ Lst l;
{
- if (LstValid (l) == FALSE) {
- return (FAILURE);
- }
- ((List) l)->isOpen = TRUE;
- ((List) l)->atEnd = LstIsEmpty (l) ? Head : Unknown;
- ((List) l)->curPtr = NULL;
+ if (LstValid(l) == FALSE)
+ return FAILURE;
+ l->isOpen = TRUE;
+ l->atEnd = LstIsEmpty(l) ? Head : Unknown;
+ l->curPtr = NULL;
- return (SUCCESS);
+ return SUCCESS;
}
diff --git a/usr.bin/make/lst.lib/lstRemove.c b/usr.bin/make/lst.lib/lstRemove.c
index f875a7adaa5..6bcb2a42fd3 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.7 2000/06/10 01:41:07 espie Exp $ */
+/* $OpenBSD: lstRemove.c,v 1.8 2000/06/17 14:34:10 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.7 2000/06/10 01:41:07 espie Exp $";
+static char rcsid[] = "$OpenBSD: lstRemove.c,v 1.8 2000/06/17 14:34:10 espie Exp $";
#endif
#endif /* not lint */
@@ -72,34 +72,23 @@ Lst_Remove(l, ln)
Lst l;
LstNode ln;
{
- register List list = (List) l;
- register ListNode lNode = (ListNode) ln;
-
- if (!LstValid (l) ||
- !LstNodeValid (ln, l)) {
+ if (!LstValid(l) || !LstNodeValid(ln, l))
return;
- }
- /*
- * unlink it from the list
- */
- if (lNode->nextPtr != NULL) {
- lNode->nextPtr->prevPtr = lNode->prevPtr;
- }
- if (lNode->prevPtr != NULL) {
- lNode->prevPtr->nextPtr = lNode->nextPtr;
- }
+ /* unlink it from the list */
+ if (ln->nextPtr != NULL)
+ ln->nextPtr->prevPtr = ln->prevPtr;
+ if (ln->prevPtr != NULL)
+ ln->prevPtr->nextPtr = ln->nextPtr;
/*
* if either the firstPtr or lastPtr of the list point to this node,
* adjust them accordingly
*/
- if (list->firstPtr == lNode) {
- list->firstPtr = lNode->nextPtr;
- }
- if (list->lastPtr == lNode) {
- list->lastPtr = lNode->prevPtr;
- }
+ if (l->firstPtr == ln)
+ l->firstPtr = ln->nextPtr;
+ if (l->lastPtr == ln)
+ l->lastPtr = ln->prevPtr;
/*
* Sequential access stuff. If the node we're removing is the current
@@ -107,30 +96,27 @@ Lst_Remove(l, ln)
* previous one was non-existent (prevPtr == NULL), we set the
* end to be Unknown, since it is.
*/
- if (list->isOpen && (list->curPtr == lNode)) {
- list->curPtr = list->prevPtr;
- if (list->curPtr == NULL) {
- list->atEnd = Unknown;
- }
+ if (l->isOpen && l->curPtr == ln) {
+ l->curPtr = l->prevPtr;
+ if (l->curPtr == NULL)
+ l->atEnd = Unknown;
}
/*
* the only way firstPtr can still point to ln is if ln is the last
- * node on the list (the list is circular, so lNode->nextptr == lNode in
+ * node on the list (the list is circular, so ln->nextptr == ln in
* this case). The list is, therefore, empty and is marked as such
*/
- if (list->firstPtr == lNode) {
- list->firstPtr = NULL;
- }
+ if (l->firstPtr == ln)
+ l->firstPtr = NULL;
/*
* note that the datum is unmolested. The caller must free it as
* necessary and as expected.
*/
- if (lNode->useCount == 0) {
+ if (ln->useCount == 0)
free(ln);
- } else {
- lNode->flags |= LN_DELETED;
- }
+ else
+ ln->flags |= LN_DELETED;
}
diff --git a/usr.bin/make/lst.lib/lstReplace.c b/usr.bin/make/lst.lib/lstReplace.c
index f7008cbece8..5a449e64944 100644
--- a/usr.bin/make/lst.lib/lstReplace.c
+++ b/usr.bin/make/lst.lib/lstReplace.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lstReplace.c,v 1.7 2000/06/10 01:41:07 espie Exp $ */
+/* $OpenBSD: lstReplace.c,v 1.8 2000/06/17 14:34:10 espie Exp $ */
/* $NetBSD: lstReplace.c,v 1.5 1996/11/06 17:59:51 christos Exp $ */
/*
@@ -41,7 +41,7 @@
#if 0
static char sccsid[] = "@(#)lstReplace.c 8.1 (Berkeley) 6/6/93";
#else
-static char rcsid[] = "$OpenBSD: lstReplace.c,v 1.7 2000/06/10 01:41:07 espie Exp $";
+static char rcsid[] = "$OpenBSD: lstReplace.c,v 1.8 2000/06/17 14:34:10 espie Exp $";
#endif
#endif /* not lint */
@@ -68,5 +68,5 @@ Lst_Replace(ln, d)
void *d;
{
if (ln != NULL)
- ((ListNode)ln)->datum = d;
+ ln->datum = d;
}
diff --git a/usr.bin/make/lst.lib/lstSucc.c b/usr.bin/make/lst.lib/lstSucc.c
index 31f09a0302d..91aeb68ef21 100644
--- a/usr.bin/make/lst.lib/lstSucc.c
+++ b/usr.bin/make/lst.lib/lstSucc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lstSucc.c,v 1.5 1999/12/18 21:53:34 espie Exp $ */
+/* $OpenBSD: lstSucc.c,v 1.6 2000/06/17 14:34:11 espie Exp $ */
/* $NetBSD: lstSucc.c,v 1.5 1996/11/06 17:59:52 christos Exp $ */
/*
@@ -41,7 +41,7 @@
#if 0
static char sccsid[] = "@(#)lstSucc.c 8.1 (Berkeley) 6/6/93";
#else
-static char rcsid[] = "$OpenBSD: lstSucc.c,v 1.5 1999/12/18 21:53:34 espie Exp $";
+static char rcsid[] = "$OpenBSD: lstSucc.c,v 1.6 2000/06/17 14:34:11 espie Exp $";
#endif
#endif /* not lint */
@@ -61,20 +61,15 @@ static char rcsid[] = "$OpenBSD: lstSucc.c,v 1.5 1999/12/18 21:53:34 espie Exp $
* The successor of the node, if it exists (note that on a circular
* list, if the node is the only one in the list, it is its own
* successor).
- *
- * Side Effects:
- * None.
- *
*-----------------------------------------------------------------------
*/
LstNode
-Lst_Succ (ln)
+Lst_Succ(ln)
LstNode ln;
{
- if (ln == NULL) {
- return (NULL);
- } else {
- return ((LstNode) ((ListNode) ln)->nextPtr);
- }
+ if (ln == NULL)
+ return NULL;
+ else
+ return ln->nextPtr;
}