Module Name: src Committed By: rillig Date: Thu Sep 8 05:43:20 UTC 2022
Modified Files: src/usr.bin/make/unit-tests: cond-cmp-unary.mk Log Message: tests/make: document an edge case in evaluating conditionals To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/cond-cmp-unary.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-cmp-unary.mk diff -u src/usr.bin/make/unit-tests/cond-cmp-unary.mk:1.2 src/usr.bin/make/unit-tests/cond-cmp-unary.mk:1.3 --- src/usr.bin/make/unit-tests/cond-cmp-unary.mk:1.2 Wed Nov 11 07:30:11 2020 +++ src/usr.bin/make/unit-tests/cond-cmp-unary.mk Thu Sep 8 05:43:20 2022 @@ -1,11 +1,11 @@ -# $NetBSD: cond-cmp-unary.mk,v 1.2 2020/11/11 07:30:11 rillig Exp $ +# $NetBSD: cond-cmp-unary.mk,v 1.3 2022/09/08 05:43:20 rillig Exp $ # # Tests for unary comparisons in .if conditions, that is, comparisons with # a single operand. If the operand is a number, it is compared to zero, # if it is a string, it is tested for emptiness. -# The number 0 evaluates to false. -.if 0 +# The number 0 in all its various representations evaluates to false. +.if 0 || 0.0 || 0e0 || 0.0e0 || 0.0e10 . error .endif @@ -55,4 +55,20 @@ . error .endif +# The condition '${VAR:M*}' is almost equivalent to '${VAR:M*} != ""'. The +# only case where they differ is for a single word whose numeric value is zero. +.if ${:U0:M*} +. error +.endif +.if ${:U0:M*} == "" +. error +.endif +# Multiple words cannot be parsed as a single number, thus evaluating to true. +.if !${:U0 0:M*} +. error +.endif +.if ${:U0 0:M*} == "" +. error +.endif + all: # nothing