Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/make/unit-tests make(1): extend documentation in the...



details:   https://anonhg.NetBSD.org/src/rev/0ec7a3807fc0
branches:  trunk
changeset: 944228:0ec7a3807fc0
user:      rillig <rillig%NetBSD.org@localhost>
date:      Thu Sep 24 06:03:44 2020 +0000

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

diffstat:

 usr.bin/make/unit-tests/varname-empty.mk |  23 +++++++++++++++++++++--
 1 files changed, 21 insertions(+), 2 deletions(-)

diffs (38 lines):

diff -r eb459f016ab9 -r 0ec7a3807fc0 usr.bin/make/unit-tests/varname-empty.mk
--- a/usr.bin/make/unit-tests/varname-empty.mk  Thu Sep 24 05:43:29 2020 +0000
+++ b/usr.bin/make/unit-tests/varname-empty.mk  Thu Sep 24 06:03:44 2020 +0000
@@ -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



Home | Main Index | Thread Index | Old Index