cond-cmp-numeric.mk revision 1.4
11.4Srillig# $NetBSD: cond-cmp-numeric.mk,v 1.4 2020/11/08 22:56:16 rillig Exp $ 21.1Srillig# 31.2Srillig# Tests for numeric comparisons in .if conditions. 41.1Srillig 51.3Srillig.MAKEFLAGS: -dc 61.3Srillig 71.3Srillig# The ${:U...} on the left-hand side is necessary for the parser. 81.3Srillig 91.3Srillig# Even if strtod(3) parses "INF" as +Infinity, make does not accept this 101.3Srillig# since it is not really a number; see TryParseNumber. 111.3Srillig.if !(${:UINF} > 1e100) 121.3Srillig. error 131.3Srillig.endif 141.3Srillig 151.3Srillig# Neither is NaN a number; see TryParseNumber. 161.3Srillig.if ${:UNaN} > NaN 171.3Srillig. error 181.3Srillig.endif 191.3Srillig 201.3Srillig# Since NaN is not parsed as a number, both operands are interpreted 211.3Srillig# as strings and are therefore equal. If they were parsed as numbers, 221.3Srillig# they would compare unequal, since NaN is unequal to any and everything, 231.3Srillig# including itself. 241.3Srillig.if !(${:UNaN} == NaN) 251.3Srillig. error 261.3Srillig.endif 271.1Srillig 281.4Srillig# The parsing code in CondParser_Comparison only performs a light check on 291.4Srillig# whether the operator is valid, leaving the rest of the work to the 301.4Srillig# evaluation functions EvalCompareNum and EvalCompareStr. Ensure that this 311.4Srillig# parse error is properly reported. 321.4Srillig# 331.4Srillig# XXX: The warning message does not mention the actual operator. 341.4Srillig.if 123 ! 123 351.4Srillig. error 361.4Srillig.else 371.4Srillig. error 381.4Srillig.endif 391.4Srillig 401.1Srilligall: 411.1Srillig @:; 42