Module Name:    src
Committed By:   rillig
Date:           Sun Nov  8 21:40:13 UTC 2020

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

Log Message:
make(1): add test for function argument with unbalanced braces


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/cond-func.exp
cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/cond-func.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-func.exp
diff -u src/usr.bin/make/unit-tests/cond-func.exp:1.1 src/usr.bin/make/unit-tests/cond-func.exp:1.2
--- src/usr.bin/make/unit-tests/cond-func.exp:1.1	Thu Aug 20 17:45:47 2020
+++ src/usr.bin/make/unit-tests/cond-func.exp	Sun Nov  8 21:40:13 2020
@@ -1,9 +1,9 @@
-make: "cond-func.mk" line 29: warning: Missing closing parenthesis for defined()
-make: "cond-func.mk" line 29: Malformed conditional (!defined(A B))
-make: "cond-func.mk" line 44: warning: Missing closing parenthesis for defined()
-make: "cond-func.mk" line 44: Malformed conditional (!defined(A&B))
-make: "cond-func.mk" line 47: warning: Missing closing parenthesis for defined()
-make: "cond-func.mk" line 47: Malformed conditional (!defined(A|B))
+make: "cond-func.mk" line 34: warning: Missing closing parenthesis for defined()
+make: "cond-func.mk" line 34: Malformed conditional (!defined(A B))
+make: "cond-func.mk" line 49: warning: Missing closing parenthesis for defined()
+make: "cond-func.mk" line 49: Malformed conditional (!defined(A&B))
+make: "cond-func.mk" line 52: warning: Missing closing parenthesis for defined()
+make: "cond-func.mk" line 52: Malformed conditional (!defined(A|B))
 make: Fatal errors encountered -- cannot continue
 make: stopped in unit-tests
 exit status 1

Index: src/usr.bin/make/unit-tests/cond-func.mk
diff -u src/usr.bin/make/unit-tests/cond-func.mk:1.5 src/usr.bin/make/unit-tests/cond-func.mk:1.6
--- src/usr.bin/make/unit-tests/cond-func.mk:1.5	Sun Nov  8 21:33:05 2020
+++ src/usr.bin/make/unit-tests/cond-func.mk	Sun Nov  8 21:40:13 2020
@@ -1,4 +1,4 @@
-# $NetBSD: cond-func.mk,v 1.5 2020/11/08 21:33:05 rillig Exp $
+# $NetBSD: cond-func.mk,v 1.6 2020/11/08 21:40:13 rillig Exp $
 #
 # Tests for those parts of the functions in .if conditions that are common
 # among several functions.
@@ -9,7 +9,12 @@
 DEF=			defined
 ${:UA B}=		variable name with spaces
 ${:UVAR(value)}=	variable name with parentheses
-${:UVAR{value}}=	variable name with braces
+${:UVAR{value}}=	variable name with balanced braces
+
+# Really strange variable names must be given indirectly via another variable,
+# so that no unbalanced braces appear in the top-level expression.
+VARNAME_UNBALANCED_BRACES=	VAR{{{value
+${VARNAME_UNBALANCED_BRACES}=	variable name with unbalanced braces
 
 .if !defined(DEF)
 .  error
@@ -59,6 +64,12 @@ ${:UVAR{value}}=	variable name with brac
 .  error
 .endif
 
+# Braces do not have any special meaning when parsing arguments.
+# They don't need to be balanced.
+.if !defined(VAR{{{value)
+.  error
+.endif
+
 # There may be spaces around the operators and parentheses, and even
 # inside the parentheses.  The spaces inside the parentheses are not
 # allowed for the empty() function (see cond-func-empty.mk), therefore

Reply via email to