Module Name:    src
Committed By:   rillig
Date:           Sat Aug 22 21:22:24 UTC 2020

Modified Files:
        src/usr.bin/make/unit-tests: Makefile varname-empty.exp
            varname-empty.mk

Log Message:
make(1): try to set the variable named "" using the command line

Before 2020-08-22, the command line argument '=cmline-plain' triggered
undefined behavior, just like the assignment '=assigned' in the Makefile.


To generate a diff of this commit:
cvs rdiff -u -r1.111 -r1.112 src/usr.bin/make/unit-tests/Makefile
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/varname-empty.exp
cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/varname-empty.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/Makefile
diff -u src/usr.bin/make/unit-tests/Makefile:1.111 src/usr.bin/make/unit-tests/Makefile:1.112
--- src/usr.bin/make/unit-tests/Makefile:1.111	Sat Aug 22 20:50:43 2020
+++ src/usr.bin/make/unit-tests/Makefile	Sat Aug 22 21:22:24 2020
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.111 2020/08/22 20:50:43 sjg Exp $
+# $NetBSD: Makefile,v 1.112 2020/08/22 21:22:24 rillig Exp $
 #
 # Unit tests for make(1)
 #
@@ -323,6 +323,7 @@ FLAGS.order=		-j1
 FLAGS.recursive=	-dL
 FLAGS.vardebug=		-k -dv FROM_CMDLINE=
 FLAGS.varmod-match-escape= -dv
+FLAGS.varname-empty=	-dv '$${:U}=cmdline-u' '=cmline-plain'
 
 # Some tests need extra post-processing.
 SED_CMDS.sh-dots+=	-e 's,^${.SHELL}: ,,'
@@ -336,6 +337,7 @@ SED_CMDS.varshell+=	-e '/command/s,No su
 POSTPROC.counter=	${TOOL_SED} -n -e '/:RELEVANT = yes/,/:RELEVANT = no/p'
 POSTPROC.vardebug=	${TOOL_SED} -n -e '/:RELEVANT = yes/,/:RELEVANT = no/p'
 POSTPROC.varmod-match-escape= ${TOOL_SED} -n -e '/^Pattern/p'
+POSTPROC.varname-empty=	${TOOL_SED} -n -e '/^Var_Set/p' -e '/^out:/p'
 
 # Some tests reuse other tests, which makes them unnecessarily fragile.
 export-all.rawout: export.mk

Index: src/usr.bin/make/unit-tests/varname-empty.exp
diff -u src/usr.bin/make/unit-tests/varname-empty.exp:1.2 src/usr.bin/make/unit-tests/varname-empty.exp:1.3
--- src/usr.bin/make/unit-tests/varname-empty.exp:1.2	Sat Aug 22 20:31:50 2020
+++ src/usr.bin/make/unit-tests/varname-empty.exp	Sat Aug 22 21:22:24 2020
@@ -1,3 +1,11 @@
-fallback
-1 2 3
+Var_Set("${:U}", "cmdline-u", ...) name expands to empty string - ignored
+Var_Set("", "cmline-plain", ...) name expands to empty string - ignored
+Var_Set("", "default", ...) name expands to empty string - ignored
+Var_Set("", "assigned", ...) name expands to empty string - ignored
+Var_Set("", "appended", ...) name expands to empty string - ignored
+Var_Set("", "", ...) name expands to empty string - ignored
+Var_Set("", "subst", ...) name expands to empty string - ignored
+Var_Set("", "shell-output", ...) name expands to empty string - ignored
+out: fallback
+out: 1 2 3
 exit status 0

Index: src/usr.bin/make/unit-tests/varname-empty.mk
diff -u src/usr.bin/make/unit-tests/varname-empty.mk:1.4 src/usr.bin/make/unit-tests/varname-empty.mk:1.5
--- src/usr.bin/make/unit-tests/varname-empty.mk:1.4	Sat Aug 22 21:12:29 2020
+++ src/usr.bin/make/unit-tests/varname-empty.mk	Sat Aug 22 21:22:24 2020
@@ -1,4 +1,4 @@
-# $NetBSD: varname-empty.mk,v 1.4 2020/08/22 21:12:29 rillig Exp $
+# $NetBSD: varname-empty.mk,v 1.5 2020/08/22 21:22:24 rillig Exp $
 #
 # Tests for the special variable with the empty name.
 #
@@ -12,7 +12,7 @@
 =	assigned	# undefined behavior until 2020-08-22
 +=	appended
 :=	subst
-!=	echo 'value'
+!=	echo 'shell-output'
 
 # The .for loop expands the expression ${i} to ${:U1}, ${:U2} and so on.
 # This only works if the variable with the empty name is guaranteed to
@@ -22,5 +22,5 @@ NUMBERS+=	${i}
 .endfor
 
 all:
-	@echo ${:Ufallback}
-	@echo ${NUMBERS}
+	@echo out: ${:Ufallback}
+	@echo out: ${NUMBERS}

Reply via email to