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): use fine-grained type names for lists ...



details:   https://anonhg.NetBSD.org/src/rev/cabef8d12c5a
branches:  trunk
changeset: 955158:cabef8d12c5a
user:      rillig <rillig%NetBSD.org@localhost>
date:      Tue Sep 22 04:05:41 2020 +0000

description:
make(1): use fine-grained type names for lists and their nodes

This is only intended to help the human reader.  There is no additional
type safety yet.

diffstat:

 usr.bin/make/arch.c    |   19 ++--
 usr.bin/make/compat.c  |    6 +-
 usr.bin/make/dir.c     |   62 ++++++++-------
 usr.bin/make/dir.h     |   16 ++--
 usr.bin/make/lst.c     |  128 ++++++++++++++++----------------
 usr.bin/make/lst.h     |   64 ++++++++--------
 usr.bin/make/main.c    |   26 +++---
 usr.bin/make/make.c    |   39 ++++-----
 usr.bin/make/make.h    |   19 ++--
 usr.bin/make/meta.c    |    8 +-
 usr.bin/make/nonints.h |   20 ++--
 usr.bin/make/parse.c   |   37 ++++----
 usr.bin/make/suff.c    |  192 +++++++++++++++++++++++++-----------------------
 usr.bin/make/targ.c    |   39 ++++-----
 usr.bin/make/var.c     |    6 +-
 15 files changed, 345 insertions(+), 336 deletions(-)

diffs (truncated from 2022 to 300 lines):

diff -r 4672c6caa07c -r cabef8d12c5a usr.bin/make/arch.c
--- a/usr.bin/make/arch.c       Tue Sep 22 02:53:52 2020 +0000
+++ b/usr.bin/make/arch.c       Tue Sep 22 04:05:41 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: arch.c,v 1.116 2020/09/21 03:12:25 rillig Exp $        */
+/*     $NetBSD: arch.c,v 1.117 2020/09/22 04:05:41 rillig Exp $        */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -133,7 +133,7 @@
 #include    "config.h"
 
 /*     "@(#)arch.c     8.2 (Berkeley) 1/2/94"  */
-MAKE_RCSID("$NetBSD: arch.c,v 1.116 2020/09/21 03:12:25 rillig Exp $");
+MAKE_RCSID("$NetBSD: arch.c,v 1.117 2020/09/22 04:05:41 rillig Exp $");
 
 #ifdef TARGET_MACHINE
 #undef MAKE_MACHINE
@@ -144,7 +144,10 @@
 #define MAKE_MACHINE_ARCH TARGET_MACHINE_ARCH
 #endif
 
