Module Name: src
Committed By: rillig
Date: Fri Sep 25 15:54:51 UTC 2020
Modified Files:
src/usr.bin/make: cond.c enum.h for.c lst.h nonints.h suff.c var.c
Log Message:
make(1): add tags to some of the unnamed structs
The tags prevent the structs from accidentally becoming compatible
types.
While here, remove a few typedefs for structs that are single-purpose,
since there is no point in abstracting from the actual representation of
these types.
To generate a diff of this commit:
cvs rdiff -u -r1.149 -r1.150 src/usr.bin/make/cond.c
cvs rdiff -u -r1.11 -r1.12 src/usr.bin/make/enum.h
cvs rdiff -u -r1.85 -r1.86 src/usr.bin/make/for.c
cvs rdiff -u -r1.67 -r1.68 src/usr.bin/make/lst.h
cvs rdiff -u -r1.127 -r1.128 src/usr.bin/make/nonints.h
cvs rdiff -u -r1.160 -r1.161 src/usr.bin/make/suff.c
cvs rdiff -u -r1.540 -r1.541 src/usr.bin/make/var.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/cond.c
diff -u src/usr.bin/make/cond.c:1.149 src/usr.bin/make/cond.c:1.150
--- src/usr.bin/make/cond.c:1.149 Fri Sep 25 15:40:06 2020
+++ src/usr.bin/make/cond.c Fri Sep 25 15:54:50 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: cond.c,v 1.149 2020/09/25 15:40:06 rillig Exp $ */
+/* $NetBSD: cond.c,v 1.150 2020/09/25 15:54:50 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -93,7 +93,7 @@
#include "dir.h"
/* "@(#)cond.c 8.2 (Berkeley) 1/2/94" */
-MAKE_RCSID("$NetBSD: cond.c,v 1.149 2020/09/25 15:40:06 rillig Exp $");
+MAKE_RCSID("$NetBSD: cond.c,v 1.150 2020/09/25 15:54:50 rillig Exp $");
/*
* The parsing of conditional expressions is based on this grammar:
@@ -138,7 +138,7 @@ typedef enum {
TOK_LPAREN, TOK_RPAREN, TOK_EOF, TOK_NONE, TOK_ERROR
} Token;
-typedef struct {
+typedef struct CondParser {
const struct If *if_info; /* Info for current statement */
const char *p; /* The remaining condition to parse */
Token curr; /* Single push-back token used in parsing */
Index: src/usr.bin/make/enum.h
diff -u src/usr.bin/make/enum.h:1.11 src/usr.bin/make/enum.h:1.12
--- src/usr.bin/make/enum.h:1.11 Tue Sep 22 06:13:38 2020
+++ src/usr.bin/make/enum.h Fri Sep 25 15:54:50 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: enum.h,v 1.11 2020/09/22 06:13:38 rillig Exp $ */
+/* $NetBSD: enum.h,v 1.12 2020/09/25 15:54:50 rillig Exp $ */
/*
Copyright (c) 2020 Roland Illig <[email protected]>
@@ -34,7 +34,7 @@
#include <stddef.h>
-typedef struct {
+typedef struct EnumToStringSpec {
int es_value;
const char *es_name;
} EnumToStringSpec;
Index: src/usr.bin/make/for.c
diff -u src/usr.bin/make/for.c:1.85 src/usr.bin/make/for.c:1.86
--- src/usr.bin/make/for.c:1.85 Tue Sep 22 20:19:46 2020
+++ src/usr.bin/make/for.c Fri Sep 25 15:54:50 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: for.c,v 1.85 2020/09/22 20:19:46 rillig Exp $ */
+/* $NetBSD: for.c,v 1.86 2020/09/25 15:54:50 rillig Exp $ */
/*
* Copyright (c) 1992, The Regents of the University of California.
@@ -60,7 +60,7 @@
#include "strlist.h"
/* "@(#)for.c 8.1 (Berkeley) 6/6/93" */
-MAKE_RCSID("$NetBSD: for.c,v 1.85 2020/09/22 20:19:46 rillig Exp $");
+MAKE_RCSID("$NetBSD: for.c,v 1.86 2020/09/25 15:54:50 rillig Exp $");
typedef enum {
FOR_SUB_ESCAPE_CHAR = 0x0001,
@@ -73,7 +73,7 @@ static int forLevel = 0; /* Nesting leve
/*
* State of a for loop.
*/
-typedef struct {
+typedef struct For {
Buffer buf; /* Body of loop */
strlist_t vars; /* Iteration variables */
strlist_t items; /* Substitution items */
Index: src/usr.bin/make/lst.h
diff -u src/usr.bin/make/lst.h:1.67 src/usr.bin/make/lst.h:1.68
--- src/usr.bin/make/lst.h:1.67 Fri Sep 25 04:18:11 2020
+++ src/usr.bin/make/lst.h Fri Sep 25 15:54:50 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: lst.h,v 1.67 2020/09/25 04:18:11 rillig Exp $ */
+/* $NetBSD: lst.h,v 1.68 2020/09/25 15:54:50 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -218,7 +218,7 @@ void *Lst_Dequeue(List *);
/* A stack is a very simple collection of items that only allows access to the
* top-most item. */
-typedef struct {
+typedef struct Stack {
void **items;
size_t len;
size_t cap;
Index: src/usr.bin/make/nonints.h
diff -u src/usr.bin/make/nonints.h:1.127 src/usr.bin/make/nonints.h:1.128
--- src/usr.bin/make/nonints.h:1.127 Wed Sep 23 03:06:38 2020
+++ src/usr.bin/make/nonints.h Fri Sep 25 15:54:50 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: nonints.h,v 1.127 2020/09/23 03:06:38 rillig Exp $ */
+/* $NetBSD: nonints.h,v 1.128 2020/09/25 15:54:50 rillig Exp $ */
/*-
* Copyright (c) 1988, 1989, 1990, 1993
@@ -131,7 +131,7 @@ void Parse_SetInput(const char *, int, i
GNodeList *Parse_MainName(void);
/* str.c */
-typedef struct {
+typedef struct Words {
char **words;
size_t len;
void *freeIt;
Index: src/usr.bin/make/suff.c
diff -u src/usr.bin/make/suff.c:1.160 src/usr.bin/make/suff.c:1.161
--- src/usr.bin/make/suff.c:1.160 Thu Sep 24 08:02:32 2020
+++ src/usr.bin/make/suff.c Fri Sep 25 15:54:51 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: suff.c,v 1.160 2020/09/24 08:02:32 rillig Exp $ */
+/* $NetBSD: suff.c,v 1.161 2020/09/25 15:54:51 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -126,7 +126,7 @@
#include "dir.h"
/* "@(#)suff.c 8.4 (Berkeley) 3/21/94" */
-MAKE_RCSID("$NetBSD: suff.c,v 1.160 2020/09/24 08:02:32 rillig Exp $");
+MAKE_RCSID("$NetBSD: suff.c,v 1.161 2020/09/25 15:54:51 rillig Exp $");
#define SUFF_DEBUG0(fmt) \
if (!DEBUG(SUFF)) (void) 0; else fprintf(debug_file, fmt)
@@ -203,12 +203,13 @@ typedef struct _Src {
* A structure for passing more than one argument to the Lst-library-invoked
* function...
*/
-typedef struct {
+typedef struct LstSrc {
SrcList *l;
Src *s;
} LstSrc;
-typedef struct {
+/* XXX: Name doesn't match content */
+typedef struct GNodeSuff {
GNode **gnp;
Suff *s;
Boolean r;
@@ -250,10 +251,10 @@ SuffStrIsPrefix(const char *pref, const
return *pref ? NULL : str;
}
-typedef struct {
+struct SuffSuffGetSuffixArgs {
char *ename; /* The end of the name */
int len; /* Length of the name */
-} SuffSuffGetSuffixArgs;
+};
/* See if suff is a suffix of str. str->ename should point to THE END
* of the string to check. (THE END == the null byte)
@@ -267,7 +268,7 @@ typedef struct {
* it is.
*/
static char *
-SuffSuffGetSuffix(const Suff *s, const SuffSuffGetSuffixArgs *str)
+SuffSuffGetSuffix(const Suff *s, const struct SuffSuffGetSuffixArgs *str)
{
char *p1; /* Pointer into suffix name */
char *p2; /* Pointer into string being examined */
@@ -668,7 +669,7 @@ SuffRebuildGraph(void *transformp, void
Suff *s = (Suff *)sp;
char *cp;
Suff *s2;
- SuffSuffGetSuffixArgs sd;
+ struct SuffSuffGetSuffixArgs sd;
/*
* First see if it is a transformation from this suffix.
@@ -1443,7 +1444,7 @@ Suff_FindPath(GNode* gn)
Suff *suff = gn->suffix;
if (suff == NULL) {
- SuffSuffGetSuffixArgs sd; /* Search string data */
+ struct SuffSuffGetSuffixArgs sd; /* Search string data */
SuffListNode *ln;
sd.len = strlen(gn->name);
sd.ename = gn->name + sd.len;
@@ -1649,7 +1650,7 @@ SuffFindArchiveDeps(GNode *gn, SrcList *
* through the entire list, we just look at suffixes to which the
* member's suffix may be transformed...
*/
- SuffSuffGetSuffixArgs sd; /* Search string data */
+ struct SuffSuffGetSuffixArgs sd; /* Search string data */
/*
* Use first matching suffix...
@@ -1715,7 +1716,7 @@ SuffFindNormalDeps(GNode *gn, SrcList *s
Src *src; /* General Src pointer */
char *pref; /* Prefix to use */
Src *targ; /* General Src target pointer */
- SuffSuffGetSuffixArgs sd; /* Search string data */
+ struct SuffSuffGetSuffixArgs sd; /* Search string data */
sd.len = strlen(gn->name);
Index: src/usr.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.540 src/usr.bin/make/var.c:1.541
--- src/usr.bin/make/var.c:1.540 Fri Sep 25 14:10:09 2020
+++ src/usr.bin/make/var.c Fri Sep 25 15:54:51 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: var.c,v 1.540 2020/09/25 14:10:09 rillig Exp $ */
+/* $NetBSD: var.c,v 1.541 2020/09/25 15:54:51 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.540 2020/09/25 14:10:09 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.541 2020/09/25 15:54:51 rillig Exp $");
#define VAR_DEBUG_IF(cond, fmt, ...) \
if (!(DEBUG(VAR) && (cond))) \
@@ -1004,7 +1004,7 @@ Var_Value(const char *name, GNode *ctxt,
/* SepBuf is a string being built from "words", interleaved with separators. */
-typedef struct {
+typedef struct SepBuf {
Buffer buf;
Boolean needSep;
char sep; /* usually ' ', but see the :ts modifier */
@@ -1191,17 +1191,17 @@ Str_SYSVMatch(const char *word, const ch
return w;
}
-typedef struct {
+struct ModifyWord_SYSVSubstArgs {
GNode *ctx;
const char *lhs;
const char *rhs;
-} ModifyWord_SYSVSubstArgs;
+};
/* Callback for ModifyWords to implement the :%.from=%.to modifier. */
static void
ModifyWord_SYSVSubst(const char *word, SepBuf *buf, void *data)
{
- const ModifyWord_SYSVSubstArgs *args = data;
+ const struct ModifyWord_SYSVSubstArgs *args = data;
char *rhs_expanded;
const char *rhs;
const char *percent;
@@ -1239,14 +1239,14 @@ ModifyWord_SYSVSubst(const char *word, S
#endif
-typedef struct {
+struct ModifyWord_SubstArgs {
const char *lhs;
size_t lhsLen;
const char *rhs;
size_t rhsLen;
VarPatternFlags pflags;
Boolean matched;
-} ModifyWord_SubstArgs;
+};
/* Callback for ModifyWords to implement the :S,from,to, modifier.
* Perform a string substitution on the given word. */
@@ -1254,7 +1254,7 @@ static void
ModifyWord_Subst(const char *word, SepBuf *buf, void *data)
{
size_t wordLen = strlen(word);
- ModifyWord_SubstArgs *args = data;
+ struct ModifyWord_SubstArgs *args = data;
const char *match;
if ((args->pflags & VARP_SUB_ONE) && args->matched)
@@ -1324,20 +1324,20 @@ VarREError(int reerr, regex_t *pat, cons
free(errbuf);
}
-typedef struct {
+struct ModifyWord_SubstRegexArgs {
regex_t re;
size_t nsub;
char *replace;
VarPatternFlags pflags;
Boolean matched;
-} ModifyWord_SubstRegexArgs;
+};
/* Callback for ModifyWords to implement the :C/from/to/ modifier.
* Perform a regex substitution on the given word. */
static void
ModifyWord_SubstRegex(const char *word, SepBuf *buf, void *data)
{
- ModifyWord_SubstRegexArgs *args = data;
+ struct ModifyWord_SubstRegexArgs *args = data;
int xrv;
const char *wp = word;
char *rp;
@@ -1413,18 +1413,18 @@ tryagain:
#endif
-typedef struct {
+struct ModifyWord_LoopArgs {
GNode *ctx;
char *tvar; /* name of temporary variable */
char *str; /* string to expand */
VarEvalFlags eflags;
-} ModifyWord_LoopArgs;
+};
/* Callback for ModifyWords to implement the :@var@...@ modifier of ODE make. */
static void
ModifyWord_Loop(const char *word, SepBuf *buf, void *data)
{
- const ModifyWord_LoopArgs *args;
+ const struct ModifyWord_LoopArgs *args;
char *s;
if (word[0] == '\0')
@@ -1784,7 +1784,7 @@ ENUM_FLAGS_RTTI_2(VarExprFlags,
VEF_UNDEF, VEF_DEF);
-typedef struct {
+typedef struct ApplyModifiersState {
const char startc; /* '\0' or '{' or '(' */
const char endc; /* '\0' or '}' or ')' */
Var * const v;
@@ -1843,7 +1843,8 @@ ParseModifierPart(
VarPatternFlags *out_pflags,/* For the first part of the :S modifier,
* sets the VARP_ANCHOR_END flag if the last
* character of the pattern is a $. */
- ModifyWord_SubstArgs *subst /* For the second part of the :S modifier,
+ struct ModifyWord_SubstArgs *subst
+ /* For the second part of the :S modifier,
* allow ampersands to be escaped and replace
* unescaped ampersands with subst->lhs. */
) {
@@ -1977,7 +1978,7 @@ ModMatchEq(const char *mod, const char *
static ApplyModifierResult
ApplyModifier_Loop(const char **pp, ApplyModifiersState *st)
{
- ModifyWord_LoopArgs args;
+ struct ModifyWord_LoopArgs args;
char prev_sep;
VarEvalFlags eflags = st->eflags & ~(unsigned)VARE_WANTRES;
VarParseResult res;
@@ -2302,7 +2303,7 @@ ApplyModifier_Match(const char **pp, App
static ApplyModifierResult
ApplyModifier_Subst(const char **pp, ApplyModifiersState *st)
{
- ModifyWord_SubstArgs args;
+ struct ModifyWord_SubstArgs args;
char *lhs, *rhs;
Boolean oneBigWord;
VarParseResult res;
@@ -2371,7 +2372,7 @@ static ApplyModifierResult
ApplyModifier_Regex(const char **pp, ApplyModifiersState *st)
{
char *re;
- ModifyWord_SubstRegexArgs args;
+ struct ModifyWord_SubstRegexArgs args;
Boolean oneBigWord;
int error;
VarParseResult res;
@@ -2964,7 +2965,7 @@ ApplyModifier_SysV(const char **pp, Appl
if (lhs[0] == '\0' && st->val[0] == '\0') {
st->newVal = st->val; /* special case */
} else {
- ModifyWord_SYSVSubstArgs args = {st->ctxt, lhs, rhs};
+ struct ModifyWord_SYSVSubstArgs args = {st->ctxt, lhs, rhs};
st->newVal = ModifyWords(st->ctxt, st->sep, st->oneBigWord, st->val,
ModifyWord_SYSVSubst, &args);
}