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): remove dead code from Var_Subst
details: https://anonhg.NetBSD.org/src/rev/e3c8774cafbb
branches: trunk
changeset: 936518:e3c8774cafbb
user: rillig <rillig%NetBSD.org@localhost>
date: Tue Jul 28 16:42:22 2020 +0000
description:
make(1): remove dead code from Var_Subst
The first parameter from Var_Subst had been a literal NULL in all cases.
These have been fixed using this command:
sed -i 's|Var_Subst(NULL, |Var_Subst(|' *.c
The one remaining case was not found because the "NULL," was followed by
a line break instead of a space.
The removed code probably wouldn't have worked as expected anyway.
Expanding a single variable to a literal string would have led to
unexpected behavior for cases like ${VAR:M${pattern}}, in case pattern
would contain an unescaped ':' itself.
diffstat:
usr.bin/make/arch.c | 11 ++---
usr.bin/make/compat.c | 8 ++--
usr.bin/make/for.c | 8 ++--
usr.bin/make/job.c | 12 +++---
usr.bin/make/main.c | 32 ++++++++---------
usr.bin/make/make.c | 8 ++--
usr.bin/make/meta.c | 23 ++++++------
usr.bin/make/nonints.h | 4 +-
usr.bin/make/parse.c | 20 +++++-----
usr.bin/make/suff.c | 8 ++--
usr.bin/make/var.c | 91 +++++++++----------------------------------------
11 files changed, 83 insertions(+), 142 deletions(-)
diffs (truncated from 798 to 300 lines):
diff -r 029ada418d5a -r e3c8774cafbb usr.bin/make/arch.c
--- a/usr.bin/make/arch.c Tue Jul 28 16:26:37 2020 +0000
+++ b/usr.bin/make/arch.c Tue Jul 28 16:42:22 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: arch.c,v 1.76 2020/07/27 19:06:45 rillig Exp $ */
+/* $NetBSD: arch.c,v 1.77 2020/07/28 16:42:22 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: arch.c,v 1.76 2020/07/27 19:06:45 rillig Exp $";
+static char rcsid[] = "$NetBSD: arch.c,v 1.77 2020/07/28 16:42:22 rillig Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)arch.c 8.2 (Berkeley) 1/2/94";
#else
-__RCSID("$NetBSD: arch.c,v 1.76 2020/07/27 19:06:45 rillig Exp $");
+__RCSID("$NetBSD: arch.c,v 1.77 2020/07/28 16:42:22 rillig Exp $");
#endif
#endif /* not lint */
#endif
@@ -276,7 +276,7 @@
*cp++ = '\0';
if (subLibName) {
- libName = Var_Subst(NULL, libName, ctxt, VARE_UNDEFERR|VARE_WANTRES);
+ libName = Var_Subst(libName, ctxt, VARE_UNDEFERR|VARE_WANTRES);
}
@@ -356,8 +356,7 @@
char *oldMemName = memName;
size_t sz;
- memName = Var_Subst(NULL, memName, ctxt,
- VARE_UNDEFERR|VARE_WANTRES);
+ memName = Var_Subst(memName, ctxt, VARE_UNDEFERR | VARE_WANTRES);
/*
* Now form an archive spec and recurse to deal with nested
diff -r 029ada418d5a -r e3c8774cafbb usr.bin/make/compat.c
--- a/usr.bin/make/compat.c Tue Jul 28 16:26:37 2020 +0000
+++ b/usr.bin/make/compat.c Tue Jul 28 16:42:22 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: compat.c,v 1.114 2020/07/19 12:26:17 rillig Exp $ */
+/* $NetBSD: compat.c,v 1.115 2020/07/28 16:42:22 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -70,14 +70,14 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: compat.c,v 1.114 2020/07/19 12:26:17 rillig Exp $";
+static char rcsid[] = "$NetBSD: compat.c,v 1.115 2020/07/28 16:42:22 rillig Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)compat.c 8.2 (Berkeley) 3/19/94";
#else
-__RCSID("$NetBSD: compat.c,v 1.114 2020/07/19 12:26:17 rillig Exp $");
+__RCSID("$NetBSD: compat.c,v 1.115 2020/07/28 16:42:22 rillig Exp $");
#endif
#endif /* not lint */
#endif
@@ -235,7 +235,7 @@
doIt = FALSE;
cmdNode = Lst_Member(gn->commands, cmd);
- cmdStart = Var_Subst(NULL, cmd, gn, VARE_WANTRES);
+ cmdStart = Var_Subst(cmd, gn, VARE_WANTRES);
/*
* brk_string will return an argv with a NULL in av[0], thus causing
diff -r 029ada418d5a -r e3c8774cafbb usr.bin/make/for.c
--- a/usr.bin/make/for.c Tue Jul 28 16:26:37 2020 +0000
+++ b/usr.bin/make/for.c Tue Jul 28 16:42:22 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: for.c,v 1.55 2020/07/19 12:26:17 rillig Exp $ */
+/* $NetBSD: for.c,v 1.56 2020/07/28 16:42:22 rillig Exp $ */
/*
* Copyright (c) 1992, The Regents of the University of California.
@@ -30,14 +30,14 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: for.c,v 1.55 2020/07/19 12:26:17 rillig Exp $";
+static char rcsid[] = "$NetBSD: for.c,v 1.56 2020/07/28 16:42:22 rillig Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)for.c 8.1 (Berkeley) 6/6/93";
#else
-__RCSID("$NetBSD: for.c,v 1.55 2020/07/19 12:26:17 rillig Exp $");
+__RCSID("$NetBSD: for.c,v 1.56 2020/07/28 16:42:22 rillig Exp $");
#endif
#endif /* not lint */
#endif
@@ -216,7 +216,7 @@
* We can't do the escapes here - because we don't know whether
* we are substuting into ${...} or $(...).
*/
- sub = Var_Subst(NULL, ptr, VAR_GLOBAL, VARE_WANTRES);
+ sub = Var_Subst(ptr, VAR_GLOBAL, VARE_WANTRES);
/*
* Split into words allowing for quoted strings.
diff -r 029ada418d5a -r e3c8774cafbb usr.bin/make/job.c
--- a/usr.bin/make/job.c Tue Jul 28 16:26:37 2020 +0000
+++ b/usr.bin/make/job.c Tue Jul 28 16:42:22 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: job.c,v 1.202 2020/07/19 12:26:17 rillig Exp $ */
+/* $NetBSD: job.c,v 1.203 2020/07/28 16:42:22 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -70,14 +70,14 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: job.c,v 1.202 2020/07/19 12:26:17 rillig Exp $";
+static char rcsid[] = "$NetBSD: job.c,v 1.203 2020/07/28 16:42:22 rillig Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)job.c 8.2 (Berkeley) 3/19/94";
#else
-__RCSID("$NetBSD: job.c,v 1.202 2020/07/19 12:26:17 rillig Exp $");
+__RCSID("$NetBSD: job.c,v 1.203 2020/07/28 16:42:22 rillig Exp $");
#endif
#endif /* not lint */
#endif
@@ -729,7 +729,7 @@
numCommands += 1;
- cmdStart = cmd = Var_Subst(NULL, cmd, job->node, VARE_WANTRES);
+ cmdStart = cmd = Var_Subst(cmd, job->node, VARE_WANTRES);
cmdTemplate = "%s\n";
@@ -917,7 +917,7 @@
static int
JobSaveCommand(void *cmd, void *gn)
{
- cmd = Var_Subst(NULL, (char *)cmd, (GNode *)gn, VARE_WANTRES);
+ cmd = Var_Subst((char *)cmd, (GNode *)gn, VARE_WANTRES);
(void)Lst_AtEnd(postCommands->commands, cmd);
return 0;
}
@@ -2248,7 +2248,7 @@
Var_Set(MAKE_JOB_PREFIX, "---", VAR_GLOBAL);
}
- targPrefix = Var_Subst(NULL, "${" MAKE_JOB_PREFIX "}",
+ targPrefix = Var_Subst("${" MAKE_JOB_PREFIX "}",
VAR_GLOBAL, VARE_WANTRES);
}
diff -r 029ada418d5a -r e3c8774cafbb usr.bin/make/main.c
--- a/usr.bin/make/main.c Tue Jul 28 16:26:37 2020 +0000
+++ b/usr.bin/make/main.c Tue Jul 28 16:42:22 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.283 2020/07/20 18:12:48 sjg Exp $ */
+/* $NetBSD: main.c,v 1.284 2020/07/28 16:42:22 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -69,7 +69,7 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: main.c,v 1.283 2020/07/20 18:12:48 sjg Exp $";
+static char rcsid[] = "$NetBSD: main.c,v 1.284 2020/07/28 16:42:22 rillig Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
@@ -81,7 +81,7 @@
#if 0
static char sccsid[] = "@(#)main.c 8.3 (Berkeley) 3/19/94";
#else
-__RCSID("$NetBSD: main.c,v 1.283 2020/07/20 18:12:48 sjg Exp $");
+__RCSID("$NetBSD: main.c,v 1.284 2020/07/28 16:42:22 rillig Exp $");
#endif
#endif /* not lint */
#endif
@@ -772,7 +772,7 @@
/* expand variable substitutions */
if (strchr(path, '$') != 0)
- xpath = Var_Subst(NULL, path, VAR_GLOBAL, VARE_WANTRES);
+ xpath = Var_Subst(path, VAR_GLOBAL, VARE_WANTRES);
else
xpath = path;
@@ -838,7 +838,7 @@
char *mp = NULL;
if (!mode)
- mode = mp = Var_Subst(NULL, "${" MAKE_MODE ":tl}",
+ mode = mp = Var_Subst("${" MAKE_MODE ":tl}",
VAR_GLOBAL, VARE_WANTRES);
if (mode && *mode) {
@@ -875,8 +875,7 @@
char *p1;
if (strchr(var, '$')) {
- value = p1 = Var_Subst(NULL, var, VAR_GLOBAL,
- VARE_WANTRES);
+ value = p1 = Var_Subst(var, VAR_GLOBAL, VARE_WANTRES);
} else if (expandVars) {
char tmp[128];
int len = snprintf(tmp, sizeof(tmp), "${%s}", var);
@@ -884,8 +883,7 @@
if (len >= (int)sizeof(tmp))
Fatal("%s: variable name too big: %s",
progname, var);
- value = p1 = Var_Subst(NULL, tmp, VAR_GLOBAL,
- VARE_WANTRES);
+ value = p1 = Var_Subst(tmp, VAR_GLOBAL, VARE_WANTRES);
} else {
value = Var_Value(var, VAR_GLOBAL, &p1);
}
@@ -1348,7 +1346,7 @@
Fatal("%s: cannot open %s.", progname,
(char *)Lst_Datum(ln));
} else {
- p1 = Var_Subst(NULL, "${" MAKEFILE_PREFERENCE "}",
+ p1 = Var_Subst("${" MAKEFILE_PREFERENCE "}",
VAR_CMD, VARE_WANTRES);
if (p1) {
(void)str2Lst_Append(makefiles, p1, NULL);
@@ -1359,7 +1357,7 @@
/* In particular suppress .depend for '-r -V .OBJDIR -f /dev/null' */
if (!noBuiltins || !printVars) {
- makeDependfile = Var_Subst(NULL, "${.MAKE.DEPENDFILE:T}",
+ makeDependfile = Var_Subst("${.MAKE.DEPENDFILE:T}",
VAR_CMD, VARE_WANTRES);
doing_depend = TRUE;
(void)ReadMakefile(makeDependfile, NULL);
@@ -1379,7 +1377,7 @@
char *value;
int n;
- value = Var_Subst(NULL, "${.MAKE.JOBS}", VAR_GLOBAL, VARE_WANTRES);
+ value = Var_Subst("${.MAKE.JOBS}", VAR_GLOBAL, VARE_WANTRES);
n = strtol(value, NULL, 0);
if (n < 1) {
(void)fprintf(stderr, "%s: illegal value for .MAKE.JOBS -- must be positive integer!\n",
@@ -1429,7 +1427,7 @@
*/
static char VPATH[] = "${VPATH}";
- vpath = Var_Subst(NULL, VPATH, VAR_CMD, VARE_WANTRES);
+ vpath = Var_Subst(VPATH, VAR_CMD, VARE_WANTRES);
path = vpath;
do {
/* skip to end of directory */
@@ -2065,7 +2063,7 @@
Lst_ForEach(gn->commands, addErrorCMD, gn);
}
const char *expr = "${MAKE_PRINT_VAR_ON_ERROR:@v@$v='${$v}'\n@}";
- char *cp = Var_Subst(NULL, expr, VAR_GLOBAL, VARE_WANTRES);
+ char *cp = Var_Subst(expr, VAR_GLOBAL, VARE_WANTRES);
if (cp) {
if (*cp)
printf("%s", cp);
@@ -2093,7 +2091,7 @@
once = 0;
const char *expr = "${.MAKEFLAGS} ${.MAKEOVERRIDES:O:u:@v@$v=${$v:Q}@}";
- char *s = Var_Subst(NULL, expr, VAR_CMD, VARE_WANTRES);
+ char *s = Var_Subst(expr, VAR_CMD, VARE_WANTRES);
if (s != NULL && s[0] != '\0') {
#ifdef POSIX
setenv("MAKEFLAGS", s, 1);
@@ -2115,7 +2113,7 @@
* Honor $TMPDIR but only if it is valid.
* Ensure it ends with /.
*/
- tmpdir = Var_Subst(NULL, "${TMPDIR:tA:U" _PATH_TMP "}/", VAR_GLOBAL,
+ tmpdir = Var_Subst("${TMPDIR:tA:U" _PATH_TMP "}/", VAR_GLOBAL,
VARE_WANTRES);
if (stat(tmpdir, &st) < 0 || !S_ISDIR(st.st_mode)) {
free(tmpdir);
@@ -2209,7 +2207,7 @@
char *cp;
if (snprintf(tmp, sizeof(tmp), "${%s:U:tl}", name) < (int)(sizeof(tmp))) {
Home |
Main Index |
Thread Index |
Old Index