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: document interaction between cmdline and ...
details: https://anonhg.NetBSD.org/src/rev/c933aee7e5a9
branches: trunk
changeset: 952975:c933aee7e5a9
user: rillig <rillig%NetBSD.org@localhost>
date: Mon Feb 22 21:14:15 2021 +0000
description:
make: document interaction between cmdline and global variables
Make prevents global variables from being or becoming visible when a
command line variable of the same name is already defined.
There is a double safety net here. Even if the call to Var_DeleteExpand
were removed, there would be no noticeable effect, other than one less
line in the debug log.
No functional change.
diffstat:
usr.bin/make/var.c | 14 ++++++++++++--
1 files changed, 12 insertions(+), 2 deletions(-)
diffs (42 lines):
diff -r 0cb30e00fa40 -r c933aee7e5a9 usr.bin/make/var.c
--- a/usr.bin/make/var.c Mon Feb 22 20:45:46 2021 +0000
+++ b/usr.bin/make/var.c Mon Feb 22 21:14:15 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: var.c,v 1.831 2021/02/16 19:46:15 rillig Exp $ */
+/* $NetBSD: var.c,v 1.832 2021/02/22 21:14:15 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -140,7 +140,7 @@
#include "metachar.h"
/* "@(#)var.c 8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.831 2021/02/16 19:46:15 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.832 2021/02/22 21:14:15 rillig Exp $");
typedef enum VarFlags {
VFL_NONE = 0,
@@ -945,6 +945,14 @@
if (scope == SCOPE_GLOBAL) {
v = VarFind(name, SCOPE_CMDLINE, FALSE);
if (v != NULL) {
+ /*
+ * When there is a variable of the same name in the
+ * command line scope, the global variable would not
+ * be visible anywhere. Therefore there is no point
+ * in setting it at all.
+ *
+ * See 'scope == SCOPE_CMDLINE' below.
+ */
if (v->flags & VFL_FROM_CMD) {
DEBUG3(VAR, "%s:%s = %s ignored!\n",
scope->name, name, val);
@@ -966,6 +974,8 @@
* This var would normally prevent the same name being
* added to SCOPE_GLOBAL, so delete it from there if
* needed. Otherwise -V name may show the wrong value.
+ *
+ * See 'scope == SCOPE_GLOBAL' above.
*/
/* XXX: name is expanded for the second time */
Var_DeleteExpand(SCOPE_GLOBAL, name);
Home |
Main Index |
Thread Index |
Old Index