Module Name: src Committed By: christos Date: Sat Jan 9 00:55:17 UTC 2016
Modified Files: src/usr.bin/make: arch.c compat.c cond.c for.c job.c main.c make.c nonints.h parse.c suff.c var.c Log Message: Preserve $$ in := assignments.. FOO=\$$CRAP BAR:=${FOO} all: echo ${FOO} echo ${BAR} To generate a diff of this commit: cvs rdiff -u -r1.64 -r1.65 src/usr.bin/make/arch.c cvs rdiff -u -r1.101 -r1.102 src/usr.bin/make/compat.c cvs rdiff -u -r1.71 -r1.72 src/usr.bin/make/cond.c cvs rdiff -u -r1.50 -r1.51 src/usr.bin/make/for.c cvs rdiff -u -r1.181 -r1.182 src/usr.bin/make/job.c cvs rdiff -u -r1.235 -r1.236 src/usr.bin/make/main.c cvs rdiff -u -r1.92 -r1.93 src/usr.bin/make/make.c cvs rdiff -u -r1.69 -r1.70 src/usr.bin/make/nonints.h cvs rdiff -u -r1.206 -r1.207 src/usr.bin/make/parse.c cvs rdiff -u -r1.75 -r1.76 src/usr.bin/make/suff.c cvs rdiff -u -r1.200 -r1.201 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.64 src/usr.bin/make/arch.c:1.65 --- src/usr.bin/make/arch.c:1.64 Sun Oct 11 00:51:24 2015 +++ src/usr.bin/make/arch.c Fri Jan 8 19:55:17 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: arch.c,v 1.64 2015/10/11 04:51:24 sjg Exp $ */ +/* $NetBSD: arch.c,v 1.65 2016/01/09 00:55:17 christos Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -69,14 +69,14 @@ */ #ifndef MAKE_NATIVE -static char rcsid[] = "$NetBSD: arch.c,v 1.64 2015/10/11 04:51:24 sjg Exp $"; +static char rcsid[] = "$NetBSD: arch.c,v 1.65 2016/01/09 00:55:17 christos 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.64 2015/10/11 04:51:24 sjg Exp $"); +__RCSID("$NetBSD: arch.c,v 1.65 2016/01/09 00:55:17 christos Exp $"); #endif #endif /* not lint */ #endif @@ -261,7 +261,7 @@ Arch_ParseArchive(char **linePtr, Lst no void *freeIt; char *result; - result = Var_Parse(cp, ctxt, TRUE, TRUE, &length, &freeIt); + result = Var_Parse(cp, ctxt, TRUE, TRUE, FALSE, &length, &freeIt); if (freeIt) free(freeIt); if (result == var_Error) { @@ -276,7 +276,7 @@ Arch_ParseArchive(char **linePtr, Lst no *cp++ = '\0'; if (subLibName) { - libName = Var_Subst(NULL, libName, ctxt, TRUE, TRUE); + libName = Var_Subst(NULL, libName, ctxt, TRUE, TRUE, FALSE); } @@ -302,7 +302,7 @@ Arch_ParseArchive(char **linePtr, Lst no void *freeIt; char *result; - result = Var_Parse(cp, ctxt, TRUE, TRUE, &length, &freeIt); + result = Var_Parse(cp, ctxt, TRUE, TRUE, FALSE, &length, &freeIt); if (freeIt) free(freeIt); if (result == var_Error) { @@ -355,7 +355,7 @@ Arch_ParseArchive(char **linePtr, Lst no char *oldMemName = memName; size_t sz; - memName = Var_Subst(NULL, memName, ctxt, TRUE, TRUE); + memName = Var_Subst(NULL, memName, ctxt, TRUE, TRUE, FALSE); /* * Now form an archive spec and recurse to deal with nested Index: src/usr.bin/make/compat.c diff -u src/usr.bin/make/compat.c:1.101 src/usr.bin/make/compat.c:1.102 --- src/usr.bin/make/compat.c:1.101 Sun Oct 11 00:51:24 2015 +++ src/usr.bin/make/compat.c Fri Jan 8 19:55:17 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: compat.c,v 1.101 2015/10/11 04:51:24 sjg Exp $ */ +/* $NetBSD: compat.c,v 1.102 2016/01/09 00:55:17 christos 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.101 2015/10/11 04:51:24 sjg Exp $"; +static char rcsid[] = "$NetBSD: compat.c,v 1.102 2016/01/09 00:55:17 christos 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.101 2015/10/11 04:51:24 sjg Exp $"); +__RCSID("$NetBSD: compat.c,v 1.102 2016/01/09 00:55:17 christos Exp $"); #endif #endif /* not lint */ #endif @@ -210,7 +210,7 @@ CompatRunCommand(void *cmdp, void *gnp) doIt = FALSE; cmdNode = Lst_Member(gn->commands, cmd); - cmdStart = Var_Subst(NULL, cmd, gn, FALSE, TRUE); + cmdStart = Var_Subst(NULL, cmd, gn, FALSE, TRUE, FALSE); /* * brk_string will return an argv with a NULL in av[0], thus causing Index: src/usr.bin/make/cond.c diff -u src/usr.bin/make/cond.c:1.71 src/usr.bin/make/cond.c:1.72 --- src/usr.bin/make/cond.c:1.71 Tue Dec 1 19:28:24 2015 +++ src/usr.bin/make/cond.c Fri Jan 8 19:55:17 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: cond.c,v 1.71 2015/12/02 00:28:24 sjg Exp $ */ +/* $NetBSD: cond.c,v 1.72 2016/01/09 00:55:17 christos Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -70,14 +70,14 @@ */ #ifndef MAKE_NATIVE -static char rcsid[] = "$NetBSD: cond.c,v 1.71 2015/12/02 00:28:24 sjg Exp $"; +static char rcsid[] = "$NetBSD: cond.c,v 1.72 2016/01/09 00:55:17 christos Exp $"; #else #include <sys/cdefs.h> #ifndef lint #if 0 static char sccsid[] = "@(#)cond.c 8.2 (Berkeley) 1/2/94"; #else -__RCSID("$NetBSD: cond.c,v 1.71 2015/12/02 00:28:24 sjg Exp $"); +__RCSID("$NetBSD: cond.c,v 1.72 2016/01/09 00:55:17 christos Exp $"); #endif #endif /* not lint */ #endif @@ -289,7 +289,7 @@ CondGetArg(char **linePtr, char **argPtr int len; void *freeIt; - cp2 = Var_Parse(cp, VAR_CMD, TRUE, TRUE, &len, &freeIt); + cp2 = Var_Parse(cp, VAR_CMD, TRUE, TRUE, FALSE, &len, &freeIt); Buf_AddBytes(&buf, strlen(cp2), cp2); if (freeIt) free(freeIt); @@ -575,7 +575,7 @@ CondGetString(Boolean doEval, Boolean *q case '$': /* if we are in quotes, then an undefined variable is ok */ str = Var_Parse(condExpr, VAR_CMD, (qt ? 0 : doEval), - TRUE, &len, freeIt); + TRUE, FALSE, &len, freeIt); if (str == var_Error) { if (*freeIt) { free(*freeIt); @@ -827,7 +827,7 @@ get_mpt_arg(char **linePtr, char **argPt /* We do all the work here and return the result as the length */ *argPtr = NULL; - val = Var_Parse(cp - 1, VAR_CMD, FALSE, TRUE, &length, &freeIt); + val = Var_Parse(cp - 1, VAR_CMD, FALSE, TRUE, FALSE, &length, &freeIt); /* * Advance *linePtr to beyond the closing ). Note that * we subtract one because 'length' is calculated from 'cp - 1'. Index: src/usr.bin/make/for.c diff -u src/usr.bin/make/for.c:1.50 src/usr.bin/make/for.c:1.51 --- src/usr.bin/make/for.c:1.50 Sun Oct 11 00:51:24 2015 +++ src/usr.bin/make/for.c Fri Jan 8 19:55:17 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: for.c,v 1.50 2015/10/11 04:51:24 sjg Exp $ */ +/* $NetBSD: for.c,v 1.51 2016/01/09 00:55:17 christos 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.50 2015/10/11 04:51:24 sjg Exp $"; +static char rcsid[] = "$NetBSD: for.c,v 1.51 2016/01/09 00:55:17 christos 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.50 2015/10/11 04:51:24 sjg Exp $"); +__RCSID("$NetBSD: for.c,v 1.51 2016/01/09 00:55:17 christos Exp $"); #endif #endif /* not lint */ #endif @@ -216,7 +216,7 @@ For_Eval(char *line) * 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, FALSE, TRUE); + sub = Var_Subst(NULL, ptr, VAR_GLOBAL, FALSE, TRUE, FALSE); /* * Split into words allowing for quoted strings. Index: src/usr.bin/make/job.c diff -u src/usr.bin/make/job.c:1.181 src/usr.bin/make/job.c:1.182 --- src/usr.bin/make/job.c:1.181 Sun Oct 11 00:51:24 2015 +++ src/usr.bin/make/job.c Fri Jan 8 19:55:17 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: job.c,v 1.181 2015/10/11 04:51:24 sjg Exp $ */ +/* $NetBSD: job.c,v 1.182 2016/01/09 00:55:17 christos 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.181 2015/10/11 04:51:24 sjg Exp $"; +static char rcsid[] = "$NetBSD: job.c,v 1.182 2016/01/09 00:55:17 christos 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.181 2015/10/11 04:51:24 sjg Exp $"); +__RCSID("$NetBSD: job.c,v 1.182 2016/01/09 00:55:17 christos Exp $"); #endif #endif /* not lint */ #endif @@ -702,7 +702,7 @@ JobPrintCommand(void *cmdp, void *jobp) numCommands += 1; - cmdStart = cmd = Var_Subst(NULL, cmd, job->node, FALSE, TRUE); + cmdStart = cmd = Var_Subst(NULL, cmd, job->node, FALSE, TRUE, FALSE); cmdTemplate = "%s\n"; @@ -890,7 +890,7 @@ JobPrintCommand(void *cmdp, void *jobp) static int JobSaveCommand(void *cmd, void *gn) { - cmd = Var_Subst(NULL, (char *)cmd, (GNode *)gn, FALSE, TRUE); + cmd = Var_Subst(NULL, (char *)cmd, (GNode *)gn, FALSE, TRUE, FALSE); (void)Lst_AtEnd(postCommands->commands, cmd); return(0); } @@ -2179,7 +2179,7 @@ Job_SetPrefix(void) } targPrefix = Var_Subst(NULL, "${" MAKE_JOB_PREFIX "}", - VAR_GLOBAL, FALSE, TRUE); + VAR_GLOBAL, FALSE, TRUE, FALSE); } /*- Index: src/usr.bin/make/main.c diff -u src/usr.bin/make/main.c:1.235 src/usr.bin/make/main.c:1.236 --- src/usr.bin/make/main.c:1.235 Sun Oct 25 01:24:44 2015 +++ src/usr.bin/make/main.c Fri Jan 8 19:55:17 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.235 2015/10/25 05:24:44 sjg Exp $ */ +/* $NetBSD: main.c,v 1.236 2016/01/09 00:55:17 christos Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -69,7 +69,7 @@ */ #ifndef MAKE_NATIVE -static char rcsid[] = "$NetBSD: main.c,v 1.235 2015/10/25 05:24:44 sjg Exp $"; +static char rcsid[] = "$NetBSD: main.c,v 1.236 2016/01/09 00:55:17 christos Exp $"; #else #include <sys/cdefs.h> #ifndef lint @@ -81,7 +81,7 @@ __COPYRIGHT("@(#) Copyright (c) 1988, 19 #if 0 static char sccsid[] = "@(#)main.c 8.3 (Berkeley) 3/19/94"; #else -__RCSID("$NetBSD: main.c,v 1.235 2015/10/25 05:24:44 sjg Exp $"); +__RCSID("$NetBSD: main.c,v 1.236 2016/01/09 00:55:17 christos Exp $"); #endif #endif /* not lint */ #endif @@ -692,7 +692,7 @@ Main_SetObjdir(const char *path) /* expand variable substitutions */ if (strchr(path, '$') != 0) { snprintf(buf, MAXPATHLEN, "%s", path); - path = p = Var_Subst(NULL, buf, VAR_GLOBAL, FALSE, TRUE); + path = p = Var_Subst(NULL, buf, VAR_GLOBAL, FALSE, TRUE, FALSE); } if (path[0] != '/') { @@ -776,7 +776,7 @@ MakeMode(const char *mode) if (!mode) mode = mp = Var_Subst(NULL, "${" MAKE_MODE ":tl}", - VAR_GLOBAL, FALSE, TRUE); + VAR_GLOBAL, FALSE, TRUE, FALSE); if (mode && *mode) { if (strstr(mode, "compat")) { @@ -1218,7 +1218,7 @@ main(int argc, char **argv) (char *)Lst_Datum(ln)); } else { p1 = Var_Subst(NULL, "${" MAKEFILE_PREFERENCE "}", - VAR_CMD, FALSE, TRUE); + VAR_CMD, FALSE, TRUE, FALSE); if (p1) { (void)str2Lst_Append(makefiles, p1, NULL); (void)Lst_Find(makefiles, NULL, ReadMakefile); @@ -1229,7 +1229,7 @@ main(int argc, char **argv) /* In particular suppress .depend for '-r -V .OBJDIR -f /dev/null' */ if (!noBuiltins || !printVars) { makeDependfile = Var_Subst(NULL, "${.MAKE.DEPENDFILE:T}", - VAR_CMD, FALSE, TRUE); + VAR_CMD, FALSE, TRUE, FALSE); doing_depend = TRUE; (void)ReadMakefile(makeDependfile, NULL); doing_depend = FALSE; @@ -1268,7 +1268,7 @@ main(int argc, char **argv) */ static char VPATH[] = "${VPATH}"; - vpath = Var_Subst(NULL, VPATH, VAR_CMD, FALSE, TRUE); + vpath = Var_Subst(NULL, VPATH, VAR_CMD, FALSE, TRUE, FALSE); path = vpath; do { /* skip to end of directory */ @@ -1316,7 +1316,7 @@ main(int argc, char **argv) if (strchr(var, '$')) { value = p1 = Var_Subst(NULL, var, VAR_GLOBAL, - FALSE, TRUE); + FALSE, TRUE, FALSE); } else if (expandVars) { char tmp[128]; @@ -1324,7 +1324,7 @@ main(int argc, char **argv) Fatal("%s: variable name too big: %s", progname, var); value = p1 = Var_Subst(NULL, tmp, VAR_GLOBAL, - FALSE, TRUE); + FALSE, TRUE, FALSE); } else { value = Var_Value(var, VAR_GLOBAL, &p1); } @@ -1862,7 +1862,7 @@ PrintOnError(GNode *gn, const char *s) } strncpy(tmp, "${MAKE_PRINT_VAR_ON_ERROR:@v@$v='${$v}'\n@}", sizeof(tmp) - 1); - cp = Var_Subst(NULL, tmp, VAR_GLOBAL, FALSE, TRUE); + cp = Var_Subst(NULL, tmp, VAR_GLOBAL, FALSE, TRUE, FALSE); if (cp) { if (*cp) printf("%s", cp); @@ -1893,7 +1893,7 @@ Main_ExportMAKEFLAGS(Boolean first) strncpy(tmp, "${.MAKEFLAGS} ${.MAKEOVERRIDES:O:u:@v@$v=${$v:Q}@}", sizeof(tmp)); - s = Var_Subst(NULL, tmp, VAR_CMD, FALSE, TRUE); + s = Var_Subst(NULL, tmp, VAR_CMD, FALSE, TRUE, FALSE); if (s && *s) { #ifdef POSIX setenv("MAKEFLAGS", s, 1); @@ -1916,7 +1916,7 @@ getTmpdir(void) * Ensure it ends with /. */ tmpdir = Var_Subst(NULL, "${TMPDIR:tA:U" _PATH_TMP "}/", VAR_GLOBAL, - FALSE, TRUE); + FALSE, TRUE, FALSE); if (stat(tmpdir, &st) < 0 || !S_ISDIR(st.st_mode)) { free(tmpdir); tmpdir = bmake_strdup(_PATH_TMP); @@ -1971,7 +1971,7 @@ getBoolean(const char *name, Boolean bf) char *cp; if (snprintf(tmp, sizeof(tmp), "${%s:tl}", name) < (int)(sizeof(tmp))) { - cp = Var_Subst(NULL, tmp, VAR_GLOBAL, FALSE, TRUE); + cp = Var_Subst(NULL, tmp, VAR_GLOBAL, FALSE, TRUE, FALSE); if (cp) { switch(*cp) { Index: src/usr.bin/make/make.c diff -u src/usr.bin/make/make.c:1.92 src/usr.bin/make/make.c:1.93 --- src/usr.bin/make/make.c:1.92 Sun Oct 11 00:51:24 2015 +++ src/usr.bin/make/make.c Fri Jan 8 19:55:17 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: make.c,v 1.92 2015/10/11 04:51:24 sjg Exp $ */ +/* $NetBSD: make.c,v 1.93 2016/01/09 00:55:17 christos Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -69,14 +69,14 @@ */ #ifndef MAKE_NATIVE -static char rcsid[] = "$NetBSD: make.c,v 1.92 2015/10/11 04:51:24 sjg Exp $"; +static char rcsid[] = "$NetBSD: make.c,v 1.93 2016/01/09 00:55:17 christos Exp $"; #else #include <sys/cdefs.h> #ifndef lint #if 0 static char sccsid[] = "@(#)make.c 8.1 (Berkeley) 6/6/93"; #else -__RCSID("$NetBSD: make.c,v 1.92 2015/10/11 04:51:24 sjg Exp $"); +__RCSID("$NetBSD: make.c,v 1.93 2016/01/09 00:55:17 christos Exp $"); #endif #endif /* not lint */ #endif @@ -485,7 +485,7 @@ Make_HandleUse(GNode *cgn, GNode *pgn) if (gn->name) free(gn->name); } - gn->name = Var_Subst(NULL, gn->uname, pgn, FALSE, TRUE); + gn->name = Var_Subst(NULL, gn->uname, pgn, FALSE, TRUE, FALSE); if (gn->name && gn->uname && strcmp(gn->name, gn->uname) != 0) { /* See if we have a target for this node. */ tgn = Targ_FindNode(gn->name, TARG_NOCREATE); Index: src/usr.bin/make/nonints.h diff -u src/usr.bin/make/nonints.h:1.69 src/usr.bin/make/nonints.h:1.70 --- src/usr.bin/make/nonints.h:1.69 Sun Oct 11 00:51:24 2015 +++ src/usr.bin/make/nonints.h Fri Jan 8 19:55:17 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: nonints.h,v 1.69 2015/10/11 04:51:24 sjg Exp $ */ +/* $NetBSD: nonints.h,v 1.70 2016/01/09 00:55:17 christos Exp $ */ /*- * Copyright (c) 1988, 1989, 1990, 1993 @@ -182,8 +182,9 @@ void Var_Set(const char *, const char *, void Var_Append(const char *, const char *, GNode *); Boolean Var_Exists(const char *, GNode *); char *Var_Value(const char *, GNode *, char **); -char *Var_Parse(const char *, GNode *, Boolean, Boolean, int *, void **); -char *Var_Subst(const char *, const char *, GNode *, Boolean, Boolean); +char *Var_Parse(const char *, GNode *, Boolean, Boolean, Boolean, + int *, void **); +char *Var_Subst(const char *, const char *, GNode *, Boolean, Boolean, Boolean); char *Var_GetTail(const char *); char *Var_GetHead(const char *); void Var_Init(void); Index: src/usr.bin/make/parse.c diff -u src/usr.bin/make/parse.c:1.206 src/usr.bin/make/parse.c:1.207 --- src/usr.bin/make/parse.c:1.206 Wed Nov 25 19:23:04 2015 +++ src/usr.bin/make/parse.c Fri Jan 8 19:55:17 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: parse.c,v 1.206 2015/11/26 00:23:04 sjg Exp $ */ +/* $NetBSD: parse.c,v 1.207 2016/01/09 00:55:17 christos Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -69,14 +69,14 @@ */ #ifndef MAKE_NATIVE -static char rcsid[] = "$NetBSD: parse.c,v 1.206 2015/11/26 00:23:04 sjg Exp $"; +static char rcsid[] = "$NetBSD: parse.c,v 1.207 2016/01/09 00:55:17 christos Exp $"; #else #include <sys/cdefs.h> #ifndef lint #if 0 static char sccsid[] = "@(#)parse.c 8.3 (Berkeley) 3/19/94"; #else -__RCSID("$NetBSD: parse.c,v 1.206 2015/11/26 00:23:04 sjg Exp $"); +__RCSID("$NetBSD: parse.c,v 1.207 2016/01/09 00:55:17 christos Exp $"); #endif #endif /* not lint */ #endif @@ -802,7 +802,7 @@ ParseMessage(char *line) while (isspace((u_char)*line)) line++; - line = Var_Subst(NULL, line, VAR_CMD, FALSE, TRUE); + line = Var_Subst(NULL, line, VAR_CMD, FALSE, TRUE, FALSE); Parse_Error(mtype, "%s", line); free(line); @@ -1219,7 +1219,7 @@ ParseDoDependency(char *line) int length; void *freeIt; - (void)Var_Parse(cp, VAR_CMD, TRUE, TRUE, &length, &freeIt); + (void)Var_Parse(cp, VAR_CMD, TRUE, TRUE, FALSE, &length, &freeIt); if (freeIt) free(freeIt); cp += length-1; @@ -1934,7 +1934,7 @@ Parse_DoVar(char *line, GNode *ctxt) if (!Var_Exists(line, ctxt)) Var_Set(line, "", ctxt, 0); - cp = Var_Subst(NULL, cp, ctxt, FALSE, TRUE); + cp = Var_Subst(NULL, cp, ctxt, FALSE, TRUE, TRUE); oldVars = oldOldVars; freeCp = TRUE; @@ -1949,7 +1949,7 @@ Parse_DoVar(char *line, GNode *ctxt) * expansion on the whole thing. The resulting string will need * freeing when we're done, so set freeCmd to TRUE. */ - cp = Var_Subst(NULL, cp, VAR_CMD, TRUE, TRUE); + cp = Var_Subst(NULL, cp, VAR_CMD, TRUE, TRUE, FALSE); freeCp = TRUE; } @@ -2288,7 +2288,7 @@ ParseDoInclude(char *line) * Substitute for any variables in the file name before trying to * find the thing. */ - file = Var_Subst(NULL, file, VAR_CMD, FALSE, TRUE); + file = Var_Subst(NULL, file, VAR_CMD, FALSE, TRUE, FALSE); Parse_include_file(file, endc == '>', silent); free(file); @@ -2518,7 +2518,7 @@ ParseTraditionalInclude(char *line) * Substitute for any variables in the file name before trying to * find the thing. */ - all_files = Var_Subst(NULL, file, VAR_CMD, FALSE, TRUE); + all_files = Var_Subst(NULL, file, VAR_CMD, FALSE, TRUE, FALSE); if (*file == '\0') { Parse_Error(PARSE_FATAL, @@ -2586,7 +2586,7 @@ ParseGmakeExport(char *line) /* * Expand the value before putting it in the environment. */ - value = Var_Subst(NULL, value, VAR_CMD, FALSE, TRUE); + value = Var_Subst(NULL, value, VAR_CMD, FALSE, TRUE, FALSE); setenv(variable, value, 1); } #endif @@ -3135,7 +3135,7 @@ Parse_File(const char *name, int fd) * variables expanded before being parsed. Tell the variable * module to complain if some variable is undefined... */ - line = Var_Subst(NULL, line, VAR_CMD, TRUE, TRUE); + line = Var_Subst(NULL, line, VAR_CMD, TRUE, TRUE, FALSE); /* * Need a non-circular list for the target nodes Index: src/usr.bin/make/suff.c diff -u src/usr.bin/make/suff.c:1.75 src/usr.bin/make/suff.c:1.76 --- src/usr.bin/make/suff.c:1.75 Sun Dec 20 17:44:10 2015 +++ src/usr.bin/make/suff.c Fri Jan 8 19:55:17 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: suff.c,v 1.75 2015/12/20 22:44:10 sjg Exp $ */ +/* $NetBSD: suff.c,v 1.76 2016/01/09 00:55:17 christos Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -69,14 +69,14 @@ */ #ifndef MAKE_NATIVE -static char rcsid[] = "$NetBSD: suff.c,v 1.75 2015/12/20 22:44:10 sjg Exp $"; +static char rcsid[] = "$NetBSD: suff.c,v 1.76 2016/01/09 00:55:17 christos Exp $"; #else #include <sys/cdefs.h> #ifndef lint #if 0 static char sccsid[] = "@(#)suff.c 8.4 (Berkeley) 3/21/94"; #else -__RCSID("$NetBSD: suff.c,v 1.75 2015/12/20 22:44:10 sjg Exp $"); +__RCSID("$NetBSD: suff.c,v 1.76 2016/01/09 00:55:17 christos Exp $"); #endif #endif /* not lint */ #endif @@ -1556,7 +1556,7 @@ SuffExpandChildren(LstNode cln, GNode *p if (DEBUG(SUFF)) { fprintf(debug_file, "Expanding \"%s\"...", cgn->name); } - cp = Var_Subst(NULL, cgn->name, pgn, TRUE, TRUE); + cp = Var_Subst(NULL, cgn->name, pgn, TRUE, TRUE, FALSE); if (cp != NULL) { Lst members = Lst_Init(FALSE); @@ -1609,7 +1609,7 @@ SuffExpandChildren(LstNode cln, GNode *p int len; void *freeIt; - junk = Var_Parse(cp, pgn, TRUE, TRUE, &len, &freeIt); + junk = Var_Parse(cp, pgn, TRUE, TRUE, FALSE, &len, &freeIt); if (junk != var_Error) { cp += len - 1; } Index: src/usr.bin/make/var.c diff -u src/usr.bin/make/var.c:1.200 src/usr.bin/make/var.c:1.201 --- src/usr.bin/make/var.c:1.200 Tue Dec 1 02:26:08 2015 +++ src/usr.bin/make/var.c Fri Jan 8 19:55:17 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: var.c,v 1.200 2015/12/01 07:26:08 sjg Exp $ */ +/* $NetBSD: var.c,v 1.201 2016/01/09 00:55:17 christos Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -69,14 +69,14 @@ */ #ifndef MAKE_NATIVE -static char rcsid[] = "$NetBSD: var.c,v 1.200 2015/12/01 07:26:08 sjg Exp $"; +static char rcsid[] = "$NetBSD: var.c,v 1.201 2016/01/09 00:55:17 christos Exp $"; #else #include <sys/cdefs.h> #ifndef lint #if 0 static char sccsid[] = "@(#)var.c 8.3 (Berkeley) 3/19/94"; #else -__RCSID("$NetBSD: var.c,v 1.200 2015/12/01 07:26:08 sjg Exp $"); +__RCSID("$NetBSD: var.c,v 1.201 2016/01/09 00:55:17 christos Exp $"); #endif #endif /* not lint */ #endif @@ -542,7 +542,7 @@ Var_Delete(const char *name, GNode *ctxt char *cp; if (strchr(name, '$')) { - cp = Var_Subst(NULL, name, VAR_GLOBAL, FALSE, TRUE); + cp = Var_Subst(NULL, name, VAR_GLOBAL, FALSE, TRUE, FALSE); } else { cp = (char *)name; } @@ -633,7 +633,7 @@ Var_Export1(const char *name, int parent } n = snprintf(tmp, sizeof(tmp), "${%s}", name); if (n < (int)sizeof(tmp)) { - val = Var_Subst(NULL, tmp, VAR_GLOBAL, FALSE, TRUE); + val = Var_Subst(NULL, tmp, VAR_GLOBAL, FALSE, TRUE, FALSE); setenv(name, val, 1); free(val); } @@ -701,7 +701,7 @@ Var_ExportVars(void) int ac; int i; - val = Var_Subst(NULL, tmp, VAR_GLOBAL, FALSE, TRUE); + val = Var_Subst(NULL, tmp, VAR_GLOBAL, FALSE, TRUE, FALSE); if (*val) { av = brk_string(val, &ac, FALSE, &as); for (i = 0; i < ac; i++) { @@ -741,7 +741,7 @@ Var_Export(char *str, int isExport) } else { track = VAR_EXPORT_PARENT; } - val = Var_Subst(NULL, str, VAR_GLOBAL, FALSE, TRUE); + val = Var_Subst(NULL, str, VAR_GLOBAL, FALSE, TRUE, FALSE); if (*val) { av = brk_string(val, &ac, FALSE, &as); for (i = 0; i < ac; i++) { @@ -831,7 +831,7 @@ Var_UnExport(char *str) /* Using .MAKE.EXPORTED */ n = snprintf(tmp, sizeof(tmp), "${" MAKE_EXPORTED ":O:u}"); if (n < (int)sizeof(tmp)) { - vlist = Var_Subst(NULL, tmp, VAR_GLOBAL, FALSE, TRUE); + vlist = Var_Subst(NULL, tmp, VAR_GLOBAL, FALSE, TRUE, FALSE); } } if (vlist) { @@ -861,7 +861,7 @@ Var_UnExport(char *str) n = snprintf(tmp, sizeof(tmp), "${" MAKE_EXPORTED ":N%s}", v->name); if (n < (int)sizeof(tmp)) { - cp = Var_Subst(NULL, tmp, VAR_GLOBAL, FALSE, TRUE); + cp = Var_Subst(NULL, tmp, VAR_GLOBAL, FALSE, TRUE, FALSE); Var_Set(MAKE_EXPORTED, cp, VAR_GLOBAL, 0); free(cp); } @@ -916,7 +916,7 @@ Var_Set(const char *name, const char *va * point in searching them all just to save a bit of memory... */ if (strchr(name, '$') != NULL) { - expanded_name = Var_Subst(NULL, name, ctxt, FALSE, TRUE); + expanded_name = Var_Subst(NULL, name, ctxt, FALSE, TRUE, FALSE); if (expanded_name[0] == 0) { if (DEBUG(VAR)) { fprintf(debug_file, "Var_Set(\"%s\", \"%s\", ...) " @@ -1026,7 +1026,7 @@ Var_Append(const char *name, const char char *expanded_name = NULL; if (strchr(name, '$') != NULL) { - expanded_name = Var_Subst(NULL, name, ctxt, FALSE, TRUE); + expanded_name = Var_Subst(NULL, name, ctxt, FALSE, TRUE, FALSE); if (expanded_name[0] == 0) { if (DEBUG(VAR)) { fprintf(debug_file, "Var_Append(\"%s\", \"%s\", ...) " @@ -1091,7 +1091,7 @@ Var_Exists(const char *name, GNode *ctxt char *cp; if ((cp = strchr(name, '$')) != NULL) { - cp = Var_Subst(NULL, name, ctxt, FALSE, TRUE); + cp = Var_Subst(NULL, name, ctxt, FALSE, TRUE, FALSE); } v = VarFind(cp ? cp : name, ctxt, FIND_CMD|FIND_GLOBAL|FIND_ENV); free(cp); @@ -1389,7 +1389,7 @@ VarSYSVMatch(GNode *ctx, Var_Parse_State addSpace = TRUE; if ((ptr = Str_SYSVMatch(word, pat->lhs, &len)) != NULL) { - varexp = Var_Subst(NULL, pat->rhs, ctx, FALSE, TRUE); + varexp = Var_Subst(NULL, pat->rhs, ctx, FALSE, TRUE, FALSE); Str_SYSVSubst(buf, varexp, ptr, len); free(varexp); } else { @@ -1809,7 +1809,7 @@ VarLoopExpand(GNode *ctx MAKE_ATTR_UNUSE if (word && *word) { Var_Set(loop->tvar, word, loop->ctxt, VAR_NO_EXPORT); - s = Var_Subst(NULL, loop->str, loop->ctxt, loop->errnum, TRUE); + s = Var_Subst(NULL, loop->str, loop->ctxt, loop->errnum, TRUE, FALSE); if (s != NULL && *s != '\0') { if (addSpace && *s != '\n') Buf_AddByte(buf, ' '); @@ -2190,7 +2190,7 @@ VarGetPattern(GNode *ctxt, Var_Parse_Sta * delimiter, assume it's a variable * substitution and recurse. */ - cp2 = Var_Parse(cp, ctxt, errnum, TRUE, &len, &freeIt); + cp2 = Var_Parse(cp, ctxt, errnum, TRUE, FALSE, &len, &freeIt); Buf_AddBytes(&buf, strlen(cp2), cp2); free(freeIt); cp += len - 1; @@ -2464,6 +2464,7 @@ static char * ApplyModifiers(char *nstr, const char *tstr, int startc, int endc, Var *v, GNode *ctxt, Boolean errnum, Boolean wantit, + Boolean assign, int *lengthPtr, void **freePtr) { const char *start; @@ -2494,7 +2495,7 @@ ApplyModifiers(char *nstr, const char *t int rlen; int c; - rval = Var_Parse(tstr, ctxt, errnum, wantit, &rlen, &freeIt); + rval = Var_Parse(tstr, ctxt, errnum, wantit, assign, &rlen, &freeIt); /* * If we have not parsed up to endc or ':', @@ -2519,8 +2520,8 @@ ApplyModifiers(char *nstr, const char *t int used; nstr = ApplyModifiers(nstr, rval, - 0, 0, - v, ctxt, errnum, wantit, &used, freePtr); + 0, 0, v, ctxt, + errnum, wantit, assign, &used, freePtr); if (nstr == var_Error || (nstr == varNoError && errnum == 0) || strlen(rval) != (size_t) used) { @@ -2708,7 +2709,8 @@ ApplyModifiers(char *nstr, const char *t int len; void *freeIt; - cp2 = Var_Parse(cp, ctxt, errnum, wantit_, &len, &freeIt); + cp2 = Var_Parse(cp, ctxt, errnum, wantit_, + assign, &len, &freeIt); Buf_AddBytes(&buf, strlen(cp2), cp2); free(freeIt); cp += len - 1; @@ -3152,7 +3154,7 @@ ApplyModifiers(char *nstr, const char *t * expand it. */ cp2 = pattern; - pattern = Var_Subst(NULL, cp2, ctxt, errnum, TRUE); + pattern = Var_Subst(NULL, cp2, ctxt, errnum, TRUE, assign); free(cp2); } if (DEBUG(VAR)) @@ -3602,7 +3604,7 @@ ApplyModifiers(char *nstr, const char *t /* coverity[+alloc : arg-*4] */ char * Var_Parse(const char *str, GNode *ctxt, - Boolean errnum, Boolean wantit, + Boolean errnum, Boolean wantit, Boolean assign, int *lengthPtr, void **freePtr) { const char *tstr; /* Pointer into str */ @@ -3708,7 +3710,8 @@ Var_Parse(const char *str, GNode *ctxt, if (*tstr == '$') { int rlen; void *freeIt; - char *rval = Var_Parse(tstr, ctxt, errnum, wantit, &rlen, &freeIt); + char *rval = Var_Parse(tstr, ctxt, errnum, wantit, + assign, &rlen, &freeIt); if (rval != NULL) { Buf_AddBytes(&buf, strlen(rval), rval); } @@ -3855,7 +3858,7 @@ Var_Parse(const char *str, GNode *ctxt, */ nstr = Buf_GetAll(&v->val, NULL); if (strchr(nstr, '$') != NULL) { - nstr = Var_Subst(NULL, nstr, ctxt, errnum, wantit); + nstr = Var_Subst(NULL, nstr, ctxt, errnum, wantit, assign); *freePtr = nstr; } @@ -3868,7 +3871,8 @@ Var_Parse(const char *str, GNode *ctxt, extraFree = NULL; if (extramodifiers != NULL) { nstr = ApplyModifiers(nstr, extramodifiers, '(', ')', - v, ctxt, errnum, wantit, &used, &extraFree); + v, ctxt, errnum, wantit, assign, + &used, &extraFree); } if (haveModifier) { @@ -3876,7 +3880,8 @@ Var_Parse(const char *str, GNode *ctxt, tstr++; nstr = ApplyModifiers(nstr, tstr, startc, endc, - v, ctxt, errnum, wantit, &used, freePtr); + v, ctxt, errnum, wantit, assign, + &used, freePtr); tstr += used; free(extraFree); } else { @@ -3941,6 +3946,7 @@ Var_Parse(const char *str, GNode *ctxt, * ctxt the context wherein to find variables * undefErr TRUE if undefineds are an error * wantit TRUE if we actually want the result + * assign TRUE if we actually want the result * * Results: * The resulting string. @@ -3951,7 +3957,7 @@ Var_Parse(const char *str, GNode *ctxt, */ char * Var_Subst(const char *var, const char *str, GNode *ctxt, - Boolean undefErr, Boolean wantit) + Boolean undefErr, Boolean wantit, Boolean assign) { Buffer buf; /* Buffer for forming things */ char *val; /* Value to substitute for a variable */ @@ -3975,6 +3981,8 @@ Var_Subst(const char *var, const char *s * In such a case, we skip over the escape character and store the * dollar sign into the buffer directly. */ + if (assign) + Buf_AddByte(&buf, *str); str++; Buf_AddByte(&buf, *str); str++; @@ -4049,7 +4057,7 @@ Var_Subst(const char *var, const char *s continue; } - val = Var_Parse(str, ctxt, undefErr, wantit, &length, &freeIt); + val = Var_Parse(str, ctxt, undefErr, wantit, assign, &length, &freeIt); /* * When we come down here, val should either point to the