varparse-dynamic.mk revision 1.7
11.7Srillig# $NetBSD: varparse-dynamic.mk,v 1.7 2023/06/01 20:56:35 rillig Exp $ 21.1Srillig 31.1Srillig# Before 2020-07-27, there was an off-by-one error in Var_Parse that skipped 41.1Srillig# the last character in the variable name. 51.6Srillig# To trigger the bug, the variable had to be undefined. 61.1Srillig.if ${.TARGET} # exact match, may be undefined 71.1Srillig.endif 81.7Srillig# expect+1: Malformed conditional (${.TARGEX}) 91.1Srillig.if ${.TARGEX} # 1 character difference, must be defined 101.1Srillig.endif 111.7Srillig# expect+1: Malformed conditional (${.TARGXX}) 121.1Srillig.if ${.TARGXX} # 2 characters difference, must be defined 131.1Srillig.endif 141.1Srillig 151.2Srillig# When a dynamic variable (such as .TARGET) is evaluated in the global 161.4Srillig# scope, it is not yet ready to be expanded. Therefore the complete 171.2Srillig# expression is returned as the variable value, hoping that it can be 181.2Srillig# resolved at a later point. 191.2Srillig# 201.5Srillig# This test covers the code in Var_Parse that deals with DEF_UNDEF but not 211.5Srillig# DEF_DEFINED for dynamic variables. 221.2Srillig.if ${.TARGET:S,^,,} != "\${.TARGET:S,^,,}" 231.2Srillig. error 241.2Srillig.endif 251.2Srillig 261.4Srillig# If a dynamic variable is expanded in a non-local scope, the expression 271.3Srillig# based on this variable is not expanded. But there may be nested variable 281.3Srillig# expressions in the modifiers, and these are kept unexpanded as well. 291.3Srillig.if ${.TARGET:M${:Ufallback}} != "\${.TARGET:M\${:Ufallback}}" 301.3Srillig. error 311.3Srillig.endif 321.3Srillig.if ${.TARGET:M${UNDEF}} != "\${.TARGET:M\${UNDEF}}" 331.3Srillig. error 341.3Srillig.endif 35