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/4087e0d757c2
branches:  trunk
changeset: 976191:4087e0d757c2
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 e0ef93223e82 -r 4087e0d757c2 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 e0ef93223e82 -r 4087e0d757c2 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