Module Name:    src
Committed By:   rillig
Date:           Sun Oct 25 12:08:53 UTC 2020

Modified Files:
        src/usr.bin/make: lst.c lst.h parse.c var.c
        src/usr.bin/make/unit-tests: include-sub.mk

Log Message:
make(1): rename type Vector to PtrVector

This allows the name Vector to be used for a more generic vector type,
which will be added soon.


To generate a diff of this commit:
cvs rdiff -u -r1.88 -r1.89 src/usr.bin/make/lst.c
cvs rdiff -u -r1.80 -r1.81 src/usr.bin/make/lst.h
cvs rdiff -u -r1.398 -r1.399 src/usr.bin/make/parse.c
cvs rdiff -u -r1.583 -r1.584 src/usr.bin/make/var.c
cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/include-sub.mk

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/lst.c
diff -u src/usr.bin/make/lst.c:1.88 src/usr.bin/make/lst.c:1.89
--- src/usr.bin/make/lst.c:1.88	Sun Oct 25 10:07:23 2020
+++ src/usr.bin/make/lst.c	Sun Oct 25 12:08:53 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: lst.c,v 1.88 2020/10/25 10:07:23 rillig Exp $ */
+/* $NetBSD: lst.c,v 1.89 2020/10/25 12:08:53 rillig Exp $ */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -34,7 +34,7 @@
 
 #include "make.h"
 
-MAKE_RCSID("$NetBSD: lst.c,v 1.88 2020/10/25 10:07:23 rillig Exp $");
+MAKE_RCSID("$NetBSD: lst.c,v 1.89 2020/10/25 12:08:53 rillig Exp $");
 
 static ListNode *
 LstNodeNew(ListNode *prev, ListNode *next, void *datum)
@@ -275,19 +275,19 @@ Lst_Dequeue(List *list)
 }
 
 void
-Vector_Init(Vector *v)
+PtrVector_Init(PtrVector *v)
 {
     v->len = 0;
     v->cap = 10;
     v->items = bmake_malloc(v->cap * sizeof v->items[0]);
 }
 
-Boolean Vector_IsEmpty(Vector *v)
+Boolean PtrVector_IsEmpty(PtrVector *v)
 {
     return v->len == 0;
 }
 
