1 1.8 rillig # $NetBSD: varmod-l-name-to-value.mk,v 1.8 2023/11/19 21:47:52 rillig Exp $ 2 1.1 rillig # 3 1.2 rillig # Tests for the :L modifier, which returns the variable name as the new value. 4 1.1 rillig 5 1.3 rillig # The empty variable name leads to an empty string. 6 1.3 rillig .if ${:L} != "" 7 1.7 rillig . error 8 1.3 rillig .endif 9 1.3 rillig 10 1.3 rillig # The variable name is converted into an expression with the variable name 11 1.3 rillig # "VARNAME" and the value "VARNAME". 12 1.3 rillig .if ${VARNAME:L} != "VARNAME" 13 1.7 rillig . error 14 1.3 rillig .endif 15 1.3 rillig 16 1.3 rillig # The value of the expression can be modified afterwards. 17 1.3 rillig .if ${VARNAME:L:S,VAR,,} != "NAME" 18 1.7 rillig . error 19 1.3 rillig .endif 20 1.3 rillig 21 1.3 rillig # The name of the expression is still the same as before. Using the :L 22 1.3 rillig # modifier, it can be restored. 23 1.3 rillig # 24 1.3 rillig # Hmmm, this can be used as a double storage or a backup mechanism. 25 1.3 rillig # Probably unintended, but maybe useful. 26 1.3 rillig .if ${VARNAME:L:S,VAR,,:L} != "VARNAME" 27 1.7 rillig . error 28 1.3 rillig .endif 29 1.1 rillig 30 1.5 rillig # Between 2020-09-22 (var.c 1.527) and 2020-09-30 (var.c 1.553), there was 31 1.8 rillig # a bug in the evaluation of expressions. Indirect modifiers like 32 1.5 rillig # the below :L did not update the definedness of the enclosing expression. 33 1.5 rillig # This resulted in a wrong "Malformed conditional". 34 1.4 rillig .if ${value:${:UL}} == "" 35 1.4 rillig .endif 36 1.4 rillig 37 1.6 rillig # As of 2020-10-02, the :L modifier does not ensure that it is followed by 38 1.6 rillig # a delimiter, that is, a ':' or endc. Neither does the :P modifier. 39 1.6 rillig .if ${value:LLLLLLPL} != "value" 40 1.6 rillig . error 41 1.6 rillig .endif 42 1.6 rillig 43 1.1 rillig all: 44 1.1 rillig @:; 45