1 # $NetBSD: cond-token-number.mk,v 1.12 2025/06/28 22:39:28 rillig Exp $ 2 # 3 # Tests for number tokens in .if conditions. 4 # 5 # TODO: Add introduction. 6 7 .if 0 8 . error 9 .endif 10 11 # Even though -0 is a number and would be accepted by strtod, it is not 12 # accepted by the condition parser. 13 # 14 # See the ch_isdigit call in CondParser_String. 15 # expect+1: Malformed conditional "-0" 16 .if -0 17 . error 18 .else 19 . error 20 .endif 21 22 # Even though +0 is a number and would be accepted by strtod, it is not 23 # accepted by the condition parser. 24 # 25 # See the ch_isdigit call in CondParser_String. 26 # expect+1: Malformed conditional "+0" 27 .if +0 28 . error 29 .else 30 . error 31 .endif 32 33 # Even though -1 is a number and would be accepted by strtod, it is not 34 # accepted by the condition parser. 35 # 36 # See the ch_isdigit call in CondParser_String. 37 # expect+1: Malformed conditional "!-1" 38 .if !-1 39 . error 40 .else 41 . error 42 .endif 43 44 # Even though +1 is a number and would be accepted by strtod, it is not 45 # accepted by the condition parser. 46 # 47 # See the ch_isdigit call in CondParser_String. 48 # expect+1: Malformed conditional "!+1" 49 .if !+1 50 . error 51 .else 52 . error 53 .endif 54 55 # When the number comes from an expression though, it may be signed. 56 # XXX: This is inconsistent. 57 .if ${:U+0} 58 . error 59 .endif 60 61 # When the number comes from an expression though, it may be signed. 62 # XXX: This is inconsistent. 63 .if !${:U+1} 64 . error 65 .endif 66 67 # Hexadecimal numbers are accepted. 68 .if 0x0 69 . error 70 .endif 71 .if 0x1 72 .else 73 . error 74 .endif 75 76 # This is not a hexadecimal number, even though it has an x. It is 77 # interpreted as a string instead. In a plain '.if', such a token evaluates 78 # to true if it is non-empty. In other '.if' directives, such a token is 79 # evaluated by either FuncDefined or FuncMake. 80 .if 3x4 81 .else 82 . error 83 .endif 84 85 # Make can do radix conversion from hex. 86 HEX= dead 87 .if 0x${HEX} == 57005 88 .else 89 . error 90 .endif 91 92 # Very small numbers round to 0. 93 .if 12345e-400 94 . error 95 .endif 96 .if 12345e-200 97 .else 98 . error 99 .endif 100 101 # Very large numbers round up to infinity on IEEE 754 implementations, or to 102 # the largest representable number (VAX); in particular, make does not fall 103 # back to checking whether a variable of that name is defined. 104 .if 12345e400 105 .else 106 . error 107 .endif 108 109 all: 110