release 2.1 of pmake
authorKeith Bostic <bostic@ucbvax.Berkeley.EDU>
Mon, 12 Mar 1990 08:54:17 +0000 (00:54 -0800)
committerKeith Bostic <bostic@ucbvax.Berkeley.EDU>
Mon, 12 Mar 1990 08:54:17 +0000 (00:54 -0800)
SCCS-vsn: usr.bin/make/lst.lib/lstAppend.c 5.1
SCCS-vsn: usr.bin/make/lst.lib/lstAtEnd.c 5.1
SCCS-vsn: usr.bin/make/lst.lib/lstAtFront.c 5.1
SCCS-vsn: usr.bin/make/lst.lib/lstClose.c 5.1
SCCS-vsn: usr.bin/make/lst.lib/lstConcat.c 5.1
SCCS-vsn: usr.bin/make/lst.lib/lstCur.c 5.1
SCCS-vsn: usr.bin/make/lst.lib/lstDatum.c 5.1
SCCS-vsn: usr.bin/make/lst.lib/lstDeQueue.c 5.1
SCCS-vsn: usr.bin/make/lst.lib/lstDestroy.c 5.1
SCCS-vsn: usr.bin/make/lst.lib/lstDupl.c 5.1
SCCS-vsn: usr.bin/make/lst.lib/lstEnQueue.c 5.1
SCCS-vsn: usr.bin/make/lst.lib/lstFake.c 5.1
SCCS-vsn: usr.bin/make/lst.lib/lstFind.c 5.1
SCCS-vsn: usr.bin/make/lst.lib/lstFindFrom.c 5.1
SCCS-vsn: usr.bin/make/lst.lib/lstFirst.c 5.1
SCCS-vsn: usr.bin/make/lst.lib/lstForEach.c 5.1
SCCS-vsn: usr.bin/make/lst.lib/lstForEachFrom.c 5.1
SCCS-vsn: usr.bin/make/lst.lib/lstIndex.c 5.1
SCCS-vsn: usr.bin/make/lst.lib/lstInit.c 5.1
SCCS-vsn: usr.bin/make/lst.lib/lstInsert.c 5.1
SCCS-vsn: usr.bin/make/lst.lib/lstIsAtEnd.c 5.1
SCCS-vsn: usr.bin/make/lst.lib/lstIsEmpty.c 5.1
SCCS-vsn: usr.bin/make/lst.lib/lstLast.c 5.1
SCCS-vsn: usr.bin/make/lst.lib/lstLength.c 5.1
SCCS-vsn: usr.bin/make/lst.lib/lstMember.c 5.1
SCCS-vsn: usr.bin/make/lst.lib/lstMove.c 5.1
SCCS-vsn: usr.bin/make/lst.lib/lstNext.c 5.1
SCCS-vsn: usr.bin/make/lst.lib/lstOpen.c 5.1
SCCS-vsn: usr.bin/make/lst.lib/lstPred.c 5.1
SCCS-vsn: usr.bin/make/lst.lib/lstPrev.c 5.1
SCCS-vsn: usr.bin/make/lst.lib/lstRemove.c 5.1
SCCS-vsn: usr.bin/make/lst.lib/lstReplace.c 5.1
SCCS-vsn: usr.bin/make/lst.lib/lstSetCirc.c 5.1
SCCS-vsn: usr.bin/make/lst.lib/lstSucc.c 5.1

34 files changed:
usr/src/usr.bin/make/lst.lib/lstAppend.c [new file with mode: 0644]
usr/src/usr.bin/make/lst.lib/lstAtEnd.c [new file with mode: 0644]
usr/src/usr.bin/make/lst.lib/lstAtFront.c [new file with mode: 0644]
usr/src/usr.bin/make/lst.lib/lstClose.c [new file with mode: 0644]
usr/src/usr.bin/make/lst.lib/lstConcat.c [new file with mode: 0644]
usr/src/usr.bin/make/lst.lib/lstCur.c [new file with mode: 0644]
usr/src/usr.bin/make/lst.lib/lstDatum.c [new file with mode: 0644]
usr/src/usr.bin/make/lst.lib/lstDeQueue.c [new file with mode: 0644]
usr/src/usr.bin/make/lst.lib/lstDestroy.c [new file with mode: 0644]
usr/src/usr.bin/make/lst.lib/lstDupl.c [new file with mode: 0644]
usr/src/usr.bin/make/lst.lib/lstEnQueue.c [new file with mode: 0644]
usr/src/usr.bin/make/lst.lib/lstFake.c [new file with mode: 0644]
usr/src/usr.bin/make/lst.lib/lstFind.c [new file with mode: 0644]
usr/src/usr.bin/make/lst.lib/lstFindFrom.c [new file with mode: 0644]
usr/src/usr.bin/make/lst.lib/lstFirst.c [new file with mode: 0644]
usr/src/usr.bin/make/lst.lib/lstForEach.c [new file with mode: 0644]
usr/src/usr.bin/make/lst.lib/lstForEachFrom.c [new file with mode: 0644]
usr/src/usr.bin/make/lst.lib/lstIndex.c [new file with mode: 0644]
usr/src/usr.bin/make/lst.lib/lstInit.c [new file with mode: 0644]
usr/src/usr.bin/make/lst.lib/lstInsert.c [new file with mode: 0644]
usr/src/usr.bin/make/lst.lib/lstIsAtEnd.c [new file with mode: 0644]
usr/src/usr.bin/make/lst.lib/lstIsEmpty.c [new file with mode: 0644]
usr/src/usr.bin/make/lst.lib/lstLast.c [new file with mode: 0644]
usr/src/usr.bin/make/lst.lib/lstLength.c [new file with mode: 0644]
usr/src/usr.bin/make/lst.lib/lstMember.c [new file with mode: 0644]
usr/src/usr.bin/make/lst.lib/lstMove.c [new file with mode: 0644]
usr/src/usr.bin/make/lst.lib/lstNext.c [new file with mode: 0644]
usr/src/usr.bin/make/lst.lib/lstOpen.c [new file with mode: 0644]
usr/src/usr.bin/make/lst.lib/lstPred.c [new file with mode: 0644]
usr/src/usr.bin/make/lst.lib/lstPrev.c [new file with mode: 0644]
usr/src/usr.bin/make/lst.lib/lstRemove.c [new file with mode: 0644]
usr/src/usr.bin/make/lst.lib/lstReplace.c [new file with mode: 0644]
usr/src/usr.bin/make/lst.lib/lstSetCirc.c [new file with mode: 0644]
usr/src/usr.bin/make/lst.lib/lstSucc.c [new file with mode: 0644]

