Module Name:    src
Committed By:   rillig
Date:           Sat Aug 22 23:06:51 UTC 2020

Modified Files:
        src/usr.bin/make: dir.c lst.c

Log Message:
make(1): migrate Lst_AtFront to Lst_PrependS

This makes Lst_AtFront unused, as well as LstInsertBefore.


To generate a diff of this commit:
cvs rdiff -u -r1.108 -r1.109 src/usr.bin/make/dir.c
cvs rdiff -u -r1.35 -r1.36 src/usr.bin/make/lst.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/make/dir.c
diff -u src/usr.bin/make/dir.c:1.108 src/usr.bin/make/dir.c:1.109
--- src/usr.bin/make/dir.c:1.108	Sat Aug 22 22:57:53 2020
+++ src/usr.bin/make/dir.c	Sat Aug 22 23:06:51 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: dir.c,v 1.108 2020/08/22 22:57:53 rillig Exp $	*/
+/*	$NetBSD: dir.c,v 1.109 2020/08/22 23:06:51 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.108 2020/08/22 22:57:53 rillig Exp $";
+static char rcsid[] = "$NetBSD: dir.c,v 1.109 2020/08/22 23:06:51 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.108 2020/08/22 22:57:53 rillig Exp $");
+__RCSID("$NetBSD: dir.c,v 1.109 2020/08/22 23:06:51 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -1564,8 +1564,11 @@ Dir_AddDir(Lst path, const char *name)
 	if (ln != NULL)
 	    return Lst_DatumS(ln);
 	else {
+	    /* XXX: It is wrong to increment the refCount if dotLast is not
+	     * used afterwards. */
 	    dotLast->refCount += 1;
-	    (void)Lst_AtFront(path, dotLast);
+	    if (path != NULL)
+		Lst_PrependS(path, dotLast);
 	}
     }
 

Index: src/usr.bin/make/lst.c
diff -u src/usr.bin/make/lst.c:1.35 src/usr.bin/make/lst.c:1.36
--- src/usr.bin/make/lst.c:1.35	Sat Aug 22 22:57:53 2020
+++ src/usr.bin/make/lst.c	Sat Aug 22 23:06:51 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: lst.c,v 1.35 2020/08/22 22:57:53 rillig Exp $ */
+/* $NetBSD: lst.c,v 1.36 2020/08/22 23:06:51 rillig Exp $ */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -37,11 +37,11 @@
 #include "make.h"
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: lst.c,v 1.35 2020/08/22 22:57:53 rillig Exp $";
+static char rcsid[] = "$NetBSD: lst.c,v 1.36 2020/08/22 23:06:51 rillig Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: lst.c,v 1.35 2020/08/22 22:57:53 rillig Exp $");
+__RCSID("$NetBSD: lst.c,v 1.36 2020/08/22 23:06:51 rillig Exp $");
 #endif /* not lint */
 #endif
 
@@ -179,46 +179,6 @@ Lst_Destroy(Lst list, FreeProc *freeProc
 
 /* Insert a new node with the given piece of data before the given node in the
  * given list. */
-static ReturnStatus
-LstInsertBefore(Lst list, LstNode node, void *datum)
-{
-    LstNode newNode;
-
-    /*
-     * check validity of arguments
-     */
-    if (LstIsValid(list) && (LstIsEmpty(list) && node == NULL))
-	goto ok;
-
-    if (!LstIsValid(list) || LstIsEmpty(list) || !LstNodeIsValid(node)) {
-	return FAILURE;
-    }
-
-    ok:
-    newNode = LstNodeNew(datum);
-
-    if (node == NULL) {
-	newNode->prev = newNode->next = NULL;
-	list->first = list->last = newNode;
-    } else {
-	newNode->prev = node->prev;
-	newNode->next = node;
-
-	if (newNode->prev != NULL) {
-	    newNode->prev->next = newNode;
-	}
-	node->prev = newNode;
-
-	if (node == list->first) {
-	    list->first = newNode;
-	}
-    }
-
-    return SUCCESS;
-}
-
-/* Insert a new node with the given piece of data before the given node in the
- * given list. */
 void
 Lst_InsertBeforeS(Lst list, LstNode node, void *datum)
 {
@@ -243,14 +203,6 @@ Lst_InsertBeforeS(Lst list, LstNode node
     }
 }
 
-/* Add a piece of data at the front of the given list. */
-ReturnStatus
-Lst_AtFront(Lst list, void *datum)
-{
-    LstNode front = Lst_First(list);
-    return LstInsertBefore(list, front, datum);
-}
-
 /* Add a piece of data at the start of the given list. */
 void
 Lst_PrependS(Lst list, void *datum)

Reply via email to