1 # $NetBSD: directive-if.mk,v 1.7 2020/11/15 20:20:58 rillig Exp $
3 # Tests for the .if directive.
13 . info 0 evaluates to false.
17 . info 1 evaluates to true.
24 # The commit from 2005-05-01 intended to detect this situation, but it failed
25 # to do this since the call to is_token had its arguments switched. They were
26 # expected as (str, token, token_len) but were actually passed as (token, str,
27 # token_len). This made is_token return true even if the directive was
28 # directly followed by alphanumerical characters, which was wrong. The
29 # typical cases produced an error message such as "Malformed conditional
30 # (x 123)", while the intended error message was "Unknown directive".
32 # Back at that time, the commits only modified the main code but did not add
33 # the corresponding unit tests. This allowed the bug to hide for more than
36 # Since 2020-11-10, the correct error message is produced. The '.ifx' is no
37 # longer interpreted as a variant of '.if', therefore the '.error' and '.else'
38 # are interpreted as ordinary directives, producing the error messages
39 # "if-less else" and "if-less endif".
53 # A plain word must not start with a '"'. It may contain a embedded quotes
54 # though, which are kept. The quotes need not be balanced. The next space
55 # ends the word, and the remaining " || 1" is parsed as "or true".
56 .if ${:Uplain"""""} == plain""""" || 1
57 . info Quotes in plain words are probably a mistake.
58 # XXX: Accepting quotes in plain words is probably a mistake as well.
66 . info Don't do this, always put a space after a directive.
70 . info Don't do this, always put a space after a directive.
76 . info Don't do this, always put a space around comparison operators.