Module Name:    src
Committed By:   rillig
Date:           Wed Feb  3 08:08:18 UTC 2021

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

Log Message:
make: replace Global_SetExpand with Global_Set for constant names


To generate a diff of this commit:
cvs rdiff -u -r1.413 -r1.414 src/usr.bin/make/job.c
cvs rdiff -u -r1.527 -r1.528 src/usr.bin/make/main.c
cvs rdiff -u -r1.171 -r1.172 src/usr.bin/make/meta.c
cvs rdiff -u -r1.191 -r1.192 src/usr.bin/make/nonints.h
cvs rdiff -u -r1.539 -r1.540 src/usr.bin/make/parse.c
cvs rdiff -u -r1.342 -r1.343 src/usr.bin/make/suff.c
cvs rdiff -u -r1.791 -r1.792 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/job.c
diff -u src/usr.bin/make/job.c:1.413 src/usr.bin/make/job.c:1.414
--- src/usr.bin/make/job.c:1.413	Wed Feb  3 08:00:36 2021
+++ src/usr.bin/make/job.c	Wed Feb  3 08:08:18 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: job.c,v 1.413 2021/02/03 08:00:36 rillig Exp $	*/
+/*	$NetBSD: job.c,v 1.414 2021/02/03 08:08:18 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.413 2021/02/03 08:00:36 rillig Exp $");
+MAKE_RCSID("$NetBSD: job.c,v 1.414 2021/02/03 08:08:18 rillig Exp $");
 
 /*
  * A shell defines how the commands are run.  All commands for a target are
@@ -2177,7 +2177,7 @@ Job_SetPrefix(void)
 	if (targPrefix != NULL) {
 		free(targPrefix);
 	} else if (!Var_Exists(MAKE_JOB_PREFIX, VAR_GLOBAL)) {
-		Global_SetExpand(MAKE_JOB_PREFIX, "---");
+		Global_Set(MAKE_JOB_PREFIX, "---");
 	}
 
 	(void)Var_Subst("${" MAKE_JOB_PREFIX "}",

Index: src/usr.bin/make/main.c
diff -u src/usr.bin/make/main.c:1.527 src/usr.bin/make/main.c:1.528
--- src/usr.bin/make/main.c:1.527	Wed Feb  3 08:00:36 2021
+++ src/usr.bin/make/main.c	Wed Feb  3 08:08:18 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: main.c,v 1.527 2021/02/03 08:00:36 rillig Exp $	*/
+/*	$NetBSD: main.c,v 1.528 2021/02/03 08:08:18 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.527 2021/02/03 08:00:36 rillig Exp $");
+MAKE_RCSID("$NetBSD: main.c,v 1.528 2021/02/03 08:08:18 rillig Exp $");
 #if defined(MAKE_NATIVE) && !defined(lint)
 __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993 "
 	    "The Regents of the University of California.  "
@@ -429,7 +429,7 @@ MainParseArgJobs(const char *argvalue)
 	}
 	Global_AppendExpand(MAKEFLAGS, "-j");
 	Global_AppendExpand(MAKEFLAGS, argvalue);
-	Global_SetExpand(".MAKE.JOBS", argvalue);
+	Global_Set(".MAKE.JOBS", argvalue);
 	maxJobTokens = opts.maxJobs;
 }
 
@@ -459,7 +459,7 @@ MainParseArg(char c, const char *argvalu
 	case 'B':
 		opts.compatMake = TRUE;
 		Global_AppendExpand(MAKEFLAGS, "-B");
-		Global_SetExpand(MAKE_MODE, "compat");
+		Global_Set(MAKE_MODE, "compat");
 		break;
 	case 'C':
 		MainParseArgChdir(argvalue);
@@ -737,7 +737,7 @@ Main_SetObjdir(Boolean writable, const c
 			    progname, path, strerror(errno));
 		} else {
 			snprintf(objdir, sizeof objdir, "%s", path);
-			Global_SetExpand(".OBJDIR", objdir);
+			Global_Set(".OBJDIR", objdir);
 			setenv("PWD", objdir, 1);
 			Dir_InitDot();
 			purge_relative_cached_realpaths();
@@ -957,7 +957,7 @@ InitVarTargets(void)
 	StringListNode *ln;
 
 	if (Lst_IsEmpty(&opts.create)) {
-		Global_SetExpand(".TARGETS", "");
+		Global_Set(".TARGETS", "");
 		return;
 	}
 
@@ -1159,8 +1159,8 @@ InitVarMake(const char *argv0)
 			make = abspath;
 	}
 
-	Global_SetExpand("MAKE", make);
-	Global_SetExpand(".MAKE", make);
+	Global_Set("MAKE", make);
+	Global_Set(".MAKE", make);
 }
 
 /*
@@ -1383,21 +1383,21 @@ main_Init(int argc, char **argv)
 	 */
 	Targ_Init();
 	Var_Init();
