Module Name:    src
Committed By:   rillig
Date:           Sun Mar 14 19:29:37 UTC 2021

Modified Files:
        src/usr.bin/make: var.c
        src/usr.bin/make/unit-tests: var-eval-short.exp

Log Message:
make: do not evaluate modifier ':[...]' in parse-only mode

In parse-only mode, variable expressions in the argument to that
modifier are not resolved.  This led to the error message about the 'Bad
modifier' in var-eval-short.mk.


To generate a diff of this commit:
cvs rdiff -u -r1.876 -r1.877 src/usr.bin/make/var.c
cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/var-eval-short.exp

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.876 src/usr.bin/make/var.c:1.877
--- src/usr.bin/make/var.c:1.876	Sun Mar 14 19:25:05 2021
+++ src/usr.bin/make/var.c	Sun Mar 14 19:29:37 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.876 2021/03/14 19:25:05 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.877 2021/03/14 19:29:37 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -140,7 +140,7 @@
 #include "metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.876 2021/03/14 19:25:05 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.877 2021/03/14 19:29:37 rillig Exp $");
 
 typedef enum VarFlags {
 	VFL_NONE	= 0,
@@ -3151,6 +3151,9 @@ ApplyModifier_Words(const char **pp, App
 	if (!IsDelimiter(**pp, st))
 		goto bad_modifier;		/* Found junk after ']' */
 
+	if (!(expr->eflags & VARE_WANTRES))
+		goto ok;
+
 	if (estr[0] == '\0')
 		goto bad_modifier;			/* Found ":[]". */
 

Index: src/usr.bin/make/unit-tests/var-eval-short.exp
diff -u src/usr.bin/make/unit-tests/var-eval-short.exp:1.5 src/usr.bin/make/unit-tests/var-eval-short.exp:1.6
--- src/usr.bin/make/unit-tests/var-eval-short.exp:1.5	Sun Mar 14 19:21:28 2021
+++ src/usr.bin/make/unit-tests/var-eval-short.exp	Sun Mar 14 19:29:37 2021
@@ -1,5 +1,3 @@
-make: Bad modifier ":[${FAIL" for variable ""
-make: "var-eval-short.mk" line 43: Malformed conditional (0 && ${:Uword:[${FAIL}]})
 make: "var-eval-short.mk" line 63: Invalid time value: ${FAIL}}
 make: "var-eval-short.mk" line 63: Malformed conditional (0 && ${:Uword:gmtime=${FAIL}})
 make: "var-eval-short.mk" line 77: Invalid time value: ${FAIL}}

Reply via email to