Module Name:    src
Committed By:   rillig
Date:           Thu Feb  4 19:00:45 UTC 2021

Modified Files:
        src/usr.bin/make: nonints.h parse.c var.c

Log Message:
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.


To generate a diff of this commit:
cvs rdiff -u -r1.196 -r1.197 src/usr.bin/make/nonints.h
cvs rdiff -u -r1.543 -r1.544 src/usr.bin/make/parse.c
cvs rdiff -u -r1.797 -r1.798 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/nonints.h
diff -u src/usr.bin/make/nonints.h:1.196 src/usr.bin/make/nonints.h:1.197
--- src/usr.bin/make/nonints.h:1.196	Wed Feb  3 15:08:17 2021
+++ src/usr.bin/make/nonints.h	Thu Feb  4 19:00:45 2021
@@ -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 Var_Undef(const char *);
 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 *);

Index: src/usr.bin/make/parse.c
diff -u src/usr.bin/make/parse.c:1.543 src/usr.bin/make/parse.c:1.544
--- src/usr.bin/make/parse.c:1.543	Wed Feb  3 14:33:09 2021
+++ src/usr.bin/make/parse.c	Thu Feb  4 19:00:45 2021
@@ -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 @@ VarAssign_EvalSubst(const char *name, co
 	 *  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 @@ VarAssign_EvalShell(const char *name, co
 	}
 
 	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 @@ VarAssign_Eval(const char *name, VarAssi
 			return FALSE;
 
 		/* Normal assignment -- just do it. */
-		Var_Set(name, uvalue, ctxt);
+		Var_SetExpand(name, uvalue, ctxt);
 	}
 
 	*out_TRUE_avalue = avalue;

Index: src/usr.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.797 src/usr.bin/make/var.c:1.798
--- src/usr.bin/make/var.c:1.797	Wed Feb  3 15:08:17 2021
+++ src/usr.bin/make/var.c	Thu Feb  4 19:00:45 2021
@@ -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 @@ Var_SetWithFlags(const char *name, const
 	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 @@ Var_SetWithFlags(const char *name, const
  *	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 @@ Global_Set(const char *name, const char 
 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 @@ ok:
 
 	(*pp)--;
 
+	/* XXX: Expanding the variable name at this point sounds wrong. */
 	if (st->eflags & VARE_WANTRES) {
 		switch (op[0]) {
 		case '+':
@@ -3293,7 +3302,8 @@ ok:
 			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 @@ ok:
 				break;
 			/* FALLTHROUGH */
 		default:
-			Var_Set(st->var->name.str, val, ctxt);
+			Var_SetExpand(st->var->name.str, val, ctxt);
 			break;
 		}
 	}
@@ -3326,7 +3336,7 @@ ApplyModifier_Remember(const char **pp, 
 	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 {

Reply via email to