-	Global_SetExpand(".MAKE.OS", utsname.sysname);
-	Global_SetExpand("MACHINE", machine);
-	Global_SetExpand("MACHINE_ARCH", machine_arch);
+	Global_Set(".MAKE.OS", utsname.sysname);
+	Global_Set("MACHINE", machine);
+	Global_Set("MACHINE_ARCH", machine_arch);
 #ifdef MAKE_VERSION
-	Global_SetExpand("MAKE_VERSION", MAKE_VERSION);
+	Global_Set("MAKE_VERSION", MAKE_VERSION);
 #endif
-	Global_SetExpand(".newline", "\n"); /* handy for :@ loops */
+	Global_Set(".newline", "\n"); /* handy for :@ loops */
 	/*
 	 * This is the traditional preference for makefiles.
 	 */
 #ifndef MAKEFILE_PREFERENCE_LIST
 # define MAKEFILE_PREFERENCE_LIST "makefile Makefile"
 #endif
-	Global_SetExpand(MAKE_MAKEFILE_PREFERENCE, MAKEFILE_PREFERENCE_LIST);
-	Global_SetExpand(MAKE_DEPENDFILE, ".depend");
+	Global_Set(MAKE_MAKEFILE_PREFERENCE, MAKEFILE_PREFERENCE_LIST);
+	Global_Set(MAKE_DEPENDFILE, ".depend");
 
 	CmdOpts_Init();
 	allPrecious = FALSE;	/* Remove targets when interrupted */
@@ -1421,10 +1421,10 @@ main_Init(int argc, char **argv)
 	 */
 	Parse_Init();
 	InitVarMake(argv[0]);
-	Global_SetExpand(MAKEFLAGS, "");
-	Global_SetExpand(MAKEOVERRIDES, "");
-	Global_SetExpand("MFLAGS", "");
-	Global_SetExpand(".ALLTARGETS", "");
+	Global_Set(MAKEFLAGS, "");
+	Global_Set(MAKEOVERRIDES, "");
+	Global_Set("MFLAGS", "");
+	Global_Set(".ALLTARGETS", "");
 	/* some makefiles need to know this */
 	Var_Set(MAKE_LEVEL ".ENV", MAKE_LEVEL_ENV, VAR_CMDLINE);
 
@@ -1436,15 +1436,15 @@ main_Init(int argc, char **argv)
 		if (makelevel < 0)
 			makelevel = 0;
 		snprintf(tmp, sizeof tmp, "%d", makelevel);
-		Global_SetExpand(MAKE_LEVEL, tmp);
+		Global_Set(MAKE_LEVEL, tmp);
 		snprintf(tmp, sizeof tmp, "%u", myPid);
-		Global_SetExpand(".MAKE.PID", tmp);
+		Global_Set(".MAKE.PID", tmp);
 		snprintf(tmp, sizeof tmp, "%u", getppid());
-		Global_SetExpand(".MAKE.PPID", tmp);
+		Global_Set(".MAKE.PPID", tmp);
 		snprintf(tmp, sizeof tmp, "%u", getuid());
