Module Name: src Committed By: rillig Date: Tue Dec 28 22:13:56 UTC 2021
Modified Files: src/usr.bin/make/unit-tests: cond-func-empty.mk cond-func.mk Log Message: tests/make: test function names without following '(' To generate a diff of this commit: cvs rdiff -u -r1.16 -r1.17 src/usr.bin/make/unit-tests/cond-func-empty.mk cvs rdiff -u -r1.9 -r1.10 src/usr.bin/make/unit-tests/cond-func.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/cond-func-empty.mk diff -u src/usr.bin/make/unit-tests/cond-func-empty.mk:1.16 src/usr.bin/make/unit-tests/cond-func-empty.mk:1.17 --- src/usr.bin/make/unit-tests/cond-func-empty.mk:1.16 Sat Dec 11 10:41:31 2021 +++ src/usr.bin/make/unit-tests/cond-func-empty.mk Tue Dec 28 22:13:56 2021 @@ -1,4 +1,4 @@ -# $NetBSD: cond-func-empty.mk,v 1.16 2021/12/11 10:41:31 rillig Exp $ +# $NetBSD: cond-func-empty.mk,v 1.17 2021/12/28 22:13:56 rillig Exp $ # # Tests for the empty() function in .if conditions, which tests a variable # expression for emptiness. @@ -189,5 +189,16 @@ VARNAME= ${VARNAME${:U1}} .if defined(VARNAME${:U2}) && !empty(VARNAME${:U2}) .endif -all: - @:; + +# If the word 'empty' is not followed by '(', it is not a function call but an +# ordinary bare word. This bare word is interpreted as 'defined(empty)', and +# since there is no variable named 'empty', the condition evaluates to false. +.if empty +. error +.endif + +empty= # defined but empty +.if empty +.else +. error +.endif Index: src/usr.bin/make/unit-tests/cond-func.mk diff -u src/usr.bin/make/unit-tests/cond-func.mk:1.9 src/usr.bin/make/unit-tests/cond-func.mk:1.10 --- src/usr.bin/make/unit-tests/cond-func.mk:1.9 Sun Nov 15 14:07:53 2020 +++ src/usr.bin/make/unit-tests/cond-func.mk Tue Dec 28 22:13:56 2021 @@ -1,4 +1,4 @@ -# $NetBSD: cond-func.mk,v 1.9 2020/11/15 14:07:53 rillig Exp $ +# $NetBSD: cond-func.mk,v 1.10 2021/12/28 22:13:56 rillig Exp $ # # Tests for those parts of the functions in .if conditions that are common # among several functions. @@ -102,9 +102,9 @@ ${VARNAME_UNBALANCED_BRACES}= variable n . info A plain function name is parsed as !empty(...). .endif -# If a variable named 'defined' is actually defined and not empty, the plain -# symbol 'defined' evaluates to true. -defined= non-empty +# If a variable named 'defined' is actually defined, the bare word 'defined' +# is interpreted as 'defined(defined)', and the condition evaluates to true. +defined= # defined but empty .if defined . info A plain function name is parsed as !empty(...). .else @@ -119,7 +119,7 @@ defined= non-empty . info Symbols may start with a function name. .endif -defined-var= non-empty +defined-var= # defined but empty .if defined-var . info Symbols may start with a function name. .else @@ -132,6 +132,3 @@ defined-var= non-empty .else . error .endif - -all: - @:;