Add 4th arg (flags) to Var_Set so that VarLoopExpand can tell it not

to export interator variables when using context VAR_CMD.

Reviewed: christos
This commit is contained in:
sjg 2001-06-12 23:36:17 +00:00
parent 015345c74b
commit e28cc22621
10 changed files with 90 additions and 86 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: arch.c,v 1.32 2000/02/15 04:41:45 sjg Exp $ */
/* $NetBSD: arch.c,v 1.33 2001/06/12 23:36:17 sjg Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -39,14 +39,14 @@
*/
#ifdef MAKE_BOOTSTRAP
static char rcsid[] = "$NetBSD: arch.c,v 1.32 2000/02/15 04:41:45 sjg Exp $";
static char rcsid[] = "$NetBSD: arch.c,v 1.33 2001/06/12 23:36:17 sjg 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.32 2000/02/15 04:41:45 sjg Exp $");
__RCSID("$NetBSD: arch.c,v 1.33 2001/06/12 23:36:17 sjg Exp $");
#endif
#endif /* not lint */
#endif
@ -1148,9 +1148,9 @@ Arch_FindLib (gn, path)
free (libName);
#ifdef LIBRARIES
Var_Set (TARGET, gn->name, gn);
Var_Set (TARGET, gn->name, gn, 0);
#else
Var_Set (TARGET, gn->path == (char *) NULL ? gn->name : gn->path, gn);
Var_Set (TARGET, gn->path == (char *) NULL ? gn->name : gn->path, gn, 0);
#endif /* LIBRARIES */
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: compat.c,v 1.34 2001/06/01 20:33:37 sjg Exp $ */
/* $NetBSD: compat.c,v 1.35 2001/06/12 23:36:17 sjg Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@ -39,14 +39,14 @@
*/
#ifdef MAKE_BOOTSTRAP
static char rcsid[] = "$NetBSD: compat.c,v 1.34 2001/06/01 20:33:37 sjg Exp $";
static char rcsid[] = "$NetBSD: compat.c,v 1.35 2001/06/12 23:36:17 sjg 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.34 2001/06/01 20:33:37 sjg Exp $");
__RCSID("$NetBSD: compat.c,v 1.35 2001/06/12 23:36:17 sjg Exp $");
#endif
#endif /* not lint */
#endif
@ -400,7 +400,7 @@ CompatMake (gnp, pgnp)
if (Lst_Member (gn->iParents, pgn) != NILLNODE) {
char *p1;
Var_Set (IMPSRC, Var_Value(TARGET, gn, &p1), pgn);
Var_Set (IMPSRC, Var_Value(TARGET, gn, &p1), pgn, 0);
if (p1)
free(p1);
}
@ -494,7 +494,7 @@ CompatMake (gnp, pgnp)
} else {
if (Lst_Member (gn->iParents, pgn) != NILLNODE) {
char *p1;
Var_Set (IMPSRC, Var_Value(TARGET, gn, &p1), pgn);
Var_Set (IMPSRC, Var_Value(TARGET, gn, &p1), pgn, 0);
if (p1)
free(p1);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: for.c,v 1.10 2000/06/06 04:56:52 mycroft Exp $ */
/* $NetBSD: for.c,v 1.11 2001/06/12 23:36:17 sjg Exp $ */
/*
* Copyright (c) 1992, The Regents of the University of California.
@ -34,14 +34,14 @@
*/
#ifdef MAKE_BOOTSTRAP
static char rcsid[] = "$NetBSD: for.c,v 1.10 2000/06/06 04:56:52 mycroft Exp $";
static char rcsid[] = "$NetBSD: for.c,v 1.11 2001/06/12 23:36:17 sjg 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.10 2000/06/06 04:56:52 mycroft Exp $");
__RCSID("$NetBSD: for.c,v 1.11 2001/06/12 23:36:17 sjg Exp $");
#endif
#endif /* not lint */
#endif
@ -347,7 +347,7 @@ For_Run()
break;
for (i = 0; i < arg.nvars; i++) {
Var_Set(arg.vars[i], values[i], VAR_GLOBAL);
Var_Set(arg.vars[i], values[i], VAR_GLOBAL, 0);
if (DEBUG(FOR))
(void) fprintf(stderr, "--- %s = %s\n", arg.vars[i],
values[i]);

View File

@ -1,4 +1,4 @@
/* $NetBSD: job.c,v 1.50 2001/06/11 04:20:32 christos Exp $ */
/* $NetBSD: job.c,v 1.51 2001/06/12 23:36:17 sjg Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@ -39,14 +39,14 @@
*/
#ifdef MAKE_BOOTSTRAP
static char rcsid[] = "$NetBSD: job.c,v 1.50 2001/06/11 04:20:32 christos Exp $";
static char rcsid[] = "$NetBSD: job.c,v 1.51 2001/06/12 23:36:17 sjg 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.50 2001/06/11 04:20:32 christos Exp $");
__RCSID("$NetBSD: job.c,v 1.51 2001/06/12 23:36:17 sjg Exp $");
#endif
#endif /* not lint */
#endif
@ -1210,7 +1210,7 @@ Job_CheckCommands(gn, abortProc)
* .DEFAULT itself.
*/
Make_HandleUse(DEFAULT, gn);
Var_Set(IMPSRC, Var_Value(TARGET, gn, &p1), gn);
Var_Set(IMPSRC, Var_Value(TARGET, gn, &p1), gn, 0);
if (p1)
free(p1);
} else if (Dir_MTime(gn) == 0) {

View File

@ -1,4 +1,4 @@
/* $NetBSD: main.c,v 1.70 2001/06/10 02:31:00 sjg Exp $ */
/* $NetBSD: main.c,v 1.71 2001/06/12 23:36:17 sjg Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -39,7 +39,7 @@
*/
#ifdef MAKE_BOOTSTRAP
static char rcsid[] = "$NetBSD: main.c,v 1.70 2001/06/10 02:31:00 sjg Exp $";
static char rcsid[] = "$NetBSD: main.c,v 1.71 2001/06/12 23:36:17 sjg Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
@ -51,7 +51,7 @@ __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993\n\
#if 0
static char sccsid[] = "@(#)main.c 8.3 (Berkeley) 3/19/94";
#else
__RCSID("$NetBSD: main.c,v 1.70 2001/06/10 02:31:00 sjg Exp $");
__RCSID("$NetBSD: main.c,v 1.71 2001/06/12 23:36:17 sjg Exp $");
#endif
#endif /* not lint */
#endif
@ -190,7 +190,7 @@ MainParseArgs(argc, argv)
rearg: while((c = getopt(argc, argv, OPTFLAGS)) != -1) {
switch(c) {
case 'D':
Var_Set(optarg, "1", VAR_GLOBAL);
Var_Set(optarg, "1", VAR_GLOBAL, 0);
Var_Append(MAKEFLAGS, "-D", VAR_GLOBAL);
Var_Append(MAKEFLAGS, optarg, VAR_GLOBAL);
break;
@ -612,13 +612,13 @@ main(argc, argv)
*/
Var_Init(); /* Initialize the lists of variables for
* parsing arguments */
Var_Set(".CURDIR", curdir, VAR_GLOBAL);
Var_Set("MACHINE", machine, VAR_GLOBAL);
Var_Set("MACHINE_ARCH", machine_arch, VAR_GLOBAL);
Var_Set(".CURDIR", curdir, VAR_GLOBAL, 0);
Var_Set("MACHINE", machine, VAR_GLOBAL, 0);
Var_Set("MACHINE_ARCH", machine_arch, VAR_GLOBAL, 0);
#ifdef MAKE_VERSION
Var_Set("MAKE_VERSION", MAKE_VERSION, VAR_GLOBAL);
Var_Set("MAKE_VERSION", MAKE_VERSION, VAR_GLOBAL, 0);
#endif
Var_Set(".newline", "\n", VAR_GLOBAL); /* handy for :@ loops */
Var_Set(".newline", "\n", VAR_GLOBAL, 0); /* handy for :@ loops */
/*
* If the MAKEOBJDIR (or by default, the _PATH_OBJDIR) directory
@ -699,7 +699,7 @@ main(argc, argv)
Dir_Init(curdir != objdir ? curdir : NULL);
Parse_Init(); /* Need to initialize the paths of #include
* directories */
Var_Set(".OBJDIR", objdir, VAR_GLOBAL);
Var_Set(".OBJDIR", objdir, VAR_GLOBAL, 0);
/*
* Initialize various variables.
@ -707,11 +707,11 @@ main(argc, argv)
* .MAKEFLAGS gets set to the empty string just in case.
* MFLAGS also gets initialized empty, for compatibility.
*/
Var_Set("MAKE", argv[0], VAR_GLOBAL);
Var_Set(".MAKE", argv[0], VAR_GLOBAL);
Var_Set(MAKEFLAGS, "", VAR_GLOBAL);
Var_Set(MAKEOVERRIDES, "", VAR_GLOBAL);
Var_Set("MFLAGS", "", VAR_GLOBAL);
Var_Set("MAKE", argv[0], VAR_GLOBAL, 0);
Var_Set(".MAKE", argv[0], VAR_GLOBAL, 0);
Var_Set(MAKEFLAGS, "", VAR_GLOBAL, 0);
Var_Set(MAKEOVERRIDES, "", VAR_GLOBAL, 0);
Var_Set("MFLAGS", "", VAR_GLOBAL, 0);
/*
* First snag any flags out of the MAKE environment variable.
@ -763,7 +763,7 @@ main(argc, argv)
Var_Append(".TARGETS", name, VAR_GLOBAL);
}
} else
Var_Set(".TARGETS", "", VAR_GLOBAL);
Var_Set(".TARGETS", "", VAR_GLOBAL, 0);
/*
@ -983,7 +983,7 @@ ReadMakefile(p, q)
if (!strcmp(fname, "-")) {
Parse_File("(stdin)", stdin);
Var_Set("MAKEFILE", "", VAR_GLOBAL);
Var_Set("MAKEFILE", "", VAR_GLOBAL, 0);
} else {
setMAKEFILE = strcmp(fname, ".depend");
@ -1016,7 +1016,7 @@ ReadMakefile(p, q)
*/
found:
if (setMAKEFILE)
Var_Set("MAKEFILE", fname, VAR_GLOBAL);
Var_Set("MAKEFILE", fname, VAR_GLOBAL, 0);
Parse_File(fname, stream);
(void)fclose(stream);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: make.c,v 1.37 2001/06/11 01:50:58 wiz Exp $ */
/* $NetBSD: make.c,v 1.38 2001/06/12 23:36:17 sjg Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -39,14 +39,14 @@
*/
#ifdef MAKE_BOOTSTRAP
static char rcsid[] = "$NetBSD: make.c,v 1.37 2001/06/11 01:50:58 wiz Exp $";
static char rcsid[] = "$NetBSD: make.c,v 1.38 2001/06/12 23:36:17 sjg 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.37 2001/06/11 01:50:58 wiz Exp $");
__RCSID("$NetBSD: make.c,v 1.38 2001/06/12 23:36:17 sjg Exp $");
#endif
#endif /* not lint */
#endif
@ -645,9 +645,9 @@ Make_Update (cgn)
while ((ln = Lst_Next (cgn->iParents)) != NILLNODE) {
pgn = (GNode *)Lst_Datum (ln);
if (pgn->flags & REMAKE) {
Var_Set (IMPSRC, cname, pgn);
Var_Set (IMPSRC, cname, pgn, 0);
if (cpref != NULL)
Var_Set (PREFIX, cpref, pgn);
Var_Set (PREFIX, cpref, pgn, 0);
}
}
if (p1)
@ -770,15 +770,15 @@ Make_DoAllVar (gn)
Lst_ForEach (gn->children, MakeAddAllSrc, (ClientData) gn);
if (!Var_Exists (OODATE, gn)) {
Var_Set (OODATE, "", gn);
Var_Set (OODATE, "", gn, 0);
}
if (!Var_Exists (ALLSRC, gn)) {
Var_Set (ALLSRC, "", gn);
Var_Set (ALLSRC, "", gn, 0);
}
if (gn->type & OP_JOIN) {
char *p1;
Var_Set (TARGET, Var_Value (ALLSRC, gn, &p1), gn);
Var_Set (TARGET, Var_Value (ALLSRC, gn, &p1), gn, 0);
if (p1)
free(p1);
}
@ -990,14 +990,14 @@ Make_ExpandUse (targs)
continue;
*eoa = '\0';
*eon = '\0';
Var_Set (MEMBER, eoa + 1, gn);
Var_Set (ARCHIVE, gn->name, gn);
Var_Set (MEMBER, eoa + 1, gn, 0);
Var_Set (ARCHIVE, gn->name, gn, 0);
*eoa = '(';
*eon = ')';
}
(void)Dir_MTime(gn);
Var_Set (TARGET, gn->path ? gn->path : gn->name, gn);
Var_Set (TARGET, gn->path ? gn->path : gn->name, gn, 0);
Lst_ForEach (gn->children, MakeUnmark, (ClientData)gn);
Lst_ForEach (gn->children, MakeHandleUse, (ClientData)gn);
Suff_FindDeps (gn);

View File

@ -1,4 +1,4 @@
/* $NetBSD: nonints.h,v 1.21 2001/05/29 17:37:52 christos Exp $ */
/* $NetBSD: nonints.h,v 1.22 2001/06/12 23:36:18 sjg Exp $ */
/*-
* Copyright (c) 1988, 1989, 1990, 1993
@ -141,7 +141,7 @@ void Targ_Propagate __P((void));
/* var.c */
void Var_Delete __P((char *, GNode *));
void Var_Set __P((char *, char *, GNode *));
void Var_Set __P((char *, char *, GNode *, int));
void Var_Append __P((char *, char *, GNode *));
Boolean Var_Exists __P((char *, GNode *));
char *Var_Value __P((char *, GNode *, char **));

View File

@ -1,4 +1,4 @@
/* $NetBSD: parse.c,v 1.69 2001/06/10 02:31:00 sjg Exp $ */
/* $NetBSD: parse.c,v 1.70 2001/06/12 23:36:18 sjg Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -39,14 +39,14 @@
*/
#ifdef MAKE_BOOTSTRAP
static char rcsid[] = "$NetBSD: parse.c,v 1.69 2001/06/10 02:31:00 sjg Exp $";
static char rcsid[] = "$NetBSD: parse.c,v 1.70 2001/06/12 23:36:18 sjg 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.69 2001/06/10 02:31:00 sjg Exp $");
__RCSID("$NetBSD: parse.c,v 1.70 2001/06/12 23:36:18 sjg Exp $");
#endif
#endif /* not lint */
#endif
@ -1158,7 +1158,7 @@ ParseDoDependency (line)
break;
#ifdef POSIX
case Posix:
Var_Set("%POSIX", "1003.2", VAR_GLOBAL);
Var_Set("%POSIX", "1003.2", VAR_GLOBAL, 0);
break;
#endif
default:
@ -1549,12 +1549,12 @@ Parse_DoVar (line, ctxt)
* so that it gets substituted!
*/
if (!Var_Exists(line, ctxt))
Var_Set(line, "", ctxt);
Var_Set(line, "", ctxt, 0);
cp = Var_Subst(NULL, cp, ctxt, FALSE);
oldVars = oldOldVars;
Var_Set(line, cp, ctxt);
Var_Set(line, cp, ctxt, 0);
free(cp);
} else if (type == VAR_SHELL) {
Boolean freeCmd = FALSE; /* TRUE if the command needs to be freed, i.e.
@ -1572,7 +1572,7 @@ Parse_DoVar (line, ctxt)
}
res = Cmd_Exec(cp, &err);
Var_Set(line, res, ctxt);
Var_Set(line, res, ctxt, 0);
free(res);
if (err)
@ -1584,7 +1584,7 @@ Parse_DoVar (line, ctxt)
/*
* Normal assignment -- just do it.
*/
Var_Set(line, cp, ctxt);
Var_Set(line, cp, ctxt, 0);
}
if (strcmp(line, MAKEOVERRIDES) == 0)
ExportMAKEFLAGS(0); /* re-export MAKEFLAGS */
@ -1890,12 +1890,12 @@ ParseSetParseFile(fname)
slash = strrchr(fname, '/');
if (slash == 0) {
Var_Set(".PARSEDIR", ".", VAR_GLOBAL);
Var_Set(".PARSEFILE", fname, VAR_GLOBAL);
Var_Set(".PARSEDIR", ".", VAR_GLOBAL, 0);
Var_Set(".PARSEFILE", fname, VAR_GLOBAL, 0);
} else {
*slash = '\0';
Var_Set(".PARSEDIR", fname, VAR_GLOBAL);
Var_Set(".PARSEFILE", slash+1, VAR_GLOBAL);
Var_Set(".PARSEDIR", fname, VAR_GLOBAL, 0);
Var_Set(".PARSEFILE", slash+1, VAR_GLOBAL, 0);
*slash = '/';
}
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: suff.c,v 1.32 2001/05/08 15:15:53 aymeric Exp $ */
/* $NetBSD: suff.c,v 1.33 2001/06/12 23:36:18 sjg Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -39,14 +39,14 @@
*/
#ifdef MAKE_BOOTSTRAP
static char rcsid[] = "$NetBSD: suff.c,v 1.32 2001/05/08 15:15:53 aymeric Exp $";
static char rcsid[] = "$NetBSD: suff.c,v 1.33 2001/06/12 23:36:18 sjg 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.32 2001/05/08 15:15:53 aymeric Exp $");
__RCSID("$NetBSD: suff.c,v 1.33 2001/06/12 23:36:18 sjg Exp $");
#endif
#endif /* not lint */
#endif
@ -1032,9 +1032,9 @@ Suff_DoPaths()
}
}
Var_Set(".INCLUDES", ptr = Dir_MakeFlags("-I", inIncludes), VAR_GLOBAL);
Var_Set(".INCLUDES", ptr = Dir_MakeFlags("-I", inIncludes), VAR_GLOBAL, 0);
free(ptr);
Var_Set(".LIBS", ptr = Dir_MakeFlags("-L", inLibs), VAR_GLOBAL);
Var_Set(".LIBS", ptr = Dir_MakeFlags("-L", inLibs), VAR_GLOBAL, 0);
free(ptr);
Lst_Destroy(inIncludes, Dir_Destroy);
@ -1811,7 +1811,7 @@ SuffFindArchiveDeps(gn, slst)
*/
for (i = (sizeof(copy)/sizeof(copy[0]))-1; i >= 0; i--) {
char *p1;
Var_Set(copy[i], Var_Value(copy[i], mem, &p1), gn);
Var_Set(copy[i], Var_Value(copy[i], mem, &p1), gn, 0);
if (p1)
free(p1);
@ -1832,8 +1832,8 @@ SuffFindArchiveDeps(gn, slst)
/*
* Set the other two local variables required for this target.
*/
Var_Set (MEMBER, name, gn);
Var_Set (ARCHIVE, gn->name, gn);
Var_Set (MEMBER, name, gn, 0);
Var_Set (ARCHIVE, gn->name, gn, 0);
if (ms != NULL) {
/*
@ -2064,10 +2064,10 @@ SuffFindNormalDeps(gn, slst)
continue;
}
Var_Set(TARGET, gn->path ? gn->path : gn->name, gn);
Var_Set(TARGET, gn->path ? gn->path : gn->name, gn, 0);
pref = (targ != NULL) ? targ->pref : gn->name;
Var_Set(PREFIX, pref, gn);
Var_Set(PREFIX, pref, gn, 0);
/*
* Now we've got the important local variables set, expand any sources
@ -2103,7 +2103,7 @@ sfnd_abort:
targ->suff->searchPath));
if (gn->path != NULL) {
char *ptr;
Var_Set(TARGET, gn->path, gn);
Var_Set(TARGET, gn->path, gn, 0);
if (targ != NULL) {
/*
@ -2126,7 +2126,7 @@ sfnd_abort:
else
ptr = gn->path;
Var_Set(PREFIX, ptr, gn);
Var_Set(PREFIX, ptr, gn, 0);
gn->path[savep] = savec;
} else {
@ -2143,7 +2143,7 @@ sfnd_abort:
else
ptr = gn->path;
Var_Set(PREFIX, ptr, gn);
Var_Set(PREFIX, ptr, gn, 0);
}
}
}
@ -2230,9 +2230,9 @@ sfnd_abort:
*/
targ->node->type |= OP_DEPS_FOUND;
Var_Set(PREFIX, targ->pref, targ->node);
Var_Set(PREFIX, targ->pref, targ->node, 0);
Var_Set(TARGET, targ->node->name, targ->node);
Var_Set(TARGET, targ->node->name, targ->node, 0);
}
}
@ -2339,14 +2339,14 @@ SuffFindDeps (gn, slst)
Arch_FindLib (gn, s->searchPath);
} else {
gn->suffix = NULL;
Var_Set (TARGET, gn->name, gn);
Var_Set (TARGET, gn->name, gn, 0);
}
/*
* Because a library (-lfoo) target doesn't follow the standard
* filesystem conventions, we don't set the regular variables for
* the thing. .PREFIX is simply made empty...
*/
Var_Set(PREFIX, "", gn);
Var_Set(PREFIX, "", gn, 0);
} else {
SuffFindNormalDeps(gn, slst);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: var.c,v 1.64 2001/06/10 02:31:01 sjg Exp $ */
/* $NetBSD: var.c,v 1.65 2001/06/12 23:36:18 sjg Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -39,14 +39,14 @@
*/
#ifdef MAKE_BOOTSTRAP
static char rcsid[] = "$NetBSD: var.c,v 1.64 2001/06/10 02:31:01 sjg Exp $";
static char rcsid[] = "$NetBSD: var.c,v 1.65 2001/06/12 23:36:18 sjg 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.64 2001/06/10 02:31:01 sjg Exp $");
__RCSID("$NetBSD: var.c,v 1.65 2001/06/12 23:36:18 sjg Exp $");
#endif
#endif /* not lint */
#endif
@ -164,6 +164,9 @@ typedef struct Var {
#define VAR_MATCH_END 0x10 /* Match at end of word */
#define VAR_NOSUBST 0x20 /* don't expand vars in VarGetPattern */
/* Var_Set flags */
#define VAR_NO_EXPORT 0x01 /* do not export */
typedef struct {
char *lhs; /* String to match */
int leftLen; /* Length of string */
@ -435,10 +438,11 @@ Var_Delete(name, ctxt)
*-----------------------------------------------------------------------
*/
void
Var_Set (name, val, ctxt)
Var_Set (name, val, ctxt, flags)
char *name; /* name of variable to set */
char *val; /* value to give to the variable */
GNode *ctxt; /* context in which to set it */
int flags;
{
register Var *v;
char *cp = name;
@ -467,7 +471,7 @@ Var_Set (name, val, ctxt)
* Any variables given on the command line are automatically exported
* to the environment (as per POSIX standard)
*/
if (ctxt == VAR_CMD) {
if (ctxt == VAR_CMD && (flags & VAR_NO_EXPORT) == 0) {
setenv(name, val, 1);
@ -1268,7 +1272,7 @@ VarLoopExpand (ctx, word, addSpace, buf, loopp)
int slen;
if (word && *word) {
Var_Set(loop->tvar, word, loop->ctxt);
Var_Set(loop->tvar, word, loop->ctxt, VAR_NO_EXPORT);
s = Var_Subst(NULL, loop->str, loop->ctxt, loop->err);
if (s != NULL && *s != '\0') {
if (addSpace && *s != '\n')
@ -2026,7 +2030,7 @@ Var_Parse (str, ctxt, err, lengthPtr, freePtr)
if (emsg)
Error (emsg, str);
else
Var_Set(v->name, newStr, v_ctxt);
Var_Set(v->name, newStr, v_ctxt, 0);
if (newStr)
free(newStr);
break;
@ -2035,7 +2039,7 @@ Var_Parse (str, ctxt, err, lengthPtr, freePtr)
break;
/* FALLTHROUGH */
default:
Var_Set(v->name, pattern.rhs, v_ctxt);
Var_Set(v->name, pattern.rhs, v_ctxt, 0);
break;
}
if (v->flags & VAR_JUNK) {