diff options
| author | rillig <rillig@NetBSD.org> | 2020-10-25 12:08:53 +0000 |
|---|---|---|
| committer | rillig <rillig@NetBSD.org> | 2020-10-25 12:08:53 +0000 |
| commit | e4b85332bc4ff0ef84dc7edaa6ca18305edbc50a (patch) | |
| tree | 4b6eefbb954111e91e7aa58f8682eb9fbb73015d /usr.bin/make | |
| parent | 4ada04e5506d1b9128d65c7a421e0e79d8b979bc (diff) | |
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 (limited to 'usr.bin/make')
| -rw-r--r-- | usr.bin/make/lst.c | 14 | ||||
| -rw-r--r-- | usr.bin/make/lst.h | 19 | ||||
| -rw-r--r-- | usr.bin/make/parse.c | 18 | ||||
| -rw-r--r-- | usr.bin/make/unit-tests/include-sub.mk | 4 | ||||
| -rw-r--r-- | usr.bin/make/var.c | 12 |
5 files changed, 34 insertions, 33 deletions
diff --git a/usr.bin/make/lst.c b/usr.bin/make/lst.c index 01afeb52d99..9fe190bf246 100644 --- a/usr.bin/make/lst.c +++ b/usr.bin/make/lst.c @@ -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); } diff --git a/usr.bin/make/lst.h b/usr.bin/make/lst.h index f603566804a..6a1ae7f0025 100644 --- a/usr.bin/make/lst.h +++ b/usr.bin/make/lst.h @@ -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 */ diff --git a/usr.bin/make/parse.c b/usr.bin/make/parse.c index 164008014d4..9057f7477d1 100644 --- a/usr.bin/make/parse.c +++ b/usr.bin/make/parse.c @@ -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 line, int fd, 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 } diff --git a/usr.bin/make/unit-tests/include-sub.mk b/usr.bin/make/unit-tests/include-sub.mk index ed675312a06..aeb7c3a6908 100644 --- a/usr.bin/make/unit-tests/include-sub.mk +++ b/usr.bin/make/unit-tests/include-sub.mk @@ -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 --git a/usr.bin/make/var.c b/usr.bin/make/var.c index 6659aa3a4f8..1b7b012b953 100644 --- a/usr.bin/make/var.c +++ b/usr.bin/make/var.c @@ -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); } |
