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 edge case for evaluating unnecessa...



details:   https://anonhg.NetBSD.org/src/rev/866ff7074943
branches:  trunk
changeset: 935411:866ff7074943
user:      rillig <rillig%NetBSD.org@localhost>
date:      Thu Jul 02 12:34:30 2020 +0000

description:
make(1): fix edge case for evaluating unnecessary conditions

diffstat:

 usr.bin/make/unit-tests/cond-short.exp |   1 -
 usr.bin/make/var.c                     |  15 +++++----------
 2 files changed, 5 insertions(+), 11 deletions(-)

diffs (64 lines):

diff -r 1afa1f9ea20d -r 866ff7074943 usr.bin/make/unit-tests/cond-short.exp
--- a/usr.bin/make/unit-tests/cond-short.exp    Thu Jul 02 11:49:48 2020 +0000
+++ b/usr.bin/make/unit-tests/cond-short.exp    Thu Jul 02 12:34:30 2020 +0000
@@ -1,7 +1,6 @@
 expected and
 expected and exists
 expected and empty
-unexpected VAR U11
 expected U23 condition
 expected VAR23
 expected or
diff -r 1afa1f9ea20d -r 866ff7074943 usr.bin/make/var.c
--- a/usr.bin/make/var.c        Thu Jul 02 11:49:48 2020 +0000
+++ b/usr.bin/make/var.c        Thu Jul 02 12:34:30 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: var.c,v 1.225 2020/07/01 18:02:26 sjg Exp $    */
+/*     $NetBSD: var.c,v 1.226 2020/07/02 12:34:30 rillig Exp $ */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.225 2020/07/01 18:02:26 sjg Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.226 2020/07/02 12:34:30 rillig 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.225 2020/07/01 18:02:26 sjg Exp $");
+__RCSID("$NetBSD: var.c,v 1.226 2020/07/02 12:34:30 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -3860,16 +3860,11 @@
            }
            /*
             * A variable inside a variable, expand.
-            * If we really started looking at a variable
-            * (str[0] == '$'), then force VARF_WANTRES
-            * since we need the nested variable expanded to
-            * get the correct name to lookup.
             */
            if (*tstr == '$') {
                int rlen;
                void *freeIt;
-               char *rval = Var_Parse(tstr, ctxt,
-                   flags|((*str == '$') ? VARF_WANTRES : 0),  &rlen, &freeIt);
+               char *rval = Var_Parse(tstr, ctxt, flags, &rlen, &freeIt);
                if (rval != NULL) {
                    Buf_AddBytes(&buf, strlen(rval), rval);
                }
@@ -4015,7 +4010,7 @@
      * return.
      */
     nstr = Buf_GetAll(&v->val, NULL);
-    if (strchr(nstr, '$') != NULL) {
+    if (strchr(nstr, '$') != NULL && (flags & VARF_WANTRES) != 0) {
        nstr = Var_Subst(NULL, nstr, ctxt, flags);
        *freePtr = nstr;
     }



Home | Main Index | Thread Index | Old Index