2023-04-24 23:44:30 +00:00
|
|
|
# $NetBSD: cond-token-number.mk,v 1.8 2023/03/04 08:07:29 rillig Exp $
|
2020-09-05 16:11:04 +00:00
|
|
|
#
|
|
|
|
# Tests for number tokens in .if conditions.
|
2020-11-20 03:54:37 +00:00
|
|
|
#
|
|
|
|
# TODO: Add introduction.
|
2020-09-05 16:11:04 +00:00
|
|
|
|
2020-11-07 19:39:21 +00:00
|
|
|
.if 0
|
|
|
|
. error
|
|
|
|
.endif
|
2020-09-05 16:11:04 +00:00
|
|
|
|
2020-11-07 19:39:21 +00:00
|
|
|
# Even though -0 is a number and would be accepted by strtod, it is not
|
|
|
|
# accepted by the condition parser.
|
|
|
|
#
|
|
|
|
# See the ch_isdigit call in CondParser_String.
|
|
|
|
.if -0
|
|
|
|
. error
|
2020-11-20 03:54:37 +00:00
|
|
|
.else
|
|
|
|
. error
|
2020-11-07 19:39:21 +00:00
|
|
|
.endif
|
|
|
|
|
|
|
|
# Even though +0 is a number and would be accepted by strtod, it is not
|
|
|
|
# accepted by the condition parser.
|
|
|
|
#
|
|
|
|
# See the ch_isdigit call in CondParser_String.
|
|
|
|
.if +0
|
|
|
|
. error
|
2020-11-20 03:54:37 +00:00
|
|
|
.else
|
|
|
|
. error
|
2020-11-07 19:39:21 +00:00
|
|
|
.endif
|
|
|
|
|
|
|
|
# Even though -1 is a number and would be accepted by strtod, it is not
|
|
|
|
# accepted by the condition parser.
|
|
|
|
#
|
|
|
|
# See the ch_isdigit call in CondParser_String.
|
|
|
|
.if !-1
|
|
|
|
. error
|
2020-11-20 03:54:37 +00:00
|
|
|
.else
|
|
|
|
. error
|
2020-11-07 19:39:21 +00:00
|
|
|
.endif
|
|
|
|
|
|
|
|
# Even though +1 is a number and would be accepted by strtod, it is not
|
|
|
|
# accepted by the condition parser.
|
|
|
|
#
|
|
|
|
# See the ch_isdigit call in CondParser_String.
|
|
|
|
.if !+1
|
|
|
|
. error
|
2020-11-20 03:54:37 +00:00
|
|
|
.else
|
|
|
|
. error
|
2020-11-07 19:39:21 +00:00
|
|
|
.endif
|
|
|
|
|
|
|
|
# When the number comes from a variable expression though, it may be signed.
|
|
|
|
# XXX: This is inconsistent.
|
|
|
|
.if ${:U+0}
|
|
|
|
. error
|
|
|
|
.endif
|
|
|
|
|
|
|
|
# When the number comes from a variable expression though, it may be signed.
|
|
|
|
# XXX: This is inconsistent.
|
|
|
|
.if !${:U+1}
|
|
|
|
. error
|
|
|
|
.endif
|
|
|
|
|
2020-11-20 03:54:37 +00:00
|
|
|
# Hexadecimal numbers are accepted.
|
|
|
|
.if 0x0
|
|
|
|
. error
|
|
|
|
.endif
|
|
|
|
.if 0x1
|
|
|
|
.else
|
|
|
|
. error
|
|
|
|
.endif
|
|
|
|
|
2022-02-05 20:03:50 +00:00
|
|
|
# This is not a hexadecimal number, even though it has an x. It is
|
|
|
|
# interpreted as a string instead. In a plain '.if', such a token evaluates
|
|
|
|
# to true if it is non-empty. In other '.if' directives, such a token is
|
|
|
|
# evaluated by either FuncDefined or FuncMake.
|
2020-11-20 03:54:37 +00:00
|
|
|
.if 3x4
|
|
|
|
.else
|
|
|
|
. error
|
|
|
|
.endif
|
|
|
|
|
2022-02-05 20:03:50 +00:00
|
|
|
# Make can do radix conversion from hex.
|
|
|
|
HEX= dead
|
|
|
|
.if 0x${HEX} == 57005
|
|
|
|
.else
|
|
|
|
. error
|
|
|
|
.endif
|
|
|
|
|
2023-04-24 23:44:30 +00:00
|
|
|
# Very small numbers round to 0.
|
|
|
|
.if 12345e-400
|
|
|
|
. error
|
|
|
|
.endif
|
|
|
|
.if 12345e-200
|
|
|
|
.else
|
|
|
|
. error
|
|
|
|
.endif
|
|
|
|
|
|
|
|
# Very large numbers round up to infinity on IEEE 754 implementations, or to
|
|
|
|
# the largest representable number (VAX); in particular, make does not fall
|
|
|
|
# back to checking whether a variable of that name is defined.
|
|
|
|
.if 12345e400
|
|
|
|
.else
|
|
|
|
. error
|
|
|
|
.endif
|
2020-11-07 19:39:21 +00:00
|
|
|
|
2023-04-24 23:44:30 +00:00
|
|
|
all:
|