1*d5e0a182SSimon J. Gerraty# $NetBSD: varmod-l-name-to-value.mk,v 1.8 2023/11/19 21:47:52 rillig Exp $ 22c3632d1SSimon J. Gerraty# 32c3632d1SSimon J. Gerraty# Tests for the :L modifier, which returns the variable name as the new value. 42c3632d1SSimon J. Gerraty 52c3632d1SSimon J. Gerraty# The empty variable name leads to an empty string. 62c3632d1SSimon J. Gerraty.if ${:L} != "" 72c3632d1SSimon J. Gerraty. error 82c3632d1SSimon J. Gerraty.endif 92c3632d1SSimon J. Gerraty 102c3632d1SSimon J. Gerraty# The variable name is converted into an expression with the variable name 112c3632d1SSimon J. Gerraty# "VARNAME" and the value "VARNAME". 122c3632d1SSimon J. Gerraty.if ${VARNAME:L} != "VARNAME" 132c3632d1SSimon J. Gerraty. error 142c3632d1SSimon J. Gerraty.endif 152c3632d1SSimon J. Gerraty 162c3632d1SSimon J. Gerraty# The value of the expression can be modified afterwards. 172c3632d1SSimon J. Gerraty.if ${VARNAME:L:S,VAR,,} != "NAME" 182c3632d1SSimon J. Gerraty. error 192c3632d1SSimon J. Gerraty.endif 202c3632d1SSimon J. Gerraty 212c3632d1SSimon J. Gerraty# The name of the expression is still the same as before. Using the :L 222c3632d1SSimon J. Gerraty# modifier, it can be restored. 232c3632d1SSimon J. Gerraty# 242c3632d1SSimon J. Gerraty# Hmmm, this can be used as a double storage or a backup mechanism. 252c3632d1SSimon J. Gerraty# Probably unintended, but maybe useful. 262c3632d1SSimon J. Gerraty.if ${VARNAME:L:S,VAR,,:L} != "VARNAME" 272c3632d1SSimon J. Gerraty. error 282c3632d1SSimon J. Gerraty.endif 292c3632d1SSimon J. Gerraty 30956e45f6SSimon J. Gerraty# Between 2020-09-22 (var.c 1.527) and 2020-09-30 (var.c 1.553), there was 31*d5e0a182SSimon J. Gerraty# a bug in the evaluation of expressions. Indirect modifiers like 32956e45f6SSimon J. Gerraty# the below :L did not update the definedness of the enclosing expression. 33956e45f6SSimon J. Gerraty# This resulted in a wrong "Malformed conditional". 34956e45f6SSimon J. Gerraty.if ${value:${:UL}} == "" 35956e45f6SSimon J. Gerraty.endif 36956e45f6SSimon J. Gerraty 37956e45f6SSimon J. Gerraty# As of 2020-10-02, the :L modifier does not ensure that it is followed by 38956e45f6SSimon J. Gerraty# a delimiter, that is, a ':' or endc. Neither does the :P modifier. 39956e45f6SSimon J. Gerraty.if ${value:LLLLLLPL} != "value" 40956e45f6SSimon J. Gerraty. error 41956e45f6SSimon J. Gerraty.endif 42956e45f6SSimon J. Gerraty 432c3632d1SSimon J. Gerratyall: 442c3632d1SSimon J. Gerraty @:; 45