Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/make Ensure VAR+=val on command line is handled corr...
details: https://anonhg.NetBSD.org/src/rev/ab5b0221437d
branches: trunk
changeset: 358012:ab5b0221437d
user: sjg <sjg%NetBSD.org@localhost>
date: Fri Dec 08 03:36:42 2017 +0000
description:
Ensure VAR+=val on command line is handled correctly
If VAR is not previously set, call Var_Set to deal with
the special case of VAR_CMD.
If VAR is previously set, and ctxt is VAR_CMD we should do the update
even if VAR_FROM_CMD is set.
diffstat:
usr.bin/make/unit-tests/varcmd.exp | 1 +
usr.bin/make/unit-tests/varcmd.mk | 7 +++++--
usr.bin/make/var.c | 10 +++++-----
3 files changed, 11 insertions(+), 7 deletions(-)
diffs (80 lines):
diff -r 0bdc3929d01a -r ab5b0221437d usr.bin/make/unit-tests/varcmd.exp
--- a/usr.bin/make/unit-tests/varcmd.exp Fri Dec 08 03:08:19 2017 +0000
+++ b/usr.bin/make/unit-tests/varcmd.exp Fri Dec 08 03:36:42 2017 +0000
@@ -1,6 +1,7 @@
default FU=<v>fu</v> FOO=<v>foo</v> VAR=<v></v>
two FU=<v>bar</v> FOO=<v>goo</v> VAR=<v></v>
immutable FU='bar'
+immutable FOO='goo'
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>
diff -r 0bdc3929d01a -r ab5b0221437d usr.bin/make/unit-tests/varcmd.mk
--- a/usr.bin/make/unit-tests/varcmd.mk Fri Dec 08 03:08:19 2017 +0000
+++ b/usr.bin/make/unit-tests/varcmd.mk Fri Dec 08 03:36:42 2017 +0000
@@ -1,4 +1,4 @@
-# $Id: varcmd.mk,v 1.2 2017/11/18 22:34:04 sjg Exp $
+# $Id: varcmd.mk,v 1.3 2017/12/08 03:36:42 sjg Exp $
#
# Test behaviour of recursive make and vars set on command line.
@@ -15,7 +15,7 @@
@echo "${TAG} FU=<v>${FU}</v> FOO=<v>${FOO}</v> VAR=<v>${VAR}</v>"
one: show
- @${.MAKE} -f ${MAKEFILE} FU=bar FOO=goo two
+ @${.MAKE} -f ${MAKEFILE} FU=bar FOO+=goo two
two: show
@${.MAKE} -f ${MAKEFILE} three
@@ -27,10 +27,13 @@
.ifmake two
# this should not work
FU+= oops
+FOO+= oops
_FU:= ${FU}
+_FOO:= ${FOO}
two: immutable
immutable:
@echo "$@ FU='${_FU}'"
+ @echo "$@ FOO='${_FOO}'"
.endif
.ifmake four
VAR=Internal
diff -r 0bdc3929d01a -r ab5b0221437d usr.bin/make/var.c
--- a/usr.bin/make/var.c Fri Dec 08 03:08:19 2017 +0000
+++ b/usr.bin/make/var.c Fri Dec 08 03:36:42 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: var.c,v 1.216 2017/11/18 22:34:04 sjg Exp $ */
+/* $NetBSD: var.c,v 1.217 2017/12/08 03:36:42 sjg Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.216 2017/11/18 22:34:04 sjg Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.217 2017/12/08 03:36:42 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.216 2017/11/18 22:34:04 sjg Exp $");
+__RCSID("$NetBSD: var.c,v 1.217 2017/12/08 03:36:42 sjg Exp $");
#endif
#endif /* not lint */
#endif
@@ -1064,8 +1064,8 @@
v = VarFind(name, ctxt, (ctxt == VAR_GLOBAL) ? (FIND_CMD|FIND_ENV) : 0);
if (v == NULL) {
- VarAdd(name, val, ctxt);
- } else if (!(v->flags & VAR_FROM_CMD)) {
+ Var_Set(name, val, ctxt, 0);
+ } else if (ctxt == VAR_CMD || !(v->flags & VAR_FROM_CMD)) {
Buf_AddByte(&v->val, ' ');
Buf_AddBytes(&v->val, strlen(val), val);
Home |
Main Index |
Thread Index |
Old Index