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): fix bug in evaluation of indirect vari...



details:   https://anonhg.NetBSD.org/src/rev/1f8693907e0b
branches:  trunk
changeset: 944472:1f8693907e0b
user:      rillig <rillig%NetBSD.org@localhost>
date:      Wed Sep 30 05:58:22 2020 +0000

description:
make(1): fix bug in evaluation of indirect variable modifiers

Since 2020-09-22, when indirect variable modifiers were applied to a
variable expression based on an undefined variable, these modifiers did
not change the state of a variable expression from undefined to defined.
The modifiers that do this are :D, :U, :L, :P.  Minimal example:

        ${VARNAME:${:UL}}

The :L modifier from the inner expression sets the value of the outer
expression to its variable name, in this case "VARNAME".  The outer
expression was not marked as being defined though, which resulted in a
"Malformed conditional" error.

In the commit from 2020-09-22, vardebug.exp had changed a lot, and I had
not inspected the change closely.  The important detail was in lines 56
and 60, where VAR_JUNK|VAR_KEEP changed into VEF_UNDEF, thereby losing
the VEF_DEF bit.

diffstat:

 usr.bin/make/unit-tests/vardebug.exp               |  4 ++--
 usr.bin/make/unit-tests/varmod-l-name-to-value.exp |  5 +----
 usr.bin/make/var.c                                 |  6 +++---
 3 files changed, 6 insertions(+), 9 deletions(-)

diffs (53 lines):

diff -r 96bbaacc5ed7 -r 1f8693907e0b usr.bin/make/unit-tests/vardebug.exp
--- a/usr.bin/make/unit-tests/vardebug.exp      Wed Sep 30 05:42:06 2020 +0000
+++ b/usr.bin/make/unit-tests/vardebug.exp      Wed Sep 30 05:58:22 2020 +0000
@@ -53,11 +53,11 @@
 Applying ${:U...} to "" (VARE_UNDEFERR|VARE_WANTRES, none, VEF_UNDEF)
 Result of ${:UM*e} is "M*e" (VARE_UNDEFERR|VARE_WANTRES, none, VEF_UNDEF|VEF_DEF)
 Indirect modifier "M*e" from "${:UM*e}"
-Applying ${:M...} to "value" (VARE_UNDEFERR|VARE_WANTRES, none, VEF_UNDEF)
+Applying ${:M...} to "value" (VARE_UNDEFERR|VARE_WANTRES, none, VEF_UNDEF|VEF_DEF)
 Pattern[] for [value] is [*e]
 ModifyWords: split "value" into 1 words
 VarMatch [value] [*e]
-Result of ${:M*e} is "value" (VARE_UNDEFERR|VARE_WANTRES, none, VEF_UNDEF)
+Result of ${:M*e} is "value" (VARE_UNDEFERR|VARE_WANTRES, none, VEF_UNDEF|VEF_DEF)
 Applying ${:M...} to "value" (VARE_UNDEFERR|VARE_WANTRES, none, VEF_UNDEF|VEF_DEF)
 Pattern[] for [value] is [valu[e]]
 ModifyWords: split "value" into 1 words
diff -r 96bbaacc5ed7 -r 1f8693907e0b usr.bin/make/unit-tests/varmod-l-name-to-value.exp
--- a/usr.bin/make/unit-tests/varmod-l-name-to-value.exp        Wed Sep 30 05:42:06 2020 +0000
+++ b/usr.bin/make/unit-tests/varmod-l-name-to-value.exp        Wed Sep 30 05:58:22 2020 +0000
@@ -1,4 +1,1 @@
-make: "varmod-l-name-to-value.mk" line 34: Malformed conditional (${value:${:UL}} == "")
-make: Fatal errors encountered -- cannot continue
-make: stopped in unit-tests
-exit status 1
+exit status 0
diff -r 96bbaacc5ed7 -r 1f8693907e0b usr.bin/make/var.c
--- a/usr.bin/make/var.c        Wed Sep 30 05:42:06 2020 +0000
+++ b/usr.bin/make/var.c        Wed Sep 30 05:58:22 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: var.c,v 1.553 2020/09/29 19:20:08 rillig Exp $ */
+/*     $NetBSD: var.c,v 1.554 2020/09/30 05:58:22 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.553 2020/09/29 19:20:08 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.554 2020/09/30 05:58:22 rillig Exp $");
 
 #define VAR_DEBUG1(fmt, arg1) DEBUG1(VAR, fmt, arg1)
 #define VAR_DEBUG2(fmt, arg1, arg2) DEBUG2(VAR, fmt, arg1, arg2)
@@ -3170,7 +3170,7 @@
            if (rval[0] != '\0') {
                const char *rval_pp = rval;
                st.val = ApplyModifiers(&rval_pp, st.val, '\0', '\0', v,
-                                       exprFlags, ctxt, eflags, freePtr);
+                                       &st.exprFlags, ctxt, eflags, freePtr);
                if (st.val == var_Error
                    || (st.val == varUndefined && !(st.eflags & VARE_UNDEFERR))
                    || *rval_pp != '\0') {



Home | Main Index | Thread Index | Old Index