1*22619282SSimon J. Gerraty# $NetBSD: moderrs.mk,v 1.38 2024/07/05 19:47:22 rillig Exp $ 2db29cad8SSimon J. Gerraty# 3db29cad8SSimon J. Gerraty# various modifier error tests 4db29cad8SSimon J. Gerraty 5db29cad8SSimon J. GerratyVAR= TheVariable 6db29cad8SSimon J. Gerraty# in case we have to change it ;-) 7db29cad8SSimon J. GerratyMOD_UNKN= Z 8db29cad8SSimon J. GerratyMOD_TERM= S,V,v 9db29cad8SSimon J. GerratyMOD_S:= ${MOD_TERM}, 10db29cad8SSimon J. Gerraty 112c3632d1SSimon J. GerratyFIB= 1 1 2 3 5 8 13 21 34 122c3632d1SSimon J. Gerraty 13956e45f6SSimon J. Gerratyall: mod-unknown-direct mod-unknown-indirect 14956e45f6SSimon J. Gerratyall: unclosed-direct unclosed-indirect 15956e45f6SSimon J. Gerratyall: unfinished-indirect unfinished-loop 16956e45f6SSimon J. Gerratyall: loop-close 17956e45f6SSimon J. Gerratyall: words 18956e45f6SSimon J. Gerratyall: exclam 192c3632d1SSimon J. Gerratyall: mod-subst-delimiter 202c3632d1SSimon J. Gerratyall: mod-regex-delimiter 212c3632d1SSimon J. Gerratyall: mod-ts-parse 222c3632d1SSimon J. Gerratyall: mod-t-parse 232c3632d1SSimon J. Gerratyall: mod-ifelse-parse 242c3632d1SSimon J. Gerratyall: mod-remember-parse 252c3632d1SSimon J. Gerratyall: mod-sysv-parse 26db29cad8SSimon J. Gerraty 27*22619282SSimon J. Gerratymod-unknown-direct: print-footer 28*22619282SSimon J. Gerraty# expect: make: in target "mod-unknown-direct": while evaluating variable "VAR" with value "TheVariable": Unknown modifier "Z" 29956e45f6SSimon J. Gerraty @echo 'VAR:Z=before-${VAR:Z}-after' 30db29cad8SSimon J. Gerraty 31*22619282SSimon J. Gerratymod-unknown-indirect: print-footer 32*22619282SSimon J. Gerraty# expect: make: in target "mod-unknown-indirect": while evaluating variable "VAR" with value "TheVariable": Unknown modifier "Z" 33956e45f6SSimon J. Gerraty @echo 'VAR:${MOD_UNKN}=before-${VAR:${MOD_UNKN}:inner}-after' 34db29cad8SSimon J. Gerraty 35956e45f6SSimon J. Gerratyunclosed-direct: print-header print-footer 36*22619282SSimon J. Gerraty# expect: make: in target "unclosed-direct": while evaluating variable "VAR" with value "Thevariable": Unclosed expression, expecting '}' for modifier "S,V,v," 37db29cad8SSimon J. Gerraty @echo VAR:S,V,v,=${VAR:S,V,v, 38db29cad8SSimon J. Gerraty 39956e45f6SSimon J. Gerratyunclosed-indirect: print-header print-footer 40*22619282SSimon J. Gerraty# expect: make: in target "unclosed-indirect": while evaluating variable "VAR" with value "Thevariable": Unclosed expression after indirect modifier, expecting '}' 41db29cad8SSimon J. Gerraty @echo VAR:${MOD_TERM},=${VAR:${MOD_S} 42db29cad8SSimon J. Gerraty 43*22619282SSimon J. Gerratyunfinished-indirect: print-footer 44*22619282SSimon J. Gerraty# expect: make: in target "unfinished-indirect": while evaluating variable "VAR" with value "TheVariable": Unfinished modifier (',' missing) 45db29cad8SSimon J. Gerraty -@echo "VAR:${MOD_TERM}=${VAR:${MOD_TERM}}" 462c3632d1SSimon J. Gerraty 47*22619282SSimon J. Gerratyunfinished-loop: print-footer 48*22619282SSimon J. Gerraty# expect: make: in target "unfinished-loop": while evaluating variable "UNDEF" with value "1 2 3": Unfinished modifier ('@' missing) 492c3632d1SSimon J. Gerraty @echo ${UNDEF:U1 2 3:@var} 50*22619282SSimon J. Gerraty# expect: make: in target "unfinished-loop": while evaluating variable "UNDEF" with value "1 2 3": Unfinished modifier ('@' missing) 512c3632d1SSimon J. Gerraty @echo ${UNDEF:U1 2 3:@var@...} 522c3632d1SSimon J. Gerraty @echo ${UNDEF:U1 2 3:@var@${var}@} 532c3632d1SSimon J. Gerraty 542c3632d1SSimon J. Gerraty# The closing brace after the ${var} is part of the replacement string. 552c3632d1SSimon J. Gerraty# In ParseModifierPart, braces and parentheses don't have to be balanced. 562c3632d1SSimon J. Gerraty# This is contrary to the :M, :N modifiers, where both parentheses and 572c3632d1SSimon J. Gerraty# braces must be balanced. 582c3632d1SSimon J. Gerraty# This is also contrary to the SysV modifier, where only the actually 592c3632d1SSimon J. Gerraty# used delimiter (either braces or parentheses) must be balanced. 60956e45f6SSimon J. Gerratyloop-close: print-header print-footer 61*22619282SSimon J. Gerraty# expect: make: in target "loop-close": while evaluating variable "UNDEF" with value "1}... 2}... 3}...": Unclosed expression, expecting '}' for modifier "@var@${var}}...@" 622c3632d1SSimon J. Gerraty @echo ${UNDEF:U1 2 3:@var@${var}}...@ 632c3632d1SSimon J. Gerraty @echo ${UNDEF:U1 2 3:@var@${var}}...@} 642c3632d1SSimon J. Gerraty 65*22619282SSimon J. Gerratywords: print-footer 66*22619282SSimon J. Gerraty# expect: make: in target "words": while evaluating variable "UNDEF" with value "1 2 3": Unfinished modifier (']' missing) 672c3632d1SSimon J. Gerraty @echo ${UNDEF:U1 2 3:[} 68*22619282SSimon J. Gerraty# expect: make: in target "words": while evaluating variable "UNDEF" with value "1 2 3": Unfinished modifier (']' missing) 692c3632d1SSimon J. Gerraty @echo ${UNDEF:U1 2 3:[#} 702c3632d1SSimon J. Gerraty 712c3632d1SSimon J. Gerraty # out of bounds => empty 722c3632d1SSimon J. Gerraty @echo 13=${UNDEF:U1 2 3:[13]} 732c3632d1SSimon J. Gerraty 742c3632d1SSimon J. Gerraty # Word index out of bounds. 752c3632d1SSimon J. Gerraty # 76956e45f6SSimon J. Gerraty # Until 2020-11-01, the behavior in this case depended upon the size 77956e45f6SSimon J. Gerraty # of unsigned long. 782c3632d1SSimon J. Gerraty # 79956e45f6SSimon J. Gerraty # On LP64I32, strtol returns LONG_MAX, which was then truncated to 80956e45f6SSimon J. Gerraty # int (undefined behavior), typically resulting in -1. This -1 was 81956e45f6SSimon J. Gerraty # interpreted as "the last word". 82956e45f6SSimon J. Gerraty # 83956e45f6SSimon J. Gerraty # On ILP32, strtol returns LONG_MAX, which is a large number. This 84956e45f6SSimon J. Gerraty # resulted in a range from LONG_MAX - 1 to 3, which was empty. 85956e45f6SSimon J. Gerraty # 86956e45f6SSimon J. Gerraty # Since 2020-11-01, the numeric overflow is detected and generates an 87956e45f6SSimon J. Gerraty # error. In the remainder of the text, the '$,' is no longer parsed 88956e45f6SSimon J. Gerraty # as part of a variable modifier, where it would have been interpreted 89956e45f6SSimon J. Gerraty # as an anchor to the :S modifier, but as a normal variable named ','. 90956e45f6SSimon J. Gerraty # That variable is undefined, resulting in an empty string. 912c3632d1SSimon J. Gerraty @echo 12345=${UNDEF:U1 2 3:[123451234512345123451234512345]:S,^$,ok,:S,^3$,ok,} 922c3632d1SSimon J. Gerraty 93*22619282SSimon J. Gerratyexclam: print-footer 94*22619282SSimon J. Gerraty# expect: make: in target "exclam": while evaluating variable "VARNAME" with value "": Unfinished modifier ('!' missing) 952c3632d1SSimon J. Gerraty @echo ${VARNAME:!echo} 962c3632d1SSimon J. Gerraty # When the final exclamation mark is missing, there is no 972c3632d1SSimon J. Gerraty # fallback to the SysV substitution modifier. 982c3632d1SSimon J. Gerraty # If there were a fallback, the output would be "exclam", 992c3632d1SSimon J. Gerraty # and the above would have produced an "Unknown modifier '!'". 100*22619282SSimon J. Gerraty# expect: make: in target "exclam": while evaluating variable "!" with value "!": Unfinished modifier ('!' missing) 1012c3632d1SSimon J. Gerraty @echo ${!:L:!=exclam} 1022c3632d1SSimon J. Gerraty 103*22619282SSimon J. Gerratymod-subst-delimiter: print-footer 104*22619282SSimon J. Gerraty# expect: make: in target "mod-subst-delimiter": while evaluating variable "VAR" with value "TheVariable": Missing delimiter for modifier ':S' 1052c3632d1SSimon J. Gerraty @echo 1: ${VAR:S 106*22619282SSimon J. Gerraty# expect: make: in target "mod-subst-delimiter": while evaluating variable "VAR" with value "TheVariable": Unfinished modifier (',' missing) 1072c3632d1SSimon J. Gerraty @echo 2: ${VAR:S, 108*22619282SSimon J. Gerraty# expect: make: in target "mod-subst-delimiter": while evaluating variable "VAR" with value "TheVariable": Unfinished modifier (',' missing) 1092c3632d1SSimon J. Gerraty @echo 3: ${VAR:S,from 110*22619282SSimon J. Gerraty# expect: make: in target "mod-subst-delimiter": while evaluating variable "VAR" with value "TheVariable": Unfinished modifier (',' missing) 111956e45f6SSimon J. Gerraty @echo 4: ${VAR:S,from, 112*22619282SSimon J. Gerraty# expect: make: in target "mod-subst-delimiter": while evaluating variable "VAR" with value "TheVariable": Unfinished modifier (',' missing) 113956e45f6SSimon J. Gerraty @echo 5: ${VAR:S,from,to 114*22619282SSimon J. Gerraty# expect: make: in target "mod-subst-delimiter": while evaluating variable "VAR" with value "TheVariable": Unclosed expression, expecting '}' for modifier "S,from,to," 115956e45f6SSimon J. Gerraty @echo 6: ${VAR:S,from,to, 116956e45f6SSimon J. Gerraty @echo 7: ${VAR:S,from,to,} 1172c3632d1SSimon J. Gerraty 118*22619282SSimon J. Gerratymod-regex-delimiter: print-footer 119*22619282SSimon J. Gerraty# expect: make: in target "mod-regex-delimiter": while evaluating variable "VAR" with value "TheVariable": Missing delimiter for modifier ':C' 1202c3632d1SSimon J. Gerraty @echo 1: ${VAR:C 121*22619282SSimon J. Gerraty# expect: make: in target "mod-regex-delimiter": while evaluating variable "VAR" with value "TheVariable": Unfinished modifier (',' missing) 1222c3632d1SSimon J. Gerraty @echo 2: ${VAR:C, 123*22619282SSimon J. Gerraty# expect: make: in target "mod-regex-delimiter": while evaluating variable "VAR" with value "TheVariable": Unfinished modifier (',' missing) 1242c3632d1SSimon J. Gerraty @echo 3: ${VAR:C,from 125*22619282SSimon J. Gerraty# expect: make: in target "mod-regex-delimiter": while evaluating variable "VAR" with value "TheVariable": Unfinished modifier (',' missing) 126956e45f6SSimon J. Gerraty @echo 4: ${VAR:C,from, 127*22619282SSimon J. Gerraty# expect: make: in target "mod-regex-delimiter": while evaluating variable "VAR" with value "TheVariable": Unfinished modifier (',' missing) 128956e45f6SSimon J. Gerraty @echo 5: ${VAR:C,from,to 129*22619282SSimon J. Gerraty# expect: make: in target "mod-regex-delimiter": while evaluating variable "VAR" with value "TheVariable": Unclosed expression, expecting '}' for modifier "C,from,to," 130956e45f6SSimon J. Gerraty @echo 6: ${VAR:C,from,to, 131956e45f6SSimon J. Gerraty @echo 7: ${VAR:C,from,to,} 1322c3632d1SSimon J. Gerraty 133956e45f6SSimon J. Gerratymod-ts-parse: print-header print-footer 1342c3632d1SSimon J. Gerraty @echo ${FIB:ts} 1352c3632d1SSimon J. Gerraty @echo ${FIB:ts\65} # octal 065 == U+0035 == '5' 136*22619282SSimon J. Gerraty# expect: make: in target "mod-ts-parse": while evaluating variable "FIB" with value "1 1 2 3 5 8 13 21 34": Bad modifier ":ts\65oct" 1372c3632d1SSimon J. Gerraty @echo ${FIB:ts\65oct} # bad modifier 138*22619282SSimon J. Gerraty# expect: make: in target "mod-ts-parse": while evaluating "${:U${FIB}:ts\65oct} # bad modifier, variable name is """ with value "1 1 2 3 5 8 13 21 34": Bad modifier ":ts\65oct" 139b0c40a00SSimon J. Gerraty @echo ${:U${FIB}:ts\65oct} # bad modifier, variable name is "" 140*22619282SSimon J. Gerraty# expect: make: in target "mod-ts-parse": while evaluating variable "FIB" with value "1 1 2 3 5 8 13 21 34": Bad modifier ":tsxy" 1412c3632d1SSimon J. Gerraty @echo ${FIB:tsxy} # modifier too long 1422c3632d1SSimon J. Gerraty 143956e45f6SSimon J. Gerratymod-t-parse: print-header print-footer 144*22619282SSimon J. Gerraty# expect: make: in target "mod-t-parse": while evaluating variable "FIB" with value "1 1 2 3 5 8 13 21 34": Bad modifier ":t" 1452c3632d1SSimon J. Gerraty @echo ${FIB:t 146*22619282SSimon J. Gerraty# expect: make: in target "mod-t-parse": while evaluating variable "FIB" with value "1 1 2 3 5 8 13 21 34": Bad modifier ":txy" 1472c3632d1SSimon J. Gerraty @echo ${FIB:txy} 148*22619282SSimon J. Gerraty# expect: make: in target "mod-t-parse": while evaluating variable "FIB" with value "1 1 2 3 5 8 13 21 34": Bad modifier ":t" 1492c3632d1SSimon J. Gerraty @echo ${FIB:t} 150*22619282SSimon J. Gerraty# expect: make: in target "mod-t-parse": while evaluating variable "FIB" with value "1 1 2 3 5 8 13 21 34": Bad modifier ":t" 1512c3632d1SSimon J. Gerraty @echo ${FIB:t:M*} 1522c3632d1SSimon J. Gerraty 153*22619282SSimon J. Gerratymod-ifelse-parse: print-footer 154*22619282SSimon J. Gerraty# expect: make: in target "mod-ifelse-parse": while evaluating then-branch of condition "FIB": Unfinished modifier (':' missing) 1552c3632d1SSimon J. Gerraty @echo ${FIB:? 156*22619282SSimon J. Gerraty# expect: make: in target "mod-ifelse-parse": while evaluating then-branch of condition "FIB": Unfinished modifier (':' missing) 1572c3632d1SSimon J. Gerraty @echo ${FIB:?then 158*22619282SSimon J. Gerraty# expect: make: in target "mod-ifelse-parse": while evaluating else-branch of condition "FIB": Unfinished modifier ('}' missing) 1592c3632d1SSimon J. Gerraty @echo ${FIB:?then: 160*22619282SSimon J. Gerraty# expect: make: in target "mod-ifelse-parse": while evaluating else-branch of condition "FIB": Unfinished modifier ('}' missing) 1612c3632d1SSimon J. Gerraty @echo ${FIB:?then:else 1622c3632d1SSimon J. Gerraty @echo ${FIB:?then:else} 1632c3632d1SSimon J. Gerraty 164*22619282SSimon J. Gerratymod-remember-parse: print-footer 1652c3632d1SSimon J. Gerraty @echo ${FIB:_} # ok 166*22619282SSimon J. Gerraty# expect: make: in target "mod-remember-parse": while evaluating variable "FIB" with value "1 1 2 3 5 8 13 21 34": Unknown modifier "__" 1672c3632d1SSimon J. Gerraty @echo ${FIB:__} # modifier name too long 1682c3632d1SSimon J. Gerraty 169*22619282SSimon J. Gerratymod-sysv-parse: print-footer 170*22619282SSimon J. Gerraty# expect: make: in target "mod-sysv-parse": while evaluating variable "FIB" with value "1 1 2 3 5 8 13 21 34": Unknown modifier "3" 171*22619282SSimon J. Gerraty# expect: make: in target "mod-sysv-parse": while evaluating variable "FIB" with value "": Unclosed expression, expecting '}' for modifier "3" 1722c3632d1SSimon J. Gerraty @echo ${FIB:3 173*22619282SSimon J. Gerraty# expect: make: in target "mod-sysv-parse": while evaluating variable "FIB" with value "1 1 2 3 5 8 13 21 34": Unknown modifier "3=" 174*22619282SSimon J. Gerraty# expect: make: in target "mod-sysv-parse": while evaluating variable "FIB" with value "": Unclosed expression, expecting '}' for modifier "3=" 1752c3632d1SSimon J. Gerraty @echo ${FIB:3= 176*22619282SSimon J. Gerraty# expect: make: in target "mod-sysv-parse": while evaluating variable "FIB" with value "1 1 2 3 5 8 13 21 34": Unknown modifier "3=x3" 177*22619282SSimon J. Gerraty# expect: make: in target "mod-sysv-parse": while evaluating variable "FIB" with value "": Unclosed expression, expecting '}' for modifier "3=x3" 1782c3632d1SSimon J. Gerraty @echo ${FIB:3=x3 1792c3632d1SSimon J. Gerraty @echo ${FIB:3=x3} # ok 180956e45f6SSimon J. Gerraty 181956e45f6SSimon J. Gerratyprint-header: .USEBEFORE 182956e45f6SSimon J. Gerraty @echo $@: 183956e45f6SSimon J. Gerratyprint-footer: .USE 184956e45f6SSimon J. Gerraty @echo 185