2021-02-11 01:51:11 +00:00
|
|
|
# $NetBSD: cond-op-not.mk,v 1.7 2021/01/19 17:49:13 rillig Exp $
|
2020-09-05 16:11:04 +00:00
|
|
|
#
|
2020-11-20 03:54:37 +00:00
|
|
|
# Tests for the ! operator in .if conditions, which negates its argument.
|
2020-09-05 16:11:04 +00:00
|
|
|
|
|
|
|
# The exclamation mark negates its operand.
|
|
|
|
.if !1
|
2020-11-07 19:39:21 +00:00
|
|
|
. error
|
2020-09-05 16:11:04 +00:00
|
|
|
.endif
|
|
|
|
|
|
|
|
# Exclamation marks can be chained.
|
|
|
|
# This doesn't happen in practice though.
|
|
|
|
.if !!!1
|
2020-11-07 19:39:21 +00:00
|
|
|
. error
|
2020-09-05 16:11:04 +00:00
|
|
|
.endif
|
|
|
|
|
|
|
|
# The ! binds more tightly than the &&.
|
|
|
|
.if !!0 && 1
|
2020-11-07 19:39:21 +00:00
|
|
|
. error
|
2020-09-05 16:11:04 +00:00
|
|
|
.endif
|
|
|
|
|
2020-11-20 03:54:37 +00:00
|
|
|
# The operator '==' binds more tightly than '!'.
|
|
|
|
# This is unusual since most other programming languages define the precedence
|
|
|
|
# to be the other way round.
|
|
|
|
.if !${:Uexpression} == "expression"
|
|
|
|
. error
|
|
|
|
.endif
|
|
|
|
|
|
|
|
.if !${:U}
|
|
|
|
. info Not empty evaluates to true.
|
|
|
|
.else
|
|
|
|
. info Not empty evaluates to false.
|
|
|
|
.endif
|
|
|
|
|
|
|
|
.if !${:U }
|
|
|
|
. info Not space evaluates to true.
|
|
|
|
.else
|
|
|
|
. info Not space evaluates to false.
|
|
|
|
.endif
|
|
|
|
|
|
|
|
.if !${:U0}
|
|
|
|
. info Not 0 evaluates to true.
|
|
|
|
.else
|
|
|
|
. info Not 0 evaluates to false.
|
|
|
|
.endif
|
|
|
|
|
|
|
|
.if !${:U1}
|
|
|
|
. info Not 1 evaluates to true.
|
|
|
|
.else
|
|
|
|
. info Not 1 evaluates to false.
|
|
|
|
.endif
|
|
|
|
|
|
|
|
.if !${:Uword}
|
|
|
|
. info Not word evaluates to true.
|
|
|
|
.else
|
|
|
|
. info Not word evaluates to false.
|
|
|
|
.endif
|
|
|
|
|
2021-02-11 01:51:11 +00:00
|
|
|
# A single exclamation mark is a parse error.
|
|
|
|
.if !
|
|
|
|
. error
|
|
|
|
.else
|
|
|
|
. error
|
|
|
|
.endif
|
|
|
|
|
2020-09-05 16:11:04 +00:00
|
|
|
all:
|
|
|
|
@:;
|