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: rename Var_Set to Var_SetExpand



details:   https://anonhg.NetBSD.org/src/rev/8adbf1489cc9
branches:  trunk
changeset: 951497:8adbf1489cc9
user:      rillig <rillig%NetBSD.org@localhost>
date:      Thu Feb 04 19:00:45 2021 +0000

description:
make: rename Var_Set to Var_SetExpand

After doing the textual renaming across all files, I added a new
function Var_Set that does not expand the variable name.  I then undid
the renaming for all calls where the variable name cannot ever contain a
dollar sign.  I omitted the word "Expand" from the textual references in
the unit tests and in the debug logging messages since the focus is
usually on the "Set" part, not on the "Expand".

No functional change.

diffstat:

 usr.bin/make/nonints.h |   3 ++-
 usr.bin/make/parse.c   |  12 ++++++------
 usr.bin/make/var.c     |  26 ++++++++++++++++++--------
 3 files changed, 26 insertions(+), 15 deletions(-)

diffs (165 lines):

diff -r b7c993869bf8 -r 8adbf1489cc9 usr.bin/make/nonints.h
--- a/usr.bin/make/nonints.h    Thu Feb 04 15:08:44 2021 +0000
+++ b/usr.bin/make/nonints.h    Thu Feb 04 19:00:45 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: nonints.h,v 1.196 2021/02/03 15:08:17 rillig Exp $     */
+/*     $NetBSD: nonints.h,v 1.197 2021/02/04 19:00:45 rillig Exp $     */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -374,6 +374,7 @@
 void Global_Set(const char *, const char *);
 void Global_SetExpand(const char *, const char *);
 void Var_Set(const char *, const char *, GNode *);
+void Var_SetExpand(const char *, const char *, GNode *);
 void Var_SetWithFlags(const char *, const char *, GNode *, VarSetFlags);
 void Var_Append(const char *, const char *, GNode *);
 void Var_AppendExpand(const char *, const char *, GNode *);
diff -r b7c993869bf8 -r 8adbf1489cc9 usr.bin/make/parse.c
--- a/usr.bin/make/parse.c      Thu Feb 04 15:08:44 2021 +0000
+++ b/usr.bin/make/parse.c      Thu Feb 04 19:00:45 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: parse.c,v 1.543 2021/02/03 14:33:09 rillig Exp $       */
+/*     $NetBSD: parse.c,v 1.544 2021/02/04 19:00:45 rillig Exp $       */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -109,7 +109,7 @@
 #include "pathnames.h"
 
 /*     "@(#)parse.c    8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: parse.c,v 1.543 2021/02/03 14:33:09 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.544 2021/02/04 19:00:45 rillig Exp $");
 
 /* types and constants */
 
@@ -1898,13 +1898,13 @@
         *  apart from making the debug log longer.
         */
        if (!Var_ExistsExpand(name, ctxt))
-               Var_Set(name, "", ctxt);
+               Var_SetExpand(name, "", ctxt);
 
        (void)Var_Subst(uvalue, ctxt,
            VARE_WANTRES | VARE_KEEP_DOLLAR | VARE_KEEP_UNDEF, &evalue);
        /* TODO: handle errors */
 
-       Var_Set(name, evalue, ctxt);
+       Var_SetExpand(name, evalue, ctxt);
 
        *out_avalue = FStr_InitOwn(evalue);
 }
@@ -1927,7 +1927,7 @@
        }
 
        cmdOut = Cmd_Exec(cmd.str, &errfmt);
-       Var_Set(name, cmdOut, ctxt);
+       Var_SetExpand(name, cmdOut, ctxt);
        *out_avalue = FStr_InitOwn(cmdOut);
 
        if (errfmt != NULL)
@@ -1964,7 +1964,7 @@
                        return FALSE;
 
                /* Normal assignment -- just do it. */
-               Var_Set(name, uvalue, ctxt);
+               Var_SetExpand(name, uvalue, ctxt);
        }
 
        *out_TRUE_avalue = avalue;
diff -r b7c993869bf8 -r 8adbf1489cc9 usr.bin/make/var.c
--- a/usr.bin/make/var.c        Thu Feb 04 15:08:44 2021 +0000
+++ b/usr.bin/make/var.c        Thu Feb 04 19:00:45 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: var.c,v 1.797 2021/02/03 15:08:17 rillig Exp $ */
+/*     $NetBSD: var.c,v 1.798 2021/02/04 19:00:45 rillig Exp $ */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -80,7 +80,9 @@
  *
  *     Var_End         Clean up the module.
  *
- *     Var_Set         Set the value of the variable, creating it if
+ *     Var_Set
+ *     Var_SetExpand
+ *                     Set the value of the variable, creating it if
  *                     necessary.
  *
  *     Var_Append
@@ -137,7 +139,7 @@
 #include "metachar.h"
 
 /*     "@(#)var.c      8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.797 2021/02/03 15:08:17 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.798 2021/02/04 19:00:45 rillig Exp $");
 
 typedef enum VarFlags {
        VAR_NONE        = 0,
@@ -1026,6 +1028,12 @@
        FStr_Done(&varname);
 }
 
+void
+Var_Set(const char *name, const char *val, GNode *ctxt)
+{
+       SetVar(name, val, ctxt, VAR_SET_NONE);
+}
+
 /*
  * Set the variable name to the value val in the given context.
  *
@@ -1038,7 +1046,7 @@
  *     ctxt            context in which to set it
  */
 void
-Var_Set(const char *name, const char *val, GNode *ctxt)
+Var_SetExpand(const char *name, const char *val, GNode *ctxt)
 {
        Var_SetWithFlags(name, val, ctxt, VAR_SET_NONE);
 }
@@ -1052,7 +1060,7 @@
 void
 Global_SetExpand(const char *name, const char *value)
 {
-       Var_Set(name, value, VAR_GLOBAL);
+       Var_SetExpand(name, value, VAR_GLOBAL);
 }
 
 /*
@@ -3282,6 +3290,7 @@
 
        (*pp)--;
 
+       /* XXX: Expanding the variable name at this point sounds wrong. */
        if (st->eflags & VARE_WANTRES) {
                switch (op[0]) {
                case '+':
@@ -3293,7 +3302,8 @@
                        if (errfmt != NULL)
                                Error(errfmt, val);
                        else
-                               Var_Set(st->var->name.str, cmd_output, ctxt);
+                               Var_SetExpand(st->var->name.str, cmd_output,
+                                   ctxt);
                        free(cmd_output);
                        break;
                }
@@ -3302,7 +3312,7 @@
                                break;
                        /* FALLTHROUGH */
                default:
-                       Var_Set(st->var->name.str, val, ctxt);
+                       Var_SetExpand(st->var->name.str, val, ctxt);
                        break;
                }
        }
@@ -3326,7 +3336,7 @@
        if (mod[1] == '=') {
                size_t n = strcspn(mod + 2, ":)}");
                char *name = bmake_strldup(mod + 2, n);
-               Var_Set(name, val, st->ctxt);
+               Var_SetExpand(name, val, st->ctxt);
                free(name);
                *pp = mod + 2 + n;
        } else {



Home | Main Index | Thread Index | Old Index