Module Name: src Committed By: rillig Date: Thu Dec 10 16:36:47 UTC 2020
Modified Files: src/usr.bin/make/unit-tests: varmod-ifelse.exp varmod-ifelse.mk Log Message: make(1): add test demonstrating how to defer evaluation in :? modifier To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/varmod-ifelse.exp cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/varmod-ifelse.mk 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/unit-tests/varmod-ifelse.exp diff -u src/usr.bin/make/unit-tests/varmod-ifelse.exp:1.4 src/usr.bin/make/unit-tests/varmod-ifelse.exp:1.5 --- src/usr.bin/make/unit-tests/varmod-ifelse.exp:1.4 Thu Nov 12 00:29:55 2020 +++ src/usr.bin/make/unit-tests/varmod-ifelse.exp Thu Dec 10 16:36:47 2020 @@ -11,6 +11,10 @@ lhs = 1.000000, rhs = 0.000000, op = == make: Bad conditional expression `1 == == 2' in 1 == == 2?yes:no lhs = "", rhs = "", op = != make: "varmod-ifelse.mk" line 92: warning: Oops, the parse error should have been propagated. +CondParser_Eval: ${ ${:U\$}{VAR} == value :?ok:bad} != "ok" +CondParser_Eval: ${VAR} == value +lhs = "value", rhs = "value", op = == +lhs = "ok", rhs = "ok", op = != make: Fatal errors encountered -- cannot continue make: stopped in unit-tests exit status 1 Index: src/usr.bin/make/unit-tests/varmod-ifelse.mk diff -u src/usr.bin/make/unit-tests/varmod-ifelse.mk:1.6 src/usr.bin/make/unit-tests/varmod-ifelse.mk:1.7 --- src/usr.bin/make/unit-tests/varmod-ifelse.mk:1.6 Thu Nov 12 00:29:55 2020 +++ src/usr.bin/make/unit-tests/varmod-ifelse.mk Thu Dec 10 16:36:47 2020 @@ -1,4 +1,4 @@ -# $NetBSD: varmod-ifelse.mk,v 1.6 2020/11/12 00:29:55 rillig Exp $ +# $NetBSD: varmod-ifelse.mk,v 1.7 2020/12/10 16:36:47 rillig Exp $ # # Tests for the ${cond:?then:else} variable modifier, which evaluates either # the then-expression or the else-expression, depending on the condition. @@ -93,5 +93,18 @@ COND:= ${${UNDEF} == "":?bad-assign:bad- .endif .MAKEFLAGS: -d0 +# As of 2020-12-10, the variable "name" is first expanded, and the result of +# this expansion is then taken as the condition. To force the variable +# expression in the condition to be evaluated at exactly the right point, +# the '$' of the intended '${VAR}' escapes from the parser in form of the +# expression ${:U\$}. Because of this escaping, the variable "name" and thus +# the condition ends up as "${VAR} == value", just as intended. +.MAKEFLAGS: -dc +VAR= value +.if ${ ${:U\$}{VAR} == value :?ok:bad} != "ok" +. error +.endif +.MAKEFLAGS: -d0 + all: @:;