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(1): don't require nested variables to be d...



details:   https://anonhg.NetBSD.org/src/rev/11081d9584de
branches:  trunk
changeset: 938758:11081d9584de
user:      rillig <rillig%NetBSD.org@localhost>
date:      Mon Sep 14 07:04:56 2020 +0000

description:
make(1): don't require nested variables to be defined in conditions

This code only applies to lint mode (-dL) for now.  After a test phase
and a thorough check for possible side effects, it will be activated in
normal mode, too.  Having this code in lint mode is required to run
src/build.sh, which relies a lot on using variables with undefined
nested variables in conditions.

In the default mode, any errors about nested undefined variables are not
printed since in Var_Subst, oldVars is true.  Therefore, it is not urgent
to properly handle these nested variables correctly there.

diffstat:

 usr.bin/make/unit-tests/cond-undef-lint.exp |  1 -
 usr.bin/make/var.c                          |  9 ++++++---
 2 files changed, 6 insertions(+), 4 deletions(-)

diffs (41 lines):

diff -r 014952ab6688 -r 11081d9584de usr.bin/make/unit-tests/cond-undef-lint.exp
--- a/usr.bin/make/unit-tests/cond-undef-lint.exp       Mon Sep 14 06:50:31 2020 +0000
+++ b/usr.bin/make/unit-tests/cond-undef-lint.exp       Mon Sep 14 07:04:56 2020 +0000
@@ -2,7 +2,6 @@
 make: "cond-undef-lint.mk" line 35: Variable "UNDEF" is undefined
 make: "cond-undef-lint.mk" line 35: Variable "VAR." is undefined
 make: "cond-undef-lint.mk" line 42: Variable "VAR.defined" is undefined
-make: "cond-undef-lint.mk" line 66: Variable "NESTED_UNDEF" is undefined
 make: Fatal errors encountered -- cannot continue
 make: stopped in unit-tests
 exit status 1
diff -r 014952ab6688 -r 11081d9584de usr.bin/make/var.c
--- a/usr.bin/make/var.c        Mon Sep 14 06:50:31 2020 +0000
+++ b/usr.bin/make/var.c        Mon Sep 14 07:04:56 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: var.c,v 1.519 2020/09/13 21:03:14 rillig Exp $ */
+/*     $NetBSD: var.c,v 1.520 2020/09/14 07:04:56 rillig Exp $ */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -121,7 +121,7 @@
 #include    "metachar.h"
 
 /*     "@(#)var.c      8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.519 2020/09/13 21:03:14 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.520 2020/09/14 07:04:56 rillig Exp $");
 
 #define VAR_DEBUG_IF(cond, fmt, ...)   \
     if (!(DEBUG(VAR) && (cond)))       \
@@ -3618,7 +3618,10 @@
      */
     nstr = Buf_GetAll(&v->val, NULL);
     if (strchr(nstr, '$') != NULL && (eflags & VARE_WANTRES)) {
-       nstr = Var_Subst(nstr, ctxt, eflags);
+        VarEvalFlags nested_eflags = eflags;
+        if (DEBUG(LINT))
+            nested_eflags &= ~(unsigned)VARE_UNDEFERR;
+       nstr = Var_Subst(nstr, ctxt, nested_eflags);
        *freePtr = nstr;
     }
 



Home | Main Index | Thread Index | Old Index