Module Name:    src
Committed By:   rillig
Date:           Thu Sep 24 06:03:45 UTC 2020

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

Log Message:
make(1): extend documentation in the varname-empty test


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 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/varname-empty.mk
diff -u src/usr.bin/make/unit-tests/varname-empty.mk:1.5 src/usr.bin/make/unit-tests/varname-empty.mk:1.6
--- src/usr.bin/make/unit-tests/varname-empty.mk:1.5	Sat Aug 22 21:22:24 2020
+++ src/usr.bin/make/unit-tests/varname-empty.mk	Thu Sep 24 06:03:44 2020
@@ -1,13 +1,32 @@
-# $NetBSD: varname-empty.mk,v 1.5 2020/08/22 21:22:24 rillig Exp $
+# $NetBSD: varname-empty.mk,v 1.6 2020/09/24 06:03:44 rillig Exp $
 #
 # Tests for the special variable with the empty name.
 #
-# The variable "" is not supposed to be assigned any value.
+# There is no variable named "" at all, and this fact is used a lot in
+# variable expressions of the form ${:Ufallback}.  These expressions are
+# based on the variable named "" and use the :U modifier to assign a
+# fallback value to the expression (but not to the variable).
+#
+# This form of expressions is used to implement value substitution in the
+# .for loops.  Another use case is in a variable assignment of the form
+# ${:Uvarname}=value, which allows for characters in the variable name that
+# would otherwise be interpreted by the parser, such as whitespace, ':',
+# '=', '$', backslash.
+#
+# The only places where a variable is assigned a value are Var_Set and
+# Var_Append, and these places protect the variable named "" from being
+# defined.  This is different from read-only variables, as that flag can
+# only apply to variables that are defined.
+#
 # This is because it is heavily used in the .for loop expansion,
 # as well as to generate arbitrary strings, as in ${:Ufallback}.
 
 # Until 2020-08-22 it was possible to assign a value to the variable with
 # the empty name, leading to all kinds of unexpected effects.
+#
+# Before 2020-08-22, the simple assignment operator '=' had an off-by-one
+# bug that caused unrelated memory to be read in Parse_DoVar, invoking
+# undefined behavior.
 ?=	default
 =	assigned	# undefined behavior until 2020-08-22
 +=	appended

Reply via email to