Module Name:    src
Committed By:   rillig
Date:           Fri Feb  5 05:15:13 UTC 2021

Modified Files:
        src/usr.bin/make: arch.c compat.c cond.c job.c main.c make.c meta.c
            nonints.h parse.c suff.c trace.c var.c

Log Message:
make: in the Var_ functions, move the scope to the front

This change provides for a more natural reading order in the code.
Placing the scope first makes it immediately clear in which context the
remaining parameters are interpreted.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.196 -r1.197 src/usr.bin/make/arch.c
cvs rdiff -u -r1.223 -r1.224 src/usr.bin/make/compat.c
cvs rdiff -u -r1.255 -r1.256 src/usr.bin/make/cond.c
cvs rdiff -u -r1.416 -r1.417 src/usr.bin/make/job.c
cvs rdiff -u -r1.531 -r1.532 src/usr.bin/make/main.c
cvs rdiff -u -r1.241 -r1.242 src/usr.bin/make/make.c
cvs rdiff -u -r1.175 -r1.176 src/usr.bin/make/meta.c
cvs rdiff -u -r1.201 -r1.202 src/usr.bin/make/nonints.h
cvs rdiff -u -r1.547 -r1.548 src/usr.bin/make/parse.c
cvs rdiff -u -r1.344 -r1.345 src/usr.bin/make/suff.c
cvs rdiff -u -r1.27 -r1.28 src/usr.bin/make/trace.c
cvs rdiff -u -r1.804 -r1.805 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/arch.c
diff -u src/usr.bin/make/arch.c:1.196 src/usr.bin/make/arch.c:1.197
--- src/usr.bin/make/arch.c:1.196	Thu Feb  4 21:42:46 2021
+++ src/usr.bin/make/arch.c	Fri Feb  5 05:15:12 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: arch.c,v 1.196 2021/02/04 21:42:46 rillig Exp $	*/
+/*	$NetBSD: arch.c,v 1.197 2021/02/05 05:15:12 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -126,7 +126,7 @@
 #include "config.h"
 
 /*	"@(#)arch.c	8.2 (Berkeley) 1/2/94"	*/
-MAKE_RCSID("$NetBSD: arch.c,v 1.196 2021/02/04 21:42:46 rillig Exp $");
+MAKE_RCSID("$NetBSD: arch.c,v 1.197 2021/02/05 05:15:12 rillig Exp $");
 
 typedef struct List ArchList;
 typedef struct ListNode ArchListNode;
@@ -973,9 +973,9 @@ Arch_FindLib(GNode *gn, SearchPath *path
 	free(libName);
 
 #ifdef LIBRARIES
-	Var_Set(TARGET, gn->name, gn);
+	Var_Set(gn, TARGET, gn->name);
 #else
-	Var_Set(TARGET, GNode_Path(gn), gn);
+	Var_Set(gn, TARGET, GNode_Path(gn));
 #endif
 }
 

Index: src/usr.bin/make/compat.c
diff -u src/usr.bin/make/compat.c:1.223 src/usr.bin/make/compat.c:1.224
--- src/usr.bin/make/compat.c:1.223	Thu Feb  4 21:42:46 2021
+++ src/usr.bin/make/compat.c	Fri Feb  5 05:15:12 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: compat.c,v 1.223 2021/02/04 21:42:46 rillig Exp $	*/
+/*	$NetBSD: compat.c,v 1.224 2021/02/05 05:15:12 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -96,7 +96,7 @@
 #include "pathnames.h"
 
 /*	"@(#)compat.c	8.2 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: compat.c,v 1.223 2021/02/04 21:42:46 rillig Exp $");
+MAKE_RCSID("$NetBSD: compat.c,v 1.224 2021/02/05 05:15:12 rillig Exp $");
 
 static GNode *curTarg = NULL;
 static pid_t compatChild;
@@ -509,7 +509,7 @@ MakeUnmade(GNode *gn, GNode *pgn)
 	}
 
 	if (Lst_FindDatum(&gn->implicitParents, pgn) != NULL)
-		Var_Set(IMPSRC, GNode_VarTarget(gn), pgn);
+		Var_Set(pgn, IMPSRC, GNode_VarTarget(gn));
 
 	/*
 	 * All the children were made ok. Now youngestChild->mtime contains the
@@ -602,7 +602,7 @@ MakeOther(GNode *gn, GNode *pgn)
 
 	if (Lst_FindDatum(&gn->implicitParents, pgn) != NULL) {
 		const char *target = GNode_VarTarget(gn);
-		Var_Set(IMPSRC, target != NULL ? target : "", pgn);
+		Var_Set(pgn, IMPSRC, target != NULL ? target : "");
 	}
 
 	switch (gn->made) {

Index: src/usr.bin/make/cond.c
diff -u src/usr.bin/make/cond.c:1.255 src/usr.bin/make/cond.c:1.256
--- src/usr.bin/make/cond.c:1.255	Thu Feb  4 21:33:13 2021
+++ src/usr.bin/make/cond.c	Fri Feb  5 05:15:12 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: cond.c,v 1.255 2021/02/04 21:33:13 rillig Exp $	*/
+/*	$NetBSD: cond.c,v 1.256 2021/02/05 05:15:12 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -95,7 +95,7 @@
 #include "dir.h"
 
 /*	"@(#)cond.c	8.2 (Berkeley) 1/2/94"	*/
