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): remove unused code for circular lists



details:   https://anonhg.NetBSD.org/src/rev/1409f9cd1050
branches:  trunk
changeset: 942860:1409f9cd1050
user:      rillig <rillig%NetBSD.org@localhost>
date:      Fri Aug 21 02:20:47 2020 +0000

description:
make(1): remove unused code for circular lists

The list library had probably been imported from a general-purpose
library that also supported circular lists.  These are not used by make
though.

After replacing Lst_Init(FALSE) with Lst_Init(), only a single call to
Lst_Init remained with a non-constant argument, and that was in
Lst_Concat, which was to be expected.

diffstat:

 usr.bin/make/arch.c  |   10 ++--
 usr.bin/make/dir.c   |   12 ++--
 usr.bin/make/job.c   |    8 +-
 usr.bin/make/lst.c   |  103 ++++----------------------------------------------
 usr.bin/make/lst.h   |    8 +--
 usr.bin/make/main.c  |   14 +++---
 usr.bin/make/make.c  |   10 ++--
 usr.bin/make/meta.c  |    8 +-
 usr.bin/make/parse.c |   30 +++++++-------
 usr.bin/make/suff.c  |   58 ++++++++++++++--------------
 usr.bin/make/targ.c  |   26 ++++++------
 11 files changed, 101 insertions(+), 186 deletions(-)

diffs (truncated from 843 to 300 lines):

diff -r 39f833f9bb9c -r 1409f9cd1050 usr.bin/make/arch.c
--- a/usr.bin/make/arch.c       Fri Aug 21 01:36:04 2020 +0000
+++ b/usr.bin/make/arch.c       Fri Aug 21 02:20:47 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: arch.c,v 1.83 2020/08/12 19:36:14 rillig Exp $ */
+/*     $NetBSD: arch.c,v 1.84 2020/08/21 02:20:47 rillig Exp $ */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: arch.c,v 1.83 2020/08/12 19:36:14 rillig Exp $";
+static char rcsid[] = "$NetBSD: arch.c,v 1.84 2020/08/21 02:20:47 rillig Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)arch.c     8.2 (Berkeley) 1/2/94";
 #else
