Module Name: src Committed By: rillig Date: Sun Dec 6 19:18:27 UTC 2020
Modified Files: src/usr.bin/make/unit-tests: opt-file.exp opt-file.mk Log Message: make(1): add test for makefile containing null bytes To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/opt-file.exp cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/opt-file.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/opt-file.exp diff -u src/usr.bin/make/unit-tests/opt-file.exp:1.2 src/usr.bin/make/unit-tests/opt-file.exp:1.3 --- src/usr.bin/make/unit-tests/opt-file.exp:1.2 Sun Dec 6 19:00:48 2020 +++ src/usr.bin/make/unit-tests/opt-file.exp Sun Dec 6 19:18:26 2020 @@ -1,2 +1,5 @@ value +make: "(stdin)" line 1: warning: Zero byte read from file, skipping rest of line. +va +VALUE2 exit status 0 Index: src/usr.bin/make/unit-tests/opt-file.mk diff -u src/usr.bin/make/unit-tests/opt-file.mk:1.3 src/usr.bin/make/unit-tests/opt-file.mk:1.4 --- src/usr.bin/make/unit-tests/opt-file.mk:1.3 Sun Dec 6 19:00:48 2020 +++ src/usr.bin/make/unit-tests/opt-file.mk Sun Dec 6 19:18:26 2020 @@ -1,17 +1,29 @@ -# $NetBSD: opt-file.mk,v 1.3 2020/12/06 19:00:48 rillig Exp $ +# $NetBSD: opt-file.mk,v 1.4 2020/12/06 19:18:26 rillig Exp $ # # Tests for the -f command line option. # TODO: Implementation -all: .PHONY file-ending-in-backslash +all: .PHONY +all: file-ending-in-backslash +all: file-containing-null-byte # Passing '-' as the filename reads from stdin. This is unusual but possible. # # In the unlikely case where a file ends in a backslash instead of a newline, # that backslash is trimmed. See ParseGetLine. file-ending-in-backslash: .PHONY - @printf '%s' 'VAR=value\' | ${MAKE} -r -f - -v VAR + @printf '%s' 'VAR=value\' \ + | ${MAKE} -r -f - -v VAR + +# If a file contains null bytes, the rest of the line is skipped, and parsing +# continues in the next line. +# +# XXX: It would be safer to just quit parsing in such a situation. +file-containing-null-byte: .PHONY + @printf '%s\n' 'VAR=value' 'VAR2=VALUE2' \ + | tr 'l' '\0' \ + | ${MAKE} -r -f - -v VAR -v VAR2 all: @:;