Module Name: src Committed By: rillig Date: Sun Jul 26 14:16:45 UTC 2020
Modified Files: src/usr.bin/make/unit-tests: moderrs.exp moderrs.mk Log Message: make(1): add test for missing input validation in :[123] modifier To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/moderrs.exp cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/moderrs.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/moderrs.exp diff -u src/usr.bin/make/unit-tests/moderrs.exp:1.3 src/usr.bin/make/unit-tests/moderrs.exp:1.4 --- src/usr.bin/make/unit-tests/moderrs.exp:1.3 Sun Jul 26 10:11:04 2020 +++ src/usr.bin/make/unit-tests/moderrs.exp Sun Jul 26 14:16:45 2020 @@ -13,10 +13,17 @@ VAR:S,V,v,=Thevariable Expect: Unclosed substitution for VAR (, missing) make: Unclosed substitution for VAR (, missing) VAR:S,V,v= -Expect: errors about missing @ delimiter +Expect: 2 errors about missing @ delimiter make: Unclosed substitution for UNDEF (@ missing) make: Unclosed substitution for UNDEF (@ missing) 1 2 3 +Expect: 2 errors about missing ] delimiter +make: Unclosed substitution for UNDEF (] missing) + +make: Unclosed substitution for UNDEF (] missing) + +13= +12345=ok exit status 0 Index: src/usr.bin/make/unit-tests/moderrs.mk diff -u src/usr.bin/make/unit-tests/moderrs.mk:1.2 src/usr.bin/make/unit-tests/moderrs.mk:1.3 --- src/usr.bin/make/unit-tests/moderrs.mk:1.2 Sun Jul 26 10:04:06 2020 +++ src/usr.bin/make/unit-tests/moderrs.mk Sun Jul 26 14:16:45 2020 @@ -1,4 +1,4 @@ -# $Id: moderrs.mk,v 1.2 2020/07/26 10:04:06 rillig Exp $ +# $Id: moderrs.mk,v 1.3 2020/07/26 14:16:45 rillig Exp $ # # various modifier error tests @@ -9,6 +9,7 @@ MOD_TERM=S,V,v MOD_S:= ${MOD_TERM}, all: modunkn modunknV varterm vartermV modtermV modloop +all: modwords modunkn: @echo "Expect: Unknown modifier 'Z'" @@ -31,7 +32,28 @@ modtermV: -@echo "VAR:${MOD_TERM}=${VAR:${MOD_TERM}}" modloop: - @echo "Expect: errors about missing @ delimiter" + @echo "Expect: 2 errors about missing @ delimiter" @echo ${UNDEF:U1 2 3:@var} @echo ${UNDEF:U1 2 3:@var@...} @echo ${UNDEF:U1 2 3:@var@${var}@} + +modwords: + @echo "Expect: 2 errors about missing ] delimiter" + @echo ${UNDEF:U1 2 3:[} + @echo ${UNDEF:U1 2 3:[#} + + # out of bounds => empty + @echo 13=${UNDEF:U1 2 3:[13]} + + # Word index out of bounds. + # + # On LP64I32, strtol returns LONG_MAX, + # which is then truncated to int (undefined behavior), + # typically resulting in -1. + # This -1 is interpreted as "the last word". + # + # On ILP32, strtol returns LONG_MAX, + # which is a large number. + # This results in a range from LONG_MAX - 1 to 3, + # which is empty. + @echo 12345=${UNDEF:U1 2 3:[123451234512345123451234512345]:S,^$,ok,:S,^3$,ok,}