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 unnecessary evaluation of :M and :...



details:   https://anonhg.NetBSD.org/src/rev/1f92405fbee3
branches:  trunk
changeset: 973477:1f92405fbee3
user:      rillig <rillig%NetBSD.org@localhost>
date:      Thu Jul 02 13:04:09 2020 +0000

description:
make(1): fix unnecessary evaluation of :M and :N modifiers

diffstat:

 usr.bin/make/unit-tests/cond-short.exp |  2 +-
 usr.bin/make/unit-tests/cond-short.mk  |  9 +++++++--
 usr.bin/make/var.c                     |  8 ++++----
 3 files changed, 12 insertions(+), 7 deletions(-)

diffs (74 lines):

diff -r 095f37439a6f -r 1f92405fbee3 usr.bin/make/unit-tests/cond-short.exp
--- a/usr.bin/make/unit-tests/cond-short.exp    Thu Jul 02 13:01:11 2020 +0000
+++ b/usr.bin/make/unit-tests/cond-short.exp    Thu Jul 02 13:04:09 2020 +0000
@@ -3,7 +3,7 @@
 expected and empty
 expected U23 condition
 expected VAR23
-unexpected M pattern
+expected M pattern
 expected or
 expected or exists
 expected or empty
diff -r 095f37439a6f -r 1f92405fbee3 usr.bin/make/unit-tests/cond-short.mk
--- a/usr.bin/make/unit-tests/cond-short.mk     Thu Jul 02 13:01:11 2020 +0000
+++ b/usr.bin/make/unit-tests/cond-short.mk     Thu Jul 02 13:04:09 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: cond-short.mk,v 1.4 2020/07/02 12:37:18 rillig Exp $
+# $NetBSD: cond-short.mk,v 1.5 2020/07/02 13:04:09 rillig Exp $
 #
 # Demonstrates that in conditions, the right-hand side of an && or ||
 # is only evaluated if it can actually influence the result.
@@ -38,11 +38,16 @@
 VAR23= ${VAR${:U22${echo   "expected VAR23" 1>&2 :L:sh}}}
 .if 1 && !empty(VAR${:U23${echo   "expected U23 condition" 1>&2 :L:sh}})
 .endif
+VAR=   # empty again, for the following tests
 
-# FIXME: The :M modifier must only be parsed, not evaluated.
+# The :M modifier is only parsed, not evaluated.
+# Before 2020-07-02, it was wrongly evaluated.
 .if 0 && !empty(VAR:M${:U${echo "unexpected M pattern" 1>&2 :L:sh}})
 .endif
 
+.if 1 && !empty(VAR:M${:U${echo   "expected M pattern" 1>&2 :L:sh}})
+.endif
+
 # The || operator.
 
 .if 1 || ${echo "unexpected or" 1>&2 :L:sh}
diff -r 095f37439a6f -r 1f92405fbee3 usr.bin/make/var.c
--- a/usr.bin/make/var.c        Thu Jul 02 13:01:11 2020 +0000
+++ b/usr.bin/make/var.c        Thu Jul 02 13:04:09 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: var.c,v 1.226 2020/07/02 12:34:30 rillig Exp $ */
+/*     $NetBSD: var.c,v 1.227 2020/07/02 13:04:09 rillig Exp $ */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.226 2020/07/02 12:34:30 rillig Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.227 2020/07/02 13:04:09 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.226 2020/07/02 12:34:30 rillig Exp $");
+__RCSID("$NetBSD: var.c,v 1.227 2020/07/02 13:04:09 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -3290,7 +3290,7 @@
                     * expand it.
                     */
                    cp2 = pattern;
-                   pattern = Var_Subst(NULL, cp2, ctxt, flags | VARF_WANTRES);
+                   pattern = Var_Subst(NULL, cp2, ctxt, flags);
                    free(cp2);
                }
                if (DEBUG(VAR))



Home | Main Index | Thread Index | Old Index