-MAKE_RCSID("$NetBSD: cond.c,v 1.255 2021/02/04 21:33:13 rillig Exp $");
+MAKE_RCSID("$NetBSD: cond.c,v 1.256 2021/02/05 05:15:12 rillig Exp $");
 
 /*
  * The parsing of conditional expressions is based on this grammar:
@@ -303,7 +303,7 @@ ParseFuncArg(CondParser *par, const char
 static Boolean
 FuncDefined(size_t argLen MAKE_ATTR_UNUSED, const char *arg)
 {
-	FStr value = Var_Value(arg, SCOPE_CMDLINE);
+	FStr value = Var_Value(SCOPE_CMDLINE, arg);
 	Boolean result = value.str != NULL;
 	FStr_Done(&value);
 	return result;

Index: src/usr.bin/make/job.c
diff -u src/usr.bin/make/job.c:1.416 src/usr.bin/make/job.c:1.417
--- src/usr.bin/make/job.c:1.416	Thu Feb  4 21:33:13 2021
+++ src/usr.bin/make/job.c	Fri Feb  5 05:15:12 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: job.c,v 1.416 2021/02/04 21:33:13 rillig Exp $	*/
+/*	$NetBSD: job.c,v 1.417 2021/02/05 05:15:12 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -142,7 +142,7 @@
 #include "trace.h"
 
 /*	"@(#)job.c	8.2 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: job.c,v 1.416 2021/02/04 21:33:13 rillig Exp $");
+MAKE_RCSID("$NetBSD: job.c,v 1.417 2021/02/05 05:15:12 rillig Exp $");
 
 /*
  * A shell defines how the commands are run.  All commands for a target are
@@ -1316,7 +1316,7 @@ Job_CheckCommands(GNode *gn, void (*abor
 		 * .DEFAULT itself.
 		 */
 		Make_HandleUse(defaultNode, gn);
-		Var_Set(IMPSRC, GNode_VarTarget(gn), gn);
+		Var_Set(gn, IMPSRC, GNode_VarTarget(gn));
 		return TRUE;
 	}
 
@@ -2136,7 +2136,7 @@ Shell_Init(void)
 	if (shellPath == NULL)
 		InitShellNameAndPath();
 
-	Var_SetWithFlags(".SHELL", shellPath, SCOPE_CMDLINE, VAR_SET_READONLY);
+	Var_SetWithFlags(SCOPE_CMDLINE, ".SHELL", shellPath, VAR_SET_READONLY);
 	if (shell->errFlag == NULL)
 		shell->errFlag = "";
 	if (shell->echoFlag == NULL)
