Module Name: src
Committed By: rillig
Date: Tue Aug 25 20:49:40 UTC 2020
Modified Files:
src/usr.bin/make/unit-tests: moderrs.exp moderrs.mk varmod-assign.exp
varmod-assign.mk
Log Message:
make(1): move test for the ::= modifier to varmod-assign
To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/usr.bin/make/unit-tests/moderrs.exp
cvs rdiff -u -r1.14 -r1.15 src/usr.bin/make/unit-tests/moderrs.mk
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/varmod-assign.exp
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/varmod-assign.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/moderrs.exp
diff -u src/usr.bin/make/unit-tests/moderrs.exp:1.15 src/usr.bin/make/unit-tests/moderrs.exp:1.16
--- src/usr.bin/make/unit-tests/moderrs.exp:1.15 Sun Aug 9 15:15:29 2020
+++ src/usr.bin/make/unit-tests/moderrs.exp Tue Aug 25 20:49:40 2020
@@ -123,13 +123,6 @@ make: Unfinished modifier for FIB ('}' m
make: Unfinished modifier for FIB ('}' missing)
then
-mod-assign-parse:
-make: Unknown modifier ':'
-
-make: Bad modifier `:' for
-value}
-make: Unfinished modifier for ASSIGN ('}' missing)
-
mod-remember-parse:
1 1 2 3 5 8 13 21 34
make: Unknown modifier '_'
Index: src/usr.bin/make/unit-tests/moderrs.mk
diff -u src/usr.bin/make/unit-tests/moderrs.mk:1.14 src/usr.bin/make/unit-tests/moderrs.mk:1.15
--- src/usr.bin/make/unit-tests/moderrs.mk:1.14 Sun Aug 9 15:15:29 2020
+++ src/usr.bin/make/unit-tests/moderrs.mk Tue Aug 25 20:49:40 2020
@@ -1,4 +1,4 @@
-# $Id: moderrs.mk,v 1.14 2020/08/09 15:15:29 rillig Exp $
+# $Id: moderrs.mk,v 1.15 2020/08/25 20:49:40 rillig Exp $
#
# various modifier error tests
@@ -20,7 +20,6 @@ all: mod-regex-undefined-subexpression
all: mod-ts-parse
all: mod-t-parse
all: mod-ifelse-parse
-all: mod-assign-parse
all: mod-remember-parse
all: mod-sysv-parse
@@ -164,12 +163,6 @@ mod-ifelse-parse:
@echo ${FIB:?then:else
@echo ${FIB:?then:else}
-mod-assign-parse:
- @echo $@:
- @echo ${ASSIGN::x} # 'x' is an unknown assignment operator
- @echo ${::=value} # trying to set the empty variable
- @echo ${ASSIGN::=value # missing closing brace
-
mod-remember-parse:
@echo $@:
@echo ${FIB:_} # ok
Index: src/usr.bin/make/unit-tests/varmod-assign.exp
diff -u src/usr.bin/make/unit-tests/varmod-assign.exp:1.2 src/usr.bin/make/unit-tests/varmod-assign.exp:1.3
--- src/usr.bin/make/unit-tests/varmod-assign.exp:1.2 Sun Aug 16 12:48:55 2020
+++ src/usr.bin/make/unit-tests/varmod-assign.exp Tue Aug 25 20:49:40 2020
@@ -10,4 +10,14 @@ mod-assign-nested: then1t1
mod-assign-nested: else2e2
mod-assign-nested: then3t3
mod-assign-nested: else4e4
+make: Bad modifier `:' for
+value}
+make: Bad modifier `:' for
+mod-assign-empty: overwritten}
+mod-assign-empty: VAR=overwritten
+make: Unknown modifier ':'
+
+sysv:y
+make: Unfinished modifier for ASSIGN ('}' missing)
+
exit status 0
Index: src/usr.bin/make/unit-tests/varmod-assign.mk
diff -u src/usr.bin/make/unit-tests/varmod-assign.mk:1.3 src/usr.bin/make/unit-tests/varmod-assign.mk:1.4
--- src/usr.bin/make/unit-tests/varmod-assign.mk:1.3 Tue Aug 25 18:59:30 2020
+++ src/usr.bin/make/unit-tests/varmod-assign.mk Tue Aug 25 20:49:40 2020
@@ -1,10 +1,12 @@
-# $NetBSD: varmod-assign.mk,v 1.3 2020/08/25 18:59:30 rillig Exp $
+# $NetBSD: varmod-assign.mk,v 1.4 2020/08/25 20:49:40 rillig Exp $
#
# Tests for the obscure ::= variable modifiers, which perform variable
# assignments during evaluation, just like the = operator in C.
all: mod-assign
all: mod-assign-nested
+all: mod-assign-empty
+all: mod-assign-parse
mod-assign:
# The ::?= modifier applies the ?= assignment operator 3 times.
@@ -46,3 +48,24 @@ mod-assign-nested:
@echo $@: ${SINK4:Q}
SINK3:= ${1:?${THEN3::=then3${IT3::=t3}}:${ELSE3::=else3${IE3::=e3}}}${THEN3}${ELSE3}${IT3}${IE3}
SINK4:= ${0:?${THEN4::=then4${IT4::=t4}}:${ELSE4::=else4${IE4::=e4}}}${THEN4}${ELSE4}${IT4}${IE4}
+
+mod-assign-empty:
+ # Assigning to the empty variable would obviously not work since that variable
+ # is write-protected. Therefore it is rejected early as a "bad modifier".
+ @echo ${::=value}
+ @echo $@: ${:Uvalue::=overwritten}
+
+ # The :L modifier sets the variable's value to its name.
+ # Since the name is still "VAR", assigning to that variable works.
+ @echo $@: ${VAR:L::=overwritten} VAR=${VAR}
+
+mod-assign-parse:
+ # The modifier for assignment operators starts with a ':'.
+ # An 'x' after that is an invalid modifier.
+ @echo ${ASSIGN::x} # 'x' is an unknown assignment operator
+
+ # When parsing an assignment operator fails because the operator is
+ # incomplete, make falls back to the SysV modifier.
+ @echo ${SYSV::=sysv\:x}${SYSV::x=:y}
+
+ @echo ${ASSIGN::=value # missing closing brace