summaryrefslogtreecommitdiffstats
path: root/usr.bin/make/lst.lib
diff options
context:
space:
mode:
authorharti <harti@FreeBSD.org>2004-12-07 10:14:16 +0000
committerharti <harti@FreeBSD.org>2004-12-07 10:14:16 +0000
commite65ea2146d73aa6aedf8ef3fb0fd535039da6887 (patch)
treedc544ee893c2b95a0e4d64009cb9fe98b5598e7c /usr.bin/make/lst.lib
parent4a639d6164f667049cce0046d22e760ca1aad3f2 (diff)
downloadFreeBSD-src-e65ea2146d73aa6aedf8ef3fb0fd535039da6887.zip
FreeBSD-src-e65ea2146d73aa6aedf8ef3fb0fd535039da6887.tar.gz
Make needs no circular lists so remove them from the list code.
Diffstat (limited to 'usr.bin/make/lst.lib')
-rw-r--r--usr.bin/make/lst.lib/lstAppend.c6
-rw-r--r--usr.bin/make/lst.lib/lstClose.c5
-rw-r--r--usr.bin/make/lst.lib/lstConcat.c38
-rw-r--r--usr.bin/make/lst.lib/lstDupl.c8
-rw-r--r--usr.bin/make/lst.lib/lstInit.c6
-rw-r--r--usr.bin/make/lst.lib/lstInsert.c6
-rw-r--r--usr.bin/make/lst.lib/lstIsAtEnd.c5
-rw-r--r--usr.bin/make/lst.lib/lstNext.c18
-rw-r--r--usr.bin/make/lst.lib/lstOpen.c3
-rw-r--r--usr.bin/make/lst.lib/lstRemove.c3
10 files changed, 22 insertions, 76 deletions
diff --git a/usr.bin/make/lst.lib/lstAppend.c b/usr.bin/make/lst.lib/lstAppend.c
index f18cee4..109292d 100644
--- a/usr.bin/make/lst.lib/lstAppend.c
+++ b/usr.bin/make/lst.lib/lstAppend.c
@@ -89,11 +89,7 @@ Lst_Append(Lst list, LstNode ln, void *d)
nLNode->useCount = nLNode->flags = 0;
if (ln == NULL) {
- if (list->isCirc) {
- nLNode->nextPtr = nLNode->prevPtr = nLNode;
- } else {
- nLNode->nextPtr = nLNode->prevPtr = NULL;
- }
+ nLNode->nextPtr = nLNode->prevPtr = NULL;
list->firstPtr = list->lastPtr = nLNode;
} else {
nLNode->prevPtr = ln;
diff --git a/usr.bin/make/lst.lib/lstClose.c b/usr.bin/make/lst.lib/lstClose.c
index 58745b8..138b03b 100644
--- a/usr.bin/make/lst.lib/lstClose.c
+++ b/usr.bin/make/lst.lib/lstClose.c
@@ -46,9 +46,8 @@ __FBSDID("$FreeBSD$");
* Close a list for sequential access.
* The sequential functions access the list in a slightly different way.
* CurPtr points to their idea of the current node in the list and they
- * access the list based on it. Because the list is circular, Lst_Next
- * and Lst_Prev will go around the list forever. Lst_IsAtEnd must be
- * used to determine when to stop.
+ * access the list based on it. Lst_IsAtEnd must be used to determine
+ * when to stop.
*/
#include "make.h"
diff --git a/usr.bin/make/lst.lib/lstConcat.c b/usr.bin/make/lst.lib/lstConcat.c
index f0c771c..5391796 100644
--- a/usr.bin/make/lst.lib/lstConcat.c
+++ b/usr.bin/make/lst.lib/lstConcat.c
@@ -87,12 +87,11 @@ Lst_Concat(Lst list1, Lst list2, int flags)
if (flags == LST_CONCLINK) {
if (list2->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.
+ * 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 --
+ * 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.
*/
list2->lastPtr->nextPtr = NULL;
/*
@@ -111,15 +110,6 @@ Lst_Concat(Lst list1, Lst list2, int flags)
}
list1->lastPtr = list2->lastPtr;
}
- if (list1->isCirc && list1->firstPtr != NULL) {
- /*
- * If the first list is supposed to be circular and it is (now)
- * non-empty, we must make sure it's circular by linking the
- * first element to the last and vice versa
- */
- list1->firstPtr->prevPtr = list1->lastPtr;
- list1->lastPtr->nextPtr = list1->firstPtr;
- }
free(list2);
} else if (list2->firstPtr != NULL) {
/*
@@ -156,23 +146,7 @@ Lst_Concat(Lst list1, Lst list2, int flags)
* of list one.
*/
list1->lastPtr = last;
-
- /*
- * The circularity of both list one and list two must be corrected
- * for -- list one because of the new nodes added to it; list two
- * because of the alteration of list2->lastPtr's nextPtr to ease the
- * above for loop.
- */
- if (list1->isCirc) {
- list1->lastPtr->nextPtr = list1->firstPtr;
- list1->firstPtr->prevPtr = list1->lastPtr;
- } else {
- last->nextPtr = NULL;
- }
-
- if (list2->isCirc) {
- list2->lastPtr->nextPtr = list2->firstPtr;
- }
+ last->nextPtr = NULL;
}
return (SUCCESS);
diff --git a/usr.bin/make/lst.lib/lstDupl.c b/usr.bin/make/lst.lib/lstDupl.c
index 07d4011..f3d4211 100644
--- a/usr.bin/make/lst.lib/lstDupl.c
+++ b/usr.bin/make/lst.lib/lstDupl.c
@@ -77,7 +77,7 @@ Lst_Duplicate(Lst list, DuplicateProc *copyProc)
return (NULL);
}
- nl = Lst_Init(list->isCirc);
+ nl = Lst_Init();
if (nl == NULL) {
return (NULL);
}
@@ -92,11 +92,7 @@ Lst_Duplicate(Lst list, DuplicateProc *copyProc)
return (NULL);
}
- if (list->isCirc && ln == list->lastPtr) {
- ln = NULL;
- } else {
- ln = ln->nextPtr;
- }
+ ln = ln->nextPtr;
}
return (nl);
diff --git a/usr.bin/make/lst.lib/lstInit.c b/usr.bin/make/lst.lib/lstInit.c
index 57059a3..f2cdf22 100644
--- a/usr.bin/make/lst.lib/lstInit.c
+++ b/usr.bin/make/lst.lib/lstInit.c
@@ -57,16 +57,13 @@ __FBSDID("$FreeBSD$");
* Results:
* The created list.
*
- * Arguments:
- * circ TRUE if the list should be made circular
- *
* Side Effects:
* A list is created, what else?
*
*-----------------------------------------------------------------------
*/
Lst
-Lst_Init(Boolean circ)
+Lst_Init(void)
{
Lst nList;
@@ -75,7 +72,6 @@ Lst_Init(Boolean circ)
nList->firstPtr = NULL;
nList->lastPtr = NULL;
nList->isOpen = FALSE;
- nList->isCirc = circ;
nList->atEnd = LstUnknown;
return (nList);
diff --git a/usr.bin/make/lst.lib/lstInsert.c b/usr.bin/make/lst.lib/lstInsert.c
index 160ace3..53d8065 100644
--- a/usr.bin/make/lst.lib/lstInsert.c
+++ b/usr.bin/make/lst.lib/lstInsert.c
@@ -90,11 +90,7 @@ Lst_Insert(Lst list, LstNode ln, void *d)
nLNode->useCount = nLNode->flags = 0;
if (ln == NULL) {
- if (list->isCirc) {
- nLNode->prevPtr = nLNode->nextPtr = nLNode;
- } else {
- nLNode->prevPtr = nLNode->nextPtr = NULL;
- }
+ nLNode->prevPtr = nLNode->nextPtr = NULL;
list->firstPtr = list->lastPtr = nLNode;
} else {
nLNode->prevPtr = ln->prevPtr;
diff --git a/usr.bin/make/lst.lib/lstIsAtEnd.c b/usr.bin/make/lst.lib/lstIsAtEnd.c
index f8881f0..5341743 100644
--- a/usr.bin/make/lst.lib/lstIsAtEnd.c
+++ b/usr.bin/make/lst.lib/lstIsAtEnd.c
@@ -46,9 +46,8 @@ __FBSDID("$FreeBSD$");
* Tell if the current node is at the end of the list.
* The sequential functions access the list in a slightly different way.
* CurPtr points to their idea of the current node in the list and they
- * access the list based on it. Because the list is circular, Lst_Next
- * and Lst_Prev will go around the list forever. Lst_IsAtEnd must be
- * used to determine when to stop.
+ * access the list based on it. Lst_IsAtEnd must be used to determine
+ * when to stop.
*/
#include "make.h"
diff --git a/usr.bin/make/lst.lib/lstNext.c b/usr.bin/make/lst.lib/lstNext.c
index 5d388af..f51d674 100644
--- a/usr.bin/make/lst.lib/lstNext.c
+++ b/usr.bin/make/lst.lib/lstNext.c
@@ -46,9 +46,8 @@ __FBSDID("$FreeBSD$");
* Return the next node for a list.
* The sequential functions access the list in a slightly different way.
* CurPtr points to their idea of the current node in the list and they
- * access the list based on it. Because the list is circular, Lst_Next
- * and Lst_Prev will go around the list forever. Lst_IsAtEnd must be
- * used to determine when to stop.
+ * access the list based on it. Lst_IsAtEnd must be used to determine
+ * when to stop.
*/
#include "make.h"
@@ -60,9 +59,8 @@ __FBSDID("$FreeBSD$");
* Return the next node for the given list.
*
* Results:
- * The next node or NULL if the list has yet to be opened. Also
- * if the list is non-circular and the end has been reached, NULL
- * is returned.
+ * The next node or NULL if the list has yet to be opened or the end
+ * has been reached.
*
* Side Effects:
* the curPtr field is updated.
@@ -97,15 +95,9 @@ Lst_Next(Lst list)
tln = list->curPtr->nextPtr;
list->curPtr = tln;
- if (tln == list->firstPtr || tln == NULL) {
- /*
- * If back at the front, then we've hit the end...
- */
+ if (tln == NULL) {
list->atEnd = LstTail;
} else {
- /*
- * Reset to Middle if gone past first.
- */
list->atEnd = LstMiddle;
}
}
diff --git a/usr.bin/make/lst.lib/lstOpen.c b/usr.bin/make/lst.lib/lstOpen.c
index 06ba566..ee58530 100644
--- a/usr.bin/make/lst.lib/lstOpen.c
+++ b/usr.bin/make/lst.lib/lstOpen.c
@@ -46,8 +46,7 @@ __FBSDID("$FreeBSD$");
* Open a list for sequential access. The sequential functions access the
* list in a slightly different way. CurPtr points to their idea of the
* current node in the list and they access the list based on it.
- * If the list is circular, Lst_Next and Lst_Prev will go around
- * the list forever. Lst_IsAtEnd must be used to determine when to stop.
+ * Lst_IsAtEnd must be used to determine when to stop.
*/
#include "make.h"
diff --git a/usr.bin/make/lst.lib/lstRemove.c b/usr.bin/make/lst.lib/lstRemove.c
index d11fcea..34d739b 100644
--- a/usr.bin/make/lst.lib/lstRemove.c
+++ b/usr.bin/make/lst.lib/lstRemove.c
@@ -108,8 +108,7 @@ Lst_Remove(Lst list, LstNode ln)
/*
* the only way firstPtr can still point to ln is if ln is the last
- * 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
+ * node on the list. The list is, therefore, empty and is marked as such
*/
if (list->firstPtr == ln) {
list->firstPtr = NULL;
OpenPOWER on IntegriCloud