Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/make make(1): properly clean up the remaining code m...



details:   https://anonhg.NetBSD.org/src/rev/c823efae7617
branches:  trunk
changeset: 942862:c823efae7617
user:      rillig <rillig%NetBSD.org@localhost>
date:      Fri Aug 21 02:56:25 2020 +0000

description:
make(1): properly clean up the remaining code mentioning circular lists

diffstat:

 usr.bin/make/lst.c |  65 ++++-------------------------------------------------
 usr.bin/make/lst.h |   8 +----
 2 files changed, 8 insertions(+), 65 deletions(-)

diffs (153 lines):

diff -r e13cd0a1fed9 -r c823efae7617 usr.bin/make/lst.c
--- a/usr.bin/make/lst.c        Fri Aug 21 02:45:33 2020 +0000
+++ b/usr.bin/make/lst.c        Fri Aug 21 02:56:25 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lst.c,v 1.5 2020/08/21 02:20:47 rillig Exp $ */
+/* $NetBSD: lst.c,v 1.6 2020/08/21 02:56:25 rillig Exp $ */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -36,11 +36,11 @@
 #include "make_malloc.h"
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: lst.c,v 1.5 2020/08/21 02:20:47 rillig Exp $";
+static char rcsid[] = "$NetBSD: lst.c,v 1.6 2020/08/21 02:56:25 rillig Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: lst.c,v 1.5 2020/08/21 02:20:47 rillig Exp $");
+__RCSID("$NetBSD: lst.c,v 1.6 2020/08/21 02:56:25 rillig Exp $");
 #endif /* not lint */
 #endif
 
@@ -467,15 +467,6 @@
     }
 
     /*
-     * 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 = NULL;
-    }
-
-    /*
      * note that the datum is unmolested. The caller must free it as
      * necessary and as expected.
      */
@@ -563,21 +554,7 @@
     }
 }
 
-/*-
- *-----------------------------------------------------------------------
- * Lst_Succ --
- *     Return the successor 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.
- *
- *-----------------------------------------------------------------------
- */
+/* Return the successor to the given node on its list, or NULL. */
 LstNode
 Lst_Succ(LstNode ln)
 {
@@ -588,21 +565,7 @@
     }
 }
 
-/*-
- *-----------------------------------------------------------------------
- * Lst_Prev --
- *     Return the predecessor to the given node on its list.
- *
- * Results:
- *     The predecessor 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
- *     predecessor).
- *
- * Side Effects:
- *     None.
- *
- *-----------------------------------------------------------------------
- */
+/* Return the predecessor to the given node on its list, or NULL. */
 LstNode
 Lst_Prev(LstNode ln)
 {
@@ -773,9 +736,6 @@
  *     Apply the given function to each element of the given list,
  *     starting from a given point.
  *
- *     If the list is circular, the application will wrap around to the
- *     beginning of the list again.
- *
  *     The function should return 0 if traversal should continue, and
  *     non-zero if it should abort.
  *
@@ -882,15 +842,6 @@
     if (flags == LST_CONCLINK) {
        if (list2->firstPtr != NULL) {
            /*
-            * 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 = 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
             * first list. If the first list isn't empty, we then link the
@@ -957,9 +908,6 @@
  * 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.
  */
 
 /*-
@@ -998,8 +946,7 @@
  *
  * 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.
+ *     if the end has been reached, NULL is returned.
  *
  * Side Effects:
  *     the curPtr field is updated.
diff -r e13cd0a1fed9 -r c823efae7617 usr.bin/make/lst.h
--- a/usr.bin/make/lst.h        Fri Aug 21 02:45:33 2020 +0000
+++ b/usr.bin/make/lst.h        Fri Aug 21 02:56:25 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lst.h,v 1.22 2020/08/21 02:20:47 rillig Exp $  */
+/*     $NetBSD: lst.h,v 1.23 2020/08/21 02:56:25 rillig Exp $  */
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -157,11 +157,7 @@
 LstNode                Lst_Member(Lst, void *);
 /* Apply a function to all elements of a lst */
 int            Lst_ForEach(Lst, int (*)(void *, void *), void *);
-/*
- * Apply a function to all elements of a lst starting from a certain point.
- * If the list is circular, the application will wrap around to the
- * beginning of the list again.
- */
+/* Apply a function to all elements of a lst starting from a certain point. */
 int            Lst_ForEachFrom(Lst, LstNode, int (*)(void *, void *),
                                void *);
 /*



Home | Main Index | Thread Index | Old Index