directive-if.mk revision 1.3
11.3Srillig# $NetBSD: directive-if.mk,v 1.3 2020/11/10 20:44:18 rillig Exp $
21.1Srillig#
31.2Srillig# Tests for the .if directive.
41.1Srillig
51.1Srillig# TODO: Implementation
61.1Srillig
71.3Srillig.if 0
81.3Srillig.  error
91.3Srillig.else
101.3Srillig.  info 0 evaluates to false.
111.3Srillig.endif
121.3Srillig
131.3Srillig.if 1
141.3Srillig.  info 1 evaluates to true.
151.3Srillig.else
161.3Srillig.  error
171.3Srillig.endif
181.3Srillig
191.3Srillig# There is no '.ifx'.
201.3Srillig#
211.3Srillig# The commit from 2005-05-01 intended to detect this situation, but it failed
221.3Srillig# to do this since the call to is_token has its arguments switched.  They are
231.3Srillig# expected as (str, token, token_len) but are actually passed as (token, str,
241.3Srillig# token_len).  This made is_token return true even if the directive was
251.3Srillig# directly followed by alphanumerical characters.
261.3Srillig#
271.3Srillig# Back at that time, the commits only modified the main code but did not add
281.3Srillig# the corresponding unit tests.  This allowed the bug to hide for more than
291.3Srillig# 15 years.
301.3Srillig.ifx 123
311.3Srillig.  error
321.3Srillig.else
331.3Srillig.  error
341.3Srillig.endif
351.3Srillig
361.3Srillig# Missing condition.
371.3Srillig.if
381.3Srillig.  error
391.3Srillig.else
401.3Srillig.  error
411.3Srillig.endif
421.3Srillig
431.1Srilligall:
44