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): rename type Vector to PtrVector



details:   https://anonhg.NetBSD.org/src/rev/21c26bd9ea1f
branches:  trunk
changeset: 956267:21c26bd9ea1f
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Oct 25 12:08:53 2020 +0000

description:
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.

diffstat:

 usr.bin/make/lst.c                     |  14 +++++++-------
 usr.bin/make/lst.h                     |  19 ++++++++++---------
 usr.bin/make/parse.c                   |  18 +++++++++---------
 usr.bin/make/unit-tests/include-sub.mk |   4 ++--
 usr.bin/make/var.c                     |  12 ++++++------
 5 files changed, 34 insertions(+), 33 deletions(-)

diffs (232 lines):

diff -r 07cd708fcbb9 -r 21c26bd9ea1f usr.bin/make/lst.c
--- a/usr.bin/make/lst.c        Sun Oct 25 12:01:33 2020 +0000
+++ b/usr.bin/make/lst.c        Sun Oct 25 12:08:53 2020 +0000
@@ -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 @@
 }
 
 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 @@
     v->len++;
 }
 
-void *Vector_Pop(Vector *v)
+void *PtrVector_Pop(PtrVector *v)
 {
     void *datum;
 
@@ -311,7 +311,7 @@
     return datum;
 }
 
-void Vector_Done(Vector *v)
+void PtrVector_Done(PtrVector *v)
 {
     free(v->items);
 }
diff -r 07cd708fcbb9 -r 21c26bd9ea1f usr.bin/make/lst.h
--- a/usr.bin/make/lst.h        Sun Oct 25 12:01:33 2020 +0000
+++ b/usr.bin/make/lst.h        Sun Oct 25 12:08:53 2020 +0000
@@ -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 @@
 /* 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 */
diff -r 07cd708fcbb9 -r 21c26bd9ea1f usr.bin/make/parse.c
--- a/usr.bin/make/parse.c      Sun Oct 25 12:01:33 2020 +0000
+++ b/usr.bin/make/parse.c      Sun Oct 25 12:08:53 2020 +0000
@@ -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 @@
  *                     (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 @@
 
     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 @@
     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 @@
        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 @@
     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 @@
     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
 }
 
diff -r 07cd708fcbb9 -r 21c26bd9ea1f usr.bin/make/unit-tests/include-sub.mk
--- a/usr.bin/make/unit-tests/include-sub.mk    Sun Oct 25 12:01:33 2020 +0000
+++ b/usr.bin/make/unit-tests/include-sub.mk    Sun Oct 25 12:08:53 2020 +0000
@@ -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))
diff -r 07cd708fcbb9 -r 21c26bd9ea1f usr.bin/make/var.c
--- a/usr.bin/make/var.c        Sun Oct 25 12:01:33 2020 +0000
+++ b/usr.bin/make/var.c        Sun Oct 25 12:08:53 2020 +0000
@@ -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 @@
 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 @@
        debug_printf("%-16s = %s\n", varname, Buf_GetAll(&var->val, NULL));
     }
 
-    Vector_Done(&varnames);
+    PtrVector_Done(&varnames);
 }



Home | Main Index | Thread Index | Old Index