-		Global_SetExpand(".MAKE.UID", tmp);
+		Global_Set(".MAKE.UID", tmp);
 		snprintf(tmp, sizeof tmp, "%u", getgid());
-		Global_SetExpand(".MAKE.GID", tmp);
+		Global_Set(".MAKE.GID", tmp);
 	}
 	if (makelevel > 0) {
 		char pn[1024];
@@ -1499,7 +1499,7 @@ main_Init(int argc, char **argv)
 #ifndef NO_PWD_OVERRIDE
 	HandlePWD(&sa);
 #endif
-	Global_SetExpand(".CURDIR", curdir);
+	Global_Set(".CURDIR", curdir);
 
 	InitObjdir(machine, machine_arch);
 
@@ -2104,7 +2104,7 @@ SetErrorVars(GNode *gn)
 	/*
 	 * We can print this even if there is no .ERROR target.
 	 */
-	Global_SetExpand(".ERROR_TARGET", gn->name);
+	Global_Set(".ERROR_TARGET", gn->name);
 	Var_Delete(".ERROR_CMD", VAR_GLOBAL);
 
 	for (ln = gn->commands.first; ln != NULL; ln = ln->next) {

Index: src/usr.bin/make/meta.c
diff -u src/usr.bin/make/meta.c:1.171 src/usr.bin/make/meta.c:1.172
--- src/usr.bin/make/meta.c:1.171	Wed Feb  3 08:00:36 2021
+++ src/usr.bin/make/meta.c	Wed Feb  3 08:08:18 2021
@@ -1,4 +1,4 @@
-/*      $NetBSD: meta.c,v 1.171 2021/02/03 08:00:36 rillig Exp $ */
+/*      $NetBSD: meta.c,v 1.172 2021/02/03 08:08:18 rillig Exp $ */
 
 /*
  * Implement 'meta' mode.
@@ -569,7 +569,7 @@ meta_init(void)
 {
 #ifdef USE_FILEMON
 	/* this allows makefiles to test if we have filemon support */
-	Global_SetExpand(".MAKE.PATH_FILEMON", filemon_path());
+	Global_Set(".MAKE.PATH_FILEMON", filemon_path());
 #endif
 }
 
@@ -616,7 +616,7 @@ meta_mode_init(const char *make_mode)
 	 * This works be cause :H will generate '.' if there is no /
 	 * and :tA will resolve that to cwd.
 	 */
-	Global_SetExpand(MAKE_META_PREFIX,
+	Global_Set(MAKE_META_PREFIX,
 	    "Building ${.TARGET:H:tA}/${.TARGET:T}");
     }
     if (once)
@@ -784,11 +784,11 @@ meta_job_error(Job *job, GNode *gn, Bool
 		status, ignerr ? "(ignored)" : "");
     }
     if (gn != NULL)
-	Global_SetExpand(".ERROR_TARGET", GNode_Path(gn));
+	Global_Set(".ERROR_TARGET", GNode_Path(gn));
     getcwd(cwd, sizeof cwd);
-    Global_SetExpand(".ERROR_CWD", cwd);
+    Global_Set(".ERROR_CWD", cwd);
     if (pbm->meta_fname[0] != '\0') {
-	Global_SetExpand(".ERROR_META_FILE", pbm->meta_fname);
+	Global_Set(".ERROR_META_FILE", pbm->meta_fname);
     }
     meta_job_finish(job);
 }