-static Lst       archives;   /* Lst of archives we've already examined */
+typedef struct List ArchList;
+typedef struct ListNode ArchListNode;
+
+static ArchList *archives;     /* The archives we've already examined */
 
 typedef struct Arch {
     char         *name;      /* Name of archive */
@@ -203,7 +206,7 @@
  *-----------------------------------------------------------------------
  */
 Boolean
-Arch_ParseArchive(char **linePtr, Lst nodeLst, GNode *ctxt)
+Arch_ParseArchive(char **linePtr, GNodeList *nodeLst, GNode *ctxt)
 {
     char           *cp;            /* Pointer into line */
     GNode          *gn;            /* New node */
@@ -361,7 +364,7 @@
             */
            free(buf);
        } else if (Dir_HasWildcards(memName)) {
-           Lst members = Lst_Init();
+           StringList *members = Lst_Init();
            Dir_Expand(memName, dirSearchPath, members);
 
            while (!Lst_IsEmpty(members)) {
@@ -466,7 +469,7 @@
     FILE *       arch;       /* Stream to archive */
     size_t       size;       /* Size of archive member */
     char         magic[SARMAG];
-    LstNode      ln;         /* Lst member containing archive descriptor */
+    ArchListNode *ln;
     Arch         *ar;        /* Archive descriptor */
     Hash_Entry   *he;        /* Entry containing member's description */
     struct ar_hdr arh;        /* archive-member header for reading archive */
@@ -1019,7 +1022,7 @@
 time_t
 Arch_MemMTime(GNode *gn)
 {
-    LstNode      ln;
+    GNodeListNode *ln;
     GNode        *pgn;
 
     Lst_Open(gn->parents);
@@ -1073,7 +1076,7 @@
  *     path            Search path
  */
 void
-Arch_FindLib(GNode *gn, Lst path)
+Arch_FindLib(GNode *gn, SearchPath *path)
 {
     char           *libName;   /* file name for archive */
     size_t          sz = strlen(gn->name) + 6 - 2;
diff -r 4672c6caa07c -r cabef8d12c5a usr.bin/make/compat.c
--- a/usr.bin/make/compat.c     Tue Sep 22 02:53:52 2020 +0000
+++ b/usr.bin/make/compat.c     Tue Sep 22 04:05:41 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: compat.c,v 1.146 2020/09/21 17:44:25 rillig Exp $      */
+/*     $NetBSD: compat.c,v 1.147 2020/09/22 04:05:41 rillig Exp $      */
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -99,7 +99,7 @@
 #include    "pathnames.h"
 
 /*     "@(#)compat.c   8.2 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: compat.c,v 1.146 2020/09/21 17:44:25 rillig Exp $");
+MAKE_RCSID("$NetBSD: compat.c,v 1.147 2020/09/22 04:05:41 rillig Exp $");
 
 static GNode       *curTarg = NULL;
 static GNode       *ENDNode;
@@ -660,7 +660,7 @@
  *     targs           The target nodes to re-create
  */
 void
-Compat_Run(Lst targs)
+Compat_Run(GNodeList *targs)
 {
     GNode        *gn = NULL;/* Current root target */
     int                  errors;   /* Number of targets not remade due to errors */
diff -r 4672c6caa07c -r cabef8d12c5a usr.bin/make/dir.c
--- a/usr.bin/make/dir.c        Tue Sep 22 02:53:52 2020 +0000
+++ b/usr.bin/make/dir.c        Tue Sep 22 04:05:41 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: dir.c,v 1.143 2020/09/22 02:26:22 rillig Exp $ */
+/*     $NetBSD: dir.c,v 1.144 2020/09/22 04:05:41 rillig Exp $ */
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -134,7 +134,7 @@
 #include "job.h"
 
 /*     "@(#)dir.c      8.2 (Berkeley) 1/2/94"  */
-MAKE_RCSID("$NetBSD: dir.c,v 1.143 2020/09/22 02:26:22 rillig Exp $");
+MAKE_RCSID("$NetBSD: dir.c,v 1.144 2020/09/22 04:05:41 rillig Exp $");
 
 #define DIR_DEBUG0(fmt) \
     if (!DEBUG(DIR)) (void) 0; else fprintf(debug_file, fmt)
@@ -216,9 +216,14 @@
  *     in a cache for when Dir_MTime was actually called.
  */
 
-Lst dirSearchPath;             /* main search path */
+typedef List CachedDirList;
+typedef ListNode CachedDirListNode;
 
-static Lst openDirectories;    /* the list of all open directories */
+typedef ListNode SearchPathNode;
+
+SearchPath *dirSearchPath;             /* main search path */
+
+static CachedDirList *openDirectories; /* the list of all open directories */
 
 /*
  * Variables for gathering statistics on the efficiency of the hashing
@@ -245,7 +250,7 @@
 
 static Hash_Table lmtimes;     /* same as mtimes but for lstat */
 
-static void DirExpandInt(const char *, Lst, Lst);
+static void DirExpandInt(const char *, SearchPath *, StringList *);
 static int DirPrintWord(void *, void *);
 static int DirPrintDir(void *, void *);
 static char *DirLookup(CachedDir *, const char *, const char *, Boolean);
@@ -395,7 +400,7 @@
 Dir_InitDot(void)
 {
     if (dot != NULL) {
-       LstNode ln;
+       CachedDirListNode *ln;
 
        /* Remove old entry from openDirectories, but do not destroy. */
        ln = Lst_FindDatum(openDirectories, dot);
@@ -446,7 +451,7 @@
 void
 Dir_SetPATH(void)
 {
-    LstNode ln;                        /* a list element */
+    CachedDirListNode *ln;
     Boolean hasLastDot = FALSE;        /* true if we should search dot last */
 
     Var_Delete(".PATH", VAR_GLOBAL);
@@ -562,7 +567,7 @@
  *-----------------------------------------------------------------------
  */
 static void
-DirMatchFiles(const char *pattern, CachedDir *dir, Lst expansions)
+DirMatchFiles(const char *pattern, CachedDir *dir, StringList *expansions)
 {
     Hash_Search search;                /* Index into the directory's table */
     Hash_Entry *entry;         /* Current entry in the table */
@@ -678,7 +683,8 @@
  *-----------------------------------------------------------------------
  */
 static void
-DirExpandCurly(const char *word, const char *brace, Lst path, Lst expansions)
+DirExpandCurly(const char *word, const char *brace, SearchPath *path,
+              StringList *expansions)
 {
     const char *prefix, *middle, *piece, *middle_end, *suffix;
     size_t prefix_len, suffix_len;
@@ -740,9 +746,9 @@
  *-----------------------------------------------------------------------
  */
 static void
-DirExpandInt(const char *word, Lst path, Lst expansions)
+DirExpandInt(const char *word, SearchPath *path, StringList *expansions)
 {
-    LstNode ln;                        /* Current node */
+    SearchPathNode *ln;
 
     Lst_Open(path);
     while ((ln = Lst_Next(path)) != NULL) {
@@ -784,7 +790,7 @@
  *-----------------------------------------------------------------------
  */
 void
-Dir_Expand(const char *word, Lst path, Lst expansions)
+Dir_Expand(const char *word, SearchPath *path, StringList *expansions)
 {
     const char *cp;
 
@@ -1053,13 +1059,13 @@
  *-----------------------------------------------------------------------
  */
 char *
-Dir_FindFile(const char *name, Lst path)
+Dir_FindFile(const char *name, SearchPath *path)
 {
-    LstNode ln;                        /* a list element */
+    SearchPathNode *ln;
     char *file;                        /* the current filename to check */
-    CachedDir *dir;            /* current path member */
+    CachedDir *dir;
     const char *base;          /* Terminal name of file */
-    Boolean hasLastDot = FALSE;        /* true we should search dot last */
+    Boolean hasLastDot = FALSE;        /* true if we should search dot last */
     Boolean hasSlash;          /* true if 'name' contains a / */
     struct make_stat mst;      /* Buffer for stat, if necessary */
     const char *trailing_dot = ".";
@@ -1501,12 +1507,12 @@
  *-----------------------------------------------------------------------
  */
 CachedDir *
-Dir_AddDir(Lst path, const char *name)
+Dir_AddDir(SearchPath *path, const char *name)
 {
-    LstNode ln = NULL;         /* node in case CachedDir structure is found */
+    SearchPathNode *ln = NULL;
     CachedDir *dir = NULL;     /* the added directory */
-    DIR *d;                    /* for reading directory */
-    struct dirent *dp;         /* entry in directory */
+    DIR *d;
+    struct dirent *dp;
 
     if (path != NULL && strcmp(name, ".DOTLAST") == 0) {
        ln = Lst_Find(path, DirFindName, name);
@@ -1600,10 +1606,10 @@
  *-----------------------------------------------------------------------
  */
 char *
-Dir_MakeFlags(const char *flag, Lst path)
+Dir_MakeFlags(const char *flag, SearchPath *path)
 {
     Buffer buf;
-    LstNode ln;                        /* the node of the current directory */
+    SearchPathNode *ln;
 
     Buf_Init(&buf, 0);
 
@@ -1646,7 +1652,7 @@
     dir->refCount -= 1;
 
     if (dir->refCount == 0) {
-       LstNode node;
+       CachedDirListNode *node;
 
        node = Lst_FindDatum(openDirectories, dir);
        if (node != NULL)
@@ -1676,7 +1682,7 @@
  *-----------------------------------------------------------------------
  */
 void
-Dir_ClearPath(Lst path)
+Dir_ClearPath(SearchPath *path)
 {
     while (!Lst_IsEmpty(path)) {
        CachedDir *dir = Lst_Dequeue(path);
@@ -1704,9 +1710,9 @@
  *-----------------------------------------------------------------------
  */
 void
-Dir_Concat(Lst path1, Lst path2)
+Dir_Concat(SearchPath *path1, SearchPath *path2)
 {
-    LstNode ln;
+    SearchPathNode *ln;
     CachedDir *dir;
 
     for (ln = Lst_First(path2); ln != NULL; ln = LstNode_Next(ln)) {
@@ -1728,7 +1734,7 @@
 void
 Dir_PrintDirectories(void)
 {
-    LstNode ln;
+    CachedDirListNode *ln;
 
     fprintf(debug_file, "#*** Directory Cache:\n");
     fprintf(debug_file,
@@ -1755,7 +1761,7 @@
 }
 
 void
-Dir_PrintPath(Lst path)
+Dir_PrintPath(SearchPath *path)
 {
     Lst_ForEach(path, DirPrintDir, NULL);
 }



Home | Main Index | Thread Index | Old Index