diff --git a/usr/src/usr.bin/make/lst.lib/lstAppend.c b/usr/src/usr.bin/make/lst.lib/lstAppend.c
new file mode 100644 (file)
index 0000000..524c651
--- /dev/null
@@ -0,0 +1,87 @@
+/*-
+ * LstAppend.c --
+ *     Add a new node with a new datum after an existing node
+ *
+ * Copyright (c) 1988 by University of California Regents
+ *
+ * Permission to use, copy, modify, and distribute this
+ * software and its documentation for any purpose and without
+ * fee is hereby granted, provided that the above copyright
+ * notice appears in all copies.  Neither the University of California nor
+ * Adam de Boor makes any representations about the suitability of this
+ * software for any purpose.  It is provided "as is" without
+ * express or implied warranty.
+ */
+#ifndef lint
+static char *rcsid =
+"$Id: lstAppend.c,v 1.6 89/06/13 15:01:33 adam Exp $ SPRITE (Berkeley)";
+#endif lint
+
+#include       "lstInt.h"
+
+/*-
+ *-----------------------------------------------------------------------
+ * Lst_Append --
+ *     Create a new node and add it to the given list after the given node.
+ *
+ * Results:
+ *     SUCCESS if all went well.
+ *
+ * Side Effects:
+ *     A new ListNode is created and linked in to the List. The lastPtr
+ *     field of the List will be altered if ln is the last node in the
+ *     list. lastPtr and firstPtr will alter if the list was empty and
+ *     ln was NILLNODE.
+ *
+ *-----------------------------------------------------------------------
+ */
+ReturnStatus
+Lst_Append (l, ln, d)
+    Lst                l;      /* affected list */
+    LstNode    ln;     /* node after which to append the datum */
+    ClientData d;      /* said datum */
+{
+    register List      list;
+    register ListNode  lNode;
+    register ListNode  nLNode;
+    
+    if (LstValid (l) && (ln == NILLNODE && LstIsEmpty (l))) {
+       goto ok;
+    }
+    
+    if (!LstValid (l) || LstIsEmpty (l)  || ! LstNodeValid (ln, l)) {
+       return (FAILURE);
+    }
+    ok:
+    
+    list = (List)l;
+    lNode = (ListNode)ln;
+
+    PAlloc (nLNode, ListNode);
+    nLNode->datum = d;
+    nLNode->useCount = nLNode->flags = 0;
+    
+    if (lNode == NilListNode) {
+       if (list->isCirc) {
+           nLNode->nextPtr = nLNode->prevPtr = nLNode;
+       } else {
+           nLNode->nextPtr = nLNode->prevPtr = NilListNode;
+       }
+       list->firstPtr = list->lastPtr = nLNode;
+    } else {
+       nLNode->prevPtr = lNode;
+       nLNode->nextPtr = lNode->nextPtr;
+       
+       lNode->nextPtr = nLNode;
+       if (nLNode->nextPtr != NilListNode) {
+           nLNode->nextPtr->prevPtr = nLNode;
+       }
+       
+       if (lNode == list->lastPtr) {
+           list->lastPtr = nLNode;
+       }
+    }
+    
+    return (SUCCESS);
+}
+
diff --git a/usr/src/usr.bin/make/lst.lib/lstAtEnd.c b/usr/src/usr.bin/make/lst.lib/lstAtEnd.c
new file mode 100644 (file)
index 0000000..cac554d
--- /dev/null
@@ -0,0 +1,45 @@
+/*-
+ * LstAtEnd.c --
+ *     Add a node at the end of the list
+ *
+ * Copyright (c) 1988 by the Regents of the University of California
+ *
+ * Permission to use, copy, modify, and distribute this
+ * software and its documentation for any purpose and without
+ * fee is hereby granted, provided that the above copyright
+ * notice appears in all copies.  Neither the University of California nor
+ * Adam de Boor makes any representations about the suitability of this
+ * software for any purpose.  It is provided "as is" without
+ * express or implied warranty.
+ *
+ */
+#ifndef lint
+static char *rcsid =
+"$Id: lstAtEnd.c,v 1.3 88/11/17 20:51:48 adam Exp $ SPRITE (Berkeley)";
+#endif lint
+
+#include       "lstInt.h"
+       
+/*-
+ *-----------------------------------------------------------------------
+ * Lst_AtEnd --
+ *     Add a node to the end of the given list
+ *
+ * Results:
+ *     SUCCESS if life is good.
+ *
+ * Side Effects:
+ *     A new ListNode is created and added to the list.
+ *
+ *-----------------------------------------------------------------------
+ */
+ReturnStatus
+Lst_AtEnd (l, d)
+    Lst                l;      /* List to which to add the datum */
+    ClientData d;      /* Datum to add */
+{
+    register LstNode   end;
+    
+    end = Lst_Last (l);
+    return (Lst_Append (l, end, d));
+}
diff --git a/usr/src/usr.bin/make/lst.lib/lstAtFront.c b/usr/src/usr.bin/make/lst.lib/lstAtFront.c
new file mode 100644 (file)
index 0000000..5fa2414
--- /dev/null
@@ -0,0 +1,46 @@
+/*-
+ * LstAtFront.c --
+ *     Add a node at the front of the list
+ *
+ * Copyright (c) 1988 by the Regents of the University of California
+ *
+ * Permission to use, copy, modify, and distribute this
+ * software and its documentation for any purpose and without
+ * fee is hereby granted, provided that the above copyright
+ * notice appears in all copies.  Neither the University of California nor
+ * Adam de Boor makes any representations about the suitability of this
+ * software for any purpose.  It is provided "as is" without
+ * express or implied warranty.
+ *
+ */
+#ifndef lint
+static char *rcsid =
+"$Id: lstAtFront.c,v 1.3 88/11/17 20:51:51 adam Exp $ SPRITE (Berkeley)";
+#endif lint
+
+#include       "lstInt.h"
+
+/*-
+ *-----------------------------------------------------------------------
+ * Lst_AtFront --
+ *     Place a piece of data at the front of a list
+ *
+ * Results:
+ *     SUCCESS or FAILURE
+ *
+ * Side Effects:
+ *     A new ListNode is created and stuck at the front of the list.
+ *     hence, firstPtr (and possible lastPtr) in the list are altered.
+ *
+ *-----------------------------------------------------------------------
+ */
+ReturnStatus
+Lst_AtFront (l, d)
+    Lst                l;
+    ClientData d;
+{
+    register LstNode   front;
+    
+    front = Lst_First (l);
+    return (Lst_Insert (l, front, d));
+}
diff --git a/usr/src/usr.bin/make/lst.lib/lstClose.c b/usr/src/usr.bin/make/lst.lib/lstClose.c
new file mode 100644 (file)
index 0000000..065a4bd
--- /dev/null
@@ -0,0 +1,51 @@
+/*-
+ * LstClose.c --
+ *     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.
+ *
+ * Copyright (c) 1988 by University of California Regents
+ *
+ * Permission to use, copy, modify, and distribute this
+ * software and its documentation for any purpose and without
+ * fee is hereby granted, provided that the above copyright
+ * notice appears in all copies.  Neither the University of California nor
+ * Adam de Boor makes any representations about the suitability of this
+ * software for any purpose.  It is provided "as is" without
+ * express or implied warranty.
+ */
+#ifndef lint
+static char *rcsid =
+"$Id: lstClose.c,v 1.6 88/11/17 20:51:55 adam Exp $ SPRITE (Berkeley)";
+#endif lint
+
+#include       "lstInt.h"
+
+/*-
+ *-----------------------------------------------------------------------
+ * Lst_Close --
+ *     Close a list which was opened for sequential access.
+ *
+ * Results:
+ *     None.
+ *
+ * Side Effects:
+ *     The list is closed.
+ *
+ *-----------------------------------------------------------------------
+ */
+void
+Lst_Close (l)
+    Lst            l;          /* The list to close */
+{
+    register List      list = (List) l;
+    
+    if (LstValid(l) == TRUE) {
+       list->isOpen = FALSE;
+       list->atEnd = Unknown;
+    }
+}
+
diff --git a/usr/src/usr.bin/make/lst.lib/lstConcat.c b/usr/src/usr.bin/make/lst.lib/lstConcat.c
new file mode 100644 (file)
index 0000000..b997232
--- /dev/null
@@ -0,0 +1,149 @@
+/*-
+ * listConcat.c --
+ *     Function to concatentate two lists.
+ *
+ * Copyright (c) 1988 by the Regents of the University of California
+ *
+ * Permission to use, copy, modify, and distribute this
+ * software and its documentation for any purpose and without
+ * fee is hereby granted, provided that the above copyright
+ * notice appears in all copies.  Neither the University of California nor
+ * Adam de Boor makes any representations about the suitability of this
+ * software for any purpose.  It is provided "as is" without
+ * express or implied warranty.
+ *
+ */
+#ifndef lint
+static char *rcsid =
+"$Id: lstConcat.c,v 1.6 89/07/06 12:50:04 adam Exp $ SPRITE (Berkeley)";
+#endif lint
+
+#include    "lstInt.h"
+
+/*-
+ *-----------------------------------------------------------------------
+ * Lst_Concat --
+ *     Concatenate two lists. New elements are created to hold the data
+ *     elements, if specified, 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.
+ *-----------------------------------------------------------------------
+ */
+ReturnStatus
+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
+                                * bookkeeping until the end */
+    register List      list1 = (List)l1;
+    register List      list2 = (List)l2;
+
+    if (!LstValid (l1) || !LstValid (l2)) {
+       return (FAILURE);
+    }
+
+    if (flags == LST_CONCLINK) {
+       if (list2->firstPtr != NilListNode) {
+           /*
+            * We set the nextPtr of the
+            * last element of list two to be NIL 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 NIL space and the first element will be untouched if it
+            * existed before and will also point to NIL space if it didn't.
+            */
+           list2->lastPtr->nextPtr = NilListNode;
+           /*
+            * 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.
+            */
+           list2->firstPtr->prevPtr = list1->lastPtr;
+           if (list1->lastPtr != NilListNode) {
+               list1->lastPtr->nextPtr = list2->firstPtr;
+           }
+           list1->lastPtr = list2->lastPtr;
+       }
+       if (list1->isCirc && list1->firstPtr != NilListNode) {
+           /*
+            * 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 ((Address)l2);
+    } else if (list2->firstPtr != NilListNode) {
+       /*
+        * We set the nextPtr of the last element of list 2 to be nil to make
+        * the loop less difficult. The loop simply goes through the entire
+        * second list creating new LstNodes and filling in the nextPtr, and
+        * prevPtr to fit into l1 and its datum field from the
+        * datum field of the corresponding element in l2. The 'last' node
+        * follows the last of the new nodes along until the entire l2 has
+        * been appended. Only then does the bookkeeping catch up with the
+        * changes. During the first iteration of the loop, if 'last' is nil,
+        * the first list must have been empty so the newly-created node is
+        * made the first node of the list.
+        */
+       list2->lastPtr->nextPtr = NilListNode;
+       for (last = list1->lastPtr, ln = list2->firstPtr;
+            ln != NilListNode;
+            ln = ln->nextPtr)
+       {
+           PAlloc (nln, ListNode);
+           nln->datum = ln->datum;
+           if (last != NilListNode) {
+               last->nextPtr = nln;
+           } else {
+               list1->firstPtr = nln;
+           }
+           nln->prevPtr = last;
+           nln->flags = nln->useCount = 0;
+           last = nln;
+       }
+
+       /*
+        * Finish bookkeeping. The last new element becomes the last element
+        * 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 = NilListNode;
+       }
+
+       if (list2->isCirc) {
+           list2->lastPtr->nextPtr = list2->firstPtr;
+       }
+    }
+
+    return (SUCCESS);
+}
+       
diff --git a/usr/src/usr.bin/make/lst.lib/lstCur.c b/usr/src/usr.bin/make/lst.lib/lstCur.c
new file mode 100644 (file)
index 0000000..3fcffd8
--- /dev/null
@@ -0,0 +1,54 @@
+/*-
+ * LstCur.c --
+ *     Return the current node in 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.
+ *
+ * Copyright (c) 1988 by University of California Regents
+ *
+ * Permission to use, copy, modify, and distribute this
+ * software and its documentation for any purpose and without
+ * fee is hereby granted, provided that the above copyright
+ * notice appears in all copies.  Neither the University of California nor
+ * Adam de Boor makes any representations about the suitability of this
+ * software for any purpose.  It is provided "as is" without
+ * express or implied warranty.
+ */
+#ifndef lint
+static char *rcsid =
+"$Id: lstCur.c,v 1.4 88/11/17 20:52:03 adam Exp $ SPRITE (Berkeley)";
+#endif lint
+
+#include       "lstInt.h"
+
+/*-
+ *-----------------------------------------------------------------------
+ * Lst_Cur --
+ *     Return the current node if the list is open for sequential
+ *     access.
+ *
+ * Results:
+ *     The current node or NILLNODE if the list isn't open..
+ *
+ * Side Effects:
+ *     None.
+ *
+ *-----------------------------------------------------------------------
+ */
+LstNode
+Lst_Cur (l)
+    Lst            l;
+{
+    register List list = (List)l;
+
+    if ((LstValid(l) == FALSE) ||
+       (list->isOpen == FALSE)) {
+           return (NILLNODE);
+    } else {
+       return ((LstNode)list->curPtr);
+    }
+}
+
diff --git a/usr/src/usr.bin/make/lst.lib/lstDatum.c b/usr/src/usr.bin/make/lst.lib/lstDatum.c
new file mode 100644 (file)
index 0000000..cb10b86
--- /dev/null
@@ -0,0 +1,45 @@
+/*-
+ * LstDatum.c --
+ *     Return the datum associated with a list node.
+ *
+ * Copyright (c) 1988 by University of California Regents
+ *
+ * Permission to use, copy, modify, and distribute this
+ * software and its documentation for any purpose and without
+ * fee is hereby granted, provided that the above copyright
+ * notice appears in all copies.  Neither the University of California nor
+ * Adam de Boor makes any representations about the suitability of this
+ * software for any purpose.  It is provided "as is" without
+ * express or implied warranty.
+ */
+#ifndef lint
+static char *rcsid =
+"$Id: lstDatum.c,v 1.4 88/11/17 20:52:07 adam Exp $ SPRITE (Berkeley)";
+#endif lint
+
+#include       "lstInt.h"
+
+/*-
+ *-----------------------------------------------------------------------
+ * Lst_Datum --
+ *     Return the datum stored in the given node.
+ *
+ * Results:
+ *     The datum or (ick!) NIL if the node is invalid.
+ *
+ * Side Effects:
+ *     None.
+ *
+ *-----------------------------------------------------------------------
+ */
+ClientData
+Lst_Datum (ln)
+    LstNode    ln;
+{
+    if (ln != NILLNODE) {
+       return (((ListNode)ln)->datum);
+    } else {
+       return ((ClientData) NIL);
+    }
+}
+
diff --git a/usr/src/usr.bin/make/lst.lib/lstDeQueue.c b/usr/src/usr.bin/make/lst.lib/lstDeQueue.c
new file mode 100644 (file)
index 0000000..010b5bf
--- /dev/null
@@ -0,0 +1,55 @@
+/*-
+ * LstDeQueue.c --
+ *     Remove the node and return its datum from the head of the list
+ *
+ * Copyright (c) 1988 by University of California Regents
+ *
+ * Permission to use, copy, modify, and distribute this
+ * software and its documentation for any purpose and without
+ * fee is hereby granted, provided that the above copyright
+ * notice appears in all copies.  Neither the University of California nor
+ * Adam de Boor makes any representations about the suitability of this
+ * software for any purpose.  It is provided "as is" without
+ * express or implied warranty.
+ */
+#ifndef lint
+static char *rcsid =
+"$Id: lstDeQueue.c,v 1.5 88/11/17 20:52:11 adam Exp $ SPRITE (Berkeley)";
+#endif lint
+
+#include       "lstInt.h"
+
+/*-
+ *-----------------------------------------------------------------------
+ * Lst_DeQueue --
+ *     Remove and return the datum at the head of the given list.
+ *
+ * Results:
+ *     The datum in the node at the head or (ick) NIL if the list
+ *     is empty.
+ *
+ * Side Effects:
+ *     The head node is removed from the list.
+ *
+ *-----------------------------------------------------------------------
+ */
+ClientData
+Lst_DeQueue (l)
+    Lst                  l;
+{
+    ClientData   rd;
+    register ListNode  tln;
+    
+    tln = (ListNode) Lst_First (l);
+    if (tln == NilListNode) {
+       return ((ClientData) NIL);
+    }
+    
+    rd = tln->datum;
+    if (Lst_Remove (l, (LstNode)tln) == FAILURE) {
+       return ((ClientData) NIL);
+    } else {
+       return (rd);
+    }
+}
+
diff --git a/usr/src/usr.bin/make/lst.lib/lstDestroy.c b/usr/src/usr.bin/make/lst.lib/lstDestroy.c
new file mode 100644 (file)
index 0000000..ba0b858
--- /dev/null
@@ -0,0 +1,72 @@
+/*-
+ * LstDestroy.c --
+ *     Nuke a list and all its resources
+ *
+ * Copyright (c) 1988 by University of California Regents
+ *
+ * Permission to use, copy, modify, and distribute this
+ * software and its documentation for any purpose and without
+ * fee is hereby granted, provided that the above copyright
+ * notice appears in all copies.  Neither the University of California nor
+ * Adam de Boor makes any representations about the suitability of this
+ * software for any purpose.  It is provided "as is" without
+ * express or implied warranty.
+ */
+#ifndef lint
+static char *rcsid =
+"$Id: lstDestroy.c,v 1.5 88/11/17 20:52:15 adam Exp $ SPRITE (Berkeley)";
+#endif lint
+
+#include       "lstInt.h"
+
+/*-
+ *-----------------------------------------------------------------------
+ * Lst_Destroy --
+ *     Destroy a list and free all its resources. If the freeProc is
+ *     given, it is called with the datum from each node in turn before
+ *     the node is freed.
+ *
+ * Results:
+ *     None.
+ *
+ * Side Effects:
+ *     The given list is freed in its entirety.
+ *
+ *-----------------------------------------------------------------------
+ */
+void
+Lst_Destroy (l, freeProc)
+    Lst                        l;
+    register void      (*freeProc)();
+{
+    register ListNode  ln;
+    register ListNode  tln = NilListNode;
+    register List      list = (List)l;
+    
+    if (l == NILLST || ! l) {
+       /*
+        * Note the check for l == (Lst)0 to catch uninitialized static Lst's.
+        * Gross, but useful.
+        */
+       return;
+    }
+    
+    if (freeProc) {
+       for (ln = list->firstPtr;
+            ln != NilListNode && tln != list->firstPtr;
+            ln = tln) {
+                tln = ln->nextPtr;
+                (*freeProc) (ln->datum);
+                free ((Address)ln);
+       }
+    } else {
+       for (ln = list->firstPtr;
+            ln != NilListNode && tln != list->firstPtr;
+            ln = tln) {
+                tln = ln->nextPtr;
+                free ((Address)ln);
+       }
+    }
+    
+    free ((Address)l);
+}
diff --git a/usr/src/usr.bin/make/lst.lib/lstDupl.c b/usr/src/usr.bin/make/lst.lib/lstDupl.c
new file mode 100644 (file)
index 0000000..4d25fda
--- /dev/null
@@ -0,0 +1,65 @@
+/*-
+ * listDupl.c --
+ *     Duplicate a list. This includes duplicating the individual
+ *     elements.
+ *
+ * Copyright (c) 1988 by the Regents of the University of California
+ *
+ */
+#ifndef lint
+static char *rcsid =
+"$Id: lstDupl.c,v 1.4 88/11/17 20:52:21 adam Exp $ SPRITE (Berkeley)";
+#endif lint
+
+#include    "lstInt.h"
+
+/*-
+ *-----------------------------------------------------------------------
+ * Lst_Duplicate --
+ *     Duplicate an entire list. If a function to copy a ClientData is
+ *     given, the individual client elements will be duplicated as well.
+ *
+ * Results:
+ *     The new Lst structure or NILLST if failure.
+ *
+ * Side Effects:
+ *     A new list is created.
+ *-----------------------------------------------------------------------
+ */
+Lst
+Lst_Duplicate (l, copyProc)
+    Lst          l;             /* the list to duplicate */
+    ClientData   (*copyProc)(); /* A function to duplicate each ClientData */
+{
+    register Lst       nl;
+    register ListNode          ln;
+    register List      list = (List)l;
+    
+    if (!LstValid (l)) {
+       return (NILLST);
+    }
+
+    nl = Lst_Init (list->isCirc);
+    if (nl == NILLST) {
+       return (NILLST);
+    }
+
+    ln = list->firstPtr;
+    while (ln != NilListNode) {
+       if (copyProc != NOCOPY) {
+           if (Lst_AtEnd (nl, (*copyProc) (ln->datum)) == FAILURE) {
+               return (NILLST);
+           }
+       } else if (Lst_AtEnd (nl, ln->datum) == FAILURE) {
+           return (NILLST);
+       }
+
+       if (list->isCirc && ln == list->lastPtr) {
+           ln = NilListNode;
+       } else {
+           ln = ln->nextPtr;
+       }
+    }
+       
+    return (nl);
+}
diff --git a/usr/src/usr.bin/make/lst.lib/lstEnQueue.c b/usr/src/usr.bin/make/lst.lib/lstEnQueue.c
new file mode 100644 (file)
index 0000000..29589c9
--- /dev/null
@@ -0,0 +1,47 @@
+/*-
+ * LstEnQueue.c--
+ *     Treat the list as a queue and place a datum at its end
+ *
+ * Copyright (c) 1988 by University of California Regents
+ *
+ * Permission to use, copy, modify, and distribute this
+ * software and its documentation for any purpose and without
+ * fee is hereby granted, provided that the above copyright
+ * notice appears in all copies.  Neither the University of California nor
+ * Adam de Boor makes any representations about the suitability of this
+ * software for any purpose.  It is provided "as is" without
+ * express or implied warranty.
+ */
+#ifndef lint
+static char *rcsid =
+"$Id: lstEnQueue.c,v 1.4 88/11/17 20:52:26 adam Exp $ SPRITE (Berkeley)";
+#endif lint
+
+#include       "lstInt.h"
+
+/*-
+ *-----------------------------------------------------------------------
+ * Lst_EnQueue --
+ *     Add the datum to the tail of the given list.
+ *
+ * Results:
+ *     SUCCESS or FAILURE as returned by Lst_Append.
+ *
+ * Side Effects:
+ *     the lastPtr field is altered all the time and the firstPtr field
+ *     will be altered if the list used to be empty.
+ *
+ *-----------------------------------------------------------------------
+ */
+ReturnStatus
+Lst_EnQueue (l, d)
+    Lst                  l;
+    ClientData   d;
+{
+    if (LstValid (l) == FALSE) {
+       return (FAILURE);
+    }
+    
+    return (Lst_Append (l, Lst_Last(l), d));
+}
+
diff --git a/usr/src/usr.bin/make/lst.lib/lstFake.c b/usr/src/usr.bin/make/lst.lib/lstFake.c
new file mode 100644 (file)
index 0000000..150227c
--- /dev/null
@@ -0,0 +1,31 @@
+/*-
+ * lstFake.c --
+ *     This is a file whose sole purpose is to force ranlib to
+ *     place enough entries in the library's table of contents to
+ *     prevent it (the table of contents) from looking like an object
+ *     file. As of this writing, the table had 0410 (shared text) entries
+ *     in it, so we define five junk variables to up the number beyond
+ *     the range of the magic numbers.
+ *
+ * Copyright (c) 1988 by the Regents of the University of California
+ *
+ * Permission to use, copy, modify, and distribute this
+ * software and its documentation for any purpose and without
+ * fee is hereby granted, provided that the above copyright
+ * notice appears in all copies.  The University of California nor
+ * Adam de Boor makes any representations about the suitability of this
+ * software for any purpose.  It is provided "as is" without
+ * express or implied warranty.
+ *
+ *
+ */
+#ifndef lint
+static char *rcsid =
+"$Id: lstFake.c,v 1.2 88/11/17 20:52:30 adam Exp $ SPRITE (Berkeley)";
+#endif lint
+
+int _junk_one__ = 1;
+int _junk_two__ = 2;
+int _junk_three__ = 3;
+int _junk_four__ = 4;
+int _junk_five__ = 5;
diff --git a/usr/src/usr.bin/make/lst.lib/lstFind.c b/usr/src/usr.bin/make/lst.lib/lstFind.c
new file mode 100644 (file)
index 0000000..355b4c5
--- /dev/null
@@ -0,0 +1,44 @@
+/*-
+ * LstFind.c --
+ *     Find a node on a list.
+ *
+ * Copyright (c) 1988 by University of California Regents
+ *
+ * Permission to use, copy, modify, and distribute this
+ * software and its documentation for any purpose and without
+ * fee is hereby granted, provided that the above copyright
+ * notice appears in all copies.  Neither the University of California nor
+ * Adam de Boor makes any representations about the suitability of this
+ * software for any purpose.  It is provided "as is" without
+ * express or implied warranty.
+ */
+#ifndef lint
+static char *rcsid =
+"$Id: lstFind.c,v 1.4 88/11/17 20:52:34 adam Exp $ SPRITE (Berkeley)";
+#endif lint
+
+#include       "lstInt.h"
+
+/*-
+ *-----------------------------------------------------------------------
+ * Lst_Find --
+ *     Find a node on the given list using the given comparison function
+ *     and the given datum.
+ *
+ * Results:
+ *     The found node or NILLNODE if none matches.
+ *
+ * Side Effects:
+ *     None.
+ *
+ *-----------------------------------------------------------------------
+ */
+LstNode
+Lst_Find (l, d, cProc)
+    Lst                l;
+    ClientData d;
+    int                (*cProc)();
+{
+    return (Lst_FindFrom (l, Lst_First(l), d, cProc));
+}
+
diff --git a/usr/src/usr.bin/make/lst.lib/lstFindFrom.c b/usr/src/usr.bin/make/lst.lib/lstFindFrom.c
new file mode 100644 (file)
index 0000000..d6e9ed2
--- /dev/null
@@ -0,0 +1,68 @@
+/*-
+ * LstFindFrom.c --
+ *     Find a node on a list from a given starting point. Used by Lst_Find.
+ *
+ * Copyright (c) 1988 by University of California Regents
+ *
+ * Permission to use, copy, modify, and distribute this
+ * software and its documentation for any purpose and without
+ * fee is hereby granted, provided that the above copyright
+ * notice appears in all copies.  Neither the University of California nor
+ * Adam de Boor makes any representations about the suitability of this
+ * software for any purpose.  It is provided "as is" without
+ * express or implied warranty.
+ */
+#ifndef lint
+static char *rcsid =
+"$Id: lstFindFrom.c,v 1.6 88/11/17 20:52:37 adam Exp $ SPRITE (Berkeley)";
+#endif lint
+
+#include       "lstInt.h"
+
+/*-
+ *-----------------------------------------------------------------------
+ * Lst_FindFrom --
+ *     Search for a node starting and ending with the given one on the
+ *     given list using the passed datum and comparison function to
+ *     determine when it has been found.
+ *
+ * Results:
+ *     The found node or NILLNODE
+ *
+ * Side Effects:
+ *     None.
+ *
+ *-----------------------------------------------------------------------
+ */
+LstNode
+Lst_FindFrom (l, ln, d, cProc)
+    Lst                        l;
+    register LstNode    ln;
+    register ClientData d;
+    register int       (*cProc)();
+{
+    register ListNode  tln;
+    Boolean            found = FALSE;
+    
+    if (!LstValid (l) || LstIsEmpty (l) || !LstNodeValid (ln, l)) {
+       return (NILLNODE);
+    }
+    
+    tln = (ListNode)ln;
+    
+    do {
+       if ((*cProc) (tln->datum, d) == 0) {
+           found = TRUE;
+           break;
+       } else {
+           tln = tln->nextPtr;
+       }
+    } while (tln != (ListNode)ln && tln != NilListNode);
+    
+    if (found) {
+       return ((LstNode)tln);
+    } else {
+       return (NILLNODE);
+    }
+}
+
diff --git a/usr/src/usr.bin/make/lst.lib/lstFirst.c b/usr/src/usr.bin/make/lst.lib/lstFirst.c
new file mode 100644 (file)
index 0000000..cd953b0
--- /dev/null
@@ -0,0 +1,45 @@
+/*-
+ * LstFirst.c --
+ *     Return the first node of a list
+ *
+ * Copyright (c) 1988 by University of California Regents
+ *
+ * Permission to use, copy, modify, and distribute this
+ * software and its documentation for any purpose and without
+ * fee is hereby granted, provided that the above copyright
+ * notice appears in all copies.  Neither the University of California nor
+ * Adam de Boor makes any representations about the suitability of this
+ * software for any purpose.  It is provided "as is" without
+ * express or implied warranty.
+ */
+#ifndef lint
+static char *rcsid =
+"$Id: lstFirst.c,v 1.5 88/11/17 20:52:44 adam Exp $ SPRITE (Berkeley)";
+#endif lint
+
+#include       "lstInt.h"
+
+/*-
+ *-----------------------------------------------------------------------
+ * Lst_First --
+ *     Return the first node on the given list.
+ *
+ * Results:
+ *     The first node or NILLNODE if the list is empty.
+ *
+ * Side Effects:
+ *     None.
+ *
+ *-----------------------------------------------------------------------
+ */
+LstNode
+Lst_First (l)
+    Lst        l;
+{
+    if (!LstValid (l) || LstIsEmpty (l)) {
+       return (NILLNODE);
+    } else {
+       return ((LstNode)((List)l)->firstPtr);
+    }
+}
+
diff --git a/usr/src/usr.bin/make/lst.lib/lstForEach.c b/usr/src/usr.bin/make/lst.lib/lstForEach.c
new file mode 100644 (file)
index 0000000..8eede2c
--- /dev/null
@@ -0,0 +1,46 @@
+/*-
+ * LstForeach.c --
+ *     Perform a given function on all elements of a list.
+ *
+ * Copyright (c) 1988 by University of California Regents
+ *
+ * Permission to use, copy, modify, and distribute this
+ * software and its documentation for any purpose and without
+ * fee is hereby granted, provided that the above copyright
+ * notice appears in all copies.  Neither the University of California nor
+ * Adam de Boor makes any representations about the suitability of this
+ * software for any purpose.  It is provided "as is" without
+ * express or implied warranty.
+ */
+#ifndef lint
+static char *rcsid =
+"$Id: lstForEach.c,v 1.8 89/11/14 16:59:42 adam Exp $ SPRITE (Berkeley)";
+#endif lint
+
+#include       "lstInt.h"
+
+/*-
+ *-----------------------------------------------------------------------
+ * Lst_ForEach --
+ *     Apply the given function to each element of the given list. The
+ *     function should return 0 if Lst_ForEach should continue and non-
+ *     zero if it should abort.
+ *
+ * Results:
+ *     None.
+ *
+ * Side Effects:
+ *     Only those created by the passed-in function.
+ *
+ *-----------------------------------------------------------------------
+ */
+/*VARARGS2*/
+void
+Lst_ForEach (l, proc, d)
+    Lst                        l;
+    register int       (*proc)();
+    register ClientData        d;
+{
+    Lst_ForEachFrom(l, Lst_First(l), proc, d);
+}
+
diff --git a/usr/src/usr.bin/make/lst.lib/lstForEachFrom.c b/usr/src/usr.bin/make/lst.lib/lstForEachFrom.c
new file mode 100644 (file)
index 0000000..2ca36c8
--- /dev/null
@@ -0,0 +1,86 @@
+/*-
+ * lstForEachFrom.c --
+ *     Perform a given function on all elements of a list starting from
+ *     a given point.
+ *
+ * Copyright (c) 1988 by University of California Regents
+ *
+ * Permission to use, copy, modify, and distribute this
+ * software and its documentation for any purpose and without
+ * fee is hereby granted, provided that the above copyright
+ * notice appears in all copies.  Neither the University of California nor
+ * Adam de Boor makes any representations about the suitability of this
+ * software for any purpose.  It is provided "as is" without
+ * express or implied warranty.
+ */
+#ifndef lint
+static char *rcsid =
+"$Id: lstForEachFrom.c,v 1.8 89/07/13 13:55:55 adam Exp $ SPRITE (Berkeley)";
+#endif lint
+
+#include       "lstInt.h"
+
+/*-
+ *-----------------------------------------------------------------------
+ * Lst_ForEachFrom --
+ *     Apply the given function to each element of the given list. The
+ *     function should return 0 if traversal should continue and non-
+ *     zero if it should abort. 
+ *
+ * Results:
+ *     None.
+ *
+ * Side Effects:
+ *     Only those created by the passed-in function.
+ *
+ *-----------------------------------------------------------------------
+ */
+/*VARARGS2*/
+void
+Lst_ForEachFrom (l, ln, proc, d)
+    Lst                        l;
+    LstNode                    ln;
+    register int       (*proc)();
+    register ClientData        d;
+{
+    register ListNode  tln = (ListNode)ln;
+    register List      list = (List)l;
+    register ListNode  next;
+    Boolean            done;
+    int                result;
+    
+    if (!LstValid (list) || LstIsEmpty (list)) {
+       return;
+    }
+    
+    do {
+       /*
+        * Take care of having the current element deleted out from under
+        * us.
+        */
+       
+       next = tln->nextPtr;
+       
+       tln->useCount++;
+       result = (*proc) (tln->datum, d);
+       tln->useCount--;
+
+       /*
+        * We're done with the traversal if
+        *  - nothing's been added after the current node and
+        *  - the next node to examine is the first in the queue or
+        *    doesn't exist.
+        */
+       done = (next == tln->nextPtr &&
+               (next == NilListNode || next == list->firstPtr));
+       
+       next = tln->nextPtr;
+
+       if (tln->flags & LN_DELETED) {
+           free((char *)tln);
+       }
+       tln = next;
+    } while (!result && !LstIsEmpty(list) && !done);
+    
+}
+
diff --git a/usr/src/usr.bin/make/lst.lib/lstIndex.c b/usr/src/usr.bin/make/lst.lib/lstIndex.c
new file mode 100644 (file)
index 0000000..1f40ec8
--- /dev/null
@@ -0,0 +1,64 @@
+/*-
+ * lstIndex.c --
+ *     Function to return the index of a datum in a Lst.
+ *
+ * Copyright (c) 1988 by the Regents of the University of California
+ *
+ * Permission to use, copy, modify, and distribute this
+ * software and its documentation for any purpose and without
+ * fee is hereby granted, provided that the above copyright
+ * notice appears in all copies.  The University of California nor
+ * Adam de Boor makes any representations about the suitability of this
+ * software for any purpose.  It is provided "as is" without
+ * express or implied warranty.
+ *
+ *
+ */
+#ifndef lint
+static char *rcsid =
+"$Id: lstIndex.c,v 1.2 88/11/17 20:52:54 adam Exp $ SPRITE (Berkeley)";
+#endif lint
+
+#include    "lstInt.h"
+
+/*-
+ *-----------------------------------------------------------------------
+ * Lst_Index --
+ *     Return the index of a datum in a Lst. Indices start at 0.
+ *
+ * Results:
+ *     Returns -1 if the datum isn't in the Lst, or the index of
+ *     the datum if it is.
+ *
+ * Side Effects:
+ *     None.
+ *
+ *-----------------------------------------------------------------------
+ */
+int
+Lst_Index(l, d)
+    Lst                        l;
+    ClientData         d;
+{
+    List               list = (List)l;
+    register ListNode  lNode;
+    register int       index;
+
+    lNode = list->firstPtr;
+
+    if (lNode == NilListNode) {
+       return(-1);
+    }
+
+    index = 0;
+
+    do {
+       if (lNode->datum == d) {
+           return(index);
+       } else {
+           lNode = lNode->nextPtr;
+           index += 1;
+       }
+    } while (lNode != NilListNode && lNode != list->firstPtr);
+    return(-1);
+}
diff --git a/usr/src/usr.bin/make/lst.lib/lstInit.c b/usr/src/usr.bin/make/lst.lib/lstInit.c
new file mode 100644 (file)
index 0000000..3d3ea38
--- /dev/null
@@ -0,0 +1,58 @@
+/*-
+ * init.c --
+ *     Initialize a new linked list.
+ *
+ * Copyright (c) 1988 by University of California Regents
+ *
+ * Permission to use, copy, modify, and distribute this
+ * software and its documentation for any purpose and without
+ * fee is hereby granted, provided that the above copyright
+ * notice appears in all copies.  Neither the University of California nor
+ * Adam de Boor makes any representations about the suitability of this
+ * software for any purpose.  It is provided "as is" without
+ * express or implied warranty.
+ */
+#ifndef lint
+static char *rcsid =
+"$Id: lstInit.c,v 1.7 88/11/17 20:52:57 adam Exp $ SPRITE (Berkeley)";
+#endif lint
+
+#include       "lstInt.h"
+
+/*-
+ *-----------------------------------------------------------------------
+ * Lst_Init --
+ *     Create and initialize a new list.
+ *
+ * Results:
+ *     The created list.
+ *
+ * Side Effects:
+ *     A list is created, what else?
+ *
+ *-----------------------------------------------------------------------
+ */
+Lst
+Lst_Init(circ)
+    Boolean            circ;   /* TRUE if the list should be made circular */
+{
+    register List      nList;
+    
+    PAlloc (nList, List);
+    
+    nList->firstPtr = NilListNode;
+    nList->lastPtr = NilListNode;
+    nList->isOpen = FALSE;
+    nList->isCirc = circ;
+    nList->atEnd = Unknown;
+    
+    return ((Lst)nList);
+}
+
+Malloc(nbytes)
+{
+#ifdef DEBUG
+    printf("malloc: %d\n", nbytes);
+#endif DEBUG
+    return(malloc(nbytes));
+}
diff --git a/usr/src/usr.bin/make/lst.lib/lstInsert.c b/usr/src/usr.bin/make/lst.lib/lstInsert.c
new file mode 100644 (file)
index 0000000..63ab6eb
--- /dev/null
@@ -0,0 +1,87 @@
+/*-
+ * LstInsert.c --
+ *     Insert a new datum before an old one
+ *
+ * Copyright (c) 1988 by University of California Regents
+ *
+ * Permission to use, copy, modify, and distribute this
+ * software and its documentation for any purpose and without
+ * fee is hereby granted, provided that the above copyright
+ * notice appears in all copies.  Neither the University of California nor
+ * Adam de Boor makes any representations about the suitability of this
+ * software for any purpose.  It is provided "as is" without
+ * express or implied warranty.
+ */
+#ifndef lint
+static char *rcsid =
+"$Id: lstInsert.c,v 1.6 89/06/13 15:01:43 adam Exp $ SPRITE (Berkeley)";
+#endif lint
+
+#include       "lstInt.h"
+
+/*-
+ *-----------------------------------------------------------------------
+ * 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.
+ *
+ *-----------------------------------------------------------------------
+ */
+ReturnStatus
+Lst_Insert (l, ln, d)
+    Lst                        l;      /* list to manipulate */
+    LstNode            ln;     /* node before which to insert d */
+    ClientData         d;      /* datum to be inserted */
+{
+    register ListNode  nLNode; /* new lnode for d */
+    register ListNode  lNode = (ListNode)ln;
+    register List      list = (List)l;
+
+
+    /*
+     * check validity of arguments
+     */
+    if (LstValid (l) && (LstIsEmpty (l) && ln == NILLNODE))
+       goto ok;
+    
+    if (!LstValid (l) || LstIsEmpty (l) || !LstNodeValid (ln, l)) {
+       return (FAILURE);
+    }
+    
+    ok:
+    PAlloc (nLNode, ListNode);
+    
+    nLNode->datum = d;
+    nLNode->useCount = nLNode->flags = 0;
+    
+    if (ln == NILLNODE) {
+       if (list->isCirc) {
+           nLNode->prevPtr = nLNode->nextPtr = nLNode;
+       } else {
+           nLNode->prevPtr = nLNode->nextPtr = NilListNode;
+       }
+       list->firstPtr = list->lastPtr = nLNode;
+    } else {
+       nLNode->prevPtr = lNode->prevPtr;
+       nLNode->nextPtr = lNode;
+       
+       if (nLNode->prevPtr != NilListNode) {
+           nLNode->prevPtr->nextPtr = nLNode;
+       }
+       lNode->prevPtr = nLNode;
+       
+       if (lNode == list->firstPtr) {
+           list->firstPtr = nLNode;
+       }
+    }
+    
+    return (SUCCESS);
+}
+       
diff --git a/usr/src/usr.bin/make/lst.lib/lstIsAtEnd.c b/usr/src/usr.bin/make/lst.lib/lstIsAtEnd.c
new file mode 100644 (file)
index 0000000..e8e2d0d
--- /dev/null
@@ -0,0 +1,55 @@
+/*-
+ * LstIsAtEnd.c --
+ *     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.
+ *
+ * Copyright (c) 1988 by University of California Regents
+ *
+ * Permission to use, copy, modify, and distribute this
+ * software and its documentation for any purpose and without
+ * fee is hereby granted, provided that the above copyright
+ * notice appears in all copies.  Neither the University of California nor
+ * Adam de Boor makes any representations about the suitability of this
+ * software for any purpose.  It is provided "as is" without
+ * express or implied warranty.
+ */
+#ifndef lint
+static char *rcsid =
+"$Id: lstIsAtEnd.c,v 1.6 88/11/17 20:53:14 adam Exp $ SPRITE (Berkeley)";
+#endif lint
+
+#include       "lstInt.h"
+
+/*-
+ *-----------------------------------------------------------------------
+ * Lst_IsAtEnd --
+ *     Return true if have reached the end of the given list.
+ *
+ * Results:
+ *     TRUE if at the end of the list (this includes the list not being
+ *     open or being invalid) or FALSE if not. We return TRUE if the list
+ *     is invalid or unopend so as to cause the caller to exit its loop
+ *     asap, the assumption being that the loop is of the form
+ *         while (!Lst_IsAtEnd (l)) {
+ *               ...
+ *         }
+ *
+ * Side Effects:
+ *     None.
+ *
+ *-----------------------------------------------------------------------
+ */
+Boolean
+Lst_IsAtEnd (l)
+    Lst            l;
+{
+    register List list = (List) l;
+
+    return (!LstValid (l) || !list->isOpen ||
+           (list->atEnd == Head) || (list->atEnd == Tail));
+}
+
diff --git a/usr/src/usr.bin/make/lst.lib/lstIsEmpty.c b/usr/src/usr.bin/make/lst.lib/lstIsEmpty.c
new file mode 100644 (file)
index 0000000..d71d029
--- /dev/null
@@ -0,0 +1,43 @@
+/*-
+ * LstIsEmpty.c --
+ *     A single function to decide if a list is empty
+ *
+ * Copyright (c) 1988 by University of California Regents
+ *
+ * Permission to use, copy, modify, and distribute this
+ * software and its documentation for any purpose and without
+ * fee is hereby granted, provided that the above copyright
+ * notice appears in all copies.  Neither the University of California nor
+ * Adam de Boor makes any representations about the suitability of this
+ * software for any purpose.  It is provided "as is" without
+ * express or implied warranty.
+ */
+#ifndef lint
+static char *rcsid =
+"$Id: lstIsEmpty.c,v 1.5 88/11/17 20:53:19 adam Exp $ SPRITE (Berkeley)";
+#endif lint
+
+#include       "lstInt.h"
+
+/*-
+ *-----------------------------------------------------------------------
+ * 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 == NilListNode (or if
+ *     the list itself is NILLIST).
+ *-----------------------------------------------------------------------
+ */
+Boolean
+Lst_IsEmpty (l)
+    Lst        l;
+{
+    return ( ! LstValid (l) || LstIsEmpty(l));
+}
+
diff --git a/usr/src/usr.bin/make/lst.lib/lstLast.c b/usr/src/usr.bin/make/lst.lib/lstLast.c
new file mode 100644 (file)
index 0000000..fa01777
--- /dev/null
@@ -0,0 +1,45 @@
+/*-
+ * LstLast.c --
+ *     Return the last element of a list
+ *
+ * Copyright (c) 1988 by University of California Regents
+ *
+ * Permission to use, copy, modify, and distribute this
+ * software and its documentation for any purpose and without
+ * fee is hereby granted, provided that the above copyright
+ * notice appears in all copies.  Neither the University of California nor
+ * Adam de Boor makes any representations about the suitability of this
+ * software for any purpose.  It is provided "as is" without
+ * express or implied warranty.
+ */
+#ifndef lint
+static char *rcsid =
+"$Id: lstLast.c,v 1.5 88/11/17 20:53:24 adam Exp $ SPRITE (Berkeley)";
+#endif lint
+
+#include       "lstInt.h"
+
+/*-
+ *-----------------------------------------------------------------------
+ * Lst_Last --
+ *     Return the last node on the list l.
+ *
+ * Results:
+ *     The requested node or NILLNODE if the list is empty.
+ *
+ * Side Effects:
+ *     None.
+ *
+ *-----------------------------------------------------------------------
+ */
+LstNode
+Lst_Last (l)
+    Lst            l;
+{
+    if (!LstValid(l) || LstIsEmpty (l)) {
+       return (NILLNODE);
+    } else {
+       return ((LstNode)((List)l)->lastPtr);
+    }
+}
+
diff --git a/usr/src/usr.bin/make/lst.lib/lstLength.c b/usr/src/usr.bin/make/lst.lib/lstLength.c
new file mode 100644 (file)
index 0000000..550b99e
--- /dev/null
@@ -0,0 +1,45 @@
+/*-
+ * lstLength.c --
+ *     Find the length of a lst
+ *
+ * Copyright (c) 1988 by the Regents of the University of California
+ * Copyright (c) 1988 by Adam de Boor
+ *
+ * Permission to use, copy, modify, and distribute this
+ * software and its documentation for any purpose and without
+ * fee is hereby granted, provided that the above copyright
+ * notice appears in all copies.  The University of California nor
+ * Adam de Boor makes any representations about the suitability of this
+ * software for any purpose.  It is provided "as is" without
+ * express or implied warranty.
+ *
+ *
+ */
+#ifndef lint
+static char *rcsid =
+"$Id: lstLength.c,v 1.2 88/11/17 20:53:27 adam Exp $ SPRITE (Berkeley)";
+#endif lint
+
+#include    "lstInt.h"
+
+int
+Lst_Length(l)
+    Lst            l;    /* List whose length is desired */
+{
+    register ListNode  node;
+    register List      list = (List)l;
+    register int       len;
+
+    if (!LstValid(l)) {
+       return -1;
+    }
+
+    for (len = 0, node = list->firstPtr;
+        node != NilListNode;
+        len++, node = node->nextPtr) {
+       if (node == list->firstPtr && len != 0) {
+           break;
+       }
+    }
+    return len;
+}
diff --git a/usr/src/usr.bin/make/lst.lib/lstMember.c b/usr/src/usr.bin/make/lst.lib/lstMember.c
new file mode 100644 (file)
index 0000000..a9f8795
--- /dev/null
@@ -0,0 +1,46 @@
+/*-
+ * lstMember.c --
+ *     See if a given datum is on a given list.
+ *
+ * Copyright (c) 1988 by the Regents of the University of California
+ * Copyright (c) 1988 by Adam de Boor
+ *
+ * Permission to use, copy, modify, and distribute this
+ * software and its documentation for any purpose and without
+ * fee is hereby granted, provided that the above copyright
+ * notice appears in all copies.  The University of California nor
+ * Adam de Boor makes any representations about the suitability of this
+ * software for any purpose.  It is provided "as is" without
+ * express or implied warranty.
+ *
+ *
+ */
+#ifndef lint
+static char *rcsid =
+"$Id: lstMember.c,v 1.5 88/11/17 20:53:32 adam Exp $ SPRITE (Berkeley)";
+#endif lint
+
+#include    "lstInt.h"
+
+LstNode
+Lst_Member (l, d)
+    Lst                        l;
+    ClientData         d;
+{
+    List               list = (List) l;
+    register ListNode  lNode;
+
+    lNode = list->firstPtr;
+    if (lNode == NilListNode) {
+       return NILLNODE;
+    }
+    
+    do {
+       if (lNode->datum == d) {
+           return (LstNode)lNode;
+       }
+       lNode = lNode->nextPtr;
+    } while (lNode != NilListNode && lNode != list->firstPtr);
+
+    return NILLNODE;
+}
diff --git a/usr/src/usr.bin/make/lst.lib/lstMove.c b/usr/src/usr.bin/make/lst.lib/lstMove.c
new file mode 100644 (file)
index 0000000..b4d6e94
--- /dev/null
@@ -0,0 +1,67 @@
+/*-
+ * LstMove.c --
+ *     Move an existing node after or before one in the same or different
+ *     list.
+ *
+ * Copyright (c) 1988 by University of California Regents
+ *
+ * Permission to use, copy, modify, and distribute this
+ * software and its documentation for any purpose and without
+ * fee is hereby granted, provided that the above copyright
+ * notice appears in all copies.  Neither the University of California nor
+ * Adam de Boor makes any representations about the suitability of this
+ * software for any purpose.  It is provided "as is" without
+ * express or implied warranty.
+ */
+#ifndef lint
+static char *rcsid =
+"$Id: lstMove.c,v 1.6 89/06/13 15:01:48 adam Exp $ SPRITE (Berkeley)";
+#endif lint
+
+#include       "lstInt.h"
+
+/*-
+ *-----------------------------------------------------------------------
+ * Lst_Move --
+ *     Move a node after or before a destination node. The nodes do not
+ *     need to be in the same list, of course.
+ *
+ * Results:
+ *     SUCCESS or FAILURE.
+ *
+ * Side Effects:
+ *     The firstPtr and lastPtr fields of either or both of the involved
+ *     lists may be altered to reflect reality.
+ *
+ *-----------------------------------------------------------------------
+ */
+ReturnStatus
+Lst_Move (ls, lns, ld, lnd, before)
+    Lst                        ls;     /* Source list */
+    register LstNode   lns;    /* source list node */
+    Lst                        ld;     /* Destination list */
+    register LstNode   lnd;    /* destination list node */
+    Boolean            before; /* true if should use Lst_Insert */
+{
+    ClientData d;
+    ReturnStatus       rval;
+    
+    if (lns == NILLNODE || lnd == NILLNODE) {
+       return (FAILURE);
+    }
+    
+    d = ((ListNode)lns)->datum;
+    
+    if (Lst_Remove (ls, lns) == FAILURE) {
+       return (FAILURE);
+    }
+    
+    if (before == TRUE) {
+       rval = Lst_Insert (ld, lnd, d);
+    } else {
+       rval = Lst_Append (ld, lnd, d);
+    }
+    
+    return (rval);
+}
+
diff --git a/usr/src/usr.bin/make/lst.lib/lstNext.c b/usr/src/usr.bin/make/lst.lib/lstNext.c
new file mode 100644 (file)
index 0000000..926c175
--- /dev/null
@@ -0,0 +1,88 @@
+/*-
+ * LstNext.c --
+ *     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.
+ *
+ * Copyright (c) 1988 by University of California Regents
+ *
+ * Permission to use, copy, modify, and distribute this
+ * software and its documentation for any purpose and without
+ * fee is hereby granted, provided that the above copyright
+ * notice appears in all copies.  Neither the University of California nor
+ * Adam de Boor makes any representations about the suitability of this
+ * software for any purpose.  It is provided "as is" without
+ * express or implied warranty.
+ */
+#ifndef lint
+static char *rcsid =
+"$Id: lstNext.c,v 1.8 88/11/17 20:53:40 adam Exp $ SPRITE (Berkeley)";
+#endif lint
+
+#include       "lstInt.h"
+
+/*-
+ *-----------------------------------------------------------------------
+ * Lst_Next --
+ *     Return the next node for the given list.
+ *
+ * Results:
+ *     The next node or NILLNODE if the list has yet to be opened. Also
+ *     if the list is non-circular and the end has been reached, NILLNODE
+ *     is returned.
+ *
+ * Side Effects:
+ *     the curPtr field is updated.
+ *
+ *-----------------------------------------------------------------------
+ */
+LstNode
+Lst_Next (l)
+    Lst                  l;
+{
+    register ListNode  tln;
+    register List      list = (List)l;
+    
+    if ((LstValid (l) == FALSE) ||
+       (list->isOpen == FALSE)) {
+           return (NILLNODE);
+    }
+    
+    list->prevPtr = list->curPtr;
+    
+    if (list->curPtr == NilListNode) {
+       if (list->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;
+       } else {
+           tln = NilListNode;
+           list->atEnd = Tail;
+       }
+    } else {
+       tln = list->curPtr->nextPtr;
+       list->curPtr = tln;
+
+       if (tln == list->firstPtr || tln == NilListNode) {
+           /*
+            * If back at the front, then we've hit the end...
+            */
+           list->atEnd = Tail;
+       } else {
+           /*
+            * Reset to Middle if gone past first.
+            */
+           list->atEnd = Middle;
+       }
+    }
+    
+    return ((LstNode)tln);
+}
+
diff --git a/usr/src/usr.bin/make/lst.lib/lstOpen.c b/usr/src/usr.bin/make/lst.lib/lstOpen.c
new file mode 100644 (file)
index 0000000..4648849
--- /dev/null
@@ -0,0 +1,55 @@
+/*-
+ * LstOpen.c --
+ *     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.
+ *
+ * Copyright (c) 1988 by University of California Regents
+ *
+ * Permission to use, copy, modify, and distribute this
+ * software and its documentation for any purpose and without
+ * fee is hereby granted, provided that the above copyright
+ * notice appears in all copies.  Neither the University of California nor
+ * Adam de Boor makes any representations about the suitability of this
+ * software for any purpose.  It is provided "as is" without
+ * express or implied warranty.
+ */
+#ifndef lint
+static char *rcsid =
+"$Id: lstOpen.c,v 1.6 88/11/17 20:53:43 adam Exp $ SPRITE (Berkeley)";
+#endif lint
+
+#include       "lstInt.h"
+
+/*-
+ *-----------------------------------------------------------------------
+ * Lst_Open --
+ *     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 NilListNode so the
+ *     other sequential functions no it was just opened and can choose
+ *     the first element accessed based on this.
+ *
+ *-----------------------------------------------------------------------
+ */
+ReturnStatus
+Lst_Open (l)
+       register Lst    l;
+{
+       if (LstValid (l) == FALSE) {
+               return (FAILURE);
+       }
+       ((List) l)->isOpen = TRUE;
+       ((List) l)->atEnd = LstIsEmpty (l) ? Head : Unknown;
+       ((List) l)->curPtr = NilListNode;
+
+       return (SUCCESS);
+}
+
diff --git a/usr/src/usr.bin/make/lst.lib/lstPred.c b/usr/src/usr.bin/make/lst.lib/lstPred.c
new file mode 100644 (file)
index 0000000..1eeb22a
--- /dev/null
@@ -0,0 +1,45 @@
+/*-
+ * LstPred.c --
+ *     Return the predecessor of a given list node
+ *
+ * Copyright (c) 1988 by University of California Regents
+ *
+ * Permission to use, copy, modify, and distribute this
+ * software and its documentation for any purpose and without
+ * fee is hereby granted, provided that the above copyright
+ * notice appears in all copies.  Neither the University of California nor
+ * Adam de Boor makes any representations about the suitability of this
+ * software for any purpose.  It is provided "as is" without
+ * express or implied warranty.
+ */
+#ifndef lint
+static char *rcsid =
+"$Id: lstPred.c,v 1.4 88/11/17 20:53:50 adam Exp $ SPRITE (Berkeley)";
+#endif lint
+
+#include       "lstInt.h"
+
+/*-
+ *-----------------------------------------------------------------------
+ * Lst_Pred --
+ *     Return the predecessor of the given node.
+ *
+ * Results:
+ *     The node's predecessor, if any, or NILLNODE if it has none.
+ *
+ * Side Effects:
+ *     None.
+ *
+ *-----------------------------------------------------------------------
+ */
+LstNode
+Lst_Pred (ln)
+    LstNode    ln;
+{
+    if (ln == NILLNODE) {
+       return (NILLNODE);
+    } else {
+       return ((LstNode)((ListNode) ln)->prevPtr);
+    }
+}
+
diff --git a/usr/src/usr.bin/make/lst.lib/lstPrev.c b/usr/src/usr.bin/make/lst.lib/lstPrev.c
new file mode 100644 (file)
index 0000000..3dcc7dd
--- /dev/null
@@ -0,0 +1,76 @@
+/*-
+ * LstPrev.c --
+ *     Get the node previous to the current one in the list and make it the
+ *     current node.
+ *     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.
+ *
+ * Copyright (c) 1988 by University of California Regents
+ *
+ * Permission to use, copy, modify, and distribute this
+ * software and its documentation for any purpose and without
+ * fee is hereby granted, provided that the above copyright
+ * notice appears in all copies.  Neither the University of California nor
+ * Adam de Boor makes any representations about the suitability of this
+ * software for any purpose.  It is provided "as is" without
+ * express or implied warranty.
+ */
+#ifndef lint
+static char *rcsid =
+"$Id: lstPrev.c,v 1.8 88/11/17 20:53:54 adam Exp $ SPRITE (Berkeley)";
+#endif lint
+
+#include       "lstInt.h"
+
+/*-
+ *-----------------------------------------------------------------------
+ * Lst_Prev --
+ *     Return the node previous to the current one for the given list.
+ *
+ * Results:
+ *     The previous node or NILLNODE if the list hasn't been opened
+ *     yet or the beginning was reached.
+ *
+ * Side Effects:
+ *     the curPtr is changed to reflect reality.
+ *
+ *-----------------------------------------------------------------------
+ */
+LstNode
+Lst_Prev (l)
+    Lst                        l;
+{
+    register ListNode  tln;
+    register List      list = (List)l;
+    
+    if ((LstValid (l) == FALSE) ||
+       (list->isOpen == FALSE)) {
+           return (NILLNODE);
+    }
+    
+    list->prevPtr = list->curPtr;
+    
+    if (list->curPtr == NilListNode) {
+       if (list->atEnd == Unknown) {
+           list->curPtr = tln = list->lastPtr;
+           list->atEnd = Middle;
+       } else {
+           tln = NilListNode;
+           list->atEnd = Head;
+       }
+    } else {
+       tln = list->curPtr->prevPtr;
+       list->curPtr = tln;
+       if (tln == list->lastPtr || tln == NilListNode) {
+           list->atEnd = Head;
+       } else {
+           list->atEnd = Middle;
+       }
+    }
+    
+    return ((LstNode)tln);
+}
+
diff --git a/usr/src/usr.bin/make/lst.lib/lstRemove.c b/usr/src/usr.bin/make/lst.lib/lstRemove.c
new file mode 100644 (file)
index 0000000..8b8877b
--- /dev/null
@@ -0,0 +1,105 @@
+/*-
+ * LstRemove.c --
+ *     Remove an element from a list
+ *
+ * Copyright (c) 1988 by University of California Regents
+ *
+ * Permission to use, copy, modify, and distribute this
+ * software and its documentation for any purpose and without
+ * fee is hereby granted, provided that the above copyright
+ * notice appears in all copies.  Neither the University of California nor
+ * Adam de Boor makes any representations about the suitability of this
+ * software for any purpose.  It is provided "as is" without
+ * express or implied warranty.
+ */
+#ifndef lint
+static char *rcsid =
+"$Id: lstRemove.c,v 1.7 89/06/13 15:01:51 adam Exp $ SPRITE (Berkeley)";
+#endif lint
+
+#include       "lstInt.h"
+
+/*-
+ *-----------------------------------------------------------------------
+ * Lst_Remove --
+ *     Remove the given node from the given list.
+ *
+ * Results:
+ *     SUCCESS or FAILURE.
+ *
+ * Side Effects:
+ *     The list's firstPtr will be set to NilListNode if ln is the last
+ *     node on the list. firsPtr and lastPtr will be altered if ln is
+ *     either the first or last node, respectively, on the list.
+ *
+ *-----------------------------------------------------------------------
+ */
+ReturnStatus
+Lst_Remove (l, ln)
+    Lst                        l;
+    LstNode            ln;
+{
+    register List      list = (List) l;
+    register ListNode  lNode = (ListNode) ln;
+
+    if (!LstValid (l) ||
+       !LstNodeValid (ln, l)) {
+           return (FAILURE);
+    }
+    
+    /*
+     * unlink it from the list
+     */
+    if (lNode->nextPtr != NilListNode) {
+       lNode->nextPtr->prevPtr = lNode->prevPtr;
+    }
+    if (lNode->prevPtr != NilListNode) {
+       lNode->prevPtr->nextPtr = lNode->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;
+    }
+
+    /*
+     * Sequential access stuff. If the node we're removing is the current
+     * node in the list, reset the current node to the previous one. If the
+     * previous one was non-existent (prevPtr == NilListNode), we set the
+     * end to be Unknown, since it is.
+     */
+    if (list->isOpen && (list->curPtr == lNode)) {
+       list->curPtr = list->prevPtr;
+       if (list->curPtr == NilListNode) {
+           list->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
+     * this case). The list is, therefore, empty and is marked as such
+     */
+    if (list->firstPtr == lNode) {
+       list->firstPtr = NilListNode;
+    }
+    
+    /*
+     * note that the datum is unmolested. The caller must free it as
+     * necessary and as expected.
+     */
+    if (lNode->useCount == 0) {
+       free ((Address)ln);
+    } else {
+       lNode->flags |= LN_DELETED;
+    }
+    
+    return (SUCCESS);
+}
+
diff --git a/usr/src/usr.bin/make/lst.lib/lstReplace.c b/usr/src/usr.bin/make/lst.lib/lstReplace.c
new file mode 100644 (file)
index 0000000..bc6dea5
--- /dev/null
@@ -0,0 +1,47 @@
+/*-
+ * LstReplace.c --
+ *     Replace the datum in a node with a new datum
+ *
+ * Copyright (c) 1988 by University of California Regents
+ *
+ * Permission to use, copy, modify, and distribute this
+ * software and its documentation for any purpose and without
+ * fee is hereby granted, provided that the above copyright
+ * notice appears in all copies.  Neither the University of California nor
+ * Adam de Boor makes any representations about the suitability of this
+ * software for any purpose.  It is provided "as is" without
+ * express or implied warranty.
+ */
+#ifndef lint
+static char *rcsid =
+"$Id: lstReplace.c,v 1.4 88/11/17 20:54:01 adam Exp $ SPRITE (Berkeley)";
+#endif lint
+
+#include       "lstInt.h"
+
+/*-
+ *-----------------------------------------------------------------------
+ * Lst_Replace --
+ *     Replace the datum in the given node with the new datum
+ *
+ * Results:
+ *     SUCCESS or FAILURE.
+ *
+ * Side Effects:
+ *     The datum field fo the node is altered.
+ *
+ *-----------------------------------------------------------------------
+ */
+ReturnStatus
+Lst_Replace (ln, d)
+    register LstNode   ln;
+    ClientData         d;
+{
+    if (ln == NILLNODE) {
+       return (FAILURE);
+    } else {
+       ((ListNode) ln)->datum = d;
+       return (SUCCESS);
+    }
+}
+
diff --git a/usr/src/usr.bin/make/lst.lib/lstSetCirc.c b/usr/src/usr.bin/make/lst.lib/lstSetCirc.c
new file mode 100644 (file)
index 0000000..1d96872
--- /dev/null
@@ -0,0 +1,65 @@
+/*-
+ * listSetCirc.c --
+ *     Change the library's notion of the circularity of a list.
+ *
+ * Copyright (c) 1988 by the Regents of the University of California
+ *
+ * Copyright (c) 1988 by Adam de Boor
+ *
+ * Permission to use, copy, modify, and distribute this
+ * software and its documentation for any purpose and without
+ * fee is hereby granted, provided that the above copyright
+ * notice appears in all copies.  The University of California nor
+ * Adam de Boor makes any representations about the suitability of this
+ * software for any purpose.  It is provided "as is" without
+ * express or implied warranty.
+ *
+ *
+ */
+#ifndef lint
+static char *rcsid =
+"$Id: lstSetCirc.c,v 1.3 88/11/17 20:54:04 adam Exp $ SPRITE (Berkeley)";
+#endif lint
+
+#include       "lstInt.h"
+
+/*
+ *------------------------------------------------------------
+ * Lst_SetCirc --
+ *     change the circularity of a list
+ *
+ * Results:
+ *     none
+ *
+ * Side Effects:
+ *     The circularity of the list is set appropriately. The head and
+ *     tail of the list will be linked or unlinked as necessary
+ *------------------------------------------------------------
+ */
+void
+Lst_SetCirc (l, circ)
+    Lst                  l;
+    Boolean      circ;
+{
+    register List list = (List) l;
+
+    /*
+     * if this isn't a change, do nothing.
+     */
+    if ((list->isCirc && circ) || (!list->isCirc && !circ)) {
+       return;
+    }
+    list->isCirc = circ;
+    
+    if (LstIsEmpty (l)) {
+       return;
+    }
+    
+    if (circ) {
+       list->firstPtr->prevPtr = list->lastPtr;
+       list->lastPtr->nextPtr = list->firstPtr;
+    } else {
+       list->firstPtr->prevPtr = NilListNode;
+       list->lastPtr->nextPtr = NilListNode;
+    }
+}
diff --git a/usr/src/usr.bin/make/lst.lib/lstSucc.c b/usr/src/usr.bin/make/lst.lib/lstSucc.c
new file mode 100644 (file)
index 0000000..c0161a1
--- /dev/null
@@ -0,0 +1,47 @@
+/*-
+ * LstSucc.c --
+ *     return the successor to a given node
+ *
+ * Copyright (c) 1988 by University of California Regents
+ *
+ * Permission to use, copy, modify, and distribute this
+ * software and its documentation for any purpose and without
+ * fee is hereby granted, provided that the above copyright
+ * notice appears in all copies.  Neither the University of California nor
+ * Adam de Boor makes any representations about the suitability of this
+ * software for any purpose.  It is provided "as is" without
+ * express or implied warranty.
+ */
+#ifndef lint
+static char *rcsid =
+"$Id: lstSucc.c,v 1.4 88/11/17 20:54:07 adam Exp $ SPRITE (Berkeley)";
+#endif lint
+
+#include       "lstInt.h"
+
+/*-
+ *-----------------------------------------------------------------------
+ * Lst_Succ --
+ *     Return the sucessor to the given node on its list.
+ *
+ * Results:
+ *     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)
+    LstNode    ln;
+{
+    if (ln == NILLNODE) {
+       return (NILLNODE);
+    } else {
+       return ((LstNode) ((ListNode) ln)->nextPtr);
+    }
+}
+