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): add tags to some of the unnamed structs



details:   https://anonhg.NetBSD.org/src/rev/8442e81016b2
branches:  trunk
changeset: 976488:8442e81016b2
user:      rillig <rillig%NetBSD.org@localhost>
date:      Fri Sep 25 15:54:50 2020 +0000

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

diffstat:

 usr.bin/make/cond.c    |   6 +++---
 usr.bin/make/enum.h    |   4 ++--
 usr.bin/make/for.c     |   6 +++---
 usr.bin/make/lst.h     |   4 ++--
 usr.bin/make/nonints.h |   4 ++--
 usr.bin/make/suff.c    |  23 ++++++++++++-----------
 usr.bin/make/var.c     |  43 ++++++++++++++++++++++---------------------
 7 files changed, 46 insertions(+), 44 deletions(-)

diffs (truncated from 375 to 300 lines):

diff -r 533127930c29 -r 8442e81016b2 usr.bin/make/cond.c
--- a/usr.bin/make/cond.c       Fri Sep 25 15:40:06 2020 +0000
+++ b/usr.bin/make/cond.c       Fri Sep 25 15:54:50 2020 +0000
@@ -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 @@
     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 */
diff -r 533127930c29 -r 8442e81016b2 usr.bin/make/enum.h
--- a/usr.bin/make/enum.h       Fri Sep 25 15:40:06 2020 +0000
+++ b/usr.bin/make/enum.h       Fri Sep 25 15:54:50 2020 +0000
@@ -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 <rillig%NetBSD.org@localhost>
@@ -34,7 +34,7 @@
 
 #include <stddef.h>
 
-typedef struct {
+typedef struct EnumToStringSpec {
        int es_value;
        const char *es_name;
 } EnumToStringSpec;
diff -r 533127930c29 -r 8442e81016b2 usr.bin/make/for.c
--- a/usr.bin/make/for.c        Fri Sep 25 15:40:06 2020 +0000
+++ b/usr.bin/make/for.c        Fri Sep 25 15:54:50 2020 +0000
@@ -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 @@
 /*
  * 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 */
diff -r 533127930c29 -r 8442e81016b2 usr.bin/make/lst.h
--- a/usr.bin/make/lst.h        Fri Sep 25 15:40:06 2020 +0000
+++ b/usr.bin/make/lst.h        Fri Sep 25 15:54:50 2020 +0000
@@ -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 @@
 
 /* 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;
diff -r 533127930c29 -r 8442e81016b2 usr.bin/make/nonints.h
--- a/usr.bin/make/nonints.h    Fri Sep 25 15:40:06 2020 +0000
+++ b/usr.bin/make/nonints.h    Fri Sep 25 15:54:50 2020 +0000
@@ -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 @@
 GNodeList *Parse_MainName(void);
 
 /* str.c */
-typedef struct {
+typedef struct Words {
     char **words;
     size_t len;
     void *freeIt;
diff -r 533127930c29 -r 8442e81016b2 usr.bin/make/suff.c
--- a/usr.bin/make/suff.c       Fri Sep 25 15:40:06 2020 +0000
+++ b/usr.bin/make/suff.c       Fri Sep 25 15:54:50 2020 +0000
@@ -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 @@
  * 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 @@
     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 @@
  *     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 @@
     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 *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 @@
         * 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 @@
     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);
diff -r 533127930c29 -r 8442e81016b2 usr.bin/make/var.c
--- a/usr.bin/make/var.c        Fri Sep 25 15:40:06 2020 +0000
+++ b/usr.bin/make/var.c        Fri Sep 25 15:54:50 2020 +0000
@@ -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 @@
 
 
 /* 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 @@
     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 @@
 #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 @@
 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 @@
     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 @@
 #endif



Home | Main Index | Thread Index | Old Index