Module Name: src Committed By: rillig Date: Mon Mar 15 18:46:05 UTC 2021
Modified Files: src/usr.bin/make/unit-tests: varmod-assign.exp varmod-assign.mk Log Message: tests/make: demonstrate that the modifier '::=' expands the varname To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/usr.bin/make/unit-tests/varmod-assign.exp cvs rdiff -u -r1.10 -r1.11 src/usr.bin/make/unit-tests/varmod-assign.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-assign.exp diff -u src/usr.bin/make/unit-tests/varmod-assign.exp:1.9 src/usr.bin/make/unit-tests/varmod-assign.exp:1.10 --- src/usr.bin/make/unit-tests/varmod-assign.exp:1.9 Tue Feb 23 16:07:14 2021 +++ src/usr.bin/make/unit-tests/varmod-assign.exp Mon Mar 15 18:46:05 2021 @@ -1,3 +1,20 @@ +Global:param = twice +Global:VARNAME = VAR.$${param} +Var_Parse: ${VARNAME} (eval) +Global:VAR.${param} = initial-value +Var_Parse: ${${VARNAME}::=assigned-value} (eval-defined) +Var_Parse: ${VARNAME}::=assigned-value} (eval-defined) +Applying ${VAR.${param}::...} to "initial-value" (eval-defined, none, regular) +Modifier part: "assigned-value" +Var_Parse: ${param} (eval) +Global:VAR.twice = assigned-value +Result of ${VAR.${param}::=assigned-value} is "" (eval-defined, none, regular) +Var_Parse: $ for symmetry with the usual assignment operators. (eval) +make: "varmod-assign.mk" line 139: FIXME: don't expand the variable name twice here, for symmetry with the usual assignment operators. +Var_Parse: ${${VARNAME}} != "initial-value" (eval-defined) +Var_Parse: ${VARNAME}} != "initial-value" (eval-defined) +Global:.MAKEFLAGS = -r -k -d v -d +Global:.MAKEFLAGS = -r -k -d v -d 0 mod-assign: first=1. mod-assign: last=3. mod-assign: appended=1 2 3. Index: src/usr.bin/make/unit-tests/varmod-assign.mk diff -u src/usr.bin/make/unit-tests/varmod-assign.mk:1.10 src/usr.bin/make/unit-tests/varmod-assign.mk:1.11 --- src/usr.bin/make/unit-tests/varmod-assign.mk:1.10 Sun Feb 14 12:14:37 2021 +++ src/usr.bin/make/unit-tests/varmod-assign.mk Mon Mar 15 18:46:05 2021 @@ -1,4 +1,4 @@ -# $NetBSD: varmod-assign.mk,v 1.10 2021/02/14 12:14:37 rillig Exp $ +# $NetBSD: varmod-assign.mk,v 1.11 2021/03/15 18:46:05 rillig Exp $ # # Tests for the obscure ::= variable modifiers, which perform variable # assignments during evaluation, just like the = operator in C. @@ -114,3 +114,31 @@ _:= $(VAR::=current}) .if ${VAR} != "current}" . error .endif + + +# Before var.c 1.888 from 2021-03-15, an expression using the modifier '::=' +# expanded its variable name once too often during evaluation. This was only +# relevant for variable names containing a '$' sign in their actual name, not +# the usual VAR.${param}. +.MAKEFLAGS: -dv +param= twice +VARNAME= VAR.$${param} # Indirect variable name because of the '$', + # to avoid difficult escaping rules. + +${VARNAME}= initial-value # Sets 'VAR.${param}' to 'expanded'. +.if defined(VAR.twice) # At this point, the '$$' is not expanded. +. error +.endif +.if ${${VARNAME}::=assigned-value} # Here the variable name gets expanded once +. error # too often. +.endif +.if !defined(VAR.twice) +. error # FIXME: This is the unwanted current behavior. +.else +. info FIXME: don't expand the variable name twice here, $\ + for symmetry with the usual assignment operators. +.endif +.if ${${VARNAME}} != "initial-value" +. error +.endif +.MAKEFLAGS: -d0