Module Name:    src
Committed By:   rillig
Date:           Fri Sep 11 05:29:46 UTC 2020

Modified Files:
        src/usr.bin/make/unit-tests: cond-op.exp cond-op.mk

Log Message:
make(1): add rationale for evaluating expression after parse error


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/cond-op.exp
cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/cond-op.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/make/unit-tests/cond-op.exp
diff -u src/usr.bin/make/unit-tests/cond-op.exp:1.4 src/usr.bin/make/unit-tests/cond-op.exp:1.5
--- src/usr.bin/make/unit-tests/cond-op.exp:1.4	Fri Sep 11 05:14:21 2020
+++ src/usr.bin/make/unit-tests/cond-op.exp	Fri Sep 11 05:29:46 2020
@@ -1,7 +1,7 @@
 make: "cond-op.mk" line 45: Malformed conditional ("!word" == !word)
-make: "cond-op.mk" line 59: Malformed conditional (0 ${ERR::=evaluated})
-make: "cond-op.mk" line 63: warning: After detecting a parse error, the rest is evaluated.
-make: "cond-op.mk" line 67: Parsing continues until here.
+make: "cond-op.mk" line 70: Malformed conditional (0 ${ERR::=evaluated})
+make: "cond-op.mk" line 74: warning: After detecting a parse error, the rest is evaluated.
+make: "cond-op.mk" line 78: Parsing continues until here.
 make: Fatal errors encountered -- cannot continue
 make: stopped in unit-tests
 exit status 1

Index: src/usr.bin/make/unit-tests/cond-op.mk
diff -u src/usr.bin/make/unit-tests/cond-op.mk:1.6 src/usr.bin/make/unit-tests/cond-op.mk:1.7
--- src/usr.bin/make/unit-tests/cond-op.mk:1.6	Fri Sep 11 05:12:08 2020
+++ src/usr.bin/make/unit-tests/cond-op.mk	Fri Sep 11 05:29:46 2020
@@ -1,4 +1,4 @@
-# $NetBSD: cond-op.mk,v 1.6 2020/09/11 05:12:08 rillig Exp $
+# $NetBSD: cond-op.mk,v 1.7 2020/09/11 05:29:46 rillig Exp $
 #
 # Tests for operators like &&, ||, ! in .if conditions.
 #
@@ -55,7 +55,18 @@
 
 # As soon as the parser sees the '$', it knows that the condition will
 # be malformed.  Therefore there is no point in evaluating it.
-# As of 2020-09-11, that part of the condition is evaluated nevertheless.
+#
+# As of 2020-09-11, that part of the condition is evaluated nevertheless,
+# since CondParser_Expr just requests the next token, without restricting
+# the token to the expected tokens.  If the parser were to restrict the
+# valid follow tokens for the token "0" to those that can actually produce
+# a correct condition (which in this case would be comparison operators,
+# TOK_AND, TOK_OR or TOK_RPAREN), the variable expression would not have
+# to be evaluated.
+#
+# This would add a good deal of complexity to the code though, for almost
+# no benefit, especially since most expressions and conditions are side
+# effect free.
 .if 0 ${ERR::=evaluated}
 .  error
 .endif

Reply via email to