2020-11-20 03:54:37 +00:00
|
|
|
# $NetBSD: cond-token-number.mk,v 1.5 2020/11/15 14:58:14 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
|
|
|
|
|
|
|
|
# This is not a hexadecimal number, even though it has an x.
|
|
|
|
# It is interpreted as a string instead, effectively meaning defined(3x4).
|
|
|
|
.if 3x4
|
|
|
|
.else
|
|
|
|
. error
|
|
|
|
.endif
|
|
|
|
|
2020-11-07 19:39:21 +00:00
|
|
|
# Ensure that parsing continues until here.
|
|
|
|
.info End of the tests.
|
|
|
|
|
|
|
|
all: # nothing
|