-__RCSID("$NetBSD: arch.c,v 1.83 2020/08/12 19:36:14 rillig Exp $");
+__RCSID("$NetBSD: arch.c,v 1.84 2020/08/21 02:20:47 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -392,7 +392,7 @@
             */
            free(buf);
        } else if (Dir_HasWildcards(memName)) {
-           Lst   members = Lst_Init(FALSE);
+           Lst   members = Lst_Init();
            char  *member;
            size_t sz = MAXPATHLEN, nsz;
            nameBuf = bmake_malloc(sz);
@@ -1305,7 +1305,7 @@
 void
 Arch_Init(void)
 {
-    archives = Lst_Init(FALSE);
+    archives = Lst_Init();
 }
 
 
diff -r 39f833f9bb9c -r 1409f9cd1050 usr.bin/make/dir.c
--- a/usr.bin/make/dir.c        Fri Aug 21 01:36:04 2020 +0000
+++ b/usr.bin/make/dir.c        Fri Aug 21 02:20:47 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: dir.c,v 1.92 2020/08/13 03:33:56 rillig Exp $  */
+/*     $NetBSD: dir.c,v 1.93 2020/08/21 02:20:47 rillig Exp $  */
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -70,14 +70,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: dir.c,v 1.92 2020/08/13 03:33:56 rillig Exp $";
+static char rcsid[] = "$NetBSD: dir.c,v 1.93 2020/08/21 02:20:47 rillig Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)dir.c      8.2 (Berkeley) 1/2/94";
 #else
-__RCSID("$NetBSD: dir.c,v 1.92 2020/08/13 03:33:56 rillig Exp $");
+__RCSID("$NetBSD: dir.c,v 1.93 2020/08/21 02:20:47 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -367,8 +367,8 @@
 Dir_Init(const char *cdname)
 {
     if (!cdname) {
-       dirSearchPath = Lst_Init(FALSE);
-       openDirectories = Lst_Init(FALSE);
+       dirSearchPath = Lst_Init();
+       openDirectories = Lst_Init();
        Hash_InitTable(&mtimes, 0);
        Hash_InitTable(&lmtimes, 0);
        return;
@@ -909,7 +909,7 @@
                        char *dp = &dirpath[strlen(dirpath) - 1];
                        if (*dp == '/')
                            *dp = '\0';
-                       path = Lst_Init(FALSE);
+                       path = Lst_Init();
                        (void)Dir_AddDir(path, dirpath);
                        DirExpandInt(cp + 1, path, expansions);
                        Lst_Destroy(path, NULL);
diff -r 39f833f9bb9c -r 1409f9cd1050 usr.bin/make/job.c
--- a/usr.bin/make/job.c        Fri Aug 21 01:36:04 2020 +0000
+++ b/usr.bin/make/job.c        Fri Aug 21 02:20:47 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: job.c,v 1.206 2020/08/10 19:53:19 rillig Exp $ */
+/*     $NetBSD: job.c,v 1.207 2020/08/21 02:20:47 rillig Exp $ */
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -70,14 +70,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: job.c,v 1.206 2020/08/10 19:53:19 rillig Exp $";
+static char rcsid[] = "$NetBSD: job.c,v 1.207 2020/08/21 02:20:47 rillig Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)job.c      8.2 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: job.c,v 1.206 2020/08/10 19:53:19 rillig Exp $");
+__RCSID("$NetBSD: job.c,v 1.207 2020/08/21 02:20:47 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -1971,7 +1971,7 @@
      * and .INTERRUPT job in the parallel job module. This has
      * the nice side effect that it avoids a lot of other problems.
      */
-    Lst lst = Lst_Init(FALSE);
+    Lst lst = Lst_Init();
     Lst_AtEnd(lst, targ);
     (void)Make_Run(lst);
     Lst_Destroy(lst, NULL);
diff -r 39f833f9bb9c -r 1409f9cd1050 usr.bin/make/lst.c
--- a/usr.bin/make/lst.c        Fri Aug 21 01:36:04 2020 +0000
+++ b/usr.bin/make/lst.c        Fri Aug 21 02:20:47 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lst.c,v 1.4 2020/08/09 20:49:15 rillig Exp $ */
+/* $NetBSD: lst.c,v 1.5 2020/08/21 02:20:47 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.4 2020/08/09 20:49:15 rillig Exp $";
+static char rcsid[] = "$NetBSD: lst.c,v 1.5 2020/08/21 02:20:47 rillig Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: lst.c,v 1.4 2020/08/09 20:49:15 rillig Exp $");
+__RCSID("$NetBSD: lst.c,v 1.5 2020/08/21 02:20:47 rillig Exp $");
 #endif /* not lint */
 #endif
 
@@ -65,8 +65,6 @@
 typedef struct List {
     ListNode firstPtr;         /* first node in list */
     ListNode lastPtr;          /* last node in list */
-    Boolean isCirc;            /* true if the list should be considered
-                                * circular */
 /*
  * fields for sequential access
  */
@@ -115,24 +113,9 @@
     return l->firstPtr == NULL;
 }
 
-/*-
- *-----------------------------------------------------------------------
- * Lst_Init --
- *     Create and initialize a new list.
- *
- * Input:
- *     circ            TRUE if the list should be made circular
- *
- * Results:
- *     The created list.
- *
- * Side Effects:
- *     A list is created, what else?
- *
- *-----------------------------------------------------------------------
- */
+/* Create and initialize a new, empty list. */
 Lst
-Lst_Init(Boolean circ)
+Lst_Init(void)
 {
     List nList;
 
@@ -141,7 +124,6 @@
     nList->firstPtr = NULL;
     nList->lastPtr = NULL;
     nList->isOpen = FALSE;
-    nList->isCirc = circ;
     nList->atEnd = Unknown;
 
     return nList;
@@ -175,7 +157,7 @@
        return NULL;
     }
 
-    nl = Lst_Init(list->isCirc);
+    nl = Lst_Init();
     if (nl == NULL) {
        return NULL;
     }
@@ -190,11 +172,7 @@
            return NULL;
        }
 
-       if (list->isCirc && ln == list->lastPtr) {
-           ln = NULL;
-       } else {
-           ln = ln->nextPtr;
-       }
+       ln = ln->nextPtr;
     }
 
     return nl;
@@ -297,11 +275,7 @@
     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 = lNode->prevPtr;
@@ -365,11 +339,7 @@
     nLNode->useCount = nLNode->flags = 0;
 
     if (lNode == 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 = lNode;
@@ -936,15 +906,6 @@
            }
            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(l2);
     } else if (list2->firstPtr != NULL) {
        /*
@@ -981,23 +942,7 @@
         * 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;
@@ -1109,34 +1054,6 @@
 
 /*-
  *-----------------------------------------------------------------------
- * 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.
- *



Home | Main Index | Thread Index | Old Index