diff options
| author | sjg <sjg@NetBSD.org> | 2008-05-15 21:05:54 +0000 |
|---|---|---|
| committer | sjg <sjg@NetBSD.org> | 2008-05-15 21:05:54 +0000 |
| commit | f2c43a72d5a2cafc08497ceabccdfd8a58b6ed76 (patch) | |
| tree | afb73dfbecbb011c3087ff1d3f4bc059394eb529 /usr.bin/make | |
| parent | f147f68f575ae2624bcf2e3a40e63dd252da4896 (diff) | |
VAR_CMD context is used by conditionals and other purposes, so
actually set VAR_FROM_CMD when appropriate and only skip setting in
VAR_GLOBAL when that flag is set.
Diffstat (limited to 'usr.bin/make')
| -rw-r--r-- | usr.bin/make/unit-tests/test.exp | 4 | ||||
| -rw-r--r-- | usr.bin/make/var.c | 27 |
2 files changed, 20 insertions, 11 deletions
diff --git a/usr.bin/make/unit-tests/test.exp b/usr.bin/make/unit-tests/test.exp index 9cfaed9c953..0b32046231a 100644 --- a/usr.bin/make/unit-tests/test.exp +++ b/usr.bin/make/unit-tests/test.exp @@ -302,5 +302,5 @@ three FU=<v>bar</v> FOO=<v>goo</v> VAR=<v></v> four FU=<v>bar</v> FOO=<v>goo</v> VAR=<v>Internal</v> five FU=<v>bar</v> FOO=<v>goo</v> VAR=<v>Internal</v> five v=is x k=is x -six v=is x k=is x -show-v v=override k=is x +six v=is y k=is y +show-v v=override k=override diff --git a/usr.bin/make/var.c b/usr.bin/make/var.c index e8bc8a735c1..f1a6e2ee43f 100644 --- a/usr.bin/make/var.c +++ b/usr.bin/make/var.c @@ -1,4 +1,4 @@ -/* $NetBSD: var.c,v 1.130 2008/05/15 18:25:12 sjg Exp $ */ +/* $NetBSD: var.c,v 1.131 2008/05/15 21:05:54 sjg Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -69,14 +69,14 @@ */ #ifndef MAKE_NATIVE -static char rcsid[] = "$NetBSD: var.c,v 1.130 2008/05/15 18:25:12 sjg Exp $"; +static char rcsid[] = "$NetBSD: var.c,v 1.131 2008/05/15 21:05:54 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.130 2008/05/15 18:25:12 sjg Exp $"); +__RCSID("$NetBSD: var.c,v 1.131 2008/05/15 21:05:54 sjg Exp $"); #endif #endif /* not lint */ #endif @@ -191,6 +191,7 @@ typedef struct Var { #define VAR_REEXPORT 32 /* Indicate if var needs re-export. * This would be true if it contains $'s */ +#define VAR_FROM_CMD 64 /* Variable came from command line */ } Var; /* @@ -729,6 +730,8 @@ Var_Export(char *str, int isExport) * VAR_CMD->context is searched. This is done to avoid the literally * thousands of unnecessary strcmp's that used to be done to * set, say, $(@) or $(<). + * If the context is VAR_GLOBAL though, we check if the variable + * was set in VAR_CMD from the command line and skip it if so. *----------------------------------------------------------------------- */ void @@ -746,14 +749,18 @@ Var_Set(const char *name, const char *val, GNode *ctxt, int flags) name = Var_Subst(NULL, cp, ctxt, 0); } else name = cp; -#ifdef skip_global_if_cmd if (ctxt == VAR_GLOBAL) { v = VarFind(name, VAR_CMD, 0); if (v != (Var *)NIL) { - goto out; + if ((v->flags & VAR_FROM_CMD)) { + if (DEBUG(VAR)) { + fprintf(debug_file, "%s:%s = %s ignored!\n", ctxt->name, name, val); + } + goto out; + } + VarFreeEnv(v, TRUE); } } -#endif v = VarFind(name, ctxt, 0); if (v == (Var *)NIL) { VarAdd(name, val, ctxt); @@ -773,7 +780,11 @@ Var_Set(const char *name, const char *val, GNode *ctxt, int flags) * to the environment (as per POSIX standard) */ if (ctxt == VAR_CMD && (flags & VAR_NO_EXPORT) == 0) { - + if (v == (Var *)NIL) { + /* we just added it */ + v = VarFind(name, ctxt, 0); + } + v->flags |= VAR_FROM_CMD; /* * If requested, don't export these in the environment * individually. We still put them in MAKEOVERRIDES so @@ -785,9 +796,7 @@ Var_Set(const char *name, const char *val, GNode *ctxt, int flags) Var_Append(MAKEOVERRIDES, name, VAR_GLOBAL); } -#ifdef skip_global_if_cmd out: -#endif if (name != cp) free(UNCONST(name)); if (v != (Var *)NIL) |
