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 GNode.context to vars



details:   https://anonhg.NetBSD.org/src/rev/a7c0d0bfa994
branches:  trunk
changeset: 946235:a7c0d0bfa994
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Nov 21 18:41:57 2020 +0000

description:
make(1): rename GNode.context to vars

Especially in the variables module, the expression 'ctxt->context' looked
redundant.  Having a GNode as a context sounds ok, but a context of a
context just doesn't make sense.

diffstat:

 usr.bin/make/make.h |   4 ++--
 usr.bin/make/targ.c |   8 ++++----
 usr.bin/make/var.c  |  22 +++++++++++-----------
 3 files changed, 17 insertions(+), 17 deletions(-)

diffs (153 lines):

diff -r 8ca43f77fdd0 -r a7c0d0bfa994 usr.bin/make/make.h
--- a/usr.bin/make/make.h       Sat Nov 21 18:28:34 2020 +0000
+++ b/usr.bin/make/make.h       Sat Nov 21 18:41:57 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: make.h,v 1.210 2020/11/16 21:53:10 rillig Exp $        */
+/*     $NetBSD: make.h,v 1.211 2020/11/21 18:41:57 rillig Exp $        */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -371,7 +371,7 @@
      *
      * Also used for the global variable scopes VAR_GLOBAL, VAR_CMDLINE,
      * VAR_INTERNAL, which contain variables with arbitrary names. */
-    HashTable /* of Var pointer */ context;
+    HashTable /* of Var pointer */ vars;
 
     /* The commands to be given to a shell to create this target. */
     StringList *commands;
diff -r 8ca43f77fdd0 -r a7c0d0bfa994 usr.bin/make/targ.c
--- a/usr.bin/make/targ.c       Sat Nov 21 18:28:34 2020 +0000
+++ b/usr.bin/make/targ.c       Sat Nov 21 18:41:57 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: targ.c,v 1.138 2020/11/21 11:59:22 rillig Exp $        */
+/*     $NetBSD: targ.c,v 1.139 2020/11/21 18:41:57 rillig Exp $        */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -119,7 +119,7 @@
 #include "dir.h"
 
 /*     "@(#)targ.c     8.2 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: targ.c,v 1.138 2020/11/21 11:59:22 rillig Exp $");
+MAKE_RCSID("$NetBSD: targ.c,v 1.139 2020/11/21 18:41:57 rillig Exp $");
 
 /*
  * All target nodes that appeared on the left-hand side of one of the
@@ -211,7 +211,7 @@
     gn->unmade_cohorts = 0;
     gn->centurion = NULL;
     gn->checked_seqno = 0;
-    HashTable_Init(&gn->context);
+    HashTable_Init(&gn->vars);
     gn->commands = Lst_New();
     gn->suffix = NULL;
     gn->fname = NULL;
@@ -240,7 +240,7 @@
     Lst_Free(gn->order_pred);  /* likewise */
     Lst_Free(gn->order_succ);  /* likewise */
     Lst_Free(gn->cohorts);     /* likewise */
