cond-token-plain.mk (bmake-20201101) | : | cond-token-plain.mk (bmake-20201117) | ||
---|---|---|---|---|
# $NetBSD: cond-token-plain.mk,v 1.4 2020/09/12 17:47:24 rillig Exp $ | # $NetBSD: cond-token-plain.mk,v 1.6 2020/11/15 14:58:14 rillig Exp $ | |||
# | # | |||
# Tests for plain tokens (that is, string literals without quotes) | # Tests for plain tokens (that is, string literals without quotes) | |||
# in .if conditions. | # in .if conditions. | |||
.MAKEFLAGS: -dc | .MAKEFLAGS: -dc | |||
.if ${:Uvalue} != value | .if ${:Uvalue} != value | |||
. error | . error | |||
.endif | .endif | |||
# Malformed condition since comment parsing is done in an early phase | # Malformed condition since comment parsing is done in an early phase | |||
# and removes the '#' and everything behind it long before the condition | # and removes the '#' and everything behind it long before the condition | |||
# parser gets to see it. | # parser gets to see it. | |||
# | # | |||
# XXX: The error message is missing for this malformed condition. | # XXX: The error message is missing for this malformed condition. | |||
# The right-hand side of the comparison is just a '"'. | # The right-hand side of the comparison is just a '"', before unescaping. | |||
.if ${:U} != "#hash" | .if ${:U} != "#hash" | |||
. error | . error | |||
.endif | .endif | |||
# To get a '#' into a condition, it has to be escaped using a backslash. | # To get a '#' into a condition, it has to be escaped using a backslash. | |||
# This prevents the comment parser from removing it, and in turn, it becomes | # This prevents the comment parser from removing it, and in turn, it becomes | |||
# visible to CondParser_String. | # visible to CondParser_String. | |||
.if ${:U\#hash} != "\#hash" | .if ${:U\#hash} != "\#hash" | |||
. error | . error | |||
.endif | .endif | |||
# Since 2002-12-30, and still as of 2020-09-11, CondParser_Token handles | # Since 2002-12-30, and still as of 2020-09-11, CondParser_Token handles | |||
# the '#' specially, even though at this point, there should be no need for | # the '#' specially, even though at this point, there should be no need for | |||
# comment handling anymore. The comments are supposed to be stripped off | # comment handling anymore. The comments are supposed to be stripped off | |||
# in a very early parsing phase. | # in a very early parsing phase. | |||
# | # | |||
# See https://gnats.netbsd.org/19596 for example makefiles demonstrating the | ||||
# original problems. This workaround is probably not needed anymore. | ||||
# | ||||
# XXX: Missing error message for the malformed condition. The right-hand | # XXX: Missing error message for the malformed condition. The right-hand | |||
# side is double-quotes, backslash, backslash. | # side before unescaping is double-quotes, backslash, backslash. | |||
# XXX: It is unexpected that the right-hand side evaluates to a single | ||||
# backslash. | ||||
.if ${:U\\} != "\\#hash" | .if ${:U\\} != "\\#hash" | |||
. error | . error | |||
.endif | .endif | |||
# The right-hand side of a comparison is not parsed as a token, therefore | # The right-hand side of a comparison is not parsed as a token, therefore | |||
# the code from CondParser_Token does not apply to it. | # the code from CondParser_Token does not apply to it. | |||
# TODO: Explain the consequences. | ||||
# TODO: Does this mean that more syntactic variants are allowed here? | ||||
.if ${:U\#hash} != \#hash | .if ${:U\#hash} != \#hash | |||
. error | . error | |||
.endif | .endif | |||
# XXX: What is the purpose of treating an escaped '#' in the following | # XXX: What is the purpose of treating an escaped '#' in the following | |||
# condition as a comment? And why only at the beginning of a token, | # condition as a comment? And why only at the beginning of a token, | |||
# just as in the shell? | # just as in the shell? | |||
.if 0 \# This is treated as a comment, but why? | .if 0 \# This is treated as a comment, but why? | |||
. error | . error | |||
.endif | .endif | |||
End of changes. 5 change blocks. | ||||
5 lines changed or deleted | 8 lines changed or added |