Index: src/usr.bin/make/nonints.h
diff -u src/usr.bin/make/nonints.h:1.191 src/usr.bin/make/nonints.h:1.192
--- src/usr.bin/make/nonints.h:1.191	Wed Feb  3 08:00:36 2021
+++ src/usr.bin/make/nonints.h	Wed Feb  3 08:08:18 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: nonints.h,v 1.191 2021/02/03 08:00:36 rillig Exp $	*/
+/*	$NetBSD: nonints.h,v 1.192 2021/02/03 08:08:18 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -371,6 +371,7 @@ typedef enum VarExportMode {
 void Var_DeleteVar(const char *, GNode *);
 void Var_Delete(const char *, GNode *);
 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_SetWithFlags(const char *, const char *, GNode *, VarSetFlags);

Index: src/usr.bin/make/parse.c
diff -u src/usr.bin/make/parse.c:1.539 src/usr.bin/make/parse.c:1.540
--- src/usr.bin/make/parse.c:1.539	Wed Feb  3 08:00:36 2021
+++ src/usr.bin/make/parse.c	Wed Feb  3 08:08:18 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: parse.c,v 1.539 2021/02/03 08:00:36 rillig Exp $	*/
+/*	$NetBSD: parse.c,v 1.540 2021/02/03 08:08:18 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.539 2021/02/03 08:00:36 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.540 2021/02/03 08:08:18 rillig Exp $");
 
 /* types and constants */
 
@@ -1327,7 +1327,7 @@ ParseDoDependencySourcesEmpty(ParseSpeci
 		break;
 #ifdef POSIX
 	case SP_POSIX:
-		Global_SetExpand("%POSIX", "1003.2");
+		Global_Set("%POSIX", "1003.2");
 		break;
 #endif
 	default:

Index: src/usr.bin/make/suff.c
diff -u src/usr.bin/make/suff.c:1.342 src/usr.bin/make/suff.c:1.343
--- src/usr.bin/make/suff.c:1.342	Wed Feb  3 08:00:36 2021
+++ src/usr.bin/make/suff.c	Wed Feb  3 08:08:18 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: suff.c,v 1.342 2021/02/03 08:00:36 rillig Exp $	*/
+/*	$NetBSD: suff.c,v 1.343 2021/02/03 08:08:18 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.342 2021/02/03 08:00:36 rillig Exp $");
+MAKE_RCSID("$NetBSD: suff.c,v 1.343 2021/02/03 08:08:18 rillig Exp $");
 
 typedef List SuffixList;
 typedef ListNode SuffixListNode;
@@ -903,11 +903,11 @@ Suff_DoPaths(void)
 	}
 
 	flags = SearchPath_ToFlags(includesPath, "-I");
-	Global_SetExpand(".INCLUDES", flags);
+	Global_Set(".INCLUDES", flags);
 	free(flags);
 
 	flags = SearchPath_ToFlags(libsPath, "-L");
-	Global_SetExpand(".LIBS", flags);
+	Global_Set(".LIBS", flags);
 	free(flags);
 
 	SearchPath_Free(includesPath);

Index: src/usr.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.791 src/usr.bin/make/var.c:1.792
--- src/usr.bin/make/var.c:1.791	Wed Feb  3 08:00:36 2021
+++ src/usr.bin/make/var.c	Wed Feb  3 08:08:18 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.791 2021/02/03 08:00:36 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.792 2021/02/03 08:08:18 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -131,7 +131,7 @@
 #include "metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.791 2021/02/03 08:00:36 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.792 2021/02/03 08:08:18 rillig Exp $");
 
 typedef enum VarFlags {
 	VAR_NONE	= 0,
@@ -868,7 +868,7 @@ UnexportVar(const char *varname, Unexpor
 		char *cp;
 		(void)Var_Subst(expr, VAR_GLOBAL, VARE_WANTRES, &cp);
 		/* TODO: handle errors */
-		Global_SetExpand(MAKE_EXPORTED, cp);
+		Global_Set(MAKE_EXPORTED, cp);
 		free(cp);
 		free(expr);
 	}
@@ -1032,6 +1032,17 @@ Var_Set(const char *name, const char *va
 }
 
 void
+Global_Set(const char *name, const char *value)
+{
+	assert(value != NULL);
+
+	if (name[0] == '\0')
+		DEBUG0(VAR, "Variable name empty - ignored\n");
+	else
+		SetVar(name, value, VAR_GLOBAL, VAR_SET_NONE);
+}
+
+void
 Global_SetExpand(const char *name, const char *value)
 {
 	Var_Set(name, value, VAR_GLOBAL);

Reply via email to