-    HashTable_Done(&gn->context); /* Do not free the variables themselves,
+    HashTable_Done(&gn->vars); /* Do not free the variables themselves,
                                 * even though they are owned by this node.
                                 * XXX: they should probably be freed. */
     Lst_Free(gn->commands);    /* Do not free the commands themselves,
diff -r 8ca43f77fdd0 -r a7c0d0bfa994 usr.bin/make/var.c
--- a/usr.bin/make/var.c        Sat Nov 21 18:28:34 2020 +0000
+++ b/usr.bin/make/var.c        Sat Nov 21 18:41:57 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: var.c,v 1.692 2020/11/21 15:32:52 rillig Exp $ */
+/*     $NetBSD: var.c,v 1.693 2020/11/21 18:41:57 rillig Exp $ */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -130,7 +130,7 @@
 #include "metachar.h"
 
 /*     "@(#)var.c      8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.692 2020/11/21 15:32:52 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.693 2020/11/21 18:41:57 rillig Exp $");
 
 #define VAR_DEBUG1(fmt, arg1) DEBUG1(VAR, fmt, arg1)
 #define VAR_DEBUG2(fmt, arg1, arg2) DEBUG2(VAR, fmt, arg1, arg2)
@@ -342,7 +342,7 @@
 static Var *
 GNode_FindVar(GNode *ctxt, const char *varname, unsigned int hash)
 {
-    return HashTable_FindValueHash(&ctxt->context, varname, hash);
+    return HashTable_FindValueHash(&ctxt->vars, varname, hash);
 }
 
 /* Find the variable in the context, and maybe in other contexts as well.
@@ -437,7 +437,7 @@
 static void
 VarAdd(const char *name, const char *val, GNode *ctxt, VarSetFlags flags)
 {
-    HashEntry *he = HashTable_CreateEntry(&ctxt->context, name, NULL);
+    HashEntry *he = HashTable_CreateEntry(&ctxt->vars, name, NULL);
     Var *v = VarNew(he->key /* aliased */, NULL, val,
                    flags & VAR_SET_READONLY ? VAR_READONLY : 0);
     HashEntry_Set(he, v);
@@ -459,7 +459,7 @@
        /* TODO: handle errors */
        name = name_freeIt;
     }
-    he = HashTable_FindEntry(&ctxt->context, name);
+    he = HashTable_FindEntry(&ctxt->vars, name);
     VAR_DEBUG3("%s:delete %s%s\n",
               ctxt->name, name, he != NULL ? "" : " (not found)");
     free(name_freeIt);
@@ -471,7 +471,7 @@
        if (strcmp(v->name, MAKE_EXPORTED) == 0)
            var_exportedVars = VAR_EXPORTED_NONE;
        assert(v->name_freeIt == NULL);
-       HashTable_DeleteEntry(&ctxt->context, he);
+       HashTable_DeleteEntry(&ctxt->vars, he);
        Buf_Destroy(&v->val, TRUE);
        free(v);
     }
@@ -595,7 +595,7 @@
        HashIter hi;
 
        /* Ouch! Exporting all variables at once is crazy... */
-       HashIter_Init(&hi, &VAR_GLOBAL->context);
+       HashIter_Init(&hi, &VAR_GLOBAL->vars);
        while (HashIter_Next(&hi) != NULL) {
            Var *var = hi.entry->value;
            Var_Export1(var->name, VAR_EXPORT_NORMAL);
@@ -962,7 +962,7 @@
            v->flags &= ~(unsigned)VAR_FROM_ENV;
            /* This is the only place where a variable is created whose
             * v->name is not the same as ctxt->context->key. */
-           HashTable_Set(&ctxt->context, name, v);
+           HashTable_Set(&ctxt->vars, name, v);
        }
     }
     free(name_freeIt);
@@ -4084,7 +4084,7 @@
 void
 Var_Stats(void)
 {
-    HashTable_DebugStats(&VAR_GLOBAL->context, "VAR_GLOBAL");
+    HashTable_DebugStats(&VAR_GLOBAL->vars, "VAR_GLOBAL");
 }
 
 /* Print all variables in a context, sorted by name. */
@@ -4098,7 +4098,7 @@
 
     Vector_Init(&vec, sizeof(const char *));
 
-    HashIter_Init(&hi, &ctxt->context);
+    HashIter_Init(&hi, &ctxt->vars);
     while (HashIter_Next(&hi) != NULL)
        *(const char **)Vector_Push(&vec) = hi.entry->key;
     varnames = vec.items;
@@ -4107,7 +4107,7 @@
 
     for (i = 0; i < vec.len; i++) {
        const char *varname = varnames[i];
-       Var *var = HashTable_FindValue(&ctxt->context, varname);
+       Var *var = HashTable_FindValue(&ctxt->vars, varname);
        debug_printf("%-16s = %s\n", varname, Buf_GetAll(&var->val, NULL));
     }
 



Home | Main Index | Thread Index | Old Index