@@ -2176,7 +2176,7 @@ Job_SetPrefix(void)
 {
 	if (targPrefix != NULL) {
 		free(targPrefix);
-	} else if (!Var_Exists(MAKE_JOB_PREFIX, SCOPE_GLOBAL)) {
+	} else if (!Var_Exists(SCOPE_GLOBAL, MAKE_JOB_PREFIX)) {
 		Global_Set(MAKE_JOB_PREFIX, "---");
 	}
 
@@ -2891,7 +2891,7 @@ Job_RunTarget(const char *target, const 
 		return FALSE;
 
 	if (fname != NULL)
-		Var_Set(ALLSRC, fname, gn);
+		Var_Set(gn, ALLSRC, fname);
 
 	JobRun(gn);
 	/* XXX: Replace with GNode_IsError(gn) */

Index: src/usr.bin/make/main.c
diff -u src/usr.bin/make/main.c:1.531 src/usr.bin/make/main.c:1.532
--- src/usr.bin/make/main.c:1.531	Fri Feb  5 04:41:17 2021
+++ src/usr.bin/make/main.c	Fri Feb  5 05:15:12 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: main.c,v 1.531 2021/02/05 04:41:17 rillig Exp $	*/
+/*	$NetBSD: main.c,v 1.532 2021/02/05 05:15:12 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -111,7 +111,7 @@
 #include "trace.h"
 
 /*	"@(#)main.c	8.3 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: main.c,v 1.531 2021/02/05 04:41:17 rillig Exp $");
+MAKE_RCSID("$NetBSD: main.c,v 1.532 2021/02/05 05:15:12 rillig Exp $");
 #if defined(MAKE_NATIVE) && !defined(lint)
 __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993 "
 	    "The Regents of the University of California.  "
@@ -693,7 +693,7 @@ Main_ParseArgLine(const char *line)
 		return;
 
 	{
-		FStr argv0 = Var_Value(".MAKE", SCOPE_GLOBAL);
+		FStr argv0 = Var_Value(SCOPE_GLOBAL, ".MAKE");
 		buf = str_concat3(argv0.str, " ", line);
 		FStr_Done(&argv0);
 	}
@@ -753,7 +753,7 @@ Main_SetObjdir(Boolean writable, const c
 static Boolean
 SetVarObjdir(Boolean writable, const char *var, const char *suffix)
 {
-	FStr path = Var_Value(var, SCOPE_CMDLINE);
+	FStr path = Var_Value(SCOPE_CMDLINE, var);
 	FStr xpath;
 
 	if (path.str == NULL || path.str[0] == '\0') {
@@ -855,7 +855,7 @@ PrintVar(const char *varname, Boolean ex
 		bmake_free(evalue);
 
 	} else {
-		FStr value = Var_Value(varname, SCOPE_GLOBAL);
+		FStr value = Var_Value(SCOPE_GLOBAL, varname);
 		printf("%s\n", value.str != NULL ? value.str : "");
 		FStr_Done(&value);
 	}
@@ -1051,13 +1051,13 @@ HandlePWD(const struct stat *curdir_st)
 	if (ignorePWD || (pwd = getenv("PWD")) == NULL)
 		return;
 
-	prefix = Var_Value("MAKEOBJDIRPREFIX", SCOPE_CMDLINE);
+	prefix = Var_Value(SCOPE_CMDLINE, "MAKEOBJDIRPREFIX");
 	if (prefix.str != NULL) {
 		FStr_Done(&prefix);
 		return;
 	}
 
-	makeobjdir = Var_Value("MAKEOBJDIR", SCOPE_CMDLINE);
+	makeobjdir = Var_Value(SCOPE_CMDLINE, "MAKEOBJDIR");
 	if (makeobjdir.str != NULL && strchr(makeobjdir.str, '$') != NULL)
 		goto ignore_pwd;
 
@@ -1238,7 +1238,7 @@ InitMaxJobs(void)
 	int n;
 
 	if (forceJobs || opts.compatMake ||
-	    !Var_Exists(".MAKE.JOBS", SCOPE_GLOBAL))
+	    !Var_Exists(SCOPE_GLOBAL, ".MAKE.JOBS"))
 		return;
 
 	(void)Var_Subst("${.MAKE.JOBS}", SCOPE_GLOBAL, VARE_WANTRES, &value);
@@ -1273,7 +1273,7 @@ static void
 InitVpath(void)
 {
 	char *vpath, savec, *path;
-	if (!Var_Exists("VPATH", SCOPE_CMDLINE))
+	if (!Var_Exists(SCOPE_CMDLINE, "VPATH"))
 		return;
 
 	(void)Var_Subst("${VPATH}", SCOPE_CMDLINE, VARE_WANTRES, &vpath);
@@ -1426,7 +1426,7 @@ main_Init(int argc, char **argv)
 	Global_Set("MFLAGS", "");
 	Global_Set(".ALLTARGETS", "");
 	/* some makefiles need to know this */
-	Var_Set(MAKE_LEVEL ".ENV", MAKE_LEVEL_ENV, SCOPE_CMDLINE);
+	Var_Set(SCOPE_CMDLINE, MAKE_LEVEL ".ENV", MAKE_LEVEL_ENV);
 
 	/* Set some other useful variables. */
 	{
@@ -1560,7 +1560,7 @@ main_PrepareMaking(void)
 	MakeMode();
 
 	{
-		FStr makeflags = Var_Value(MAKEFLAGS, SCOPE_GLOBAL);
+		FStr makeflags = Var_Value(SCOPE_GLOBAL, MAKEFLAGS);
 		Global_Append("MFLAGS", makeflags.str);
 		FStr_Done(&makeflags);
 	}
@@ -1691,7 +1691,7 @@ ReadMakefile(const char *fname)
 
 	if (strcmp(fname, "-") == 0) {
 		Parse_File(NULL /*stdin*/, -1);
-		Var_Set("MAKEFILE", "", SCOPE_INTERNAL);
+		Var_Set(SCOPE_INTERNAL, "MAKEFILE", "");
 	} else {
 		/* if we've chdir'd, rebuild the path name */
 		if (strcmp(curdir, objdir) != 0 && *fname != '/') {
@@ -1735,7 +1735,7 @@ ReadMakefile(const char *fname)
 		 */
 found:
 		if (!doing_depend)
-			Var_Set("MAKEFILE", fname, SCOPE_INTERNAL);
+			Var_Set(SCOPE_INTERNAL, "MAKEFILE", fname);
 		Parse_File(fname, fd);
 	}
 	free(path);

Index: src/usr.bin/make/make.c
diff -u src/usr.bin/make/make.c:1.241 src/usr.bin/make/make.c:1.242
--- src/usr.bin/make/make.c:1.241	Thu Feb  4 21:42:46 2021
+++ src/usr.bin/make/make.c	Fri Feb  5 05:15:12 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: make.c,v 1.241 2021/02/04 21:42:46 rillig Exp $	*/
+/*	$NetBSD: make.c,v 1.242 2021/02/05 05:15:12 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -103,7 +103,7 @@
 #include "job.h"
 
 /*	"@(#)make.c	8.1 (Berkeley) 6/6/93"	*/
-MAKE_RCSID("$NetBSD: make.c,v 1.241 2021/02/04 21:42:46 rillig Exp $");
+MAKE_RCSID("$NetBSD: make.c,v 1.242 2021/02/05 05:15:12 rillig Exp $");
 
 /* Sequence # to detect recursion. */
 static unsigned int checked_seqno = 1;
@@ -568,9 +568,9 @@ UpdateImplicitParentsVars(GNode *cgn, co
 	for (ln = cgn->implicitParents.first; ln != NULL; ln = ln->next) {
 		GNode *pgn = ln->datum;
 		if (pgn->flags & REMAKE) {
-			Var_Set(IMPSRC, cname, pgn);
+			Var_Set(pgn, IMPSRC, cname);
 			if (cpref != NULL)
-				Var_Set(PREFIX, cpref, pgn);
+				Var_Set(pgn, PREFIX, cpref);
 		}
 	}
 }
@@ -823,11 +823,11 @@ MakeAddAllSrc(GNode *cgn, GNode *pgn)
 		allsrc = child;
 
 	if (allsrc != NULL)
-		Var_Append(ALLSRC, allsrc, pgn);
+		Var_Append(pgn, ALLSRC, allsrc);
 
 	if (pgn->type & OP_JOIN) {
 		if (cgn->made == MADE)
-			Var_Append(OODATE, child, pgn);
+			Var_Append(pgn, OODATE, child);
 
 	} else if ((pgn->mtime < cgn->mtime) ||
 		   (cgn->mtime >= now && cgn->made == MADE)) {
@@ -849,7 +849,7 @@ MakeAddAllSrc(GNode *cgn, GNode *pgn)
 		 * to now in Make_Update. According to some people,
 		 * this is good...
 		 */
-		Var_Append(OODATE, child, pgn);
+		Var_Append(pgn, OODATE, child);
 	}
 }
 
@@ -879,13 +879,13 @@ Make_DoAllVar(GNode *gn)
 	for (ln = gn->children.first; ln != NULL; ln = ln->next)
 		MakeAddAllSrc(ln->datum, gn);
 
-	if (!Var_Exists(OODATE, gn))
-		Var_Set(OODATE, "", gn);
-	if (!Var_Exists(ALLSRC, gn))
-		Var_Set(ALLSRC, "", gn);
+	if (!Var_Exists(gn, OODATE))
+		Var_Set(gn, OODATE, "");
+	if (!Var_Exists(gn, ALLSRC))
+		Var_Set(gn, ALLSRC, "");
 
 	if (gn->type & OP_JOIN)
-		Var_Set(TARGET, GNode_VarAllsrc(gn), gn);
+		Var_Set(gn, TARGET, GNode_VarAllsrc(gn));
 	gn->flags |= DONE_ALLSRC;
 }
 
@@ -1237,14 +1237,14 @@ Make_ExpandUse(GNodeList *targs)
 				continue;
 			*eoa = '\0';
 			*eon = '\0';
-			Var_Set(MEMBER, eoa + 1, gn);
-			Var_Set(ARCHIVE, gn->name, gn);
+			Var_Set(gn, MEMBER, eoa + 1);
+			Var_Set(gn, ARCHIVE, gn->name);
 			*eoa = '(';
 			*eon = ')';
 		}
 
 		Dir_UpdateMTime(gn, FALSE);
-		Var_Set(TARGET, GNode_Path(gn), gn);
+		Var_Set(gn, TARGET, GNode_Path(gn));
 		UnmarkChildren(gn);
 		HandleUseNodes(gn);
 

Index: src/usr.bin/make/meta.c
diff -u src/usr.bin/make/meta.c:1.175 src/usr.bin/make/meta.c:1.176
--- src/usr.bin/make/meta.c:1.175	Thu Feb  4 21:33:14 2021
+++ src/usr.bin/make/meta.c	Fri Feb  5 05:15:12 2021
@@ -1,4 +1,4 @@
-/*      $NetBSD: meta.c,v 1.175 2021/02/04 21:33:14 rillig Exp $ */
+/*      $NetBSD: meta.c,v 1.176 2021/02/05 05:15:12 rillig Exp $ */
 
 /*
  * Implement 'meta' mode.
@@ -323,7 +323,7 @@ is_submake(const char *cmd, GNode *gn)
     Boolean rc = FALSE;
 
     if (p_make == NULL) {
-	p_make = Var_Value(".MAKE", gn).str;
+	p_make = Var_Value(gn, ".MAKE").str;
 	p_len = strlen(p_make);
     }
     cp = strchr(cmd, '$');
@@ -479,7 +479,7 @@ meta_create(BuildMon *pbm, GNode *gn)
 
     fp = NULL;
 
-    dname = Var_Value(".OBJDIR", gn);
+    dname = Var_Value(gn, ".OBJDIR");
     tname = GNode_VarTarget(gn);
 
     /* if this succeeds objdir_realpath is realpath of dname */
@@ -609,7 +609,7 @@ meta_mode_init(const char *make_mode)
 	get_mode_bf(metaMissing, "missing-meta=");
 	get_mode_bf(metaSilent, "silent=");
     }