-void Vector_Push(Vector *v, void *datum)
+void PtrVector_Push(PtrVector *v, void *datum)
 {
     if (v->len >= v->cap) {
 	v->cap *= 2;
@@ -298,7 +298,7 @@ void Vector_Push(Vector *v, void *datum)
     v->len++;
 }
 
-void *Vector_Pop(Vector *v)
+void *PtrVector_Pop(PtrVector *v)
 {
     void *datum;
 
@@ -311,7 +311,7 @@ void *Vector_Pop(Vector *v)
     return datum;
 }
 
-void Vector_Done(Vector *v)
+void PtrVector_Done(PtrVector *v)
 {
     free(v->items);
 }

Index: src/usr.bin/make/lst.h
diff -u src/usr.bin/make/lst.h:1.80 src/usr.bin/make/lst.h:1.81
--- src/usr.bin/make/lst.h:1.80	Sun Oct 25 10:07:23 2020
+++ src/usr.bin/make/lst.h	Sun Oct 25 12:08:53 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: lst.h,v 1.80 2020/10/25 10:07:23 rillig Exp $	*/
+/*	$NetBSD: lst.h,v 1.81 2020/10/25 12:08:53 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -163,17 +163,18 @@ void Lst_Enqueue(List *, void *);
 /* Remove the head node of the queue and return its datum. */
 void *Lst_Dequeue(List *);
 
-/* A vector is an ordered collection of items, allowing fast indexed access. */
-typedef struct Vector {
+/* A pointer vector is an ordered collection of pointers, allowing for fast
+ * indexed access. */
+typedef struct PtrVector {
     void **items;
     size_t len;
     size_t cap;
-} Vector;
+} PtrVector;
 
-void Vector_Init(Vector *);
-Boolean Vector_IsEmpty(Vector *);
-void Vector_Push(Vector *, void *);
-void *Vector_Pop(Vector *);
-void Vector_Done(Vector *);
+void PtrVector_Init(PtrVector *);
+Boolean PtrVector_IsEmpty(PtrVector *);
+void PtrVector_Push(PtrVector *, void *);
+void *PtrVector_Pop(PtrVector *);
+void PtrVector_Done(PtrVector *);
 
 #endif /* MAKE_LST_H */

Index: src/usr.bin/make/parse.c
diff -u src/usr.bin/make/parse.c:1.398 src/usr.bin/make/parse.c:1.399
--- src/usr.bin/make/parse.c:1.398	Fri Oct 23 20:04:56 2020
+++ src/usr.bin/make/parse.c	Sun Oct 25 12:08:53 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: parse.c,v 1.398 2020/10/23 20:04:56 rillig Exp $	*/
+/*	$NetBSD: parse.c,v 1.399 2020/10/25 12:08:53 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -131,7 +131,7 @@
 #include "pathnames.h"
 
 /*	"@(#)parse.c	8.3 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: parse.c,v 1.398 2020/10/23 20:04:56 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.399 2020/10/25 12:08:53 rillig Exp $");
 
 /* types and constants */
 
@@ -281,7 +281,7 @@ static IFile *curFile;
  *			(not printed since it is below a .for loop)
  *	includes[0]:	include-main.mk:27
  */
-static Vector /* of IFile pointer */ includes;
+static PtrVector /* of IFile pointer */ includes;
 
 /* include paths (lists of directories) */
 SearchPath *parseIncPath;	/* dirs for "..." includes */
@@ -2404,7 +2404,7 @@ Parse_SetInput(const char *name, int lin
 
     if (curFile != NULL)
 	/* Save existing file info */
-	Vector_Push(&includes, curFile);
+	PtrVector_Push(&includes, curFile);
 
     /* Allocate and fill in new structure */
     curFile = bmake_malloc(sizeof *curFile);
@@ -2599,7 +2599,7 @@ ParseEOF(void)
     free(curFile->P_str);
     free(curFile);
 
-    if (Vector_IsEmpty(&includes)) {
+    if (PtrVector_IsEmpty(&includes)) {
 	curFile = NULL;
 	/* We've run out of input */
 	Var_Delete(".PARSEDIR", VAR_GLOBAL);
@@ -2609,7 +2609,7 @@ ParseEOF(void)
 	return FALSE;
     }
 
-    curFile = Vector_Pop(&includes);
+    curFile = PtrVector_Pop(&includes);
     DEBUG2(PARSE, "ParseEOF: returning to file %s, line %d\n",
 	   curFile->fname, curFile->lineno);
 
@@ -3147,7 +3147,7 @@ Parse_Init(void)
     parseIncPath = Lst_New();
     sysIncPath = Lst_New();
     defIncPath = Lst_New();
-    Vector_Init(&includes);
+    PtrVector_Init(&includes);
 #ifdef CLEANUP
     targCmds = Lst_New();
 #endif
@@ -3163,8 +3163,8 @@ Parse_End(void)
     Lst_Destroy(defIncPath, Dir_Destroy);
     Lst_Destroy(sysIncPath, Dir_Destroy);
     Lst_Destroy(parseIncPath, Dir_Destroy);
-    assert(Vector_IsEmpty(&includes));
-    Vector_Done(&includes);
+    assert(PtrVector_IsEmpty(&includes));
+    PtrVector_Done(&includes);
 #endif
 }
 

Index: src/usr.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.583 src/usr.bin/make/var.c:1.584
--- src/usr.bin/make/var.c:1.583	Sat Oct 24 20:51:49 2020
+++ src/usr.bin/make/var.c	Sun Oct 25 12:08:53 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.583 2020/10/24 20:51:49 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.584 2020/10/25 12:08:53 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -121,7 +121,7 @@
 #include    "metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.583 2020/10/24 20:51:49 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.584 2020/10/25 12:08:53 rillig Exp $");
 
 #define VAR_DEBUG1(fmt, arg1) DEBUG1(VAR, fmt, arg1)
 #define VAR_DEBUG2(fmt, arg1, arg2) DEBUG2(VAR, fmt, arg1, arg2)
@@ -3865,16 +3865,16 @@ Var_Stats(void)
 void
 Var_Dump(GNode *ctxt)
 {
-    Vector varnames;
+    PtrVector varnames;
     HashIter hi;
     HashEntry *he;
     size_t i;
 
-    Vector_Init(&varnames);
+    PtrVector_Init(&varnames);
 
     HashIter_Init(&hi, &ctxt->context);
     while ((he = HashIter_Next(&hi)) != NULL)
-	Vector_Push(&varnames, he->key);
+	PtrVector_Push(&varnames, he->key);
 
     qsort(varnames.items, varnames.len, sizeof varnames.items[0], str_cmp_asc);
 
@@ -3884,5 +3884,5 @@ Var_Dump(GNode *ctxt)
 	debug_printf("%-16s = %s\n", varname, Buf_GetAll(&var->val, NULL));
     }
 
-    Vector_Done(&varnames);
+    PtrVector_Done(&varnames);
 }

Index: src/usr.bin/make/unit-tests/include-sub.mk
diff -u src/usr.bin/make/unit-tests/include-sub.mk:1.5 src/usr.bin/make/unit-tests/include-sub.mk:1.6
--- src/usr.bin/make/unit-tests/include-sub.mk:1.5	Sun Oct 18 08:58:29 2020
+++ src/usr.bin/make/unit-tests/include-sub.mk	Sun Oct 25 12:08:53 2020
@@ -1,4 +1,4 @@
-# $NetBSD: include-sub.mk,v 1.5 2020/10/18 08:58:29 rillig Exp $
+# $NetBSD: include-sub.mk,v 1.6 2020/10/25 12:08:53 rillig Exp $
 
 .if ${.INCLUDEDFROMFILE} == "include-main.mk"
 .  info sub-before-ok
@@ -20,7 +20,7 @@
 # To see the variable 'includes' in action:
 #
 # Breakpoints:
-#	Parse_File		at "Vector_Push(&includes, curFile)"
+#	Parse_File		at "PtrVector_Push(&includes, curFile)"
 #	ParseMessage		at entry
 # Watches:
 #	((const IFile *[10])(*includes.items))

Reply via email to