-    if (metaVerbose && !Var_Exists(MAKE_META_PREFIX, SCOPE_GLOBAL)) {
+    if (metaVerbose && !Var_Exists(SCOPE_GLOBAL, MAKE_META_PREFIX)) {
 	/*
 	 * The default value for MAKE_META_PREFIX
 	 * prints the absolute path of the target.
@@ -643,12 +643,12 @@ meta_mode_init(const char *make_mode)
     /*
      * We ignore any paths that match ${.MAKE.META.IGNORE_PATTERNS}
      */
-    value = Var_Value(MAKE_META_IGNORE_PATTERNS, SCOPE_GLOBAL);
+    value = Var_Value(SCOPE_GLOBAL, MAKE_META_IGNORE_PATTERNS);
     if (value.str != NULL) {
 	metaIgnorePatterns = TRUE;
 	FStr_Done(&value);
     }
-    value = Var_Value(MAKE_META_IGNORE_FILTER, SCOPE_GLOBAL);
+    value = Var_Value(SCOPE_GLOBAL, MAKE_META_IGNORE_FILTER);
     if (value.str != NULL) {
 	metaIgnoreFilter = TRUE;
 	FStr_Done(&value);
@@ -989,7 +989,13 @@ meta_ignore(GNode *gn, const char *p)
 	const char *expr;
 	char *pm;
 
-	Var_Set(".p.", p, gn);
+	/*
+	 * XXX: This variable is set on a target GNode but is not one of
+	 * the usual local variables.  It should be deleted afterwards.
+	 * Ideally it would not be created in the first place, just like
+	 * in a .for loop.
+	 */
+	Var_Set(gn, ".p.", p);
 	expr = "${" MAKE_META_IGNORE_PATTERNS ":@m@${.p.:M$m}@}";
 	(void)Var_Subst(expr, gn, VARE_WANTRES, &pm);
 	/* TODO: handle errors */
@@ -1089,7 +1095,7 @@ meta_oodate(GNode *gn, Boolean oodate)
     if (oodate)
 	return oodate;		/* we're done */
 
-    dname = Var_Value(".OBJDIR", gn);
+    dname = Var_Value(gn, ".OBJDIR");
     tname = GNode_VarTarget(gn);
 
     /* if this succeeds fname3 is realpath of dname */
@@ -1223,12 +1229,12 @@ meta_oodate(GNode *gn, Boolean oodate)
 			snprintf(lcwd_vname, sizeof lcwd_vname, LCWD_VNAME_FMT, pid);
 			snprintf(ldir_vname, sizeof ldir_vname, LDIR_VNAME_FMT, pid);
 			lastpid = pid;
-			ldir = Var_Value(ldir_vname, SCOPE_GLOBAL);
+			ldir = Var_Value(SCOPE_GLOBAL, ldir_vname);
 			if (ldir.str != NULL) {
 			    strlcpy(latestdir, ldir.str, sizeof latestdir);
 			    FStr_Done(&ldir);
 			}
-			ldir = Var_Value(lcwd_vname, SCOPE_GLOBAL);
+			ldir = Var_Value(SCOPE_GLOBAL, lcwd_vname);
 			if (ldir.str != NULL) {
 			    strlcpy(lcwd, ldir.str, sizeof lcwd);
 			    FStr_Done(&ldir);
@@ -1251,8 +1257,8 @@ meta_oodate(GNode *gn, Boolean oodate)
 		/* Process according to record type. */
 		switch (buf[0]) {
 		case 'X':		/* eXit */
-		    Var_DeleteExpand(lcwd_vname, SCOPE_GLOBAL);
-		    Var_DeleteExpand(ldir_vname, SCOPE_GLOBAL);
+		    Var_DeleteExpand(SCOPE_GLOBAL, lcwd_vname);
+		    Var_DeleteExpand(SCOPE_GLOBAL, ldir_vname);
 		    lastpid = 0;	/* no need to save ldir_vname */
 		    break;
 
@@ -1601,8 +1607,8 @@ meta_oodate(GNode *gn, Boolean oodate)
 	 * We have decided it is oodate, so .OODATE needs to be set.
 	 * All we can sanely do is set it to .ALLSRC.
 	 */
-	Var_Delete(OODATE, gn);
-	Var_Set(OODATE, GNode_VarAllsrc(gn), gn);
+	Var_Delete(gn, OODATE);
+	Var_Set(gn, OODATE, GNode_VarAllsrc(gn));
     }
 
  oodate_out:

Index: src/usr.bin/make/nonints.h
diff -u src/usr.bin/make/nonints.h:1.201 src/usr.bin/make/nonints.h:1.202
--- src/usr.bin/make/nonints.h:1.201	Fri Feb  5 04:41:17 2021
+++ src/usr.bin/make/nonints.h	Fri Feb  5 05:15:12 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: nonints.h,v 1.201 2021/02/05 04:41:17 rillig Exp $	*/
+/*	$NetBSD: nonints.h,v 1.202 2021/02/05 05:15:12 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -368,18 +368,18 @@ typedef enum VarExportMode {
 	VEM_LITERAL
 } VarExportMode;
 
-void Var_Delete(const char *, GNode *);
-void Var_DeleteExpand(const char *, GNode *);
+void Var_Delete(GNode *, const char *);
+void Var_DeleteExpand(GNode *, const char *);
 void Var_Undef(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_SetExpandWithFlags(const char *, const char *, GNode *, VarSetFlags);
-void Var_Append(const char *, const char *, GNode *);
-void Var_AppendExpand(const char *, const char *, GNode *);
-Boolean Var_Exists(const char *, GNode *);
-Boolean Var_ExistsExpand(const char *, GNode *);
-FStr Var_Value(const char *, GNode *);
+void Var_Set(GNode *, const char *, const char *);
+void Var_SetExpand(GNode *, const char *, const char *);
+void Var_SetWithFlags(GNode *, const char *, const char *, VarSetFlags);
+void Var_SetExpandWithFlags(GNode *, const char *, const char *, VarSetFlags);
+void Var_Append(GNode *, const char *, const char *);
+void Var_AppendExpand(GNode *, const char *, const char *);
+Boolean Var_Exists(GNode *, const char *);
+Boolean Var_ExistsExpand(GNode *, const char *);
+FStr Var_Value(GNode *, const char *);
 const char *GNode_ValueDirect(GNode *, const char *);
 VarParseResult Var_Parse(const char **, GNode *, VarEvalFlags, FStr *);
 VarParseResult Var_Subst(const char *, GNode *, VarEvalFlags, char **);

Index: src/usr.bin/make/parse.c
diff -u src/usr.bin/make/parse.c:1.547 src/usr.bin/make/parse.c:1.548
--- src/usr.bin/make/parse.c:1.547	Fri Feb  5 04:41:17 2021
+++ src/usr.bin/make/parse.c	Fri Feb  5 05:15:12 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: parse.c,v 1.547 2021/02/05 04:41:17 rillig Exp $	*/
+/*	$NetBSD: parse.c,v 1.548 2021/02/05 05:15:12 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.547 2021/02/05 04:41:17 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.548 2021/02/05 05:15:12 rillig Exp $");
 
 /* types and constants */
 
@@ -576,13 +576,13 @@ PrintLocation(FILE *f, const char *fname
 	/* Find out which makefile is the culprit.
 	 * We try ${.PARSEDIR} and apply realpath(3) if not absolute. */
 
-	dir = Var_Value(".PARSEDIR", SCOPE_GLOBAL);
+	dir = Var_Value(SCOPE_GLOBAL, ".PARSEDIR");
 	if (dir.str == NULL)
 		dir.str = ".";
 	if (dir.str[0] != '/')
 		dir.str = realpath(dir.str, dirbuf);
 
-	base = Var_Value(".PARSEFILE", SCOPE_GLOBAL);
+	base = Var_Value(SCOPE_GLOBAL, ".PARSEFILE");
 	if (base.str == NULL)
 		base.str = str_basename(fname);
 
@@ -1886,7 +1886,7 @@ VarCheckSyntax(VarAssignOp type, const c
 }
 
 static void
-VarAssign_EvalSubst(const char *name, const char *uvalue, GNode *scope,
+VarAssign_EvalSubst(GNode *scope, const char *name, const char *uvalue,
 		    FStr *out_avalue)
 {
 	char *evalue;
@@ -1898,14 +1898,14 @@ VarAssign_EvalSubst(const char *name, co
 	 * TODO: Add a test that demonstrates why this code is needed,
 	 *  apart from making the debug log longer.
 	 */
-	if (!Var_ExistsExpand(name, scope))
-		Var_SetExpand(name, "", scope);
+	if (!Var_ExistsExpand(scope, name))
+		Var_SetExpand(scope, name, "");
 
 	(void)Var_Subst(uvalue, scope,
 	    VARE_WANTRES | VARE_KEEP_DOLLAR | VARE_KEEP_UNDEF, &evalue);
 	/* TODO: handle errors */
 
-	Var_SetExpand(name, evalue, scope);
+	Var_SetExpand(scope, name, evalue);
 
 	*out_avalue = FStr_InitOwn(evalue);
 }
@@ -1928,7 +1928,7 @@ VarAssign_EvalShell(const char *name, co
 	}
 
 	cmdOut = Cmd_Exec(cmd.str, &errfmt);
-	Var_SetExpand(name, cmdOut, scope);
+	Var_SetExpand(scope, name, cmdOut);
 	*out_avalue = FStr_InitOwn(cmdOut);
 
 	if (errfmt != NULL)
@@ -1955,17 +1955,17 @@ VarAssign_Eval(const char *name, VarAssi
 	FStr avalue = FStr_InitRefer(uvalue);
 
 	if (op == VAR_APPEND)
-		Var_AppendExpand(name, uvalue, scope);
+		Var_AppendExpand(scope, name, uvalue);
 	else if (op == VAR_SUBST)
-		VarAssign_EvalSubst(name, uvalue, scope, &avalue);
+		VarAssign_EvalSubst(scope, name, uvalue, &avalue);
 	else if (op == VAR_SHELL)
 		VarAssign_EvalShell(name, uvalue, scope, &avalue);
 	else {
-		if (op == VAR_DEFAULT && Var_ExistsExpand(name, scope))
+		if (op == VAR_DEFAULT && Var_ExistsExpand(scope, name))
 			return FALSE;
 
 		/* Normal assignment -- just do it. */
-		Var_SetExpand(name, uvalue, scope);
+		Var_SetExpand(scope, name, uvalue);
 	}
 
 	*out_TRUE_avalue = avalue;
@@ -2359,7 +2359,7 @@ StrContainsWord(const char *str, const c
 static Boolean
 VarContainsWord(const char *varname, const char *word)
 {
-	FStr val = Var_Value(varname, SCOPE_GLOBAL);
+	FStr val = Var_Value(SCOPE_GLOBAL, varname);
 	Boolean found = val.str != NULL && StrContainsWord(val.str, word);
 	FStr_Done(&val);
 	return found;

Index: src/usr.bin/make/suff.c
diff -u src/usr.bin/make/suff.c:1.344 src/usr.bin/make/suff.c:1.345
--- src/usr.bin/make/suff.c:1.344	Thu Feb  4 21:42:46 2021
+++ src/usr.bin/make/suff.c	Fri Feb  5 05:15:12 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: suff.c,v 1.344 2021/02/04 21:42:46 rillig Exp $	*/
+/*	$NetBSD: suff.c,v 1.345 2021/02/05 05:15:12 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -114,7 +114,7 @@
 #include "dir.h"
 
 /*	"@(#)suff.c	8.4 (Berkeley) 3/21/94"	*/
-MAKE_RCSID("$NetBSD: suff.c,v 1.344 2021/02/04 21:42:46 rillig Exp $");
+MAKE_RCSID("$NetBSD: suff.c,v 1.345 2021/02/05 05:15:12 rillig Exp $");
 
 typedef List SuffixList;
 typedef ListNode SuffixListNode;
@@ -1626,8 +1626,8 @@ FindDepsArchive(GNode *gn, CandidateSear
 	gn->unmade++;
 
 	/* Copy in the variables from the member node to this one. */
-	Var_Set(PREFIX, GNode_VarPrefix(mem), gn);
-	Var_Set(TARGET, GNode_VarTarget(mem), gn);
+	Var_Set(gn, PREFIX, GNode_VarPrefix(mem));
+	Var_Set(gn, TARGET, GNode_VarTarget(mem));
 
 	memSuff = mem->suffix;
 	if (memSuff == NULL) {	/* Didn't know what it was. */
@@ -1637,10 +1637,10 @@ FindDepsArchive(GNode *gn, CandidateSear
 
 
 	/* Set the other two local variables required for this target. */
-	Var_Set(MEMBER, name, gn);
-	Var_Set(ARCHIVE, gn->name, gn);
+	Var_Set(gn, MEMBER, name);
+	Var_Set(gn, ARCHIVE, gn->name);
 	/* Set $@ for compatibility with other makes. */
-	Var_Set(TARGET, gn->name, gn);
+	Var_Set(gn, TARGET, gn->name);
 
 	/*
 	 * Now we've got the important local variables set, expand any sources
@@ -1691,7 +1691,7 @@ FindDepsLib(GNode *gn)
 		Arch_FindLib(gn, suff->searchPath);
 	} else {
 		Suffix_Unassign(&gn->suffix);
-		Var_Set(TARGET, gn->name, gn);
+		Var_Set(gn, TARGET, gn->name);
 	}
 
 	/*
@@ -1699,7 +1699,7 @@ FindDepsLib(GNode *gn)
 	 * filesystem conventions, we don't set the regular variables for
 	 * the thing. .PREFIX is simply made empty.
 	 */
-	Var_Set(PREFIX, "", gn);
+	Var_Set(gn, PREFIX, "");
 }
 
 static void
@@ -1776,7 +1776,7 @@ FindDepsRegularPath(GNode *gn, Candidate
 	if (gn->path == NULL)
 		return;
 
-	Var_Set(TARGET, gn->path, gn);
+	Var_Set(gn, TARGET, gn->path);
 
 	if (targ != NULL) {
 		/*
@@ -1791,7 +1791,7 @@ FindDepsRegularPath(GNode *gn, Candidate
 		savec = gn->path[savep];
 		gn->path[savep] = '\0';
 
-		Var_Set(PREFIX, str_basename(gn->path), gn);
+		Var_Set(gn, PREFIX, str_basename(gn->path));
 
 		gn->path[savep] = savec;
 	} else {
@@ -1800,7 +1800,7 @@ FindDepsRegularPath(GNode *gn, Candidate
 		 * known suffix.
 		 */
 		Suffix_Unassign(&gn->suffix);
-		Var_Set(PREFIX, str_basename(gn->path), gn);
+		Var_Set(gn, PREFIX, str_basename(gn->path));
 	}
 }
 
@@ -1890,8 +1890,8 @@ FindDepsRegular(GNode *gn, CandidateSear
 		}
 	}
 
-	Var_Set(TARGET, GNode_Path(gn), gn);
-	Var_Set(PREFIX, targ != NULL ? targ->prefix : gn->name, gn);
+	Var_Set(gn, TARGET, GNode_Path(gn));
+	Var_Set(gn, PREFIX, targ != NULL ? targ->prefix : gn->name);
 
 	/*
 	 * Now we've got the important local variables set, expand any sources
@@ -1981,8 +1981,8 @@ FindDepsRegular(GNode *gn, CandidateSear
 			 * we need to do is set the standard variables.
 			 */
 			targ->node->type |= OP_DEPS_FOUND;
-			Var_Set(PREFIX, targ->prefix, targ->node);
-			Var_Set(TARGET, targ->node->name, targ->node);
+			Var_Set(targ->node, PREFIX, targ->prefix);
+			Var_Set(targ->node, TARGET, targ->node->name);
 		}
 	}
 
@@ -2048,8 +2048,8 @@ FindDeps(GNode *gn, CandidateSearcher *c
 	gn->type |= OP_DEPS_FOUND;
 
 	/* Make sure we have these set, may get revised below. */
-	Var_Set(TARGET, GNode_Path(gn), gn);
-	Var_Set(PREFIX, gn->name, gn);
+	Var_Set(gn, TARGET, GNode_Path(gn));
+	Var_Set(gn, PREFIX, gn->name);
 
 	DEBUG1(SUFF, "SuffFindDeps \"%s\"\n", gn->name);
 

Index: src/usr.bin/make/trace.c
diff -u src/usr.bin/make/trace.c:1.27 src/usr.bin/make/trace.c:1.28
--- src/usr.bin/make/trace.c:1.27	Thu Feb  4 21:33:14 2021
+++ src/usr.bin/make/trace.c	Fri Feb  5 05:15:12 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: trace.c,v 1.27 2021/02/04 21:33:14 rillig Exp $	*/
+/*	$NetBSD: trace.c,v 1.28 2021/02/05 05:15:12 rillig Exp $	*/
 
 /*
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -48,7 +48,7 @@
 #include "job.h"
 #include "trace.h"
 
-MAKE_RCSID("$NetBSD: trace.c,v 1.27 2021/02/04 21:33:14 rillig Exp $");
+MAKE_RCSID("$NetBSD: trace.c,v 1.28 2021/02/05 05:15:12 rillig Exp $");
 
 static FILE *trfile;
 static pid_t trpid;
@@ -71,7 +71,7 @@ Trace_Init(const char *pathname)
 		trpid = getpid();
 		/* XXX: This variable may get overwritten later, which
 		 * would make trwd point to undefined behavior. */
-		curDir = Var_Value(".CURDIR", SCOPE_GLOBAL);
+		curDir = Var_Value(SCOPE_GLOBAL, ".CURDIR");
 		trwd = curDir.str;
 
 		trfile = fopen(pathname, "a");

Index: src/usr.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.804 src/usr.bin/make/var.c:1.805
--- src/usr.bin/make/var.c:1.804	Fri Feb  5 04:41:17 2021
+++ src/usr.bin/make/var.c	Fri Feb  5 05:15:12 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.804 2021/02/05 04:41:17 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.805 2021/02/05 05:15:12 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -139,7 +139,7 @@
 #include "metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.804 2021/02/05 04:41:17 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.805 2021/02/05 05:15:12 rillig Exp $");
 
 typedef enum VarFlags {
 	VAR_NONE	= 0,
@@ -490,7 +490,7 @@ VarAdd(const char *name, const char *val
  * The variable name is kept as-is, it is not expanded.
  */
 void
-Var_Delete(const char *varname, GNode *scope)
+Var_Delete(GNode *scope, const char *varname)
 {
 	HashEntry *he = HashTable_FindEntry(&scope->vars, varname);
 	Var *v;
@@ -517,7 +517,7 @@ Var_Delete(const char *varname, GNode *s
  * The variable name is expanded once.
  */
 void
-Var_DeleteExpand(const char *name, GNode *scope)
+Var_DeleteExpand(GNode *scope, const char *name)
 {
 	FStr varname = FStr_InitRefer(name);
 
@@ -529,7 +529,7 @@ Var_DeleteExpand(const char *name, GNode
 		varname = FStr_InitOwn(expanded);
 	}
 
-	Var_Delete(varname.str, scope);
+	Var_Delete(scope, varname.str);
 	FStr_Done(&varname);
 }
 
@@ -919,7 +919,7 @@ Var_UnExport(Boolean isEnv, const char *
 
 /* Set the variable to the value; the name is not expanded. */
 void
-Var_SetWithFlags(const char *name, const char *val, GNode *scope,
+Var_SetWithFlags(GNode *scope, const char *name, const char *val,
 		 VarSetFlags flags)
 {
 	Var *v;
@@ -956,7 +956,7 @@ Var_SetWithFlags(const char *name, const
 			 * needed. Otherwise -V name may show the wrong value.
 			 */
 			/* XXX: name is expanded for the second time */
-			Var_DeleteExpand(name, SCOPE_GLOBAL);
+			Var_DeleteExpand(SCOPE_GLOBAL, name);
 		}
 		VarAdd(name, val, scope, flags);
 	} else {
@@ -1003,8 +1003,8 @@ Var_SetWithFlags(const char *name, const
 
 /* See Var_Set for documentation. */
 void
-Var_SetExpandWithFlags(const char *name, const char *val, GNode *scope,
-		 VarSetFlags flags)
+Var_SetExpandWithFlags(GNode *scope, const char *name, const char *val,
+		       VarSetFlags flags)
 {
 	const char *unexpanded_name = name;
 	FStr varname = FStr_InitRefer(name);
@@ -1023,15 +1023,15 @@ Var_SetExpandWithFlags(const char *name,
 			    "name expands to empty string - ignored\n",
 		    unexpanded_name, val);
 	} else
-		Var_SetWithFlags(varname.str, val, scope, flags);
+		Var_SetWithFlags(scope, varname.str, val, flags);
 
 	FStr_Done(&varname);
 }
 
 void
-Var_Set(const char *name, const char *val, GNode *scope)
+Var_Set(GNode *scope, const char *name, const char *val)
 {
-	Var_SetWithFlags(name, val, scope, VAR_SET_NONE);
+	Var_SetWithFlags(scope, name, val, VAR_SET_NONE);
 }
 
 /*
@@ -1046,27 +1046,27 @@ Var_Set(const char *name, const char *va
  *	scope		scope in which to set it
  */
 void
-Var_SetExpand(const char *name, const char *val, GNode *scope)
+Var_SetExpand(GNode *scope, const char *name, const char *val)
 {
-	Var_SetExpandWithFlags(name, val, scope, VAR_SET_NONE);
+	Var_SetExpandWithFlags(scope, name, val, VAR_SET_NONE);
 }
 
 void
 Global_Set(const char *name, const char *value)
 {
-	Var_Set(name, value, SCOPE_GLOBAL);
+	Var_Set(SCOPE_GLOBAL, name, value);
 }
 
 void
 Global_SetExpand(const char *name, const char *value)
 {
-	Var_SetExpand(name, value, SCOPE_GLOBAL);
+	Var_SetExpand(SCOPE_GLOBAL, name, value);
 }
 
 void
 Global_Delete(const char *name)
 {
-	Var_Delete(name, SCOPE_GLOBAL);
+	Var_Delete(SCOPE_GLOBAL, name);
 }
 
 /*
@@ -1076,14 +1076,14 @@ Global_Delete(const char *name)
  * and the given value are appended.
  */
 void
-Var_Append(const char *name, const char *val, GNode *scope)
+Var_Append(GNode *scope, const char *name, const char *val)
 {
 	Var *v;
 
 	v = VarFind(name, scope, scope == SCOPE_GLOBAL);
 
 	if (v == NULL) {
-		Var_SetWithFlags(name, val, scope, VAR_SET_NONE);
+		Var_SetWithFlags(scope, name, val, VAR_SET_NONE);
 	} else if (v->flags & VAR_READONLY) {
 		DEBUG1(VAR, "Ignoring append to %s since it is read-only\n",
 		    name);
@@ -1132,7 +1132,7 @@ Var_Append(const char *name, const char 
  *	a big win and must be tolerated.
  */
 void
-Var_AppendExpand(const char *name, const char *val, GNode *scope)
+Var_AppendExpand(GNode *scope, const char *name, const char *val)
 {
 	char *name_freeIt = NULL;
 
@@ -1153,7 +1153,7 @@ Var_AppendExpand(const char *name, const
 		}
 	}
 
-	Var_Append(name, val, scope);
+	Var_Append(scope, name, val);
 
 	free(name_freeIt);
 }
@@ -1161,11 +1161,11 @@ Var_AppendExpand(const char *name, const
 void
 Global_Append(const char *name, const char *value)
 {
-	Var_Append(name, value, SCOPE_GLOBAL);
+	Var_Append(SCOPE_GLOBAL, name, value);
 }
 
 Boolean
-Var_Exists(const char *name, GNode *scope)
+Var_Exists(GNode *scope, const char *name)
 {
 	Var *v = VarFind(name, scope, TRUE);
 	if (v == NULL)
@@ -1184,7 +1184,7 @@ Var_Exists(const char *name, GNode *scop
  *	scope		Scope in which to start search
  */
 Boolean
-Var_ExistsExpand(const char *name, GNode *scope)
+Var_ExistsExpand(GNode *scope, const char *name)
 {
 	FStr varname = FStr_InitRefer(name);
 	Boolean exists;
@@ -1196,7 +1196,7 @@ Var_ExistsExpand(const char *name, GNode
 		varname = FStr_InitOwn(expanded);
 	}
 
-	exists = Var_Exists(varname.str, scope);
+	exists = Var_Exists(scope, varname.str);
 	FStr_Done(&varname);
 	return exists;
 }
@@ -1215,7 +1215,7 @@ Var_ExistsExpand(const char *name, GNode
  *	out_freeIt when the returned value is no longer needed.
  */
 FStr
-Var_Value(const char *name, GNode *scope)
+Var_Value(GNode *scope, const char *name)
 {
 	Var *v = VarFind(name, scope, TRUE);
 	char *value;
@@ -1682,7 +1682,7 @@ ModifyWord_Loop(const char *word, SepBuf
 
 	args = data;
 	/* XXX: The variable name should not be expanded here. */
-	Var_SetExpandWithFlags(args->tvar, word, args->ctx, VAR_SET_NO_EXPORT);
+	Var_SetExpandWithFlags(args->ctx, args->tvar, word, VAR_SET_NO_EXPORT);
 	(void)Var_Subst(args->str, args->ctx, args->eflags, &s);
 	/* TODO: handle errors */
 
@@ -2378,7 +2378,7 @@ ApplyModifier_Loop(const char **pp, cons
 	    ModifyWords(val, ModifyWord_Loop, &args, st->oneBigWord, st->sep));
 	st->sep = prev_sep;
 	/* XXX: Consider restoring the previous variable instead of deleting. */
-	Var_DeleteExpand(args.tvar, st->scope);
+	Var_DeleteExpand(st->scope, args.tvar);
 	free(args.tvar);
 	free(args.str);
 	return AMR_OK;
@@ -3301,7 +3301,7 @@ ok:
 	if (st->eflags & VARE_WANTRES) {
 		switch (op[0]) {
 		case '+':
-			Var_AppendExpand(st->var->name.str, val, scope);
+			Var_AppendExpand(scope, st->var->name.str, val);
 			break;
 		case '!': {
 			const char *errfmt;
@@ -3309,8 +3309,8 @@ ok:
 			if (errfmt != NULL)
 				Error(errfmt, val);
 			else
-				Var_SetExpand(st->var->name.str, cmd_output,
-				    scope);
+				Var_SetExpand(scope,
+				    st->var->name.str, cmd_output);
 			free(cmd_output);
 			break;
 		}
@@ -3319,7 +3319,7 @@ ok:
 				break;
 			/* FALLTHROUGH */
 		default:
-			Var_SetExpand(st->var->name.str, val, scope);
+			Var_SetExpand(scope, st->var->name.str, val);
 			break;
 		}
 	}
@@ -3343,11 +3343,11 @@ ApplyModifier_Remember(const char **pp, 
 	if (mod[1] == '=') {
 		size_t n = strcspn(mod + 2, ":)}");
 		char *name = bmake_strldup(mod + 2, n);
-		Var_SetExpand(name, val, st->scope);
+		Var_SetExpand(st->scope, name, val);
 		free(name);
 		*pp = mod + 2 + n;
 	} else {
-		Var_Set("_", val, st->scope);
+		Var_Set(st->scope, "_", val);
 		*pp = mod + 1;
 	}
 	st->newVal = FStr_InitRefer(val);

Reply via email to