CVS commit: src/usr.bin/make/unit-tests

2021-08-02 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Aug  3 04:46:49 UTC 2021

Modified Files:
src/usr.bin/make/unit-tests: varmod-order-numeric.mk
varmod-order-reverse.mk varmod-order-shuffle.mk
varmod-order-string.mk varmod-order.exp varmod-order.mk

Log Message:
tests/make: fix test for the variable modifier ':On'

The variable modifier ':On' sorts words numerically.  If these words are
not numeric at all, they get assigned the numeric value 0.  Internally,
':On' uses qsort for sorting the words.  Since qsort is not specified to
use a stable sorting algorithm, the test data must only use words that
either are written in the same way or that are numerically different.

The test varmod-order failed this requirement by trying to numerically
sort a list of non-numeric words.  This led to different results on BSD
and Ubuntu, as could be expected.

To fix the tests, distinguish between words and numbers in the tests.
While here, clean up the tests for all variants of the variable modifier
':O'.

Found by sjg on Ubuntu.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/varmod-order-numeric.mk \
src/usr.bin/make/unit-tests/varmod-order-reverse.mk \
src/usr.bin/make/unit-tests/varmod-order.exp
cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/varmod-order-shuffle.mk \
src/usr.bin/make/unit-tests/varmod-order.mk
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/varmod-order-string.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/varmod-order-numeric.mk
diff -u src/usr.bin/make/unit-tests/varmod-order-numeric.mk:1.4 src/usr.bin/make/unit-tests/varmod-order-numeric.mk:1.5
--- src/usr.bin/make/unit-tests/varmod-order-numeric.mk:1.4	Sat Jul 31 20:55:46 2021
+++ src/usr.bin/make/unit-tests/varmod-order-numeric.mk	Tue Aug  3 04:46:49 2021
@@ -1,11 +1,17 @@
-# $NetBSD: varmod-order-numeric.mk,v 1.4 2021/07/31 20:55:46 rillig Exp $
+# $NetBSD: varmod-order-numeric.mk,v 1.5 2021/08/03 04:46:49 rillig Exp $
 #
-# Tests for the :On variable modifier, which returns the words, sorted in
-# ascending numeric order.
+# Tests for the variable modifiers ':On', which returns the words, sorted in
+# ascending numeric order, and for ':Orn' and ':Onr', which additionally
+# reverse the order.
+#
+# The variable modifiers ':On', ':Onr' and ':Orn' were added in var.c 1.939
+# from 2021-07-30.
 
 # This list contains only 32-bit numbers since the make code needs to conform
 # to C90, which does not provide integer types larger than 32 bit.  It uses
-# 'long long' by default, but that type is overridable if necessary.
+# 'long long' by default, but that type is overridable if necessary to support
+# older environments.
+#
 # To get 53-bit integers even in C90, it would be possible to switch to
 # 'double' instead, but that would allow floating-point numbers as well, which
 # is out of scope for this variable modifier.
@@ -24,6 +30,14 @@ NUMBERS=	3 5 7 1 42 -42 5K -3m 1M 1k -2G
 .  error ${NUMBERS:Onr}
 .endif
 
+# Duplicate numbers are preserved in the output.  In this case the
+# equal-valued numbers are spelled the same, so they are indistinguishable in
+# the output.
+DUPLICATES=	3 1 2 2 1 1	# https://oeis.org/A034002
+.if ${DUPLICATES:On} != "1 1 1 2 2 3"
+.  error ${DUPLICATES:On}
+.endif
+
 # If there are several numbers that have the same integer value, they are
 # returned in unspecified order.
 SAME_VALUE:=	${:U 79 80 0x0050 81 :On}
@@ -32,9 +46,9 @@ SAME_VALUE:=	${:U 79 80 0x0050 81 :On}
 .endif
 
 # Hexadecimal and octal numbers are supported as well.
-OCTAL=		0 010 0x7 9
-.if ${OCTAL:On} != "0 0x7 010 9"
-.  error ${OCTAL:On}
+MIXED_BASE=	0 010 0x7 9
+.if ${MIXED_BASE:On} != "0 0x7 010 9"
+.  error ${MIXED_BASE:On}
 .endif
 
 all:
Index: src/usr.bin/make/unit-tests/varmod-order-reverse.mk
diff -u src/usr.bin/make/unit-tests/varmod-order-reverse.mk:1.4 src/usr.bin/make/unit-tests/varmod-order-reverse.mk:1.5
--- src/usr.bin/make/unit-tests/varmod-order-reverse.mk:1.4	Sat Oct 24 08:46:08 2020
+++ src/usr.bin/make/unit-tests/varmod-order-reverse.mk	Tue Aug  3 04:46:49 2021
@@ -1,13 +1,12 @@
-# $NetBSD: varmod-order-reverse.mk,v 1.4 2020/10/24 08:46:08 rillig Exp $
+# $NetBSD: varmod-order-reverse.mk,v 1.5 2021/08/03 04:46:49 rillig Exp $
 #
 # Tests for the :Or variable modifier, which returns the words, sorted in
 # descending order.
 
-NUMBERS=	one two three four five six seven eight nine ten
+WORDS=		one two three four five six seven eight nine ten
 
-.if ${NUMBERS:Or} != "two three ten six seven one nine four five eight"
-.  error ${NUMBERS:Or}
+.if ${WORDS:Or} != "two three ten six seven one nine four five eight"
+.  error ${WORDS:Or}
 .endif
 
 all:
-	@:;
Index: src/usr.bin/make/unit-tests/varmod-order.exp
diff -u src/usr.bin/make/unit-tests/varmod-order.exp:1.4 src/usr.bin/make/unit-tests/varmod-order.exp:1.

CVS commit: src/usr.bin/make/unit-tests

2021-07-28 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu Jul 29 06:31:18 UTC 2021

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

Log Message:
tests/make: test spaces around numbers in comparisons

Just to see whether it is possible to write a conditional in the form
${ ${A} < ${B} :? ${A} : ${B} }, that is, with leading and trailing
whitespace, to make it easier for humans to read the code.

It's not possible, the result of this computation cannot be used in
further numeric comparisons, at least not in .if directives.  Leading
space would work, but trailing space wouldn't.

On the other hand, they would work in expressions of the form
${ ${A} < ${B} :? ... : ... } since in these, the condition is first
expanded and then parsed.  But that is an implementation detail that is
not documented and it is also difficult to understand.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/cond-cmp-numeric.exp
cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/cond-cmp-numeric.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-cmp-numeric.exp
diff -u src/usr.bin/make/unit-tests/cond-cmp-numeric.exp:1.5 src/usr.bin/make/unit-tests/cond-cmp-numeric.exp:1.6
--- src/usr.bin/make/unit-tests/cond-cmp-numeric.exp:1.5	Thu Jan 21 23:32:28 2021
+++ src/usr.bin/make/unit-tests/cond-cmp-numeric.exp	Thu Jul 29 06:31:18 2021
@@ -6,6 +6,10 @@ CondParser_Eval: !(${:UNaN} == NaN)
 lhs = "NaN", rhs = "NaN", op = ==
 CondParser_Eval: 123 ! 123
 make: "cond-cmp-numeric.mk" line 34: Malformed conditional (123 ! 123)
+CondParser_Eval: ${:U 123} < 124
+lhs = 123.00, rhs = 124.00, op = <
+CondParser_Eval: ${:U123 } < 124
+make: "cond-cmp-numeric.mk" line 50: String comparison operator must be either == or !=
 make: Fatal errors encountered -- cannot continue
 make: stopped in unit-tests
 exit status 1

Index: src/usr.bin/make/unit-tests/cond-cmp-numeric.mk
diff -u src/usr.bin/make/unit-tests/cond-cmp-numeric.mk:1.4 src/usr.bin/make/unit-tests/cond-cmp-numeric.mk:1.5
--- src/usr.bin/make/unit-tests/cond-cmp-numeric.mk:1.4	Sun Nov  8 22:56:16 2020
+++ src/usr.bin/make/unit-tests/cond-cmp-numeric.mk	Thu Jul 29 06:31:18 2021
@@ -1,4 +1,4 @@
-# $NetBSD: cond-cmp-numeric.mk,v 1.4 2020/11/08 22:56:16 rillig Exp $
+# $NetBSD: cond-cmp-numeric.mk,v 1.5 2021/07/29 06:31:18 rillig Exp $
 #
 # Tests for numeric comparisons in .if conditions.
 
@@ -37,5 +37,21 @@
 .  error
 .endif
 
+# Leading spaces are allowed for numbers.
+# See EvalCompare and TryParseNumber.
+.if ${:U 123} < 124
+.else
+.  error
+.endif
+
+# Trailing spaces are NOT allowed for numbers.
+# See EvalCompare and TryParseNumber.
+# expect+1: String comparison operator must be either == or !=
+.if ${:U123 } < 124
+.  error
+.else
+.  error
+.endif
+
 all:
 	@:;



CVS commit: src/usr.bin/make/unit-tests

2021-07-03 Thread Simon J. Gerraty
Module Name:src
Committed By:   sjg
Date:   Sun Jul  4 01:28:54 UTC 2021

Modified Files:
src/usr.bin/make/unit-tests: objdir-writable.exp objdir-writable.mk

Log Message:
Do not assume /tmp is safe to use if TMPDIR is set


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/objdir-writable.exp
cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/objdir-writable.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/objdir-writable.exp
diff -u src/usr.bin/make/unit-tests/objdir-writable.exp:1.2 src/usr.bin/make/unit-tests/objdir-writable.exp:1.3
--- src/usr.bin/make/unit-tests/objdir-writable.exp:1.2	Sat Feb  6 18:26:03 2021
+++ src/usr.bin/make/unit-tests/objdir-writable.exp	Sun Jul  4 01:28:54 2021
@@ -1,5 +1,5 @@
 make warning: TMPDIR/roobj: Permission denied.
-/tmp
+TMPDIR
 TMPDIR/roobj
 TMPDIR/roobj
 exit status 0

Index: src/usr.bin/make/unit-tests/objdir-writable.mk
diff -u src/usr.bin/make/unit-tests/objdir-writable.mk:1.4 src/usr.bin/make/unit-tests/objdir-writable.mk:1.5
--- src/usr.bin/make/unit-tests/objdir-writable.mk:1.4	Sat Nov 14 07:36:00 2020
+++ src/usr.bin/make/unit-tests/objdir-writable.mk	Sun Jul  4 01:28:54 2021
@@ -1,8 +1,9 @@
-# $NetBSD: objdir-writable.mk,v 1.4 2020/11/14 07:36:00 sjg Exp $
+# $NetBSD: objdir-writable.mk,v 1.5 2021/07/04 01:28:54 sjg Exp $
 
 # test checking for writable objdir
 
-RO_OBJDIR?= ${TMPDIR:U/tmp}/roobj
+TMPDIR?= /tmp
+RO_OBJDIR?= ${TMPDIR}/roobj
 
 .if make(do-objdir)
 # this should succeed
@@ -20,12 +21,12 @@ rm-objdir:
 	@rmdir ${RO_OBJDIR}
 
 no-objdir:
-	@MAKEOBJDIR=${RO_OBJDIR} ${.MAKE} -r -f /dev/null -C /tmp -V .OBJDIR
+	@MAKEOBJDIR=${RO_OBJDIR} ${.MAKE} -r -f /dev/null -C ${TMPDIR} -V .OBJDIR
 
 ro-objdir:
-	@MAKEOBJDIR=${RO_OBJDIR} ${.MAKE} -r -f /dev/null -C /tmp -V .OBJDIR MAKE_OBJDIR_CHECK_WRITABLE=no
+	@MAKEOBJDIR=${RO_OBJDIR} ${.MAKE} -r -f /dev/null -C ${TMPDIR} -V .OBJDIR MAKE_OBJDIR_CHECK_WRITABLE=no
 
 explicit-objdir:
-	@MAKEOBJDIR=/tmp ${.MAKE} -r -f ${MAKEFILE:tA} -C /tmp do-objdir -V .OBJDIR
+	@MAKEOBJDIR=${TMPDIR} ${.MAKE} -r -f ${MAKEFILE:tA} -C ${TMPDIR} do-objdir -V .OBJDIR
 .endif
 



CVS commit: src/usr.bin/make/unit-tests

2021-07-03 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Jul  3 22:39:40 UTC 2021

Modified Files:
src/usr.bin/make/unit-tests: job-output-null.exp job-output-null.mk

Log Message:
tests/make: make test job-output-null more portable

Previously, the test dependend on implementation details of the system's
printf command.

Thank you sjg for the detailed analysis on macOS, FreeBSD and Linux.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/job-output-null.exp \
src/usr.bin/make/unit-tests/job-output-null.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/job-output-null.exp
diff -u src/usr.bin/make/unit-tests/job-output-null.exp:1.1 src/usr.bin/make/unit-tests/job-output-null.exp:1.2
--- src/usr.bin/make/unit-tests/job-output-null.exp:1.1	Thu Apr 15 19:02:29 2021
+++ src/usr.bin/make/unit-tests/job-output-null.exp	Sat Jul  3 22:39:40 2021
@@ -1,4 +1,4 @@
 hello
 hello
-hello world without   newline, hello world without   newline, hello world without   newline.
+hello without   newline, hello without   newline.
 exit status 0
Index: src/usr.bin/make/unit-tests/job-output-null.mk
diff -u src/usr.bin/make/unit-tests/job-output-null.mk:1.1 src/usr.bin/make/unit-tests/job-output-null.mk:1.2
--- src/usr.bin/make/unit-tests/job-output-null.mk:1.1	Thu Apr 15 19:02:29 2021
+++ src/usr.bin/make/unit-tests/job-output-null.mk	Sat Jul  3 22:39:40 2021
@@ -1,4 +1,4 @@
-# $NetBSD: job-output-null.mk,v 1.1 2021/04/15 19:02:29 rillig Exp $
+# $NetBSD: job-output-null.mk,v 1.2 2021/07/03 22:39:40 rillig Exp $
 #
 # Test how null bytes in the output of a command are handled.  Make processes
 # them using null-terminated strings, which may cut off some of the output.
@@ -7,20 +7,33 @@
 # inconsistently.  It's an edge case though since typically the child
 # processes output text.
 
+# Note: The printf commands used in this test must only use a single format
+# string, without parameters.  This is because it is implementation-dependent
+# how many times the command 'printf "fmt%s" "" "" ""' calls write(2).
+#
+#	NetBSD /bin/sh		1 x write("fmtfmtfmt")
+#	Dash			1 x write("fmtfmtfmt")
+#	NetBSD /bin/ksh		3 x write("fmt") (via /bin/printf)
+#	Bash 5			3 x write("fmt")
+#
+# In the latter case the output may arrive in parts, which in this test makes
+# a crucial difference since the outcome of the test depends on whether there
+# is a '\n' in each of the blocks from the output.
+
 .MAKEFLAGS: -j1		# force jobs mode
 
 all: .PHONY
 	# The null byte from the command output is kept as-is.
 	# See CollectOutput, which looks like it intended to replace these
 	# null bytes with simple spaces.
-	@printf 'hello\0world%s\n' ''
+	@printf 'hello\0world\n'
 
 	# Give the parent process a chance to see the above output, but not
 	# yet the output from the next printf command.
 	@sleep 1
 
 	# All null bytes from the command output are kept as-is.
-	@printf 'hello\0world%s\n' '' '' '' '' '' ''
+	@printf 'hello\0world\n''hello\0world\n''hello\0world\n'
 
 	@sleep 1
 
@@ -29,4 +42,4 @@ all: .PHONY
 	#
 	# The three null bytes in a row test whether this output is
 	# compressed to a single space like in DebugFailedTarget.  It isn't.
-	@printf 'hello\0world\0without\0\0\0newline%s' ', ' ', ' '.'
+	@printf 'hello\0without\0\0\0newline, hello\0without\0\0\0newline.'



CVS commit: src/usr.bin/make/unit-tests

2021-06-28 Thread Simon J. Gerraty
Module Name:src
Committed By:   sjg
Date:   Tue Jun 29 00:35:23 UTC 2021

Modified Files:
src/usr.bin/make/unit-tests: Makefile

Log Message:
Allow BROKEN_TESTS to cause TESTS to be skipped.

Some tests simply do not work in some environments.
Eg. shell-ksh on macos/arm64
Allow local site to set BROKEN_TESTS to skip those they know
will not work.

Reviewed by: rillig


To generate a diff of this commit:
cvs rdiff -u -r1.279 -r1.280 src/usr.bin/make/unit-tests/Makefile

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.279 src/usr.bin/make/unit-tests/Makefile:1.280
--- src/usr.bin/make/unit-tests/Makefile:1.279	Wed Jun 16 09:39:48 2021
+++ src/usr.bin/make/unit-tests/Makefile	Tue Jun 29 00:35:23 2021
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.279 2021/06/16 09:39:48 rillig Exp $
+# $NetBSD: Makefile,v 1.280 2021/06/29 00:35:23 sjg Exp $
 #
 # Unit tests for make(1)
 #
@@ -429,6 +429,12 @@ TESTS+=		varparse-mod
 TESTS+=		varparse-undef-partial
 TESTS+=		varquote
 
+# Some tests just do not work on some platforms or environments
+# so allow for some filtering.
+.if !empty(BROKEN_TESTS)
+TESTS:= ${TESTS:${BROKEN_TESTS:S,^,N,:ts:}}
+.endif
+
 # Ideas for more tests:
 #	char-0020-space.mk
 #	char-005C-backslash.mk



CVS commit: src/usr.bin/make/unit-tests

2021-06-25 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Jun 25 15:56:02 UTC 2021

Modified Files:
src/usr.bin/make/unit-tests: directive-for-escape.exp
directive-for-escape.mk

Log Message:
tests/make: demonstrate newline injection in .for loop


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 \
src/usr.bin/make/unit-tests/directive-for-escape.exp
cvs rdiff -u -r1.8 -r1.9 src/usr.bin/make/unit-tests/directive-for-escape.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/directive-for-escape.exp
diff -u src/usr.bin/make/unit-tests/directive-for-escape.exp:1.9 src/usr.bin/make/unit-tests/directive-for-escape.exp:1.10
--- src/usr.bin/make/unit-tests/directive-for-escape.exp:1.9	Thu Jun 24 23:22:17 2021
+++ src/usr.bin/make/unit-tests/directive-for-escape.exp	Fri Jun 25 15:56:02 2021
@@ -79,4 +79,18 @@ For: loop body:
 make: "directive-for-escape.mk" line 118: eight  and no cents.
 make: "directive-for-escape.mk" line 119: eight dollardollardollardollar and no cents.
 make: "directive-for-escape.mk" line 128: eight  and no cents.
-exit status 0
+For: end for 1
+For: loop body:
+.  info short: ${:U"
+"}
+.  info long: ${:U"
+"}
+make: Unclosed variable expression, expecting '}' for modifier "U"" of variable "" with value """
+make: "directive-for-escape.mk" line 134: short: "
+make: "directive-for-escape.mk" line 135: Invalid line type
+make: Unclosed variable expression, expecting '}' for modifier "U"" of variable "" with value """
+make: "directive-for-escape.mk" line 136: long: "
+make: "directive-for-escape.mk" line 137: Invalid line type
+make: Fatal errors encountered -- cannot continue
+make: stopped in unit-tests
+exit status 1

Index: src/usr.bin/make/unit-tests/directive-for-escape.mk
diff -u src/usr.bin/make/unit-tests/directive-for-escape.mk:1.8 src/usr.bin/make/unit-tests/directive-for-escape.mk:1.9
--- src/usr.bin/make/unit-tests/directive-for-escape.mk:1.8	Thu Jun 24 23:22:17 2021
+++ src/usr.bin/make/unit-tests/directive-for-escape.mk	Fri Jun 25 15:56:02 2021
@@ -1,4 +1,4 @@
-# $NetBSD: directive-for-escape.mk,v 1.8 2021/06/24 23:22:17 rillig Exp $
+# $NetBSD: directive-for-escape.mk,v 1.9 2021/06/25 15:56:02 rillig Exp $
 #
 # Test escaping of special characters in the iteration values of a .for loop.
 # These values get expanded later using the :U variable modifier, and this
@@ -127,4 +127,12 @@ closing-brace=		}		# guard against an
 ${closing-brace}=		# alternative interpretation
 .info eight ${$}${$}${$}${$} and no cents.
 
+# What happens if the values from the .for loop contain a literal newline?
+# Oops, the newline is added verbatim to the loop body, where it is later
+# interpreted as an ordinary newline.
+.for i in "${.newline}"
+.  info short: $i
+.  info long: ${i}
+.endfor
+
 all:



CVS commit: src/usr.bin/make/unit-tests

2021-06-24 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu Jun 24 23:22:17 UTC 2021

Modified Files:
src/usr.bin/make/unit-tests: directive-for-escape.exp
directive-for-escape.mk

Log Message:
tests/make: test .for loop over a variable named '$'

It's an impractical edge case, nevertheless it's accepted by make.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/usr.bin/make/unit-tests/directive-for-escape.exp
cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/unit-tests/directive-for-escape.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/directive-for-escape.exp
diff -u src/usr.bin/make/unit-tests/directive-for-escape.exp:1.8 src/usr.bin/make/unit-tests/directive-for-escape.exp:1.9
--- src/usr.bin/make/unit-tests/directive-for-escape.exp:1.8	Tue Feb 23 15:56:30 2021
+++ src/usr.bin/make/unit-tests/directive-for-escape.exp	Thu Jun 24 23:22:17 2021
@@ -72,4 +72,11 @@ make: "directive-for-escape.mk" line 107
 make: "directive-for-escape.mk" line 108: . ${i2}: two
 make: "directive-for-escape.mk" line 109: . ${i,}: comma
 make: "directive-for-escape.mk" line 110: .  adjacent: innerinnerinnerinner
+For: end for 1
+For: loop body:
+.  info eight  and no cents.
+.  info eight ${:Udollar}${:Udollar}${:Udollar}${:Udollar} and no cents.
+make: "directive-for-escape.mk" line 118: eight  and no cents.
+make: "directive-for-escape.mk" line 119: eight dollardollardollardollar and no cents.
+make: "directive-for-escape.mk" line 128: eight  and no cents.
 exit status 0

Index: src/usr.bin/make/unit-tests/directive-for-escape.mk
diff -u src/usr.bin/make/unit-tests/directive-for-escape.mk:1.7 src/usr.bin/make/unit-tests/directive-for-escape.mk:1.8
--- src/usr.bin/make/unit-tests/directive-for-escape.mk:1.7	Mon Feb 15 07:58:19 2021
+++ src/usr.bin/make/unit-tests/directive-for-escape.mk	Thu Jun 24 23:22:17 2021
@@ -1,4 +1,4 @@
-# $NetBSD: directive-for-escape.mk,v 1.7 2021/02/15 07:58:19 rillig Exp $
+# $NetBSD: directive-for-escape.mk,v 1.8 2021/06/24 23:22:17 rillig Exp $
 #
 # Test escaping of special characters in the iteration values of a .for loop.
 # These values get expanded later using the :U variable modifier, and this
@@ -110,4 +110,21 @@ i,=		comma
 .  info .  adjacent: $i${i}${i:M*}$i
 .endfor
 
+# The variable name can be a single '$' since there is no check on valid
+# variable names. ForLoop_SubstVarShort skips "stupid" variable names though,
+# but ForLoop_SubstVarLong naively parses the body of the loop, substituting
+# each '${$}' with an actual 'dollar'.
+.for $ in dollar
+.  info eight  and no cents.
+.  info eight ${$}${$}${$}${$} and no cents.
+.endfor
+# Outside a .for loop, '${$}' is interpreted differently. The outer '$' starts
+# a variable expression. The inner '$' is followed by a '}' and is thus a
+# silent syntax error, the '$' is skipped. The variable name is thus '', and
+# since since there is never a variable named '', the whole expression '${$}'
+# evaluates to an empty string.
+closing-brace=		}		# guard against an
+${closing-brace}=		# alternative interpretation
+.info eight ${$}${$}${$}${$} and no cents.
+
 all:



CVS commit: src/usr.bin/make/unit-tests

2021-06-21 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Jun 21 08:28:37 UTC 2021

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

Log Message:
tests/make: remove unnecessary -dL from moderrs.mk

It was only needed for the test for unmatched subexpressions in the
modifier ':C'.  That test has been moved to varmod-subst-regex.mk.


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/usr.bin/make/unit-tests/moderrs.exp
cvs rdiff -u -r1.29 -r1.30 src/usr.bin/make/unit-tests/moderrs.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.31 src/usr.bin/make/unit-tests/moderrs.exp:1.32
--- src/usr.bin/make/unit-tests/moderrs.exp:1.31	Mon Jun 21 08:17:39 2021
+++ src/usr.bin/make/unit-tests/moderrs.exp	Mon Jun 21 08:28:37 2021
@@ -134,4 +134,4 @@ make: Unclosed variable expression, expe
 
 1 1 2 x3 5 8 1x3 21 34
 
-exit status 2
+exit status 0

Index: src/usr.bin/make/unit-tests/moderrs.mk
diff -u src/usr.bin/make/unit-tests/moderrs.mk:1.29 src/usr.bin/make/unit-tests/moderrs.mk:1.30
--- src/usr.bin/make/unit-tests/moderrs.mk:1.29	Mon Jun 21 08:17:39 2021
+++ src/usr.bin/make/unit-tests/moderrs.mk	Mon Jun 21 08:28:37 2021
@@ -1,10 +1,7 @@
-# $NetBSD: moderrs.mk,v 1.29 2021/06/21 08:17:39 rillig Exp $
+# $NetBSD: moderrs.mk,v 1.30 2021/06/21 08:28:37 rillig Exp $
 #
 # various modifier error tests
 
-# report unmatched subexpressions
-.MAKEFLAGS: -dL
-
 '=		'\''
 VAR=		TheVariable
 # in case we have to change it ;-)



CVS commit: src/usr.bin/make/unit-tests

2021-06-21 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Jun 21 08:17:39 UTC 2021

Modified Files:
src/usr.bin/make/unit-tests: moderrs.exp moderrs.mk
varmod-subst-regex.exp varmod-subst-regex.mk

Log Message:
tests/make: move and extend test for unmatched '\1' in ':C'

This test lived together with a few unrelated tests in moderrs.mk, it is
better placed in varmod-subst-regex.mk though.

While here, extend, document and explain the test since its purpose was
not obvious from reading the code alone.


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 src/usr.bin/make/unit-tests/moderrs.exp
cvs rdiff -u -r1.28 -r1.29 src/usr.bin/make/unit-tests/moderrs.mk
cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/varmod-subst-regex.exp
cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/varmod-subst-regex.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.30 src/usr.bin/make/unit-tests/moderrs.exp:1.31
--- src/usr.bin/make/unit-tests/moderrs.exp:1.30	Mon Jun 21 04:24:17 2021
+++ src/usr.bin/make/unit-tests/moderrs.exp	Mon Jun 21 08:17:39 2021
@@ -86,15 +86,6 @@ make: Unclosed variable expression, expe
 6: TheVariable
 7: TheVariable
 
-mod-regex-undefined-subexpression:
-one one 2 3 5 8 one3 2one 34
-make: No match for subexpression \2
-make: No match for subexpression \2
-make: No match for subexpression \1
-make: No match for subexpression \2
-make: No match for subexpression \1
-()+() ()+() ()+() 3 5 8 (3)+() ()+(1) 34
-
 mod-ts-parse:
 112358132134
 15152535558513521534

Index: src/usr.bin/make/unit-tests/moderrs.mk
diff -u src/usr.bin/make/unit-tests/moderrs.mk:1.28 src/usr.bin/make/unit-tests/moderrs.mk:1.29
--- src/usr.bin/make/unit-tests/moderrs.mk:1.28	Mon Jun 21 04:24:17 2021
+++ src/usr.bin/make/unit-tests/moderrs.mk	Mon Jun 21 08:17:39 2021
@@ -1,4 +1,4 @@
-# $NetBSD: moderrs.mk,v 1.28 2021/06/21 04:24:17 sjg Exp $
+# $NetBSD: moderrs.mk,v 1.29 2021/06/21 08:17:39 rillig Exp $
 #
 # various modifier error tests
 
@@ -22,7 +22,6 @@ all:	words
 all:	exclam
 all:	mod-subst-delimiter
 all:	mod-regex-delimiter
-all:	mod-regex-undefined-subexpression
 all:	mod-ts-parse
 all:	mod-t-parse
 all:	mod-ifelse-parse
@@ -122,23 +121,6 @@ mod-regex-delimiter: print-header print-
 	@echo 6: ${VAR:C,from,to,
 	@echo 7: ${VAR:C,from,to,}
 
-# In regular expressions with alternatives, not all capturing groups are
-# always set; some may be missing.  Warn about these.
-#
-# Since there is no way to turn off this warning, the combination of
-# alternative matches and capturing groups is seldom used, if at all.
-#
-# A newly added modifier 'U' such as in :C,(a.)|(b.),\1\2,U might be added
-# for treating undefined capturing groups as empty, but that would create a
-# syntactical ambiguity since the :S and :C modifiers are open-ended (see
-# mod-subst-chain).  Luckily the modifier :U does not make sense after :C,
-# therefore this case does not happen in practice.
-# The sub-modifier for the :S and :C modifiers would have to be chosen
-# wisely, to not create ambiguities while parsing.
-mod-regex-undefined-subexpression: print-header print-footer
-	@echo ${FIB:C,1(.*),one\1,}		# all ok
-	@echo ${FIB:C,1(.*)|2(.*),(\1)+(\2),:Q}	# no match for subexpression
-
 mod-ts-parse: print-header print-footer
 	@echo ${FIB:ts}
 	@echo ${FIB:ts\65}	# octal 065 == U+0035 == '5'

Index: src/usr.bin/make/unit-tests/varmod-subst-regex.exp
diff -u src/usr.bin/make/unit-tests/varmod-subst-regex.exp:1.5 src/usr.bin/make/unit-tests/varmod-subst-regex.exp:1.6
--- src/usr.bin/make/unit-tests/varmod-subst-regex.exp:1.5	Tue Feb 23 15:19:41 2021
+++ src/usr.bin/make/unit-tests/varmod-subst-regex.exp	Mon Jun 21 08:17:39 2021
@@ -22,4 +22,25 @@ make: Regex compilation error: (details 
 mod-regex-errors:
 make: Unknown modifier "Z"
 mod-regex-errors: xy
-exit status 0
+unmatched-subexpression.ok: one one 2 3 5 8 one3 2one 34
+make: No match for subexpression \2
+unmatched-subexpression.1: ()()
+make: No match for subexpression \2
+unmatched-subexpression.1: ()()
+make: No match for subexpression \1
+unmatched-subexpression.2: ()()
+unmatched-subexpression.3: 3
+unmatched-subexpression.5: 5
+unmatched-subexpression.8: 8
+make: No match for subexpression \2
+unmatched-subexpression.13: (3)()
+make: No match for subexpression \1
+unmatched-subexpression.21: ()(1)
+unmatched-subexpression.34: 34
+make: No match for subexpression \2
+make: No match for subexpression \2
+make: No match for subexpression \1
+make: No match for subexpression \2
+make: No match for subexpression \1
+unmatched-subexpression.all: ()() ()() ()() 3 5 8 (3)() ()(1) 34
+exit status 2

Index: src/usr.bin/make/unit-tests/varmod-subst-regex.mk
diff -u src/usr.bin/make/unit-tests/varmod-subst-regex.mk:1.6 src/usr.bin/make/unit-tests/varmod-subst-regex.mk:1.7
--- src/usr.bin

CVS commit: src/usr.bin/make/unit-tests

2021-06-17 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu Jun 17 15:25:34 UTC 2021

Modified Files:
src/usr.bin/make/unit-tests: deptgt-order.exp deptgt-order.mk

Log Message:
tests/make: add test for circular dependency in .ORDER


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/deptgt-order.exp
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/deptgt-order.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/deptgt-order.exp
diff -u src/usr.bin/make/unit-tests/deptgt-order.exp:1.1 src/usr.bin/make/unit-tests/deptgt-order.exp:1.2
--- src/usr.bin/make/unit-tests/deptgt-order.exp:1.1	Sun Aug 16 12:07:51 2020
+++ src/usr.bin/make/unit-tests/deptgt-order.exp	Thu Jun 17 15:25:33 2021
@@ -1 +1,4 @@
+: 'Making two out of one.'
+: 'Making three out of two.'
+: 'Making all out of three.'
 exit status 0

Index: src/usr.bin/make/unit-tests/deptgt-order.mk
diff -u src/usr.bin/make/unit-tests/deptgt-order.mk:1.2 src/usr.bin/make/unit-tests/deptgt-order.mk:1.3
--- src/usr.bin/make/unit-tests/deptgt-order.mk:1.2	Sun Aug 16 14:25:16 2020
+++ src/usr.bin/make/unit-tests/deptgt-order.mk	Thu Jun 17 15:25:33 2021
@@ -1,8 +1,18 @@
-# $NetBSD: deptgt-order.mk,v 1.2 2020/08/16 14:25:16 rillig Exp $
+# $NetBSD: deptgt-order.mk,v 1.3 2021/06/17 15:25:33 rillig Exp $
 #
 # Tests for the special target .ORDER in dependency declarations.
 
-# TODO: Implementation
+all one two three: .PHONY
 
-all:
-	@:;
+two: one
+	: 'Making $@ out of $>.'
+three: two
+	: 'Making $@ out of $>.'
+
+# This .ORDER creates a circular dependency since 'three' depends on 'one'
+# but 'one' is supposed to be built after 'three'.
+.ORDER: three one
+
+# XXX: The circular dependency should be detected here.
+all: three
+	: 'Making $@ out of $>.'



CVS commit: src/usr.bin/make/unit-tests

2021-06-11 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Jun 11 13:01:28 UTC 2021

Modified Files:
src/usr.bin/make/unit-tests: varmod-ifelse.exp varmod-ifelse.mk

Log Message:
tests/make: demonstrate handling of '+' and '*' in modifier ':?'

It doesn't make sense that these two characters are handled differently,
but that's what the current code has been doing for years.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/usr.bin/make/unit-tests/varmod-ifelse.exp
cvs rdiff -u -r1.16 -r1.17 src/usr.bin/make/unit-tests/varmod-ifelse.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/varmod-ifelse.exp
diff -u src/usr.bin/make/unit-tests/varmod-ifelse.exp:1.10 src/usr.bin/make/unit-tests/varmod-ifelse.exp:1.11
--- src/usr.bin/make/unit-tests/varmod-ifelse.exp:1.10	Mon Apr 19 23:51:42 2021
+++ src/usr.bin/make/unit-tests/varmod-ifelse.exp	Fri Jun 11 13:01:28 2021
@@ -23,6 +23,10 @@ make: Bad conditional expression 'string
 make: "varmod-ifelse.mk" line 159: .
 make: Bad conditional expression 'string == "literal" ||  >= 10' in 'string == "literal" ||  >= 10?yes:no'
 make: "varmod-ifelse.mk" line 160: .
+make: "varmod-ifelse.mk" line 167: true
+make: "varmod-ifelse.mk" line 169: false
+make: Bad conditional expression '	' in '	?true:false'
+make: "varmod-ifelse.mk" line 171: 
 make: Fatal errors encountered -- cannot continue
 make: stopped in unit-tests
 exit status 1

Index: src/usr.bin/make/unit-tests/varmod-ifelse.mk
diff -u src/usr.bin/make/unit-tests/varmod-ifelse.mk:1.16 src/usr.bin/make/unit-tests/varmod-ifelse.mk:1.17
--- src/usr.bin/make/unit-tests/varmod-ifelse.mk:1.16	Mon Apr 19 23:51:42 2021
+++ src/usr.bin/make/unit-tests/varmod-ifelse.mk	Fri Jun 11 13:01:28 2021
@@ -1,4 +1,4 @@
-# $NetBSD: varmod-ifelse.mk,v 1.16 2021/04/19 23:51:42 rillig Exp $
+# $NetBSD: varmod-ifelse.mk,v 1.17 2021/06/11 13:01:28 rillig Exp $
 #
 # Tests for the ${cond:?then:else} variable modifier, which evaluates either
 # the then-expression or the else-expression, depending on the condition.
@@ -158,3 +158,14 @@ NUMBER=		no		# not really a number
 NUMBER=		# empty, not really a number either
 .info ${${STRING} == "literal" && ${NUMBER} >= 10:?yes:no}.
 .info ${${STRING} == "literal" || ${NUMBER} >= 10:?yes:no}.
+
+# CondParser_LeafToken handles [0-9-+] specially, treating them as a number.
+PLUS=		+
+ASTERISK=	*
+EMPTY=		# empty
+# "true" since "+" is not the empty string.
+.info ${${PLUS}		:?true:false}
+# "false" since the variable named "*" is not defined.
+.info ${${ASTERISK}	:?true:false}
+# syntax error since the condition is completely blank.
+.info ${${EMPTY}	:?true:false}



CVS commit: src/usr.bin/make/unit-tests

2021-05-30 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun May 30 20:26:42 UTC 2021

Modified Files:
src/usr.bin/make/unit-tests: varmod-unique.mk

Log Message:
tests/make: test whitespace normalization for modifier ':u'


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/varmod-unique.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/varmod-unique.mk
diff -u src/usr.bin/make/unit-tests/varmod-unique.mk:1.4 src/usr.bin/make/unit-tests/varmod-unique.mk:1.5
--- src/usr.bin/make/unit-tests/varmod-unique.mk:1.4	Mon Aug 31 17:41:38 2020
+++ src/usr.bin/make/unit-tests/varmod-unique.mk	Sun May 30 20:26:41 2021
@@ -1,4 +1,4 @@
-# $NetBSD: varmod-unique.mk,v 1.4 2020/08/31 17:41:38 rillig Exp $
+# $NetBSD: varmod-unique.mk,v 1.5 2021/05/30 20:26:41 rillig Exp $
 #
 # Tests for the :u variable modifier, which discards adjacent duplicate
 # words.
@@ -15,10 +15,18 @@
 .  warning The :u modifier must do nothing with an empty word list.
 .endif
 
-.if ${:U1:u} != "1"
+.if ${:U   :u} != ""
+.  warning The modifier ':u' must normalize the whitespace.
+.endif
+
+.if ${:Uword:u} != "word"
 .  warning The :u modifier must do nothing with a single-element word list.
 .endif
 
+.if ${:U   word   :u} != "word"
+.  warning The modifier ':u' must normalize the whitespace.
+.endif
+
 .if ${:U1 1 1 1 1 1 1 1:u} != "1"
 .  warning The :u modifier must merge _all_ adjacent duplicate words.
 .endif



CVS commit: src/usr.bin/make/unit-tests

2021-05-18 Thread Simon J. Gerraty
Module Name:src
Committed By:   sjg
Date:   Tue May 18 17:05:45 UTC 2021

Modified Files:
src/usr.bin/make/unit-tests: Makefile opt-chdir.mk

Log Message:
Do not trust that /nonexistent does not exist

Use /nonexistent.${.MAKE.PID} to avoid failure when
/nonexistent actually exists.


To generate a diff of this commit:
cvs rdiff -u -r1.277 -r1.278 src/usr.bin/make/unit-tests/Makefile
cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/opt-chdir.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.277 src/usr.bin/make/unit-tests/Makefile:1.278
--- src/usr.bin/make/unit-tests/Makefile:1.277	Tue Apr 27 16:20:06 2021
+++ src/usr.bin/make/unit-tests/Makefile	Tue May 18 17:05:45 2021
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.277 2021/04/27 16:20:06 rillig Exp $
+# $NetBSD: Makefile,v 1.278 2021/05/18 17:05:45 sjg Exp $
 #
 # Unit tests for make(1)
 #
@@ -487,6 +487,7 @@ SED_CMDS.job-output-long-lines= \
 	${:D marker should always be at the beginning of the line. } \
 	-e '/^aa*--- job-b ---$$/d' \
 	-e '/^bb*--- job-a ---$$/d'
+SED_CMDS.opt-chdir=		-e 's,\(nonexistent\).[1-9][0-9]*,\1,'
 SED_CMDS.opt-debug-graph1=	${STD_SED_CMDS.dg1}
 SED_CMDS.opt-debug-graph2=	${STD_SED_CMDS.dg2}
 SED_CMDS.opt-debug-graph3=	${STD_SED_CMDS.dg3}

Index: src/usr.bin/make/unit-tests/opt-chdir.mk
diff -u src/usr.bin/make/unit-tests/opt-chdir.mk:1.5 src/usr.bin/make/unit-tests/opt-chdir.mk:1.6
--- src/usr.bin/make/unit-tests/opt-chdir.mk:1.5	Sun Nov 15 05:43:56 2020
+++ src/usr.bin/make/unit-tests/opt-chdir.mk	Tue May 18 17:05:45 2021
@@ -1,4 +1,4 @@
-# $NetBSD: opt-chdir.mk,v 1.5 2020/11/15 05:43:56 sjg Exp $
+# $NetBSD: opt-chdir.mk,v 1.6 2021/05/18 17:05:45 sjg Exp $
 #
 # Tests for the -C command line option, which changes the directory at the
 # beginning.
@@ -23,5 +23,7 @@ chdir-root: .PHONY .IGNORE
 	@MAKE_OBJDIR_CHECK_WRITABLE=no ${MAKE} -C / -V 'cwd: $${.CURDIR}'
 
 # Trying to change to a nonexistent directory exits immediately.
+# Note: just because the whole point of /nonexistent is that it should
+# not exist - doesn't mean it doesn't.
 chdir-nonexistent: .PHONY .IGNORE
-	@${MAKE} -C /nonexistent
+	@${MAKE} -C /nonexistent.${.MAKE.PID}



CVS commit: src/usr.bin/make/unit-tests

2021-05-14 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri May 14 19:37:16 UTC 2021

Modified Files:
src/usr.bin/make/unit-tests: varmod-subst.mk

Log Message:
tests/make: show that in ':S', '.' and '*' are ordinary characters


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/unit-tests/varmod-subst.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/varmod-subst.mk
diff -u src/usr.bin/make/unit-tests/varmod-subst.mk:1.7 src/usr.bin/make/unit-tests/varmod-subst.mk:1.8
--- src/usr.bin/make/unit-tests/varmod-subst.mk:1.7	Sun Nov 15 20:20:58 2020
+++ src/usr.bin/make/unit-tests/varmod-subst.mk	Fri May 14 19:37:16 2021
@@ -1,4 +1,4 @@
-# $NetBSD: varmod-subst.mk,v 1.7 2020/11/15 20:20:58 rillig Exp $
+# $NetBSD: varmod-subst.mk,v 1.8 2021/05/14 19:37:16 rillig Exp $
 #
 # Tests for the :S,from,to, variable modifier.
 
@@ -78,6 +78,14 @@ WORDS=		sequences of letters
 .  warning The :S modifier matches a too long suffix anchored at both ends.
 .endif
 
+.if ${WORDS:S,*,replacement,} != ${WORDS}
+.  error The '*' seems to be interpreted as a wildcard of some kind.
+.endif
+
+.if ${WORDS:S,.,replacement,} != ${WORDS}
+.  error The '.' seems to be interpreted as a wildcard of some kind.
+.endif
+
 mod-subst:
 	@echo $@:
 	@echo :${:Ua b b c:S,a b,,:Q}:



CVS commit: src/usr.bin/make/unit-tests

2021-04-25 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Apr 25 21:05:38 UTC 2021

Modified Files:
src/usr.bin/make/unit-tests: cond-token-var.mk

Log Message:
tests/make: add tests for ${...} without operator in conditions

These tests are already covered in cond-cmp-unary.mk, but my first guess
was to search for these tests in cond-token-var.mk, so keep them in both
tests.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/cond-token-var.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-token-var.mk
diff -u src/usr.bin/make/unit-tests/cond-token-var.mk:1.5 src/usr.bin/make/unit-tests/cond-token-var.mk:1.6
--- src/usr.bin/make/unit-tests/cond-token-var.mk:1.5	Sun Nov 15 14:58:14 2020
+++ src/usr.bin/make/unit-tests/cond-token-var.mk	Sun Apr 25 21:05:38 2021
@@ -1,4 +1,4 @@
-# $NetBSD: cond-token-var.mk,v 1.5 2020/11/15 14:58:14 rillig Exp $
+# $NetBSD: cond-token-var.mk,v 1.6 2021/04/25 21:05:38 rillig Exp $
 #
 # Tests for variable expressions in .if conditions.
 #
@@ -46,3 +46,24 @@ DEF=	defined
 # Since the expression is defined now, it doesn't generate any parse error.
 .if ${UNDEF:U}
 .endif
+
+# If the value of the variable expression is a number, it is compared against
+# zero.
+.if ${:U0}
+.  error
+.endif
+.if !${:U1}
+.  error
+.endif
+
+# If the value of the variable expression is not a number, any non-empty
+# value evaluates to true, even if there is only whitespace.
+.if ${:U}
+.  error
+.endif
+.if !${:U }
+.  error
+.endif
+.if !${:Uanything}
+.  error
+.endif



CVS commit: src/usr.bin/make/unit-tests

2021-04-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Apr 19 23:43:15 UTC 2021

Modified Files:
src/usr.bin/make/unit-tests: varmod-ifelse.exp varmod-ifelse.mk

Log Message:
tests/make: add another example for parsing of the modifier ':?'


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/usr.bin/make/unit-tests/varmod-ifelse.exp
cvs rdiff -u -r1.14 -r1.15 src/usr.bin/make/unit-tests/varmod-ifelse.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/varmod-ifelse.exp
diff -u src/usr.bin/make/unit-tests/varmod-ifelse.exp:1.8 src/usr.bin/make/unit-tests/varmod-ifelse.exp:1.9
--- src/usr.bin/make/unit-tests/varmod-ifelse.exp:1.8	Mon Apr 19 23:27:17 2021
+++ src/usr.bin/make/unit-tests/varmod-ifelse.exp	Mon Apr 19 23:43:14 2021
@@ -19,6 +19,10 @@ make: Bad conditional expression 'string
 make: "varmod-ifelse.mk" line 153: .
 make: Bad conditional expression 'string == "literal" || no >= 10' in 'string == "literal" || no >= 10?yes:no'
 make: "varmod-ifelse.mk" line 154: .
+make: Bad conditional expression 'string == "literal" &&  >= 10' in 'string == "literal" &&  >= 10?yes:no'
+make: "varmod-ifelse.mk" line 159: .
+make: Bad conditional expression 'string == "literal" ||  >= 10' in 'string == "literal" ||  >= 10?yes:no'
+make: "varmod-ifelse.mk" line 160: .
 make: Fatal errors encountered -- cannot continue
 make: stopped in unit-tests
 exit status 1

Index: src/usr.bin/make/unit-tests/varmod-ifelse.mk
diff -u src/usr.bin/make/unit-tests/varmod-ifelse.mk:1.14 src/usr.bin/make/unit-tests/varmod-ifelse.mk:1.15
--- src/usr.bin/make/unit-tests/varmod-ifelse.mk:1.14	Mon Apr 19 23:27:17 2021
+++ src/usr.bin/make/unit-tests/varmod-ifelse.mk	Mon Apr 19 23:43:14 2021
@@ -1,4 +1,4 @@
-# $NetBSD: varmod-ifelse.mk,v 1.14 2021/04/19 23:27:17 rillig Exp $
+# $NetBSD: varmod-ifelse.mk,v 1.15 2021/04/19 23:43:14 rillig Exp $
 #
 # Tests for the ${cond:?then:else} variable modifier, which evaluates either
 # the then-expression or the else-expression, depending on the condition.
@@ -152,3 +152,9 @@ STRING=		string
 NUMBER=		no		# not really a number
 .info ${${STRING} == "literal" && ${NUMBER} >= 10:?yes:no}.
 .info ${${STRING} == "literal" || ${NUMBER} >= 10:?yes:no}.
+
+# The following situation occasionally occurs with MKINET6 or similar
+# variables.
+NUMBER=		# empty, not really a number either
+.info ${${STRING} == "literal" && ${NUMBER} >= 10:?yes:no}.
+.info ${${STRING} == "literal" || ${NUMBER} >= 10:?yes:no}.



CVS commit: src/usr.bin/make/unit-tests

2021-04-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Apr 19 23:27:17 UTC 2021

Modified Files:
src/usr.bin/make/unit-tests: varmod-ifelse.exp varmod-ifelse.mk

Log Message:
tests/make: add detailed explanation for error message in conditional


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/unit-tests/varmod-ifelse.exp
cvs rdiff -u -r1.13 -r1.14 src/usr.bin/make/unit-tests/varmod-ifelse.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/varmod-ifelse.exp
diff -u src/usr.bin/make/unit-tests/varmod-ifelse.exp:1.7 src/usr.bin/make/unit-tests/varmod-ifelse.exp:1.8
--- src/usr.bin/make/unit-tests/varmod-ifelse.exp:1.7	Mon Apr 19 22:22:27 2021
+++ src/usr.bin/make/unit-tests/varmod-ifelse.exp	Mon Apr 19 23:27:17 2021
@@ -16,7 +16,9 @@ CondParser_Eval: ${VAR} == value 
 lhs = "value", rhs = "value", op = ==
 lhs = "ok", rhs = "ok", op = !=
 make: Bad conditional expression 'string == "literal" && no >= 10' in 'string == "literal" && no >= 10?yes:no'
-make: "varmod-ifelse.mk" line 127: .
+make: "varmod-ifelse.mk" line 153: .
+make: Bad conditional expression 'string == "literal" || no >= 10' in 'string == "literal" || no >= 10?yes:no'
+make: "varmod-ifelse.mk" line 154: .
 make: Fatal errors encountered -- cannot continue
 make: stopped in unit-tests
 exit status 1

Index: src/usr.bin/make/unit-tests/varmod-ifelse.mk
diff -u src/usr.bin/make/unit-tests/varmod-ifelse.mk:1.13 src/usr.bin/make/unit-tests/varmod-ifelse.mk:1.14
--- src/usr.bin/make/unit-tests/varmod-ifelse.mk:1.13	Mon Apr 19 22:22:27 2021
+++ src/usr.bin/make/unit-tests/varmod-ifelse.mk	Mon Apr 19 23:27:17 2021
@@ -1,4 +1,4 @@
-# $NetBSD: varmod-ifelse.mk,v 1.13 2021/04/19 22:22:27 rillig Exp $
+# $NetBSD: varmod-ifelse.mk,v 1.14 2021/04/19 23:27:17 rillig Exp $
 #
 # Tests for the ${cond:?then:else} variable modifier, which evaluates either
 # the then-expression or the else-expression, depending on the condition.
@@ -111,8 +111,34 @@ VAR=	value
 .endif
 .MAKEFLAGS: -d0
 
-# Seen on 2021-04-19 when building external/bsd/tmux with HAVE_LLVM=yes
-# and HAVE_GCC=no.
+# On 2021-04-19, when building external/bsd/tmux with HAVE_LLVM=yes and
+# HAVE_GCC=no, the following conditional generated this error message:
+#
+#	make: Bad conditional expression 'string == "literal" && no >= 10'
+#	in 'string == "literal" && no >= 10?yes:no'
+#
+# Despite the error message (which was not clearly marked with "error:"),
+# the build continued, for historical reasons, see main_Exit.
+#
+# The tricky detail here is that the condition that looks so obvious in the
+# form written in the makefile becomes tricky when it is actually evaluated.
+# This is because the condition is written in the place of the variable name
+# of the expression, and in an expression, the variable name is always
+# expanded first, before even looking at the modifiers.  This happens for the
+# modifier ':?' as well, so when CondEvalExpression gets to see the
+# expression, it already looks like this:
+#
+#	string == "literal" && no >= 10
+#
+# When parsing such an expression, the parser used to be strict.  It first
+# evaluated the left-hand side of the operator '&&' and then started parsing
+# the right-hand side 'no >= 10'.  The word 'no' is obviously a string
+# literal, not enclosed in quotes, which is ok, even on the left-hand side of
+# the comparison operator, but only because this is a condition in the
+# modifier ':?'.  In an ordinary directive '.if', this would be a parse error.
+# For strings, only the comparison operators '==' and '!=' are defined,
+# therefore parsing stopped at the '>', producing the 'Bad conditional
+# expression'.
 #
 # TODO: make should at least describe the part of the condition that is
 #  wrong. In this case it is probably the "no >= 10".  Ideally that should
@@ -123,5 +149,6 @@ VAR=	value
 #  seen at compile-time" that the operand types of '>=' don't match.  Only
 #  that the concept of "compile-time" does not really apply here.
 STRING=		string
-NUMBER=		no
+NUMBER=		no		# not really a number
 .info ${${STRING} == "literal" && ${NUMBER} >= 10:?yes:no}.
+.info ${${STRING} == "literal" || ${NUMBER} >= 10:?yes:no}.



CVS commit: src/usr.bin/make/unit-tests

2021-04-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Apr 19 22:05:29 UTC 2021

Modified Files:
src/usr.bin/make/unit-tests: varmod-ifelse.exp varmod-ifelse.mk

Log Message:
tests/make: demonstrate unexpected behavior of the modifier ':?'


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/varmod-ifelse.exp
cvs rdiff -u -r1.11 -r1.12 src/usr.bin/make/unit-tests/varmod-ifelse.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/varmod-ifelse.exp
diff -u src/usr.bin/make/unit-tests/varmod-ifelse.exp:1.5 src/usr.bin/make/unit-tests/varmod-ifelse.exp:1.6
--- src/usr.bin/make/unit-tests/varmod-ifelse.exp:1.5	Thu Dec 10 16:36:47 2020
+++ src/usr.bin/make/unit-tests/varmod-ifelse.exp	Mon Apr 19 22:05:29 2021
@@ -15,6 +15,8 @@ CondParser_Eval: ${ ${:U\$}{VAR} == valu
 CondParser_Eval: ${VAR} == value 
 lhs = "value", rhs = "value", op = ==
 lhs = "ok", rhs = "ok", op = !=
+make: Bad conditional expression `string == "literal" && no >= 10' in string == "literal" && no >= 10?yes:no
+make: "varmod-ifelse.mk" line 127: .
 make: Fatal errors encountered -- cannot continue
 make: stopped in unit-tests
 exit status 1

Index: src/usr.bin/make/unit-tests/varmod-ifelse.mk
diff -u src/usr.bin/make/unit-tests/varmod-ifelse.mk:1.11 src/usr.bin/make/unit-tests/varmod-ifelse.mk:1.12
--- src/usr.bin/make/unit-tests/varmod-ifelse.mk:1.11	Sun Apr 11 13:35:56 2021
+++ src/usr.bin/make/unit-tests/varmod-ifelse.mk	Mon Apr 19 22:05:29 2021
@@ -1,4 +1,4 @@
-# $NetBSD: varmod-ifelse.mk,v 1.11 2021/04/11 13:35:56 rillig Exp $
+# $NetBSD: varmod-ifelse.mk,v 1.12 2021/04/19 22:05:29 rillig Exp $
 #
 # Tests for the ${cond:?then:else} variable modifier, which evaluates either
 # the then-expression or the else-expression, depending on the condition.
@@ -111,5 +111,18 @@ VAR=	value
 .endif
 .MAKEFLAGS: -d0
 
-all:
-	@:;
+# Seen on 2021-04-19 when building external/bsd/tmux with HAVE_LLVM=yes
+# and HAVE_GCC=no.
+#
+# TODO: make should at least describe the part of the condition that is
+#  wrong. In this case it is probably the "no >= 10".  Ideally that should
+#  not matter though since the left-hand side of the '&&' evaluates to false,
+#  thus the right-hand side only needs to be parsed, not evaluated.  Since
+#  this is the modifier ':?', which expands subexpressions before parsing
+#  the condition, the "no >= 10" is probably a parse error since it "can be
+#  seen at compile-time" that the operand types of '>=' don't match.  Only
+#  that the concept of "compile-time" does not really apply here.
+STRING=		string
+NUMBER=		no
+.info ${${STRING} == "literal" && ${NUMBER} >= 10:?yes:no}.
+# XXX: In the diagnostic, the second placeholder is missing the quotes.



CVS commit: src/usr.bin/make/unit-tests

2021-04-12 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Apr 12 16:09:57 UTC 2021

Modified Files:
src/usr.bin/make/unit-tests: varmod-sysv.exp varmod-sysv.mk

Log Message:
tests/make: fix test for modifier ':from=to'

I had forgotten to remove the single quotes, to produce a really empty
word.  Plus I had forgotten the modifier ':Q' for the result, which
meant that the single quotes did not show up in the output.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/usr.bin/make/unit-tests/varmod-sysv.exp
cvs rdiff -u -r1.13 -r1.14 src/usr.bin/make/unit-tests/varmod-sysv.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/varmod-sysv.exp
diff -u src/usr.bin/make/unit-tests/varmod-sysv.exp:1.8 src/usr.bin/make/unit-tests/varmod-sysv.exp:1.9
--- src/usr.bin/make/unit-tests/varmod-sysv.exp:1.8	Mon Apr 12 16:04:30 2021
+++ src/usr.bin/make/unit-tests/varmod-sysv.exp	Mon Apr 12 16:09:57 2021
@@ -5,23 +5,23 @@ word modifier   
 suffix   ="suffix"
 prefix   ="prefix"
 pre-middle-suffix="pre-middle-suffix"
-''   =NS  "NS"
+''   =NS  ""
 suffix   =NS  "suffixNS"
 prefix   =NS  "prefixNS"
 pre-middle-suffix=NS  "pre-middle-suffixNS"
-''   =%   "%"
+''   =%   ""
 suffix   =%   "suffix%"
 prefix   =%   "prefix%"
 pre-middle-suffix=%   "pre-middle-suffix%"
-''   =%NS "%NS"
+''   =%NS ""
 suffix   =%NS "suffix%NS"
 prefix   =%NS "prefix%NS"
 pre-middle-suffix=%NS "pre-middle-suffix%NS"
-''   =NPre%   "NPre%"
+''   =NPre%   ""
 suffix   =NPre%   "suffixNPre%"
 prefix   =NPre%   "prefixNPre%"
 pre-middle-suffix=NPre%   "pre-middle-suffixNPre%"
-''   =NPre%NS "NPre%NS"
+''   =NPre%NS ""
 suffix   =NPre%NS "suffixNPre%NS"
 prefix   =NPre%NS "prefixNPre%NS"
 pre-middle-suffix=NPre%NS "pre-middle-suffixNPre%NS"
@@ -53,7 +53,7 @@ pre-middle-suffixffix=NPre%NS   
 suffix   %=   ""
 prefix   %=   ""
 pre-middle-suffix%=   ""
-''   %=NS "NS"
+''   %=NS ""
 suffix   %=NS "NS"
 prefix   %=NS "NS"
 pre-middle-suffix%=NS "NS"
@@ -61,15 +61,15 @@ pre-middle-suffix%=NS   
 suffix   %=%  "suffix"
 prefix   %=%  "prefix"
 pre-middle-suffix%=%  "pre-middle-suffix"
-''   %=%NS"NS"
+''   %=%NS""
 suffix   %=%NS"suffixNS"
 prefix   %=%NS"prefixNS"
 pre-middle-suffix%=%NS"pre-middle-suffixNS"
-''   %=NPre%  "NPre"
+''   %=NPre%  ""
 suffix   %=NPre%  "NPresuffix"
 prefix   %=NPre%  "NPreprefix"
 pre-middle-suffix%=NPre%  "NPrepre-middle-suffix"
-''   %=NPre%NS"NPreNS"
+''   %=NPre%NS""
 suffix   %=NPre%NS"NPresuffixNS"
 prefix   %=NPre%NS"NPreprefixNS"
 pre-middle-suffix%=NPre%NS"NPrepre-middle-suffixNS"

Index: src/usr.bin/make/unit-tests/varmod-sysv.mk
diff -u src/usr.bin/make/unit-tests/varmod-sysv.mk:1.13 src/usr.bin/make/unit-tests/varmod-sysv.mk:1.14
--- src/usr.bin/make/unit-tests/varmod-sysv.mk:1.13	Mon Apr 12 16:04:30 2021
+++ src/usr.bin/make/unit-tests/varmod-sysv.mk	Mon Apr 12 16:09:57 2021
@@ -1,4 +1,4 @@
-# $NetBSD: varmod-sysv.mk,v 1.13 2021/04/12 16:04:30 rillig Exp $
+# $NetBSD: varmod-sysv.mk,v 1.14 2021/04/12 16:09:57 ri

CVS commit: src/usr.bin/make/unit-tests

2021-04-12 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Apr 12 16:04:31 UTC 2021

Modified Files:
src/usr.bin/make/unit-tests: varmod-sysv.exp varmod-sysv.mk

Log Message:
tests/make: add table test for the modifier ':from=to'

Just to prevent any accidental change in the upcoming refactoring to
reduce memory allocation in ApplyModifier_SysV.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/unit-tests/varmod-sysv.exp
cvs rdiff -u -r1.12 -r1.13 src/usr.bin/make/unit-tests/varmod-sysv.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/varmod-sysv.exp
diff -u src/usr.bin/make/unit-tests/varmod-sysv.exp:1.7 src/usr.bin/make/unit-tests/varmod-sysv.exp:1.8
--- src/usr.bin/make/unit-tests/varmod-sysv.exp:1.7	Tue Feb 23 00:04:48 2021
+++ src/usr.bin/make/unit-tests/varmod-sysv.exp	Mon Apr 12 16:04:30 2021
@@ -1,5 +1,150 @@
 make: Unfinished modifier for "word214" ('=' missing)
 make: "varmod-sysv.mk" line 214: Malformed conditional (${word214:L:from${:D=}to})
+word modifier result  
+''   =""
+suffix   ="suffix"
+prefix   ="prefix"
+pre-middle-suffix="pre-middle-suffix"
+''   =NS  "NS"
+suffix   =NS  "suffixNS"
+prefix   =NS  "prefixNS"
+pre-middle-suffix=NS  "pre-middle-suffixNS"
+''   =%   "%"
+suffix   =%   "suffix%"
+prefix   =%   "prefix%"
+pre-middle-suffix=%   "pre-middle-suffix%"
+''   =%NS "%NS"
+suffix   =%NS "suffix%NS"
+prefix   =%NS "prefix%NS"
+pre-middle-suffix=%NS "pre-middle-suffix%NS"
+''   =NPre%   "NPre%"
+suffix   =NPre%   "suffixNPre%"
+prefix   =NPre%   "prefixNPre%"
+pre-middle-suffix=NPre%   "pre-middle-suffixNPre%"
+''   =NPre%NS "NPre%NS"
+suffix   =NPre%NS "suffixNPre%NS"
+prefix   =NPre%NS "prefixNPre%NS"
+pre-middle-suffix=NPre%NS "pre-middle-suffixNPre%NS"
+''   ffix=""
+suffix   ffix="su"
+prefix   ffix="prefix"
+pre-middle-suffixffix="pre-middle-su"
+''   ffix=NS  ""
+suffix   ffix=NS  "suNS"
+prefix   ffix=NS  "prefix"
+pre-middle-suffixffix=NS  "pre-middle-suNS"
+''   ffix=%   ""
+suffix   ffix=%   "su%"
+prefix   ffix=%   "prefix"
+pre-middle-suffixffix=%   "pre-middle-su%"
+''   ffix=%NS ""
+suffix   ffix=%NS "su%NS"
+prefix   ffix=%NS "prefix"
+pre-middle-suffixffix=%NS "pre-middle-su%NS"
+''   ffix=NPre%   ""
+suffix   ffix=NPre%   "suNPre%"
+prefix   ffix=NPre%   "prefix"
+pre-middle-suffixffix=NPre%   "pre-middle-suNPre%"
+''   ffix=NPre%NS ""
+suffix   ffix=NPre%NS "suNPre%NS"
+prefix   ffix=NPre%NS "prefix"
+pre-middle-suffixffix=NPre%NS "pre-middle-suNPre%NS"
+''   %=   ""
+suffix   %=   ""
+prefix   %=   ""
+pre-middle-suffix%=   ""
+''   %=NS "NS"
+suffix   %=NS "NS"
+prefix   %=NS "NS"
+pre-middle-suffix%=NS "NS"
+''   %=%  ""
+suffix   %=%  "suffix"
+prefix   %=%  "prefix"
+pre-middle-suffix%=%  "pre-middle-suffix"
+''   %=%NS"NS"
+suffix   %=%NS"su

CVS commit: src/usr.bin/make/unit-tests

2021-04-09 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Apr  9 14:42:00 UTC 2021

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

Log Message:
Don't use a shell pattern to copy files, copy them explicitly. When running
as non-root, [at]*.mk matches archive.mk which we already copied. This was
copied as 444 and trying to overwrite it gives EACCES.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/usr.bin/make/unit-tests/archive.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/archive.mk
diff -u src/usr.bin/make/unit-tests/archive.mk:1.11 src/usr.bin/make/unit-tests/archive.mk:1.12
--- src/usr.bin/make/unit-tests/archive.mk:1.11	Sun Nov 15 09:07:53 2020
+++ src/usr.bin/make/unit-tests/archive.mk	Fri Apr  9 10:42:00 2021
@@ -1,4 +1,4 @@
-# $NetBSD: archive.mk,v 1.11 2020/11/15 14:07:53 rillig Exp $
+# $NetBSD: archive.mk,v 1.12 2021/04/09 14:42:00 christos Exp $
 #
 # Very basic demonstration of handling archives, based on the description
 # in PSD.doc/tutorial.ms.
@@ -8,11 +8,11 @@
 # several other tests.
 
 ARCHIVE=	libprog.a
-FILES=		archive.mk modmisc.mk varmisc.mk
+FILES=		archive.mk archive-suffix.mk modmisc.mk ternary.mk varmisc.mk
 
 all:
 .if ${.PARSEDIR:tA} != ${.CURDIR:tA}
-	@cd ${MAKEFILE:H} && cp ${FILES} [at]*.mk ${.CURDIR}
+	@cd ${MAKEFILE:H} && cp ${FILES} ${.CURDIR}
 .endif
 # The following targets create and remove files.  The filesystem cache in
 # dir.c would probably not handle this correctly, therefore each of the



CVS commit: src/usr.bin/make/unit-tests

2021-04-04 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Apr  4 21:59:46 UTC 2021

Removed Files:
src/usr.bin/make/unit-tests: varmod-loop-varname.out
varmod-loop-varname.rawout varmod-loop-varname.status

Log Message:
tests/make: remove accidentally added intermediate files


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r0 src/usr.bin/make/unit-tests/varmod-loop-varname.out \
src/usr.bin/make/unit-tests/varmod-loop-varname.rawout \
src/usr.bin/make/unit-tests/varmod-loop-varname.status

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/make/unit-tests

2021-03-15 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Mar 15 18:46:05 UTC 2021

Modified Files:
src/usr.bin/make/unit-tests: varmod-assign.exp varmod-assign.mk

Log Message:
tests/make: demonstrate that the modifier '::=' expands the varname


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/usr.bin/make/unit-tests/varmod-assign.exp
cvs rdiff -u -r1.10 -r1.11 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/varmod-assign.exp
diff -u src/usr.bin/make/unit-tests/varmod-assign.exp:1.9 src/usr.bin/make/unit-tests/varmod-assign.exp:1.10
--- src/usr.bin/make/unit-tests/varmod-assign.exp:1.9	Tue Feb 23 16:07:14 2021
+++ src/usr.bin/make/unit-tests/varmod-assign.exp	Mon Mar 15 18:46:05 2021
@@ -1,3 +1,20 @@
+Global:param = twice
+Global:VARNAME = VAR.$${param}
+Var_Parse: ${VARNAME} (eval)
+Global:VAR.${param} = initial-value
+Var_Parse: ${${VARNAME}::=assigned-value} (eval-defined)
+Var_Parse: ${VARNAME}::=assigned-value} (eval-defined)
+Applying ${VAR.${param}::...} to "initial-value" (eval-defined, none, regular)
+Modifier part: "assigned-value"
+Var_Parse: ${param} (eval)
+Global:VAR.twice = assigned-value
+Result of ${VAR.${param}::=assigned-value} is "" (eval-defined, none, regular)
+Var_Parse: $ for symmetry with the usual assignment operators. (eval)
+make: "varmod-assign.mk" line 139: FIXME: don't expand the variable name twice here, for symmetry with the usual assignment operators.
+Var_Parse: ${${VARNAME}} != "initial-value" (eval-defined)
+Var_Parse: ${VARNAME}} != "initial-value" (eval-defined)
+Global:.MAKEFLAGS =  -r -k -d v -d
+Global:.MAKEFLAGS =  -r -k -d v -d 0
 mod-assign: first=1.
 mod-assign: last=3.
 mod-assign: appended=1 2 3.

Index: src/usr.bin/make/unit-tests/varmod-assign.mk
diff -u src/usr.bin/make/unit-tests/varmod-assign.mk:1.10 src/usr.bin/make/unit-tests/varmod-assign.mk:1.11
--- src/usr.bin/make/unit-tests/varmod-assign.mk:1.10	Sun Feb 14 12:14:37 2021
+++ src/usr.bin/make/unit-tests/varmod-assign.mk	Mon Mar 15 18:46:05 2021
@@ -1,4 +1,4 @@
-# $NetBSD: varmod-assign.mk,v 1.10 2021/02/14 12:14:37 rillig Exp $
+# $NetBSD: varmod-assign.mk,v 1.11 2021/03/15 18:46:05 rillig Exp $
 #
 # Tests for the obscure ::= variable modifiers, which perform variable
 # assignments during evaluation, just like the = operator in C.
@@ -114,3 +114,31 @@ _:=	$(VAR::=current})
 .if ${VAR} != "current}"
 .  error
 .endif
+
+
+# Before var.c 1.888 from 2021-03-15, an expression using the modifier '::='
+# expanded its variable name once too often during evaluation.  This was only
+# relevant for variable names containing a '$' sign in their actual name, not
+# the usual VAR.${param}.
+.MAKEFLAGS: -dv
+param=		twice
+VARNAME=	VAR.$${param}	# Indirect variable name because of the '$',
+# to avoid difficult escaping rules.
+
+${VARNAME}=	initial-value	# Sets 'VAR.${param}' to 'expanded'.
+.if defined(VAR.twice)		# At this point, the '$$' is not expanded.
+.  error
+.endif
+.if ${${VARNAME}::=assigned-value} # Here the variable name gets expanded once
+.  error			# too often.
+.endif
+.if !defined(VAR.twice)
+.  error			# FIXME: This is the unwanted current behavior.
+.else
+.  info		FIXME: don't expand the variable name twice here, $\
+	for symmetry with the usual assignment operators.
+.endif
+.if ${${VARNAME}} != "initial-value"
+.  error
+.endif
+.MAKEFLAGS: -d0



CVS commit: src/usr.bin/make/unit-tests

2021-03-15 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Mar 15 17:54:50 UTC 2021

Modified Files:
src/usr.bin/make/unit-tests: varmod-loop.exp varmod-loop.mk

Log Message:
tests/make: convert varmod-loop to parse-time

In case of unexpected failures, this provides the line number of the
'.error' directive.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/unit-tests/varmod-loop.exp
cvs rdiff -u -r1.12 -r1.13 src/usr.bin/make/unit-tests/varmod-loop.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/varmod-loop.exp
diff -u src/usr.bin/make/unit-tests/varmod-loop.exp:1.7 src/usr.bin/make/unit-tests/varmod-loop.exp:1.8
--- src/usr.bin/make/unit-tests/varmod-loop.exp:1.7	Mon Mar 15 17:11:08 2021
+++ src/usr.bin/make/unit-tests/varmod-loop.exp	Mon Mar 15 17:54:49 2021
@@ -1,18 +1,12 @@
-ParseReadLine (133): 'USE_8_DOLLARS=	${:U1:@var@${8_DOLLARS}@} ${8_DOLLARS} '
+ParseReadLine (144): 'USE_8_DOLLARS=	${:U1:@var@${8_DOLLARS}@} ${8_DOLLARS} '
 CondParser_Eval: ${USE_8_DOLLARS} != "\$\$\$\$ \$\$\$\$ \$\$\$\$"
 lhs = "  ", rhs = "  ", op = !=
-ParseReadLine (138): 'SUBST_CONTAINING_LOOP:= ${USE_8_DOLLARS}'
+ParseReadLine (149): 'SUBST_CONTAINING_LOOP:= ${USE_8_DOLLARS}'
 CondParser_Eval: ${SUBST_CONTAINING_LOOP} != "\$\$ \$\$\$\$ \$\$\$\$"
 lhs = "$$  ", rhs = "$$  ", op = !=
-ParseReadLine (163): '.MAKEFLAGS: -d0'
+ParseReadLine (174): '.MAKEFLAGS: -d0'
 ParseDoDependency(.MAKEFLAGS: -d0)
-mod-loop-varname:
-:+one+ +two+ +three+:
-:x1y x2y x3y:
-:x1y x2y x3y:
-:mod-loop-varname: :x1y x2y x3y: ::
-:x1y x2y x3y:
-empty: :xy xy xy:
+:varname-overwriting-target: :x1y x2y x3y: ::
 mod-loop-resolve:w1d2d3w w2i3w w1i2d3 2i${RES3}w w1d2d3 2i${RES3} 1i${RES2}w:
 mod-loop-varname-dollar:(1) (2) (3).
 mod-loop-varname-dollar:() () ().

Index: src/usr.bin/make/unit-tests/varmod-loop.mk
diff -u src/usr.bin/make/unit-tests/varmod-loop.mk:1.12 src/usr.bin/make/unit-tests/varmod-loop.mk:1.13
--- src/usr.bin/make/unit-tests/varmod-loop.mk:1.12	Mon Mar 15 17:11:08 2021
+++ src/usr.bin/make/unit-tests/varmod-loop.mk	Mon Mar 15 17:54:49 2021
@@ -1,10 +1,10 @@
-# $NetBSD: varmod-loop.mk,v 1.12 2021/03/15 17:11:08 rillig Exp $
+# $NetBSD: varmod-loop.mk,v 1.13 2021/03/15 17:54:49 rillig Exp $
 #
 # Tests for the :@var@...${var}...@ variable modifier.
 
 .MAKE.SAVE_DOLLARS=	yes
 
-all: mod-loop-varname
+all: varname-overwriting-target
 all: mod-loop-resolve
 all: mod-loop-varname-dollar
 all: mod-loop-dollar
@@ -13,31 +13,42 @@ all: mod-loop-dollar
 # dynamically.  There's no practical use-case for this, and hopefully nobody
 # will ever depend on this, but technically it's possible.
 # Therefore, in -dL mode, this is forbidden, see lint.mk.
-mod-loop-varname:
-	@echo $@:
-	@echo :${:Uone two three:@${:Ubar:S,b,v,}@+${var}+@:Q}:
-
-	# ":::" is a very creative variable name, unlikely in practice.
-	# The expression ${\:\:\:} would not work since backslashes can only
-	# be escaped in the modifiers, but not in the variable name.
-	@echo :${:U1 2 3:@:::@x${${:U\:\:\:}}y@}:
+.if ${:Uone two three:@${:Ubar:S,b,v,}@+${var}+@} != "+one+ +two+ +three+"
+.  error
+.endif
+
+# ":::" is a very creative variable name, unlikely in practice.
+# The expression ${\:\:\:} would not work since backslashes can only
+# be escaped in the modifiers, but not in the variable name.
+.if ${:U1 2 3:@:::@x${${:U\:\:\:}}y@} != "x1y x2y x3y"
+.  error
+.endif
 
-	# "@@" is another creative variable name.
-	@echo :${:U1 2 3:@\@\@@x${@@}y@}:
+# "@@" is another creative variable name.
+.if ${:U1 2 3:@\@\@@x${@@}y@} != "x1y x2y x3y"
+.  error
+.endif
 
+varname-overwriting-target:
 	# Even "@" works as a variable name since the variable is installed
 	# in the "current" scope, which in this case is the one from the
-	# target.
+	# target.  Because of this, after the loop has finished, '$@' is
+	# undefined.  This is something that make doesn't expect, this may
+	# even trigger an assertion failure somewhere.
 	@echo :$@: :${:U1 2 3:@\@@x${@}y@}: :$@:
 
-	# In extreme cases, even the backslash can be used as variable name.
-	# It needs to be doubled though.
-	@echo :${:U1 2 3:@\\@x${${:Ux:S,x,\\,}}y@}:
-
-	# The variable name can technically be empty, and in this situation
-	# the variable value cannot be accessed since the empty "variable"
-	# is protected to always return an empty string.
-	@echo empty: :${:U1 2 3:@@x${}y@}:
+# In extreme cases, even the backslash can be used as variable name.
+# It needs to be doubled though.
+.if ${:U1 2 3:@\\@x${${:Ux:S,x,\\,}}y@} != "x1y x2y x3y"
+.  error
+.endif
+
+# The variable name can technically be empty, and in this situation
+# the variable value cannot be accessed since the empty "variable"
+# is protected to always return an empty string.
+.if ${:U1 2 3:@@x${}y@} != "xy xy xy"
+.  error
+.endif
 
 
 # The :@ 

CVS commit: src/usr.bin/make/unit-tests

2021-03-15 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Mar 15 17:11:08 UTC 2021

Modified Files:
src/usr.bin/make/unit-tests: varmod-loop.exp varmod-loop.mk

Log Message:
tests/make: add position marker in test 'varmod-loop'


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/varmod-loop.exp
cvs rdiff -u -r1.11 -r1.12 src/usr.bin/make/unit-tests/varmod-loop.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/varmod-loop.exp
diff -u src/usr.bin/make/unit-tests/varmod-loop.exp:1.6 src/usr.bin/make/unit-tests/varmod-loop.exp:1.7
--- src/usr.bin/make/unit-tests/varmod-loop.exp:1.6	Tue Feb 23 14:17:21 2021
+++ src/usr.bin/make/unit-tests/varmod-loop.exp	Mon Mar 15 17:11:08 2021
@@ -1,11 +1,12 @@
-ParseReadLine (132): 'USE_8_DOLLARS=	${:U1:@var@${8_DOLLARS}@} ${8_DOLLARS} '
+ParseReadLine (133): 'USE_8_DOLLARS=	${:U1:@var@${8_DOLLARS}@} ${8_DOLLARS} '
 CondParser_Eval: ${USE_8_DOLLARS} != "\$\$\$\$ \$\$\$\$ \$\$\$\$"
 lhs = "  ", rhs = "  ", op = !=
-ParseReadLine (137): 'SUBST_CONTAINING_LOOP:= ${USE_8_DOLLARS}'
+ParseReadLine (138): 'SUBST_CONTAINING_LOOP:= ${USE_8_DOLLARS}'
 CondParser_Eval: ${SUBST_CONTAINING_LOOP} != "\$\$ \$\$\$\$ \$\$\$\$"
 lhs = "$$  ", rhs = "$$  ", op = !=
-ParseReadLine (162): '.MAKEFLAGS: -d0'
+ParseReadLine (163): '.MAKEFLAGS: -d0'
 ParseDoDependency(.MAKEFLAGS: -d0)
+mod-loop-varname:
 :+one+ +two+ +three+:
 :x1y x2y x3y:
 :x1y x2y x3y:

Index: src/usr.bin/make/unit-tests/varmod-loop.mk
diff -u src/usr.bin/make/unit-tests/varmod-loop.mk:1.11 src/usr.bin/make/unit-tests/varmod-loop.mk:1.12
--- src/usr.bin/make/unit-tests/varmod-loop.mk:1.11	Mon Mar 15 12:15:03 2021
+++ src/usr.bin/make/unit-tests/varmod-loop.mk	Mon Mar 15 17:11:08 2021
@@ -1,4 +1,4 @@
-# $NetBSD: varmod-loop.mk,v 1.11 2021/03/15 12:15:03 rillig Exp $
+# $NetBSD: varmod-loop.mk,v 1.12 2021/03/15 17:11:08 rillig Exp $
 #
 # Tests for the :@var@...${var}...@ variable modifier.
 
@@ -14,6 +14,7 @@ all: mod-loop-dollar
 # will ever depend on this, but technically it's possible.
 # Therefore, in -dL mode, this is forbidden, see lint.mk.
 mod-loop-varname:
+	@echo $@:
 	@echo :${:Uone two three:@${:Ubar:S,b,v,}@+${var}+@:Q}:
 
 	# ":::" is a very creative variable name, unlikely in practice.



CVS commit: src/usr.bin/make/unit-tests

2021-03-14 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 14 20:41:39 UTC 2021

Modified Files:
src/usr.bin/make/unit-tests: var-eval-short.exp var-eval-short.mk

Log Message:
tests/make: document today's bug fixes in the test


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/var-eval-short.exp
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/var-eval-short.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/var-eval-short.exp
diff -u src/usr.bin/make/unit-tests/var-eval-short.exp:1.6 src/usr.bin/make/unit-tests/var-eval-short.exp:1.7
--- src/usr.bin/make/unit-tests/var-eval-short.exp:1.6	Sun Mar 14 19:29:37 2021
+++ src/usr.bin/make/unit-tests/var-eval-short.exp	Sun Mar 14 20:41:39 2021
@@ -1,14 +1,14 @@
-make: "var-eval-short.mk" line 63: Invalid time value: ${FAIL}}
-make: "var-eval-short.mk" line 63: Malformed conditional (0 && ${:Uword:gmtime=${FAIL}})
 make: "var-eval-short.mk" line 77: Invalid time value: ${FAIL}}
-make: "var-eval-short.mk" line 77: Malformed conditional (0 && ${:Uword:localtime=${FAIL}})
+make: "var-eval-short.mk" line 77: Malformed conditional (0 && ${:Uword:gmtime=${FAIL}})
+make: "var-eval-short.mk" line 91: Invalid time value: ${FAIL}}
+make: "var-eval-short.mk" line 91: Malformed conditional (0 && ${:Uword:localtime=${FAIL}})
 CondParser_Eval: 0 && ${0:?${FAIL}then:${FAIL}else}
 Var_Parse: ${0:?${FAIL}then:${FAIL}else} with none
 Applying ${0:?...} to "" (none, none, undefined)
 Modifier part: "${FAIL}then"
 Modifier part: "${FAIL}else"
 Result of ${0:?${FAIL}then:${FAIL}else} is "" (none, none, defined)
-ParseReadLine (142): 'DEFINED=	defined'
+ParseReadLine (156): 'DEFINED=	defined'
 Global:DEFINED = defined
 CondParser_Eval: 0 && ${DEFINED:L:?${FAIL}then:${FAIL}else}
 Var_Parse: ${DEFINED:L:?${FAIL}then:${FAIL}else} with none
@@ -18,7 +18,7 @@ Applying ${DEFINED:?...} to "defined" (n
 Modifier part: "${FAIL}then"
 Modifier part: "${FAIL}else"
 Result of ${DEFINED:?${FAIL}then:${FAIL}else} is "defined" (none, none, regular)
-ParseReadLine (145): '.MAKEFLAGS: -d0'
+ParseReadLine (159): '.MAKEFLAGS: -d0'
 ParseDoDependency(.MAKEFLAGS: -d0)
 Global:.MAKEFLAGS =  -r -k -d cpv -d
 Global:.MAKEFLAGS =  -r -k -d cpv -d 0

Index: src/usr.bin/make/unit-tests/var-eval-short.mk
diff -u src/usr.bin/make/unit-tests/var-eval-short.mk:1.3 src/usr.bin/make/unit-tests/var-eval-short.mk:1.4
--- src/usr.bin/make/unit-tests/var-eval-short.mk:1.3	Sun Mar 14 19:21:28 2021
+++ src/usr.bin/make/unit-tests/var-eval-short.mk	Sun Mar 14 20:41:39 2021
@@ -1,4 +1,4 @@
-# $NetBSD: var-eval-short.mk,v 1.3 2021/03/14 19:21:28 rillig Exp $
+# $NetBSD: var-eval-short.mk,v 1.4 2021/03/14 20:41:39 rillig Exp $
 #
 # Tests for each variable modifier to ensure that they only do the minimum
 # necessary computations.  If the result of the expression is not needed, they
@@ -34,20 +34,34 @@ FAIL=	${:!echo unexpected 1>&2!}
 .if 0 && ${0:?${FAIL}:${FAIL}}
 .endif
 
+# Before var.c,v 1.870 from 2021-03-14, the expression ${FAIL} was evaluated
+# after the loop, when undefining the temporary global loop variable.
 .if 0 && ${:Uword:@${FAIL}@expr@}
 .endif
 
 .if 0 && ${:Uword:@var@${FAIL}@}
 .endif
 
+# Before var.c,v 1.877 from 2021-03-14, the modifier ':[...]' did not expand
+# the nested expression ${FAIL} and then tried to parse the unexpanded text,
+# which failed since '$' is not a valid range character.
 .if 0 && ${:Uword:[${FAIL}]}
 .endif
 
+# Before var.c,v 1.867 from 2021-03-14, the modifier ':_' defined the variable
+# even though the whole expression should have only been parsed, not
+# evaluated.
 .if 0 && ${:Uword:_=VAR}
 .elif defined(VAR)
 .  error
 .endif
 
+# Before var.c,v 1.856 from 2021-03-14, the modifier ':C' did not expand the
+# nested expression ${FAIL} and then tried to compile the unexpanded text as a
+# regular expression, which failed both because of the '{FAIL}', which is not
+# a valid repetition, and because of the '', which are repeated
+# repetitions as well.
+# '${FAIL}'
 .if 0 && ${:Uword:C,${FAIL},,}
 .endif
 



CVS commit: src/usr.bin/make/unit-tests

2021-03-14 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 14 19:16:41 UTC 2021

Modified Files:
src/usr.bin/make/unit-tests: var-eval-short.exp var-eval-short.mk

Log Message:
tests/make: add test for the ':?' modifier in parse-only mode

The debug output for this scenario will change a bit in an upcoming
commit, but that will not affect anything outside the debug log.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/var-eval-short.exp
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/var-eval-short.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/var-eval-short.exp
diff -u src/usr.bin/make/unit-tests/var-eval-short.exp:1.3 src/usr.bin/make/unit-tests/var-eval-short.exp:1.4
--- src/usr.bin/make/unit-tests/var-eval-short.exp:1.3	Sun Mar 14 18:02:44 2021
+++ src/usr.bin/make/unit-tests/var-eval-short.exp	Sun Mar 14 19:16:41 2021
@@ -4,6 +4,26 @@ make: "var-eval-short.mk" line 63: Inval
 make: "var-eval-short.mk" line 63: Malformed conditional (0 && ${:Uword:gmtime=${FAIL}})
 make: "var-eval-short.mk" line 77: Invalid time value: ${FAIL}}
 make: "var-eval-short.mk" line 77: Malformed conditional (0 && ${:Uword:localtime=${FAIL}})
+CondParser_Eval: 0 && ${0:?${FAIL}then:${FAIL}else}
+Var_Parse: ${0:?${FAIL}then:${FAIL}else} with none
+Applying ${0:?...} to "" (none, none, undefined)
+Modifier part: "${FAIL}then"
+Modifier part: "${FAIL}else"
+Result of ${0:?${FAIL}then:${FAIL}else} is "${FAIL}else" (none, none, defined)
+ParseReadLine (141): 'DEFINED=	defined'
+Global:DEFINED = defined
+CondParser_Eval: 0 && ${DEFINED:L:?${FAIL}then:${FAIL}else}
+Var_Parse: ${DEFINED:L:?${FAIL}then:${FAIL}else} with none
+Applying ${DEFINED:L} to "defined" (none, none, regular)
+Result of ${DEFINED:L} is "defined" (none, none, regular)
+Applying ${DEFINED:?...} to "defined" (none, none, regular)
+Modifier part: "${FAIL}then"
+Modifier part: "${FAIL}else"
+Result of ${DEFINED:?${FAIL}then:${FAIL}else} is "${FAIL}else" (none, none, regular)
+ParseReadLine (144): '.MAKEFLAGS: -d0'
+ParseDoDependency(.MAKEFLAGS: -d0)
+Global:.MAKEFLAGS =  -r -k -d cpv -d
+Global:.MAKEFLAGS =  -r -k -d cpv -d 0
 make: Fatal errors encountered -- cannot continue
 make: stopped in unit-tests
 exit status 1

Index: src/usr.bin/make/unit-tests/var-eval-short.mk
diff -u src/usr.bin/make/unit-tests/var-eval-short.mk:1.1 src/usr.bin/make/unit-tests/var-eval-short.mk:1.2
--- src/usr.bin/make/unit-tests/var-eval-short.mk:1.1	Sun Mar 14 11:49:37 2021
+++ src/usr.bin/make/unit-tests/var-eval-short.mk	Sun Mar 14 19:16:41 2021
@@ -1,4 +1,4 @@
-# $NetBSD: var-eval-short.mk,v 1.1 2021/03/14 11:49:37 rillig Exp $
+# $NetBSD: var-eval-short.mk,v 1.2 2021/03/14 19:16:41 rillig Exp $
 #
 # Tests for each variable modifier to ensure that they only do the minimum
 # necessary computations.  If the result of the expression is not needed, they
@@ -125,4 +125,22 @@ DEFINED=	# defined
 .if 0 && ${:Uword:word=replacement}
 .endif
 
+# Before var.c 1.XXX from 2021-03-14, Var_Parse returned "${FAIL}else" for the
+# irrelevant right-hand side of the condition, even though this was not
+# necessary.  Since the return value from Var_Parse is supposed to be ignored
+# anyway, and since it is actually ignored in an overly complicated way,
+# an empty string suffices.
+.MAKEFLAGS: -dcpv
+.if 0 && ${0:?${FAIL}then:${FAIL}else}
+.endif
+
+# The ':L' is applied before the ':?' modifier, giving the expression a name
+# and a value, just to see whether this value gets passed through or whether
+# the parse-only mode results in an empty string (only visible in the debug
+# log).
+DEFINED=	defined
+.if 0 && ${DEFINED:L:?${FAIL}then:${FAIL}else}
+.endif
+.MAKEFLAGS: -d0
+
 all:



CVS commit: src/usr.bin/make/unit-tests

2021-03-14 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 14 17:14:16 UTC 2021

Modified Files:
src/usr.bin/make/unit-tests: varmod-remember.mk

Log Message:
tests/make: demonstrate unintended edge case for the ':_' modifier


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/varmod-remember.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/varmod-remember.mk
diff -u src/usr.bin/make/unit-tests/varmod-remember.mk:1.4 src/usr.bin/make/unit-tests/varmod-remember.mk:1.5
--- src/usr.bin/make/unit-tests/varmod-remember.mk:1.4	Sun Mar 14 17:07:11 2021
+++ src/usr.bin/make/unit-tests/varmod-remember.mk	Sun Mar 14 17:14:15 2021
@@ -1,4 +1,4 @@
-# $NetBSD: varmod-remember.mk,v 1.4 2021/03/14 17:07:11 rillig Exp $
+# $NetBSD: varmod-remember.mk,v 1.5 2021/03/14 17:14:15 rillig Exp $
 #
 # Tests for the :_ modifier, which saves the current variable value
 # in the _ variable or another, to be used later again.
@@ -17,4 +17,16 @@
 .  error
 .endif
 
+# The ':_' modifier takes a variable name as optional argument.  This variable
+# name can refer to other variables, though this was rather an implementation
+# oversight than an intended feature.  The variable name stops at the first
+# '}' or ')' and thus cannot use the usual form ${VARNAME} of long variable
+# names.
+S=	INDIRECT_VARNAME
+.if ${value:L:@var@${var:_=$S}@} != "value"
+.  error
+.elif ${INDIRECT_VARNAME} != "value"
+.  error
+.endif
+
 all:



CVS commit: src/usr.bin/make/unit-tests

2021-03-14 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 14 17:07:11 UTC 2021

Modified Files:
src/usr.bin/make/unit-tests: varmod-remember.exp varmod-remember.mk

Log Message:
tests/make: convert test for ':_' modifier to parse time


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/varmod-remember.exp
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/varmod-remember.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/varmod-remember.exp
diff -u src/usr.bin/make/unit-tests/varmod-remember.exp:1.2 src/usr.bin/make/unit-tests/varmod-remember.exp:1.3
--- src/usr.bin/make/unit-tests/varmod-remember.exp:1.2	Sun Aug 23 15:18:43 2020
+++ src/usr.bin/make/unit-tests/varmod-remember.exp	Sun Mar 14 17:07:11 2021
@@ -1,3 +1 @@
-1 2 3 1 2 3 1 2 3
-1 2 3, SAVED=3
 exit status 0

Index: src/usr.bin/make/unit-tests/varmod-remember.mk
diff -u src/usr.bin/make/unit-tests/varmod-remember.mk:1.3 src/usr.bin/make/unit-tests/varmod-remember.mk:1.4
--- src/usr.bin/make/unit-tests/varmod-remember.mk:1.3	Sun Aug 23 15:18:43 2020
+++ src/usr.bin/make/unit-tests/varmod-remember.mk	Sun Mar 14 17:07:11 2021
@@ -1,12 +1,20 @@
-# $NetBSD: varmod-remember.mk,v 1.3 2020/08/23 15:18:43 rillig Exp $
+# $NetBSD: varmod-remember.mk,v 1.4 2021/03/14 17:07:11 rillig Exp $
 #
 # Tests for the :_ modifier, which saves the current variable value
 # in the _ variable or another, to be used later again.
 
+.if ${1 2 3:L:_:@var@${_}@} != "1 2 3 1 2 3 1 2 3"
+.  error
+.endif
+
 # In the parameterized form, having the variable name on the right side of
 # the = assignment operator is confusing.  In almost all other situations
 # the variable name is on the left-hand side of the = operator.  Luckily
 # this modifier is only rarely needed.
+.if ${1 2 3:L:@var@${var:_=SAVED:}@} != "1 2 3"
+.  error
+.elif ${SAVED} != "3"
+.  error
+.endif
+
 all:
-	@echo ${1 2 3:L:_:@var@${_}@}
-	@echo ${1 2 3:L:@var@${var:_=SAVED:}@}, SAVED=${SAVED}



CVS commit: src/usr.bin/make/unit-tests

2021-03-14 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 14 16:00:07 UTC 2021

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

Log Message:
make: add test for edge case in modifier ':[...]'

TryParseIntBase0 wrongly returns successful for a string that does not
start with a number at all.  Its only caller, ApplyModifier_Words,
already handles all error cases properly.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/modword.exp
cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/modword.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/modword.exp
diff -u src/usr.bin/make/unit-tests/modword.exp:1.3 src/usr.bin/make/unit-tests/modword.exp:1.4
--- src/usr.bin/make/unit-tests/modword.exp:1.3	Tue Feb 23 16:07:14 2021
+++ src/usr.bin/make/unit-tests/modword.exp	Sun Mar 14 16:00:07 2021
@@ -71,6 +71,8 @@ make: Bad modifier ":[1.]" for variable 
 LIST:[1.]="" is an error
 make: Bad modifier ":[1..]" for variable "LIST"
 LIST:[1..]="" is an error
+make: Bad modifier ":[1.. ]" for variable "LIST"
+LIST:[1.. ]="" is an error
 LIST:[1..1]="one"
 make: Bad modifier ":[1..1.]" for variable "LIST"
 LIST:[1..1.]="" is an error

Index: src/usr.bin/make/unit-tests/modword.mk
diff -u src/usr.bin/make/unit-tests/modword.mk:1.5 src/usr.bin/make/unit-tests/modword.mk:1.6
--- src/usr.bin/make/unit-tests/modword.mk:1.5	Sun Nov 15 20:20:58 2020
+++ src/usr.bin/make/unit-tests/modword.mk	Sun Mar 14 16:00:07 2021
@@ -1,4 +1,4 @@
-# $NetBSD: modword.mk,v 1.5 2020/11/15 20:20:58 rillig Exp $
+# $NetBSD: modword.mk,v 1.6 2021/03/14 16:00:07 rillig Exp $
 #
 # Test behaviour of new :[] modifier
 # TODO: When was this modifier new?
@@ -99,6 +99,7 @@ mod-squarebrackets-n:
 mod-squarebrackets-start-end:
 	@echo 'LIST:[1.]="${LIST:[1.]}" is an error'
 	@echo 'LIST:[1..]="${LIST:[1..]}" is an error'
+	@echo 'LIST:[1.. ]="${LIST:[1.. ]}" is an error'
 	@echo 'LIST:[1..1]="${LIST:[1..1]}"'
 	@echo 'LIST:[1..1.]="${LIST:[1..1.]}" is an error'
 	@echo 'LIST:[1..2]="${LIST:[1..2]}"'



CVS commit: src/usr.bin/make/unit-tests

2021-03-14 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 14 10:45:51 UTC 2021

Modified Files:
src/usr.bin/make/unit-tests: Makefile opt-debug-lint.exp
opt-debug-lint.mk

Log Message:
make: demonstrate wrong expression evaluation in -dL mode


To generate a diff of this commit:
cvs rdiff -u -r1.271 -r1.272 src/usr.bin/make/unit-tests/Makefile
cvs rdiff -u -r1.14 -r1.15 src/usr.bin/make/unit-tests/opt-debug-lint.exp
cvs rdiff -u -r1.12 -r1.13 src/usr.bin/make/unit-tests/opt-debug-lint.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.271 src/usr.bin/make/unit-tests/Makefile:1.272
--- src/usr.bin/make/unit-tests/Makefile:1.271	Sun Feb 14 20:16:17 2021
+++ src/usr.bin/make/unit-tests/Makefile	Sun Mar 14 10:45:51 2021
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.271 2021/02/14 20:16:17 rillig Exp $
+# $NetBSD: Makefile,v 1.272 2021/03/14 10:45:51 rillig Exp $
 #
 # Unit tests for make(1)
 #
@@ -493,6 +493,7 @@ SED_CMDS.opt-debug-jobs+=	-e 's,JobFinis
 SED_CMDS.opt-debug-jobs+=	-e 's,Command: ${.SHELL:T},Command: ,'
 # The "-q" may be there or not, see jobs.c, variable shells.
 SED_CMDS.opt-debug-jobs+=	-e 's,^\(.Command: \) -q,\1,'
+SED_CMDS.opt-debug-lint+=	${STD_SED_CMDS.regex}
 SED_CMDS.opt-jobs-no-action=	${STD_SED_CMDS.hide-from-output}
 SED_CMDS.opt-no-action-runflags= ${STD_SED_CMDS.hide-from-output}
 # For Compat_RunCommand, useShell == FALSE.
@@ -508,8 +509,7 @@ SED_CMDS.suff-transform-debug+=	${STD_SE
 SED_CMDS.var-op-shell+=		${STD_SED_CMDS.shell}
 SED_CMDS.var-op-shell+=		-e '/command/s,No such.*,not found,'
 SED_CMDS.vardebug+=		-e 's,${.SHELL},,'
-SED_CMDS.varmod-subst-regex+= \
-			-e 's,\(Regex compilation error:\).*,\1 (details omitted),'
+SED_CMDS.varmod-subst-regex+=	${STD_SED_CMDS.regex}
 SED_CMDS.varname-dot-parsedir=	-e '/in some cases/ s,^make: "[^"]*,make: ",'
 SED_CMDS.varname-dot-parsefile=	-e '/in some cases/ s,^make: "[^"]*,make: ",'
 SED_CMDS.varname-dot-shell=	-e 's, = /[^ ]*, = (details omitted),g'
@@ -587,6 +587,11 @@ STD_SED_CMDS.shell+=		-e 's,^${.SHELL:T}
 STD_SED_CMDS.shell+=		-e 's,^${.SHELL:T}: [0-9][0-9]*: ,,'
 STD_SED_CMDS.shell+=		-e 's,^${.SHELL:T}: ,,'
 
+# The actual error messages for a failed regcomp or regexec differ between the
+# implementations.
+STD_SED_CMDS.regex= \
+	-e 's,\(Regex compilation error:\).*,\1 (details omitted),'
+
 # End of the configuration helpers section.
 
 UNIT_TESTS:=	${.PARSEDIR}

Index: src/usr.bin/make/unit-tests/opt-debug-lint.exp
diff -u src/usr.bin/make/unit-tests/opt-debug-lint.exp:1.14 src/usr.bin/make/unit-tests/opt-debug-lint.exp:1.15
--- src/usr.bin/make/unit-tests/opt-debug-lint.exp:1.14	Tue Feb 23 15:19:41 2021
+++ src/usr.bin/make/unit-tests/opt-debug-lint.exp	Sun Mar 14 10:45:51 2021
@@ -3,6 +3,7 @@ make: "opt-debug-lint.mk" line 41: Varia
 make: "opt-debug-lint.mk" line 61: Missing delimiter ':' after modifier "L"
 make: "opt-debug-lint.mk" line 61: Missing delimiter ':' after modifier "P"
 make: "opt-debug-lint.mk" line 69: Unknown modifier "${"
+make: Regex compilation error: (details omitted)
 make: Fatal errors encountered -- cannot continue
 make: stopped in unit-tests
 exit status 1

Index: src/usr.bin/make/unit-tests/opt-debug-lint.mk
diff -u src/usr.bin/make/unit-tests/opt-debug-lint.mk:1.12 src/usr.bin/make/unit-tests/opt-debug-lint.mk:1.13
--- src/usr.bin/make/unit-tests/opt-debug-lint.mk:1.12	Sun Dec 20 19:10:53 2020
+++ src/usr.bin/make/unit-tests/opt-debug-lint.mk	Sun Mar 14 10:45:51 2021
@@ -1,4 +1,4 @@
-# $NetBSD: opt-debug-lint.mk,v 1.12 2020/12/20 19:10:53 rillig Exp $
+# $NetBSD: opt-debug-lint.mk,v 1.13 2021/03/14 10:45:51 rillig Exp $
 #
 # Tests for the -dL command line option, which runs additional checks
 # to catch common mistakes, such as unclosed variable expressions.
@@ -77,5 +77,16 @@ ${UNDEF}: ${UNDEF}
 .  error
 .endif
 
-all:
-	@:;
+# Before var.c 1.XXX from 2021-03-14, the whole variable text was evaluated
+# to check for unclosed expressions and unknown operators.  During this check,
+# the subexpression '${:U2}' was not expanded, instead it was copied verbatim
+# into the regular expression, which was '.*=.{1,${:U2}}$'.  This regular
+# expression was then compiled (despite VARE_WANTRES being unset), which
+# resulted in a wrong error message.
+#
+# This only happened in lint mode since in default mode the early check for
+# unclosed expressions and unknown modifiers is skipped.
+#
+# See VarCheckSyntax, ApplyModifier_Regex.
+#
+VARMOD_REGEX=	${:UA=111 B=222 C=33:C/.*=.{1,${:U2}}$//g}



CVS commit: src/usr.bin/make/unit-tests

2021-02-23 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Feb 23 21:59:31 UTC 2021

Modified Files:
src/usr.bin/make/unit-tests: var-class-cmdline.exp var-class-cmdline.mk

Log Message:
make: document the history of bugs in "cmdline overrides global"

For performance reasons, the implementation of the simple rule "cmdline
overrides global" grew into code that is much more complicated than a
straight-forward implementation.  This added complexity made it easy for
bugs to sneak in.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/var-class-cmdline.exp
cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/var-class-cmdline.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/var-class-cmdline.exp
diff -u src/usr.bin/make/unit-tests/var-class-cmdline.exp:1.3 src/usr.bin/make/unit-tests/var-class-cmdline.exp:1.4
--- src/usr.bin/make/unit-tests/var-class-cmdline.exp:1.3	Tue Feb 23 14:17:21 2021
+++ src/usr.bin/make/unit-tests/var-class-cmdline.exp	Tue Feb 23 21:59:31 2021
@@ -1,4 +1,4 @@
-make: "var-class-cmdline.mk" line 23: global
-make: "var-class-cmdline.mk" line 32: makeflags
+make: "var-class-cmdline.mk" line 67: global
+make: "var-class-cmdline.mk" line 76: makeflags
 makeflags
 exit status 0

Index: src/usr.bin/make/unit-tests/var-class-cmdline.mk
diff -u src/usr.bin/make/unit-tests/var-class-cmdline.mk:1.4 src/usr.bin/make/unit-tests/var-class-cmdline.mk:1.5
--- src/usr.bin/make/unit-tests/var-class-cmdline.mk:1.4	Tue Feb 23 14:17:21 2021
+++ src/usr.bin/make/unit-tests/var-class-cmdline.mk	Tue Feb 23 21:59:31 2021
@@ -1,18 +1,62 @@
-# $NetBSD: var-class-cmdline.mk,v 1.4 2021/02/23 14:17:21 rillig Exp $
+# $NetBSD: var-class-cmdline.mk,v 1.5 2021/02/23 21:59:31 rillig Exp $
 #
 # Tests for variables specified on the command line.
 #
 # Variables that are specified on the command line override those from the
 # global scope.
 #
-# For performance reasons, variable lookup often starts in the global scope
-# since that is where most practically used variables are stored.  But even
-# in these cases, variables from the command line scope must override the
-# global variables.  Therefore, whenever a global variable is tried to be
-# set, it is ignored when there is already a variable of the same name in
-# the cmdline scope.  In the same vein, when a cmdline variable is set and
-# there is already a variable of the same name in the global scope, that
-# global variable is deleted first.
+# For performance reasons, the actual implementation is more complex than the
+# above single-sentence rule, in order to avoid unnecessary lookups in scopes,
+# which before var.c 1.586 from 2020-10-25 calculated the hash value of the
+# variable name once for each lookup.  Instead, when looking up the value of
+# a variable, the search often starts in the global scope since that is where
+# most of the variables are stored.  This conflicts with the statement that
+# variables from the cmdline scope override global variables, since after the
+# common case of finding a variable in the global scope, another lookup would
+# be needed in the cmdline scope to ensure that there is no overriding
+# variable there.
+#
+# Instead of this costly lookup scheme, make implements it in a different
+# way:
+#
+#	Whenever a global variable is created, this creation is ignored if
+#	there is a cmdline variable of the same name.
+#
+#	Whenever a cmdline variable is created, any global variable of the
+#	same name is deleted.
+#
+#	Whenever a global variable is deleted, nothing special happens.
+#
+#	Deleting a cmdline variable is not possible.
+#
+# These 4 rules provide the guarantee that whenever a global variable exists,
+# there cannot be a cmdline variable of the same name.  Therefore, after
+# finding a variable in the global scope, no additional lookup is needed in
+# the cmdline scope.
+#
+# The above ruleset provides the same guarantees as the simple rule "cmdline
+# overrides global".  Due to an implementation mistake, the actual behavior
+# was not entirely equivalent to the simple rule though.  The mistake was
+# that when a cmdline variable with '$$' in its name was added, a global
+# variable was deleted, but not with the exact same name as the cmdline
+# variable.  Instead, the name of the global variable was expanded one more
+# time than the name of the cmdline variable.  For variable names that didn't
+# have a '$$' in their name, it was implemented correctly all the time.
+#
+# The bug was added in var.c 1.183 on 2013-07-16, when Var_Set called
+# Var_Delete to delete the global variable.  Just two months earlier, in var.c
+# 1.174 from 2013-05-18, Var_Delete had started to expand the variable name.
+# Together, these two changes made the variable name be expanded twice in a
+# row.  This bug was fixed in var.c 1.835 from 2021-02-22.
+#
+# Another bug was th

CVS commit: src/usr.bin/make/unit-tests

2021-02-23 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Feb 23 16:04:16 UTC 2021

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

Log Message:
make: add test for confusing error message for bad modifier

In the expression ${:U}, the variable name is empty.  Since these
expressions are generated by .for loops, the error messages for them
must not end with a trailing space.  Putting the variable name in quotes
helps against that.


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/usr.bin/make/unit-tests/moderrs.exp
cvs rdiff -u -r1.26 -r1.27 src/usr.bin/make/unit-tests/moderrs.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.27 src/usr.bin/make/unit-tests/moderrs.exp:1.28
--- src/usr.bin/make/unit-tests/moderrs.exp:1.27	Tue Feb 23 15:56:30 2021
+++ src/usr.bin/make/unit-tests/moderrs.exp	Tue Feb 23 16:04:16 2021
@@ -100,6 +100,8 @@ mod-ts-parse:
 15152535558513521534
 make: Bad modifier `:ts\65oct' for FIB
 65oct}
+make: Bad modifier `:ts\65oct' for 
+65oct}
 make: Bad modifier `:tsxy' for FIB
 xy}
 

Index: src/usr.bin/make/unit-tests/moderrs.mk
diff -u src/usr.bin/make/unit-tests/moderrs.mk:1.26 src/usr.bin/make/unit-tests/moderrs.mk:1.27
--- src/usr.bin/make/unit-tests/moderrs.mk:1.26	Tue Feb 23 15:56:30 2021
+++ src/usr.bin/make/unit-tests/moderrs.mk	Tue Feb 23 16:04:16 2021
@@ -1,4 +1,4 @@
-# $NetBSD: moderrs.mk,v 1.26 2021/02/23 15:56:30 rillig Exp $
+# $NetBSD: moderrs.mk,v 1.27 2021/02/23 16:04:16 rillig Exp $
 #
 # various modifier error tests
 
@@ -140,6 +140,7 @@ mod-ts-parse: print-header print-footer
 	@echo ${FIB:ts}
 	@echo ${FIB:ts\65}	# octal 065 == U+0035 == '5'
 	@echo ${FIB:ts\65oct}	# bad modifier
+	@echo ${:U${FIB}:ts\65oct} # bad modifier, variable name is ""
 	@echo ${FIB:tsxy}	# modifier too long
 
 mod-t-parse: print-header print-footer



CVS commit: src/usr.bin/make/unit-tests

2021-02-23 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Feb 23 14:17:21 UTC 2021

Modified Files:
src/usr.bin/make/unit-tests: var-class-cmdline.exp var-class-cmdline.mk
varmod-loop.exp varmod-loop.mk

Log Message:
make: demonstrate how to undefine variables during evaluation

For a very long time now, I had thought that it would be impossible to
undefine global variables during the evaluation of variable expressions.
This is something that the memory management in Var_Parse relies upon,
see the comment 'the value of the variable must not change'.

After several unsuccessful attempts at referring to an already freed
previous value of a variable, today I discovered how to unset a global
variable while evaluating an expression, which has the same effect.  To
demonstrate that this use-after-free can reliably crash make, it would
need a memory allocator with a debug mode that never re-allocates the
same memory block after it has been used once.  This is something that
jemalloc cannot do at the moment.  Valgrind would be another idea, but
that has not been ported to NetBSD.

Undefining a global variable while evaluating an expression is made
possible by an implementation detail of the modifier ':@'.  That
modifier undefines the loop variable, without restoring its previous
value, see ApplyModifier_Loop.

By the very old conventions of ODE Make, these loop variables are named
'.V.' and thus do not conflict with variables from other naming
conventions.  In NetBSD and pkgsrc, these loop variables are typically
called 'var', sometimes '_var' with a leading underscore, which also
doesn't conflict with the typical form 'VAR' of variables in the global
namespace.  Therefore, in practice these loop variables don't interfere
with other variables.

One case that can practically arise is when an outer variable has a
modifier ':@word@${VAR.${word}}@' and one of the referenced variables
uses the same variable name in the modifier, see varmod-loop.mk 1.10
line 91 for a detailed explanation.

By using the ${:@VAR@@} modifier in a place that is evaluated with
cmdline scope, it is not only possible to undefine global variables, it
is possible to undefine cmdline variables as well.  When evaluated in a
specific make target, the expression ${:@\@@@} can even be used to
undefine the variable '.TARGET', which will probably crash make with an
assertion failure.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/var-class-cmdline.exp
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/var-class-cmdline.mk
cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/varmod-loop.exp
cvs rdiff -u -r1.9 -r1.10 src/usr.bin/make/unit-tests/varmod-loop.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/var-class-cmdline.exp
diff -u src/usr.bin/make/unit-tests/var-class-cmdline.exp:1.2 src/usr.bin/make/unit-tests/var-class-cmdline.exp:1.3
--- src/usr.bin/make/unit-tests/var-class-cmdline.exp:1.2	Mon Feb 22 22:04:28 2021
+++ src/usr.bin/make/unit-tests/var-class-cmdline.exp	Tue Feb 23 14:17:21 2021
@@ -1,4 +1,4 @@
 make: "var-class-cmdline.mk" line 23: global
-make: "var-class-cmdline.mk" line 30: makeflags
+make: "var-class-cmdline.mk" line 32: makeflags
 makeflags
 exit status 0

Index: src/usr.bin/make/unit-tests/var-class-cmdline.mk
diff -u src/usr.bin/make/unit-tests/var-class-cmdline.mk:1.3 src/usr.bin/make/unit-tests/var-class-cmdline.mk:1.4
--- src/usr.bin/make/unit-tests/var-class-cmdline.mk:1.3	Mon Feb 22 22:04:28 2021
+++ src/usr.bin/make/unit-tests/var-class-cmdline.mk	Tue Feb 23 14:17:21 2021
@@ -1,4 +1,4 @@
-# $NetBSD: var-class-cmdline.mk,v 1.3 2021/02/22 22:04:28 rillig Exp $
+# $NetBSD: var-class-cmdline.mk,v 1.4 2021/02/23 14:17:21 rillig Exp $
 #
 # Tests for variables specified on the command line.
 #
@@ -23,9 +23,11 @@ VAR=	global
 .info ${VAR}
 
 # The global variable is "overridden" by simply deleting it and then
-# installing the cmdline variable instead.  Since there is no way to
+# installing the cmdline variable instead.  Since there is no obvious way to
 # undefine a cmdline variable, there is no need to remember the old value
 # of the global variable could become visible again.
+#
+# See varmod-loop.mk for a non-obvious way to undefine a cmdline variable.
 .MAKEFLAGS: VAR=makeflags
 .info ${VAR}
 

Index: src/usr.bin/make/unit-tests/varmod-loop.exp
diff -u src/usr.bin/make/unit-tests/varmod-loop.exp:1.5 src/usr.bin/make/unit-tests/varmod-loop.exp:1.6
--- src/usr.bin/make/unit-tests/varmod-loop.exp:1.5	Thu Nov 12 00:40:55 2020
+++ src/usr.bin/make/unit-tests/varmod-loop.exp	Tue Feb 23 14:17:21 2021
@@ -1,10 +1,10 @@
-ParseReadLine (117): 'USE_8_DOLLARS=	${:U1:@var@${8_DOLLARS}@} ${8_DOLLARS} '
+ParseReadLine (132): 'USE_8_DOLLARS=	${:U1:@var@${8_DOLLARS}@} ${8_DOLLARS} '
 CondParser_Eval: ${USE_8_DOLLARS} != "\$\$\$\$ \$\$\$\

CVS commit: src/usr.bin/make/unit-tests

2021-02-22 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Feb 22 23:59:43 UTC 2021

Modified Files:
src/usr.bin/make/unit-tests: varmod-edge.exp varmod-edge.mk

Log Message:
make: add test for confusing double space in error message


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/usr.bin/make/unit-tests/varmod-edge.exp
cvs rdiff -u -r1.13 -r1.14 src/usr.bin/make/unit-tests/varmod-edge.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/varmod-edge.exp
diff -u src/usr.bin/make/unit-tests/varmod-edge.exp:1.10 src/usr.bin/make/unit-tests/varmod-edge.exp:1.11
--- src/usr.bin/make/unit-tests/varmod-edge.exp:1.10	Sun Dec 20 19:47:34 2020
+++ src/usr.bin/make/unit-tests/varmod-edge.exp	Mon Feb 22 23:59:43 2021
@@ -18,6 +18,10 @@ make: "varmod-edge.mk" line 166: ok colo
 make: "varmod-edge.mk" line 165: Unknown modifier ':'
 make: "varmod-edge.mk" line 165: Unknown modifier ':'
 make: "varmod-edge.mk" line 166: ok colons
+make: "varmod-edge.mk" line 175: Unknown modifier 'Z'
+make: "varmod-edge.mk" line 175: Malformed conditional (${:Z})
+make: Unfinished modifier for  (',' missing)
+make: "varmod-edge.mk" line 184: Malformed conditional (${:S,})
 make: Fatal errors encountered -- cannot continue
 make: stopped in unit-tests
 exit status 1

Index: src/usr.bin/make/unit-tests/varmod-edge.mk
diff -u src/usr.bin/make/unit-tests/varmod-edge.mk:1.13 src/usr.bin/make/unit-tests/varmod-edge.mk:1.14
--- src/usr.bin/make/unit-tests/varmod-edge.mk:1.13	Sat Oct 24 08:46:08 2020
+++ src/usr.bin/make/unit-tests/varmod-edge.mk	Mon Feb 22 23:59:43 2021
@@ -1,4 +1,4 @@
-# $NetBSD: varmod-edge.mk,v 1.13 2020/10/24 08:46:08 rillig Exp $
+# $NetBSD: varmod-edge.mk,v 1.14 2021/02/22 23:59:43 rillig Exp $
 #
 # Tests for edge cases in variable modifiers.
 #
@@ -169,5 +169,23 @@ EXP.colons=	# empty
 .  endif
 .endfor
 
+# Even in expressions based on an unnamed variable, there may be errors.
+# XXX: The error message should mention the variable name of the expression,
+# even though that name is empty in this case.
+.if ${:Z}
+.  error
+.else
+.  error
+.endif
+
+# Even in expressions based on an unnamed variable, there may be errors.
+# XXX: The error message should not contain two spaces in a row.
+# XXX: The error message should report the filename:lineno.
+.if ${:S,}
+.  error
+.else
+.  error
+.endif
+
 all:
 	@echo ok



CVS commit: src/usr.bin/make/unit-tests

2021-02-22 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Feb 22 22:04:28 UTC 2021

Modified Files:
src/usr.bin/make/unit-tests: var-class-cmdline.exp var-class-cmdline.mk

Log Message:
make: add test for cmdline variables overriding global variables


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/var-class-cmdline.exp
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/var-class-cmdline.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/var-class-cmdline.exp
diff -u src/usr.bin/make/unit-tests/var-class-cmdline.exp:1.1 src/usr.bin/make/unit-tests/var-class-cmdline.exp:1.2
--- src/usr.bin/make/unit-tests/var-class-cmdline.exp:1.1	Sun Aug 16 12:07:51 2020
+++ src/usr.bin/make/unit-tests/var-class-cmdline.exp	Mon Feb 22 22:04:28 2021
@@ -1 +1,4 @@
+make: "var-class-cmdline.mk" line 23: global
+make: "var-class-cmdline.mk" line 30: makeflags
+makeflags
 exit status 0

Index: src/usr.bin/make/unit-tests/var-class-cmdline.mk
diff -u src/usr.bin/make/unit-tests/var-class-cmdline.mk:1.2 src/usr.bin/make/unit-tests/var-class-cmdline.mk:1.3
--- src/usr.bin/make/unit-tests/var-class-cmdline.mk:1.2	Sun Aug 16 14:25:16 2020
+++ src/usr.bin/make/unit-tests/var-class-cmdline.mk	Mon Feb 22 22:04:28 2021
@@ -1,8 +1,34 @@
-# $NetBSD: var-class-cmdline.mk,v 1.2 2020/08/16 14:25:16 rillig Exp $
+# $NetBSD: var-class-cmdline.mk,v 1.3 2021/02/22 22:04:28 rillig Exp $
 #
 # Tests for variables specified on the command line.
+#
+# Variables that are specified on the command line override those from the
+# global scope.
+#
+# For performance reasons, variable lookup often starts in the global scope
+# since that is where most practically used variables are stored.  But even
+# in these cases, variables from the command line scope must override the
+# global variables.  Therefore, whenever a global variable is tried to be
+# set, it is ignored when there is already a variable of the same name in
+# the cmdline scope.  In the same vein, when a cmdline variable is set and
+# there is already a variable of the same name in the global scope, that
+# global variable is deleted first.
+#
+# Most cmdline variables are set at the very beginning, when parsing the
+# command line arguments.  Using the special target '.MAKEFLAGS', it is
+# possible to set cmdline variables at any later time.
+
+# A normal global variable, without any cmdline variable nearby.
+VAR=	global
+.info ${VAR}
 
-# TODO: Implementation
+# The global variable is "overridden" by simply deleting it and then
+# installing the cmdline variable instead.  Since there is no way to
+# undefine a cmdline variable, there is no need to remember the old value
+# of the global variable could become visible again.
+.MAKEFLAGS: VAR=makeflags
+.info ${VAR}
 
-all:
-	@:;
+# If Var_SetWithFlags should ever forget to delete the global variable,
+# the below line would print "global" instead of the current "makeflags".
+.MAKEFLAGS: -V VAR



CVS commit: src/usr.bin/make/unit-tests

2021-02-16 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Feb 16 19:43:09 UTC 2021

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

Log Message:
make: document the bad state in which the test varcmd.mk is


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/varcmd.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/varcmd.mk
diff -u src/usr.bin/make/unit-tests/varcmd.mk:1.5 src/usr.bin/make/unit-tests/varcmd.mk:1.6
--- src/usr.bin/make/unit-tests/varcmd.mk:1.5	Sat Oct 24 08:50:17 2020
+++ src/usr.bin/make/unit-tests/varcmd.mk	Tue Feb 16 19:43:09 2021
@@ -1,6 +1,17 @@
-# $NetBSD: varcmd.mk,v 1.5 2020/10/24 08:50:17 rillig Exp $
+# $NetBSD: varcmd.mk,v 1.6 2021/02/16 19:43:09 rillig Exp $
 #
 # Test behaviour of recursive make and vars set on command line.
+#
+# FIXME: The purpose of this test is unclear.  The test uses six levels of
+# sub-makes, which makes it incredibly hard to understand.  There must be at
+# least an introductory explanation about what _should_ happen here.
+# The variable names are terrible, as well as their values.
+#
+# This test produces different results if the large block with the condition
+# "scope == SCOPE_GLOBAL" in Var_SetWithFlags is removed.  This test should
+# be rewritten to make it clear why there is a difference and why this is
+# actually intended.  Removing that large block of code makes only this test
+# and vardebug.mk fail, which is not enough.
 
 FU=	fu
 FOO?=	foo
@@ -57,4 +68,3 @@ five:	show show-v
 
 six:	show-v
 	@${.MAKE} -f ${MAKEFILE} V=override show-v
-



CVS commit: src/usr.bin/make/unit-tests

2021-02-16 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Feb 16 19:01:18 UTC 2021

Modified Files:
src/usr.bin/make/unit-tests: directive-export.mk

Log Message:
make: test exporting a variable that itself depends on a subprocess

When the point that "isn't going to end well" is reached, the stacktrace
is quite long but still reasonable:

main
main_ReadFiles
ReadAllMakefiles
ReadMakefiledirective-export.mk
Parse_File
ParseLine   # line 3 has: _!= :;:
ParseVarassign
Parse_DoVar
VarAssign_Eval
VarAssign_EvalShell # because of the '!='
Cmd_Exec:;:
Var_ReexportVars# before starting the subprocess
ExportVar   EMPTY_SHELL
ExportVarEnv# was only marked for export
Var_Subst   ${EMPTY_SHELL}  # to get the value to export
VarSubstExpr${EMPTY_SHELL}
Var_Parse   ${EMPTY_SHELL}
Var_Subst   ${:sh}  # since EMPTY_SHELL= ${:sh}
VarSubstExpr${:sh}
Var_Parse   ${:sh}
ApplyModifiers
ApplySingleModifier :sh
ApplyModifier
ApplyModifier_SunShell  :sh
Cmd_Exec""  # empty command
Var_ReexportVars
ExportVar   EMPTY_SHELL
ExportVarEnv# skipping this edge case


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/unit-tests/directive-export.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/directive-export.mk
diff -u src/usr.bin/make/unit-tests/directive-export.mk:1.7 src/usr.bin/make/unit-tests/directive-export.mk:1.8
--- src/usr.bin/make/unit-tests/directive-export.mk:1.7	Tue Feb 16 18:12:46 2021
+++ src/usr.bin/make/unit-tests/directive-export.mk	Tue Feb 16 19:01:18 2021
@@ -1,4 +1,4 @@
-# $NetBSD: directive-export.mk,v 1.7 2021/02/16 18:12:46 rillig Exp $
+# $NetBSD: directive-export.mk,v 1.8 2021/02/16 19:01:18 rillig Exp $
 #
 # Tests for the .export directive.
 #
@@ -34,5 +34,11 @@ VAR=		value $$ ${INDIRECT}
 # An empty argument means no additional variables to export.
 .export ${:U}
 
+
+# Trigger the "This isn't going to end well" in ExportVarEnv.
+EMPTY_SHELL=	${:sh}
+.export EMPTY_SHELL	# only marked for export at this point
+_!=		:;:	# Force the variable to be actually exported.
+
+
 all:
-	@:;



CVS commit: src/usr.bin/make/unit-tests

2021-02-16 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Feb 16 18:12:46 UTC 2021

Modified Files:
src/usr.bin/make/unit-tests: directive-export.mk

Log Message:
make: clarify what .export ${:U} means


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/directive-export.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/directive-export.mk
diff -u src/usr.bin/make/unit-tests/directive-export.mk:1.6 src/usr.bin/make/unit-tests/directive-export.mk:1.7
--- src/usr.bin/make/unit-tests/directive-export.mk:1.6	Sun Dec 13 01:07:54 2020
+++ src/usr.bin/make/unit-tests/directive-export.mk	Tue Feb 16 18:12:46 2021
@@ -1,4 +1,4 @@
-# $NetBSD: directive-export.mk,v 1.6 2020/12/13 01:07:54 rillig Exp $
+# $NetBSD: directive-export.mk,v 1.7 2021/02/16 18:12:46 rillig Exp $
 #
 # Tests for the .export directive.
 #
@@ -28,8 +28,11 @@ VAR=		value $$ ${INDIRECT}
 .  error
 .endif
 
-# No argument means to export all variables.
+# No syntactical argument means to export all variables.
 .export
 
+# An empty argument means no additional variables to export.
+.export ${:U}
+
 all:
 	@:;



CVS commit: src/usr.bin/make/unit-tests

2021-02-16 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Feb 16 18:02:19 UTC 2021

Modified Files:
src/usr.bin/make/unit-tests: directive-undef.exp directive-undef.mk

Log Message:
make: demonstrate inconsistency in .undef of an exported variable


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/directive-undef.exp
cvs rdiff -u -r1.9 -r1.10 src/usr.bin/make/unit-tests/directive-undef.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/directive-undef.exp
diff -u src/usr.bin/make/unit-tests/directive-undef.exp:1.5 src/usr.bin/make/unit-tests/directive-undef.exp:1.6
--- src/usr.bin/make/unit-tests/directive-undef.exp:1.5	Tue Dec 22 20:10:21 2020
+++ src/usr.bin/make/unit-tests/directive-undef.exp	Tue Feb 16 18:02:19 2021
@@ -1,5 +1,6 @@
 make: "directive-undef.mk" line 29: The .undef directive requires an argument
 make: "directive-undef.mk" line 86: Unknown modifier 'Z'
+make: "directive-undef.mk" line 103: warning: UT_EXPORTED is still listed in .MAKE.EXPORTED even though spaceit is not exported anymore.
 make: Fatal errors encountered -- cannot continue
 make: stopped in unit-tests
 exit status 1

Index: src/usr.bin/make/unit-tests/directive-undef.mk
diff -u src/usr.bin/make/unit-tests/directive-undef.mk:1.9 src/usr.bin/make/unit-tests/directive-undef.mk:1.10
--- src/usr.bin/make/unit-tests/directive-undef.mk:1.9	Tue Dec 22 20:10:21 2020
+++ src/usr.bin/make/unit-tests/directive-undef.mk	Tue Feb 16 18:02:19 2021
@@ -1,4 +1,4 @@
-# $NetBSD: directive-undef.mk,v 1.9 2020/12/22 20:10:21 rillig Exp $
+# $NetBSD: directive-undef.mk,v 1.10 2021/02/16 18:02:19 rillig Exp $
 #
 # Tests for the .undef directive.
 #
@@ -86,5 +86,22 @@ ${DOLLAR}=	dollar
 .undef ${VARNAMES:L:Z}
 
 
+UT_EXPORTED=	exported-value
+.export UT_EXPORTED
+.if ${:!echo "\${UT_EXPORTED:-not-exported}"!} != "exported-value"
+.  error
+.endif
+.if !${.MAKE.EXPORTED:MUT_EXPORTED}
+.  error
+.endif
+.undef UT_EXPORTED		# XXX: does not update .MAKE.EXPORTED
+.if ${:!echo "\${UT_EXPORTED:-not-exported}"!} != "not-exported"
+.  error
+.endif
+.if ${.MAKE.EXPORTED:MUT_EXPORTED}
+.  warning UT_EXPORTED is still listed in .MAKE.EXPORTED even though $\
+	   it is not exported anymore.
+.endif
+
+
 all:
-	@:;



CVS commit: src/usr.bin/make/unit-tests

2021-02-14 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Feb 15 07:58:19 UTC 2021

Modified Files:
src/usr.bin/make/unit-tests: directive-for-escape.exp
directive-for-escape.mk

Log Message:
make: improve comments in test for expansions in .for loops


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/directive-for-escape.exp \
src/usr.bin/make/unit-tests/directive-for-escape.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/directive-for-escape.exp
diff -u src/usr.bin/make/unit-tests/directive-for-escape.exp:1.6 src/usr.bin/make/unit-tests/directive-for-escape.exp:1.7
--- src/usr.bin/make/unit-tests/directive-for-escape.exp:1.6	Mon Jan 25 19:05:39 2021
+++ src/usr.bin/make/unit-tests/directive-for-escape.exp	Mon Feb 15 07:58:19 2021
@@ -37,19 +37,19 @@ make: "directive-for-escape.mk" line 55:
 For: end for 1
 For: loop body:
 .  info ${:Ubegin<${UNDEF:Ufallback:N{{{>end}
-make: "directive-for-escape.mk" line 66: beginend
+make: "directive-for-escape.mk" line 67: beginend
 For: end for 1
 For: loop body:
 .  info ${:U\$}
-make: "directive-for-escape.mk" line 74: $
+make: "directive-for-escape.mk" line 75: $
 For: end for 1
 For: loop body:
 .  info ${NUMBERS} ${:Ureplaced}
-make: "directive-for-escape.mk" line 82: one two three replaced
+make: "directive-for-escape.mk" line 83: one two three replaced
 For: end for 1
 For: loop body:
 .  info ${:Ureplaced}
-make: "directive-for-escape.mk" line 92: replaced
+make: "directive-for-escape.mk" line 93: replaced
 For: end for 1
 For: loop body:
 .  info .$$i: ${:Uinner}
@@ -62,14 +62,14 @@ For: loop body:
 .  info . $${i2}: ${i2}
 .  info . $${i,}: ${i,}
 .  info .  adjacent: ${:Uinner}${:Uinner}${:Uinner:M*}${:Uinner}
-make: "directive-for-escape.mk" line 100: .$i: inner
-make: "directive-for-escape.mk" line 101: .  ${i}: inner
-make: "directive-for-escape.mk" line 102: .   ${i:M*}: inner
-make: "directive-for-escape.mk" line 103: .  $(i): inner
-make: "directive-for-escape.mk" line 104: .   $(i:M*): inner
-make: "directive-for-escape.mk" line 105: . ${i${:U}}: outer
-make: "directive-for-escape.mk" line 106: .${i\}}: inner}
-make: "directive-for-escape.mk" line 107: . ${i2}: two
-make: "directive-for-escape.mk" line 108: . ${i,}: comma
-make: "directive-for-escape.mk" line 109: .  adjacent: innerinnerinnerinner
+make: "directive-for-escape.mk" line 101: .$i: inner
+make: "directive-for-escape.mk" line 102: .  ${i}: inner
+make: "directive-for-escape.mk" line 103: .   ${i:M*}: inner
+make: "directive-for-escape.mk" line 104: .  $(i): inner
+make: "directive-for-escape.mk" line 105: .   $(i:M*): inner
+make: "directive-for-escape.mk" line 106: . ${i${:U}}: outer
+make: "directive-for-escape.mk" line 107: .${i\}}: inner}
+make: "directive-for-escape.mk" line 108: . ${i2}: two
+make: "directive-for-escape.mk" line 109: . ${i,}: comma
+make: "directive-for-escape.mk" line 110: .  adjacent: innerinnerinnerinner
 exit status 0
Index: src/usr.bin/make/unit-tests/directive-for-escape.mk
diff -u src/usr.bin/make/unit-tests/directive-for-escape.mk:1.6 src/usr.bin/make/unit-tests/directive-for-escape.mk:1.7
--- src/usr.bin/make/unit-tests/directive-for-escape.mk:1.6	Mon Jan 25 19:05:39 2021
+++ src/usr.bin/make/unit-tests/directive-for-escape.mk	Mon Feb 15 07:58:19 2021
@@ -1,4 +1,4 @@
-# $NetBSD: directive-for-escape.mk,v 1.6 2021/01/25 19:05:39 rillig Exp $
+# $NetBSD: directive-for-escape.mk,v 1.7 2021/02/15 07:58:19 rillig Exp $
 #
 # Test escaping of special characters in the iteration values of a .for loop.
 # These values get expanded later using the :U variable modifier, and this
@@ -7,8 +7,8 @@
 
 .MAKEFLAGS: -df
 
-# Even though the .for loops takes quotes into account when splitting the
-# string into words, the quotes don't need to be balances, as of 2020-12-31.
+# Even though the .for loops take quotes into account when splitting the
+# string into words, the quotes don't need to be balanced, as of 2020-12-31.
 # This could be considered a bug.
 ASCII=	!"\#$$%&'()*+,-./0-9:;<=>?@A-Z[\]_^a-z{|}~
 
@@ -33,7 +33,7 @@ ASCII.2020-12-31=	!"\\\#$$%&'()*+,-./0-9
 #
 # XXX: It is unexpected that the variable V gets expanded in the loop body.
 # The double '$$' should prevent exactly this.  Probably nobody was
-# adventurous enough to use literal dollar signs in the values for a .for
+# adventurous enough to use literal dollar signs in the values of a .for
 # loop.
 V=		value
 VALUES=		$$ $${V} $${V:=-with-modifier} $$(V) $$(V:=-with-modifier)
@@ -43,14 +43,14 @@ VALUES=		$$ $${V} $${V:=-with-modifier} 
 
 # Try to cover the code for nested '{}' in for_var_len, without success.
 #
-# The value of VALUES is not meant to be a variable expression.  Instead, it
-# is meant to represent dollar, lbrace, "UNDEF:U", back

CVS commit: src/usr.bin/make/unit-tests

2021-02-14 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Feb 14 17:47:33 UTC 2021

Modified Files:
src/usr.bin/make/unit-tests: varmod-indirect.mk

Log Message:
make: add test for indirect ':U' modifier

Unlike ':ts' and ':tW', the effects of ':U' are visible even after the
modifiers from the nested expression have been applied.  These subtle
details, like many others, are not documented in the manual page.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/unit-tests/varmod-indirect.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/varmod-indirect.mk
diff -u src/usr.bin/make/unit-tests/varmod-indirect.mk:1.7 src/usr.bin/make/unit-tests/varmod-indirect.mk:1.8
--- src/usr.bin/make/unit-tests/varmod-indirect.mk:1.7	Sun Feb 14 17:22:37 2021
+++ src/usr.bin/make/unit-tests/varmod-indirect.mk	Sun Feb 14 17:47:33 2021
@@ -1,4 +1,4 @@
-# $NetBSD: varmod-indirect.mk,v 1.7 2021/02/14 17:22:37 rillig Exp $
+# $NetBSD: varmod-indirect.mk,v 1.8 2021/02/14 17:47:33 rillig Exp $
 #
 # Tests for indirect variable modifiers, such as in ${VAR:${M_modifiers}}.
 # These can be used for very basic purposes like converting a string to either
@@ -217,10 +217,31 @@ _:=	before ${UNDEF:${:UZ}} after
 .  error
 .endif
 # In this expression, the ':ts*' is indirect, therefore the changed separator
-# only lasts until the end of the indirect modifier.  It does not affect the
-# ':M' since that is outside the scope.
+# only applies to the modifiers from the indirect text.  It does not affect
+# the ':M' since that is not part of the text from the indirect modifier.
+#
+# Implementation detail: when ApplyModifiersIndirect calls ApplyModifiers
+# (which creates a new ApplyModifiersState containing a fresh separator),
+# the outer separator character is not passed by reference to the inner
+# evaluation, therefore the scope of the inner separator ends after applying
+# the modifier ':ts*'.
 .if ${1 2 3:L:${:Uts*}:Ua b c:M*} != "a b c"
 .  error
 .endif
 
+# A direct modifier ':U' turns the expression from undefined to defined.
+# An indirect modifier ':U' has the same effect, unlike the separator from
+# ':ts*' or the single-word marker from ':tW'.
+#
+# This is because when ApplyModifiersIndirect calls ApplyModifiers, it passes
+# the definedness of the outer expression by reference.  If that weren't the
+# case, the first condition below would result in a parse error because its
+# left-hand side would be undefined.
+.if ${UNDEF:${:UUindirect-fallback}} != "indirect-fallback"
+.  error
+.endif
+.if ${UNDEF:${:UUindirect-fallback}:Uouter-fallback} != "outer-fallback"
+.  error
+.endif
+
 all:



CVS commit: src/usr.bin/make/unit-tests

2021-02-14 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Feb 14 17:22:37 UTC 2021

Modified Files:
src/usr.bin/make/unit-tests: varmod-indirect.mk

Log Message:
make: document since when indirect modifiers are supported


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/varmod-indirect.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/varmod-indirect.mk
diff -u src/usr.bin/make/unit-tests/varmod-indirect.mk:1.6 src/usr.bin/make/unit-tests/varmod-indirect.mk:1.7
--- src/usr.bin/make/unit-tests/varmod-indirect.mk:1.6	Sun Feb 14 16:12:46 2021
+++ src/usr.bin/make/unit-tests/varmod-indirect.mk	Sun Feb 14 17:22:37 2021
@@ -1,11 +1,13 @@
-# $NetBSD: varmod-indirect.mk,v 1.6 2021/02/14 16:12:46 rillig Exp $
+# $NetBSD: varmod-indirect.mk,v 1.7 2021/02/14 17:22:37 rillig Exp $
 #
 # Tests for indirect variable modifiers, such as in ${VAR:${M_modifiers}}.
 # These can be used for very basic purposes like converting a string to either
 # uppercase or lowercase, as well as for fairly advanced modifiers that first
 # look like line noise and are hard to decipher.
 #
-# TODO: Since when are indirect modifiers supported?
+# Initial support for indirect modifiers was added in var.c 1.101 from
+# 2006-02-18.  Since var.c 1.108 from 2006-05-11 it is possible to use
+# indirect modifiers for all but the very first modifier as well.
 
 
 # To apply a modifier indirectly via another variable, the whole
@@ -202,7 +204,7 @@ _:=	before ${UNDEF:${:UZ}} after
 # interpretation only lasts until the end of the indirect modifier, it does
 # not influence the outer variable expression.
 #
-# In this expression, the direct ':ts*' has no effect since ':U' does not
+# In this first expression, the direct ':ts*' has no effect since ':U' does not
 # treat the expression value as a list of words but as a single word.  It has
 # to be ':U', not ':D', since the "expression name" is "1 2 3" and there is no
 # variable of that name.



CVS commit: src/usr.bin/make/unit-tests

2021-02-14 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Feb 14 16:12:46 UTC 2021

Modified Files:
src/usr.bin/make/unit-tests: varmod-indirect.exp varmod-indirect.mk

Log Message:
make: add more tests for edge cases in evaluating variable expressions

As a preparation for refactoring the code around variable expressions,
there need to be a few tests for indirect variable modifiers since these
were not covered before.

Indirect modifiers may include ':ts' and ':tW', which change the
interpretation of the variable expression in small details.  The scope
of these changes is limited to the indirect modifier, any evaluations
outside this indirect modifier are unaffected.

The changes to the .exp file are mostly line number changes, plus a
demonstration of a newly found bug, where an expression is evaluated
successfully despite producing a parse error.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/usr.bin/make/unit-tests/varmod-indirect.exp
cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/varmod-indirect.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/varmod-indirect.exp
diff -u src/usr.bin/make/unit-tests/varmod-indirect.exp:1.8 src/usr.bin/make/unit-tests/varmod-indirect.exp:1.9
--- src/usr.bin/make/unit-tests/varmod-indirect.exp:1.8	Tue Feb  2 16:18:16 2021
+++ src/usr.bin/make/unit-tests/varmod-indirect.exp	Sun Feb 14 16:12:46 2021
@@ -1,18 +1,20 @@
-make: "varmod-indirect.mk" line 13: Unknown modifier '$'
-make: "varmod-indirect.mk" line 108: before
-make: "varmod-indirect.mk" line 108: after
-make: "varmod-indirect.mk" line 114: before
-make: "varmod-indirect.mk" line 114: after
-make: "varmod-indirect.mk" line 120: before
-make: "varmod-indirect.mk" line 120: after
-make: "varmod-indirect.mk" line 124: Unknown modifier 'Z'
-make: "varmod-indirect.mk" line 125: before
-make: "varmod-indirect.mk" line 125: after
-ParseReadLine (134): '_:=	before ${UNDEF} after'
+make: "varmod-indirect.mk" line 17: Unknown modifier '$'
+make: "varmod-indirect.mk" line 50: Unknown modifier '$'
+make: "varmod-indirect.mk" line 53: warning: FIXME: this expression should have resulted in a parse error rather than returning the unparsed portion of the expression.
+make: "varmod-indirect.mk" line 138: before
+make: "varmod-indirect.mk" line 138: after
+make: "varmod-indirect.mk" line 144: before
+make: "varmod-indirect.mk" line 144: after
+make: "varmod-indirect.mk" line 150: before
+make: "varmod-indirect.mk" line 150: after
+make: "varmod-indirect.mk" line 154: Unknown modifier 'Z'
+make: "varmod-indirect.mk" line 155: before
+make: "varmod-indirect.mk" line 155: after
+ParseReadLine (164): '_:=	before ${UNDEF} after'
 Global:_ = 
 Var_Parse: ${UNDEF} after with VARE_WANTRES|VARE_KEEP_DOLLAR|VARE_KEEP_UNDEF
 Global:_ = before ${UNDEF} after
-ParseReadLine (137): '_:=	before ${UNDEF:${:US,a,a,}} after'
+ParseReadLine (167): '_:=	before ${UNDEF:${:US,a,a,}} after'
 Var_Parse: ${UNDEF:${:US,a,a,}} after with VARE_WANTRES|VARE_KEEP_DOLLAR|VARE_KEEP_UNDEF
 Var_Parse: ${:US,a,a,}} after with VARE_WANTRES|VARE_KEEP_DOLLAR|VARE_KEEP_UNDEF
 Applying ${:U...} to "" (VARE_WANTRES|VARE_KEEP_DOLLAR|VARE_KEEP_UNDEF, none, VES_UNDEF)
@@ -27,7 +29,7 @@ Var_Parse: ${:US,a,a,}} after with VARE_
 Applying ${:U...} to "" (VARE_WANTRES|VARE_KEEP_DOLLAR|VARE_KEEP_UNDEF, none, VES_UNDEF)
 Result of ${:US,a,a,} is "S,a,a," (VARE_WANTRES|VARE_KEEP_DOLLAR|VARE_KEEP_UNDEF, none, VES_DEF)
 Global:_ = before ${UNDEF:S,a,a,} after
-ParseReadLine (147): '_:=	before ${UNDEF:${:U}} after'
+ParseReadLine (177): '_:=	before ${UNDEF:${:U}} after'
 Var_Parse: ${UNDEF:${:U}} after with VARE_WANTRES|VARE_KEEP_DOLLAR|VARE_KEEP_UNDEF
 Var_Parse: ${:U}} after with VARE_WANTRES|VARE_KEEP_DOLLAR|VARE_KEEP_UNDEF
 Applying ${:U} to "" (VARE_WANTRES|VARE_KEEP_DOLLAR|VARE_KEEP_UNDEF, none, VES_UNDEF)
@@ -37,20 +39,20 @@ Var_Parse: ${:U}} after with VARE_WANTRE
 Applying ${:U} to "" (VARE_WANTRES|VARE_KEEP_DOLLAR|VARE_KEEP_UNDEF, none, VES_UNDEF)
 Result of ${:U} is "" (VARE_WANTRES|VARE_KEEP_DOLLAR|VARE_KEEP_UNDEF, none, VES_DEF)
 Global:_ = before ${UNDEF:} after
-ParseReadLine (152): '_:=	before ${UNDEF:${:UZ}} after'
+ParseReadLine (182): '_:=	before ${UNDEF:${:UZ}} after'
 Var_Parse: ${UNDEF:${:UZ}} after with VARE_WANTRES|VARE_KEEP_DOLLAR|VARE_KEEP_UNDEF
 Var_Parse: ${:UZ}} after with VARE_WANTRES|VARE_KEEP_DOLLAR|VARE_KEEP_UNDEF
 Applying ${:U...} to "" (VARE_WANTRES|VARE_KEEP_DOLLAR|VARE_KEEP_UNDEF, none, VES_UNDEF)
 Result of ${:UZ} is "Z" (VARE_WANTRES|VARE_KEEP_DOLLAR|VARE_KEEP_UNDEF, none, VES_DEF)
 Indirect modifier "Z" from "${:UZ}"
 Applying ${UNDEF:Z} to "" (VARE_WANTRES|VARE_KEEP_DOLLAR|VARE_KEEP_UNDEF, none, VES_UNDEF)
-make: "varmod-indirect.mk" line 152: Unknown modifier 'Z'
+make: "varmod-indirect.mk" line 182: Unknown modifier 'Z'
 Result of ${UNDEF:Z} is error (VARE_WANTRES|VARE_KEEP_DOLLAR|VARE_KE

CVS commit: src/usr.bin/make/unit-tests

2021-02-14 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Feb 14 13:24:45 UTC 2021

Modified Files:
src/usr.bin/make/unit-tests: Makefile

Log Message:
make: fix TMPDIR in unit-tests

Combining the assignment operator ':=' with the variable modifier ':U'
on the same variable does not work as intended.  At the point where the
':U' is evaluated, the variable is guaranteed to be defined because the
code in VarAssign_EvalSubst says so.


To generate a diff of this commit:
cvs rdiff -u -r1.269 -r1.270 src/usr.bin/make/unit-tests/Makefile

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.269 src/usr.bin/make/unit-tests/Makefile:1.270
--- src/usr.bin/make/unit-tests/Makefile:1.269	Sat Feb  6 18:26:03 2021
+++ src/usr.bin/make/unit-tests/Makefile	Sun Feb 14 13:24:45 2021
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.269 2021/02/06 18:26:03 sjg Exp $
+# $NetBSD: Makefile,v 1.270 2021/02/14 13:24:45 rillig Exp $
 #
 # Unit tests for make(1)
 #
@@ -622,8 +622,10 @@ LANG=		C
 .if ${.OBJDIR} != ${.CURDIR}
 # easy
 TMPDIR:=	${.OBJDIR}/tmp
+.elif defined(TMPDIR)
+TMPDIR:=	${TMPDIR}/uid${.MAKE.UID}
 .else
-TMPDIR:=	${TMPDIR:U/tmp}/uid${.MAKE.UID}
+TMPDIR:=	/tmp/uid${.MAKE.UID}
 .endif
 # make sure it exists
 .if !exist(${TMPDIR})



CVS commit: src/usr.bin/make/unit-tests

2021-02-14 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Feb 14 12:14:37 UTC 2021

Modified Files:
src/usr.bin/make/unit-tests: varmod-assign.mk

Log Message:
make: add test for ::= modifier enclosed in parentheses


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 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/varmod-assign.mk
diff -u src/usr.bin/make/unit-tests/varmod-assign.mk:1.9 src/usr.bin/make/unit-tests/varmod-assign.mk:1.10
--- src/usr.bin/make/unit-tests/varmod-assign.mk:1.9	Fri Jan 22 22:54:53 2021
+++ src/usr.bin/make/unit-tests/varmod-assign.mk	Sun Feb 14 12:14:37 2021
@@ -1,4 +1,4 @@
-# $NetBSD: varmod-assign.mk,v 1.9 2021/01/22 22:54:53 rillig Exp $
+# $NetBSD: varmod-assign.mk,v 1.10 2021/02/14 12:14:37 rillig Exp $
 #
 # Tests for the obscure ::= variable modifiers, which perform variable
 # assignments during evaluation, just like the = operator in C.
@@ -91,7 +91,7 @@ mod-assign-shell-error:
 	@${SH_ERR::=previous}
 	@${SH_ERR::!= echo word; false } echo err=${SH_ERR}
 
-# XXX: The ::= modifier expands its right-hand side, exactly once.
+# XXX: The ::= modifier expands its right-hand side exactly once.
 # This differs subtly from normal assignments such as '+=' or '=', which copy
 # their right-hand side literally.
 APPEND.prev=		previous
@@ -104,3 +104,13 @@ APPEND.dollar=		$${APPEND.indirect}
 .if ${APPEND.var} != "previous indirect \${:Unot expanded}"
 .  error
 .endif
+
+
+# The assignment modifier can be used in a variable expression that is
+# enclosed in parentheses.  In such a case, parsing stops at the first ')',
+# not at the first '}'.
+VAR=	previous
+_:=	$(VAR::=current})
+.if ${VAR} != "current}"
+.  error
+.endif



CVS commit: src/usr.bin/make/unit-tests

2021-02-07 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Feb  7 17:17:25 UTC 2021

Modified Files:
src/usr.bin/make/unit-tests: var-op-sunsh.mk

Log Message:
make: fix typo in comment in test


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/var-op-sunsh.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/var-op-sunsh.mk
diff -u src/usr.bin/make/unit-tests/var-op-sunsh.mk:1.6 src/usr.bin/make/unit-tests/var-op-sunsh.mk:1.7
--- src/usr.bin/make/unit-tests/var-op-sunsh.mk:1.6	Sun Nov 15 20:20:58 2020
+++ src/usr.bin/make/unit-tests/var-op-sunsh.mk	Sun Feb  7 17:17:25 2021
@@ -1,4 +1,4 @@
-# $NetBSD: var-op-sunsh.mk,v 1.6 2020/11/15 20:20:58 rillig Exp $
+# $NetBSD: var-op-sunsh.mk,v 1.7 2021/02/07 17:17:25 rillig Exp $
 #
 # Tests for the :sh= variable assignment operator, which runs its right-hand
 # side through the shell.  It is a seldom-used alternative to the !=
@@ -75,7 +75,7 @@ VAR.key:shift=		Shift
 # the ':sh' assignment operator modifier.  Let's see what happens ...
 #
 # Well, the end result is correct but the way until there is rather
-# adventurous.  This only works because the parser replaces each an every
+# adventurous.  This only works because the parser replaces each and every
 # whitespace character that is not nested with '\0' (see Parse_DoVar).
 # The variable name therefore ends before the first ':sh', and the last
 # ':sh' turns the assignment operator into the shell command evaluation.



CVS commit: src/usr.bin/make/unit-tests

2021-02-06 Thread Simon J. Gerraty
Module Name:src
Committed By:   sjg
Date:   Sat Feb  6 18:26:03 UTC 2021

Modified Files:
src/usr.bin/make/unit-tests: Makefile cmdline.exp cmdline.mk export.exp
objdir-writable.exp

Log Message:
Avoid test failures when more than one user run them.

Use a private  TMPDIR
a subdir of .OBJDIR if using it
otherwise /tmp/uid${.MAKE.UID}


To generate a diff of this commit:
cvs rdiff -u -r1.268 -r1.269 src/usr.bin/make/unit-tests/Makefile
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/cmdline.exp \
src/usr.bin/make/unit-tests/objdir-writable.exp
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/cmdline.mk
cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/export.exp

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.268 src/usr.bin/make/unit-tests/Makefile:1.269
--- src/usr.bin/make/unit-tests/Makefile:1.268	Thu Feb  4 00:16:03 2021
+++ src/usr.bin/make/unit-tests/Makefile	Sat Feb  6 18:26:03 2021
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.268 2021/02/04 00:16:03 rillig Exp $
+# $NetBSD: Makefile,v 1.269 2021/02/06 18:26:03 sjg Exp $
 #
 # Unit tests for make(1)
 #
@@ -31,6 +31,8 @@
 # src/tests/usr.bin/make/t_make.sh.
 #
 
+.MAIN: all
+
 # we use these below but we might be an older make
 .MAKE.OS?= ${uname -s:L:sh}
 .MAKE.UID?= ${id -u:L:sh}
@@ -441,16 +443,10 @@ TESTS+=		varquote
 #	escape-for-item.mk
 #	posix-*.mk (see posix.mk and posix1.mk)
 
-.if ${.OBJDIR} != ${.CURDIR}
-RO_OBJDIR:=	${.OBJDIR}/roobj
-.else
-RO_OBJDIR:=	${TMPDIR:U/tmp}/roobj
-.endif
 # Additional environment variables for some of the tests.
 # The base environment is -i PATH="$PATH".
 ENV.depsrc-optional+=   TZ=UTC
 ENV.envfirst=		FROM_ENV=value-from-env
-ENV.objdir-writable+=	RO_OBJDIR=${RO_OBJDIR}
 ENV.varmisc=		FROM_ENV=env
 ENV.varmisc+=		FROM_ENV_BEFORE=env
 ENV.varmisc+=		FROM_ENV_AFTER=env
@@ -486,7 +482,6 @@ SED_CMDS.job-output-long-lines= \
 	${:D marker should always be at the beginning of the line. } \
 	-e '/^aa*--- job-b ---$$/d' \
 	-e '/^bb*--- job-a ---$$/d'
-SED_CMDS.objdir-writable=	-e 's,${RO_OBJDIR},OBJDIR/roobj,g'
 SED_CMDS.opt-debug-graph1=	${STD_SED_CMDS.dg1}
 SED_CMDS.opt-debug-graph2=	${STD_SED_CMDS.dg2}
 SED_CMDS.opt-debug-graph3=	${STD_SED_CMDS.dg3}
@@ -593,8 +588,6 @@ STD_SED_CMDS.shell+=		-e 's,^${.SHELL:T}
 
 # End of the configuration helpers section.
 
-.MAIN: all
-
 UNIT_TESTS:=	${.PARSEDIR}
 .PATH: ${UNIT_TESTS}
 
@@ -623,7 +616,22 @@ LC_ALL=		C
 LANG=		C
 .export LANG LC_ALL
 
+
+# for many tests we need a TMPDIR that will not collide
+# with other users.
+.if ${.OBJDIR} != ${.CURDIR}
+# easy
+TMPDIR:=	${.OBJDIR}/tmp
+.else
+TMPDIR:=	${TMPDIR:U/tmp}/uid${.MAKE.UID}
+.endif
+# make sure it exists
+.if !exist(${TMPDIR})
+x!= echo; mkdir -p ${TMPDIR}
+.endif
+
 MAKE_TEST_ENV?=	MALLOC_OPTIONS="JA"	# for jemalloc
+MAKE_TEST_ENV+= TMPDIR=${TMPDIR}
 
 .if ${.MAKE.OS} == "NetBSD"
 LIMIT_RESOURCES?=	ulimit -v 20
@@ -657,6 +665,7 @@ _SED_CMDS+=	-e 's,${TEST_MAKE:T:S,.,\\.,
 _SED_CMDS+=	-e 's,^usage: ${TEST_MAKE:T:S,.,\\.,g} ,usage: make ,'
 # replace anything after 'stopped in' with unit-tests
 _SED_CMDS+=	-e '/stopped/s, /.*, unit-tests,'
+_SED_CMDS+=	-e 's,${TMPDIR},TMPDIR,g'
 # strip ${.CURDIR}/ from the output
 _SED_CMDS+=	-e 's,${.CURDIR:S,.,\\.,g}/,,g'
 _SED_CMDS+=	-e 's,${UNIT_TESTS:S,.,\\.,g}/,,g'

Index: src/usr.bin/make/unit-tests/cmdline.exp
diff -u src/usr.bin/make/unit-tests/cmdline.exp:1.1 src/usr.bin/make/unit-tests/cmdline.exp:1.2
--- src/usr.bin/make/unit-tests/cmdline.exp:1.1	Tue Jul 28 22:44:44 2020
+++ src/usr.bin/make/unit-tests/cmdline.exp	Sat Feb  6 18:26:03 2021
@@ -1,5 +1,5 @@
 makeobjdir-direct:
-show-objdir: /tmp/6a8899d2-d227-4b55-9b6b-f3c8eeb83fd5
+show-objdir: TMPDIR/6a8899d2-d227-4b55-9b6b-f3c8eeb83fd5
 makeobjdir-indirect:
-show-objdir: /tmp/a7b41170-53f8-4cc2-bc5c-e4c3dd93ec45/
+show-objdir: TMPDIR/a7b41170-53f8-4cc2-bc5c-e4c3dd93ec45/
 exit status 0
Index: src/usr.bin/make/unit-tests/objdir-writable.exp
diff -u src/usr.bin/make/unit-tests/objdir-writable.exp:1.1 src/usr.bin/make/unit-tests/objdir-writable.exp:1.2
--- src/usr.bin/make/unit-tests/objdir-writable.exp:1.1	Thu Nov 12 23:35:21 2020
+++ src/usr.bin/make/unit-tests/objdir-writable.exp	Sat Feb  6 18:26:03 2021
@@ -1,5 +1,5 @@
-make warning: OBJDIR/roobj: Permission denied.
+make warning: TMPDIR/roobj: Permission denied.
 /tmp
-OBJDIR/roobj
-OBJDIR/roobj
+TMPDIR/roobj
+TMPDIR/roobj
 exit status 0

Index: src/usr.bin/make/unit-tests/cmdline.mk
diff -u src/usr.bin/make/unit-tests/cmdline.mk:1.2 src/usr.bin/make/unit-tests/cmdline.mk:1.3
--- src/usr.bin/make/unit-tests/cmdline.mk:1.2	Sun Nov 15 14:07:53 2020
+++ src/usr.bin/make/unit-tests/cmdline.mk	Sat Feb  6 18:26:03 2021
@@ -1,8 +1,8 @@
-# $NetBSD: cmdline.mk,v 1.2 2020/11/15 14:07:53 rillig Exp $
+# $NetBSD: cmdline.mk,v 1.3 2021/02/06 18:26:03 sjg Exp $

CVS commit: src/usr.bin/make/unit-tests

2021-02-05 Thread Simon J. Gerraty
Module Name:src
Committed By:   sjg
Date:   Sat Feb  6 04:55:08 UTC 2021

Modified Files:
src/usr.bin/make/unit-tests: var-op-shell.exp var-op-shell.mk

Log Message:
Use plain kill to test signaled child

Recent update to Darwin18 make the test using kill -14
stop working.

Reviewed by: rillig


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/var-op-shell.exp
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/var-op-shell.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/var-op-shell.exp
diff -u src/usr.bin/make/unit-tests/var-op-shell.exp:1.2 src/usr.bin/make/unit-tests/var-op-shell.exp:1.3
--- src/usr.bin/make/unit-tests/var-op-shell.exp:1.2	Mon Nov  9 20:39:46 2020
+++ src/usr.bin/make/unit-tests/var-op-shell.exp	Sat Feb  6 04:55:08 2021
@@ -1,7 +1,7 @@
 make: "var-op-shell.mk" line 28: warning: "echo "failed"; false" returned non-zero status
 make: "var-op-shell.mk" line 34: warning: "false" returned non-zero status
-make: "var-op-shell.mk" line 59: warning: "kill -14 $$" exited on a signal
+make: "var-op-shell.mk" line 56: warning: "kill $$" exited on a signal
 /bin/no/such/command: not found
-make: "var-op-shell.mk" line 65: warning: "/bin/no/such/command" returned non-zero status
+make: "var-op-shell.mk" line 62: warning: "/bin/no/such/command" returned non-zero status
 stderr
 exit status 0

Index: src/usr.bin/make/unit-tests/var-op-shell.mk
diff -u src/usr.bin/make/unit-tests/var-op-shell.mk:1.3 src/usr.bin/make/unit-tests/var-op-shell.mk:1.4
--- src/usr.bin/make/unit-tests/var-op-shell.mk:1.3	Mon Nov  9 20:39:46 2020
+++ src/usr.bin/make/unit-tests/var-op-shell.mk	Sat Feb  6 04:55:08 2021
@@ -1,4 +1,4 @@
-# $NetBSD: var-op-shell.mk,v 1.3 2020/11/09 20:39:46 rillig Exp $
+# $NetBSD: var-op-shell.mk,v 1.4 2021/02/06 04:55:08 sjg Exp $
 #
 # Tests for the != variable assignment operator, which runs its right-hand
 # side through the shell.
@@ -50,13 +50,10 @@ OUTPUT!=	echo "before"; false; echo "aft
 .  error
 .endif
 
-# NB: The signal number must be numeric since some shells (which ones?) don't
-# accept symbolic signal names.  14 is typically SIGALRM.
-#
-# XXX: The number of the signal is not mentioned in the warning since that
-# would have been difficult to implement; currently the errfmt is a format
-# string containing a single %s conversion.
-OUTPUT!=	kill -14 
+# This should result in a warning about "exited on a signal".
+# This used to be kill -14 (SIGALRM), but that stopped working on
+# Darwin18 after recent update.
+OUTPUT!=	kill 
 .if ${OUTPUT} != ""
 .  error
 .endif



CVS commit: src/usr.bin/make/unit-tests

2021-02-03 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu Feb  4 00:16:03 UTC 2021

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

Log Message:
make: remove .PARSEDIR from test output of varname-empty

The .PARSEDIR has nothing to do with .CURDIR.  This wrong assumption
made the NetBSD test suite fail since the actual .PARSEDIR was not
replaced with "".


To generate a diff of this commit:
cvs rdiff -u -r1.267 -r1.268 src/usr.bin/make/unit-tests/Makefile
cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/unit-tests/varname-empty.exp

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.267 src/usr.bin/make/unit-tests/Makefile:1.268
--- src/usr.bin/make/unit-tests/Makefile:1.267	Wed Feb  3 08:34:15 2021
+++ src/usr.bin/make/unit-tests/Makefile	Thu Feb  4 00:16:03 2021
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.267 2021/02/03 08:34:15 rillig Exp $
+# $NetBSD: Makefile,v 1.268 2021/02/04 00:16:03 rillig Exp $
 #
 # Unit tests for make(1)
 #
@@ -520,6 +520,7 @@ SED_CMDS.varname-dot-shell=	-e 's, = /[^
 SED_CMDS.varname-dot-shell+=	-e 's,"/[^" ]*","(details omitted)",g'
 SED_CMDS.varname-dot-shell+=	-e 's,\[/[^] ]*\],[(details omitted)],g'
 SED_CMDS.varname-empty=		-e 's,${.CURDIR},,g'
+SED_CMDS.varname-empty+=	-e '/\.PARSEDIR/d'
 SED_CMDS.varname-empty+=	-e '/\.SHELL/d'
 
 # Some tests need an additional round of postprocessing.

Index: src/usr.bin/make/unit-tests/varname-empty.exp
diff -u src/usr.bin/make/unit-tests/varname-empty.exp:1.7 src/usr.bin/make/unit-tests/varname-empty.exp:1.8
--- src/usr.bin/make/unit-tests/varname-empty.exp:1.7	Wed Feb  3 08:40:47 2021
+++ src/usr.bin/make/unit-tests/varname-empty.exp	Thu Feb  4 00:16:03 2021
@@ -14,7 +14,6 @@ Global:.PATH = . 
 Global:.TARGETS = 
 Internal:MAKEFILE = varname-empty.mk
 Global:.MAKE.MAKEFILES = varname-empty.mk
-Global:.PARSEDIR = 
 Global:.PARSEFILE = varname-empty.mk
 Global:delete .INCLUDEDFROMDIR (not found)
 Global:delete .INCLUDEDFROMFILE (not found)



CVS commit: src/usr.bin/make/unit-tests

2021-02-03 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed Feb  3 08:34:15 UTC 2021

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

Log Message:
make: in the test varname-empty, keep more debug output

Filtering out the interesting lines based on the very specific pattern
"Var_Set" was surprising.


To generate a diff of this commit:
cvs rdiff -u -r1.266 -r1.267 src/usr.bin/make/unit-tests/Makefile
cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/varname-empty.exp
cvs rdiff -u -r1.7 -r1.8 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.266 src/usr.bin/make/unit-tests/Makefile:1.267
--- src/usr.bin/make/unit-tests/Makefile:1.266	Tue Feb  2 17:27:35 2021
+++ src/usr.bin/make/unit-tests/Makefile	Wed Feb  3 08:34:15 2021
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.266 2021/02/02 17:27:35 rillig Exp $
+# $NetBSD: Makefile,v 1.267 2021/02/03 08:34:15 rillig Exp $
 #
 # Unit tests for make(1)
 #
@@ -519,11 +519,12 @@ SED_CMDS.varname-dot-parsefile=	-e '/in 
 SED_CMDS.varname-dot-shell=	-e 's, = /[^ ]*, = (details omitted),g'
 SED_CMDS.varname-dot-shell+=	-e 's,"/[^" ]*","(details omitted)",g'
 SED_CMDS.varname-dot-shell+=	-e 's,\[/[^] ]*\],[(details omitted)],g'
+SED_CMDS.varname-empty=		-e 's,${.CURDIR},,g'
+SED_CMDS.varname-empty+=	-e '/\.SHELL/d'
 
 # Some tests need an additional round of postprocessing.
 POSTPROC.deptgt-suffixes=	awk '/^\#\*\*\* Suffixes/,/^never-stop/'
 POSTPROC.gnode-submake=		awk '/Input graph/, /^$$/'
-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.5 src/usr.bin/make/unit-tests/varname-empty.exp:1.6
--- src/usr.bin/make/unit-tests/varname-empty.exp:1.5	Sun Nov 15 20:50:46 2020
+++ src/usr.bin/make/unit-tests/varname-empty.exp	Wed Feb  3 08:34:15 2021
@@ -1,13 +1,48 @@
+Var_Parse: ${:U} with VARE_WANTRES
+Applying ${:U} to "" (VARE_WANTRES, none, VES_UNDEF)
+Result of ${:U} is "" (VARE_WANTRES, none, VES_DEF)
 Var_Set("${:U}", "cmdline-u", ...) name expands to empty string - ignored
 Var_Set("", "cmdline-plain", ...) name expands to empty string - ignored
+Global:.CURDIR = 
+Var_Parse: ${MAKE_OBJDIR_CHECK_WRITABLE:U} with VARE_WANTRES
+Applying ${MAKE_OBJDIR_CHECK_WRITABLE:U} to "" (VARE_WANTRES, none, VES_UNDEF)
+Result of ${MAKE_OBJDIR_CHECK_WRITABLE:U} is "" (VARE_WANTRES, none, VES_DEF)
+Global:.OBJDIR = 
+Global:delete .PATH (not found)
+Global:.PATH = .
+Global:.PATH = . 
+Global:.TARGETS = 
+Internal:MAKEFILE = varname-empty.mk
+Global:.MAKE.MAKEFILES = varname-empty.mk
+Global:.PARSEDIR = 
+Global:.PARSEFILE = varname-empty.mk
+Global:delete .INCLUDEDFROMDIR (not found)
+Global:delete .INCLUDEDFROMFILE (not found)
 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
+Var_Parse: ${:Ufallback} != "fallback" with VARE_UNDEFERR|VARE_WANTRES
+Applying ${:U...} to "" (VARE_UNDEFERR|VARE_WANTRES, none, VES_UNDEF)
+Result of ${:Ufallback} is "fallback" (VARE_UNDEFERR|VARE_WANTRES, none, VES_DEF)
+Var_Parse: ${:U} with VARE_WANTRES
+Applying ${:U} to "" (VARE_WANTRES, none, VES_UNDEF)
+Result of ${:U} is "" (VARE_WANTRES, none, VES_DEF)
 Var_Set("${:U}", "assigned indirectly", ...) name expands to empty string - ignored
-Var_Set("", "assigned", ...) name expands to empty string - ignored
+Var_Parse: ${:Ufallback} != "fallback" with VARE_UNDEFERR|VARE_WANTRES
+Applying ${:U...} to "" (VARE_UNDEFERR|VARE_WANTRES, none, VES_UNDEF)
+Result of ${:Ufallback} is "fallback" (VARE_UNDEFERR|VARE_WANTRES, none, VES_DEF)
+Var_Parse: ${:U} with VARE_WANTRES
+Applying ${:U} to "" (VARE_WANTRES, none, VES_UNDEF)
+Result of ${:U} is "" (VARE_WANTRES, none, VES_DEF)
+Var_Append("${:U}", "appended indirectly", ...) name expands to empty string - ignored
+Var_Parse: ${:Ufallback} != "fallback" with VARE_UNDEFERR|VARE_WANTRES
+Applying ${:U...} to "" (VARE_UNDEFERR|VARE_WANTRES, none, VES_UNDEF)
+Result of ${:Ufallback} is "fallback" (VARE_UNDEFERR|VARE_WANTRES, none, VES_DEF)
+Global:.MAKEFLAGS =  -r -d v -d
+Global:.MAKEFLAGS =  -r -d v -d 0
 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.7 src/usr.bin/make/unit-tests/varname-empty.mk:1.8
--- src

CVS commit: src/usr.bin/make/unit-tests

2021-02-02 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Feb  2 17:27:35 UTC 2021

Modified Files:
src/usr.bin/make/unit-tests: Makefile opt-debug-graph2.exp
opt-debug-graph2.mk opt-debug-graph3.exp opt-debug-graph3.mk

Log Message:
make: demonstrate that neither -dg2 nor -dg3 produces debug output


To generate a diff of this commit:
cvs rdiff -u -r1.265 -r1.266 src/usr.bin/make/unit-tests/Makefile
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/opt-debug-graph2.exp \
src/usr.bin/make/unit-tests/opt-debug-graph2.mk \
src/usr.bin/make/unit-tests/opt-debug-graph3.exp \
src/usr.bin/make/unit-tests/opt-debug-graph3.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.265 src/usr.bin/make/unit-tests/Makefile:1.266
--- src/usr.bin/make/unit-tests/Makefile:1.265	Mon Feb  1 20:31:41 2021
+++ src/usr.bin/make/unit-tests/Makefile	Tue Feb  2 17:27:35 2021
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.265 2021/02/01 20:31:41 rillig Exp $
+# $NetBSD: Makefile,v 1.266 2021/02/02 17:27:35 rillig Exp $
 #
 # Unit tests for make(1)
 #
@@ -488,6 +488,8 @@ SED_CMDS.job-output-long-lines= \
 	-e '/^bb*--- job-a ---$$/d'
 SED_CMDS.objdir-writable=	-e 's,${RO_OBJDIR},OBJDIR/roobj,g'
 SED_CMDS.opt-debug-graph1=	${STD_SED_CMDS.dg1}
+SED_CMDS.opt-debug-graph2=	${STD_SED_CMDS.dg2}
+SED_CMDS.opt-debug-graph3=	${STD_SED_CMDS.dg3}
 SED_CMDS.opt-debug-jobs=	-e 's,([0-9][0-9]*),(),'
 SED_CMDS.opt-debug-jobs+=	-e 's,pid [0-9][0-9]*,pid ,'
 SED_CMDS.opt-debug-jobs+=	-e 's,Process [0-9][0-9]*,Process ,'
@@ -539,6 +541,11 @@ STD_SED_CMDS.dg1+=	-e 's,^\(\.MAKE *=\) 
 STD_SED_CMDS.dg1+=	-e 's,^\(\.MAKE\.[A-Z_]* *=\) .*,\1 ,'
 STD_SED_CMDS.dg1+=	-e 's,^\(MACHINE[_ARCH]* *=\) .*,\1 ,'
 STD_SED_CMDS.dg1+=	-e 's,^\(MAKE *=\) .*,\1 ,'
+STD_SED_CMDS.dg1+=	-e 's,^\(\.SHELL *=\) .*,\1 ,'
+
+STD_SED_CMDS.dg2=	${STD_SED_CMDS.dg1}
+STD_SED_CMDS.dg2+=	-e 's,\(last modified\) ..:..:.. ... ..\, ,\1 ,'
+STD_SED_CMDS.dg3=	${STD_SED_CMDS.dg2}
 
 # Omit details such as process IDs from the output of the -dj option.
 STD_SED_CMDS.dj= \

Index: src/usr.bin/make/unit-tests/opt-debug-graph2.exp
diff -u src/usr.bin/make/unit-tests/opt-debug-graph2.exp:1.1 src/usr.bin/make/unit-tests/opt-debug-graph2.exp:1.2
--- src/usr.bin/make/unit-tests/opt-debug-graph2.exp:1.1	Sat Sep  5 06:20:51 2020
+++ src/usr.bin/make/unit-tests/opt-debug-graph2.exp	Tue Feb  2 17:27:35 2021
@@ -1 +1,10 @@
-exit status 0
+: 'Making made-target.'
+false
+*** Error code 1 (continuing)
+false
+*** Error code 1 (continuing)
+`all' not remade because of errors.
+
+Stop.
+make: stopped in unit-tests
+exit status 1
Index: src/usr.bin/make/unit-tests/opt-debug-graph2.mk
diff -u src/usr.bin/make/unit-tests/opt-debug-graph2.mk:1.1 src/usr.bin/make/unit-tests/opt-debug-graph2.mk:1.2
--- src/usr.bin/make/unit-tests/opt-debug-graph2.mk:1.1	Sat Sep  5 06:20:51 2020
+++ src/usr.bin/make/unit-tests/opt-debug-graph2.mk	Tue Feb  2 17:27:35 2021
@@ -1,9 +1,23 @@
-# $NetBSD: opt-debug-graph2.mk,v 1.1 2020/09/05 06:20:51 rillig Exp $
+# $NetBSD: opt-debug-graph2.mk,v 1.2 2021/02/02 17:27:35 rillig Exp $
 #
 # Tests for the -dg2 command line option, which prints the input
 # graph after making everything, or before exiting on error.
+#
+# FIXME: The documentation is wrong.  There is no debug output despite
+# the error.
+
+.MAKEFLAGS: -dg2
+
+.MAIN: all
+
+made-target: .PHONY
+	: 'Making $@.'
+
+error-target: .PHONY
+	false
 
-# TODO: Implementation
+aborted-target: .PHONY aborted-target-dependency
+aborted-target-dependency: .PHONY
+	false
 
-all:
-	@:;
+all: made-target error-target aborted-target
Index: src/usr.bin/make/unit-tests/opt-debug-graph3.exp
diff -u src/usr.bin/make/unit-tests/opt-debug-graph3.exp:1.1 src/usr.bin/make/unit-tests/opt-debug-graph3.exp:1.2
--- src/usr.bin/make/unit-tests/opt-debug-graph3.exp:1.1	Sat Sep  5 06:20:51 2020
+++ src/usr.bin/make/unit-tests/opt-debug-graph3.exp	Tue Feb  2 17:27:35 2021
@@ -1 +1,10 @@
-exit status 0
+: 'Making made-target.'
+false
+*** Error code 1 (continuing)
+false
+*** Error code 1 (continuing)
+`all' not remade because of errors.
+
+Stop.
+make: stopped in unit-tests
+exit status 1
Index: src/usr.bin/make/unit-tests/opt-debug-graph3.mk
diff -u src/usr.bin/make/unit-tests/opt-debug-graph3.mk:1.1 src/usr.bin/make/unit-tests/opt-debug-graph3.mk:1.2
--- src/usr.bin/make/unit-tests/opt-debug-graph3.mk:1.1	Sat Sep  5 06:20:51 2020
+++ src/usr.bin/make/unit-tests/opt-debug-graph3.mk	Tue Feb  2 17:27:35 2021
@@ -1,9 +1,23 @@
-# $NetBSD: opt-debug-graph3.mk,v 1.1 2020/09/05 06:20:51 rillig Exp $
+# $NetBSD: opt-debug-graph3.mk,v 1.2 2021/02/02 17:27:35 rillig Exp $
 #
 # Tests for the -dg3 command line option, which prints the input
 # graph before exiting on error.
+#
+# FIXME: The documentation is wrong.  There is no debug output despite
+# the error.
+

CVS commit: src/usr.bin/make/unit-tests

2021-01-30 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Jan 30 13:50:18 UTC 2021

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

Log Message:
make(1): update documentation of test lint.mk


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/lint.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/lint.mk
diff -u src/usr.bin/make/unit-tests/lint.mk:1.3 src/usr.bin/make/unit-tests/lint.mk:1.4
--- src/usr.bin/make/unit-tests/lint.mk:1.3	Tue Sep 15 16:22:04 2020
+++ src/usr.bin/make/unit-tests/lint.mk	Sat Jan 30 13:50:18 2021
@@ -1,10 +1,13 @@
-# $NetBSD: lint.mk,v 1.3 2020/09/15 16:22:04 rillig Exp $
+# $NetBSD: lint.mk,v 1.4 2021/01/30 13:50:18 rillig Exp $
 #
-# Demonstrates stricter checks that are only enabled in the lint mode,
-# using the -dL option.
+# Demonstrates stricter checks that are only enabled in lint mode, using the
+# option -dL.
 
-# Ouch: as of 2020-08-03, make exits successfully even though the error
-# message has been issued as PARSE_FATAL.
+# Before main.c 1.421 from 2020-11-01, make exited successfully even though
+# the error message had been issued as PARSE_FATAL.  This was because back
+# then, make checked for parse errors only after parsing each top-level
+# makefile, in Parse_File.  After that, when expanding variable expressions
+# in shell commands, the parse errors were not checked again.
 
 # Ouch: as of 2020-08-03, the variable is malformed and parsing stops
 # for a moment, but is continued after the wrongly-guessed end of the



CVS commit: src/usr.bin/make/unit-tests

2021-01-30 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Jan 30 12:14:08 UTC 2021

Modified Files:
src/usr.bin/make/unit-tests: opt-touch-jobs.mk

Log Message:
make(1): explain test opt-touch-jobs


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/opt-touch-jobs.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/opt-touch-jobs.mk
diff -u src/usr.bin/make/unit-tests/opt-touch-jobs.mk:1.1 src/usr.bin/make/unit-tests/opt-touch-jobs.mk:1.2
--- src/usr.bin/make/unit-tests/opt-touch-jobs.mk:1.1	Sat Nov 14 15:35:20 2020
+++ src/usr.bin/make/unit-tests/opt-touch-jobs.mk	Sat Jan 30 12:14:08 2021
@@ -1,4 +1,4 @@
-# $NetBSD: opt-touch-jobs.mk,v 1.1 2020/11/14 15:35:20 rillig Exp $
+# $NetBSD: opt-touch-jobs.mk,v 1.2 2021/01/30 12:14:08 rillig Exp $
 #
 # Tests for the -t command line option in jobs mode.
 
@@ -9,12 +9,18 @@
 .MAKEFLAGS: opt-touch-use
 .MAKEFLAGS: opt-touch-make
 
+# .PHONY targets are not touched since they do not represent actual files.
+# See Job_Touch.
 opt-touch-phony: .PHONY
 	: Making $@.
 
+# .JOIN targets are not touched since they do not represent actual files.
+# See Job_Touch.
 opt-touch-join: .JOIN
 	: Making $@.
 
+# .USE targets are not touched since they do not represent actual files.
+# See Job_Touch.
 opt-touch-use: .USE
 	: Making use of $@.
 



CVS commit: src/usr.bin/make/unit-tests

2021-01-26 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Jan 26 23:51:20 UTC 2021

Modified Files:
src/usr.bin/make/unit-tests: directive-error.exp directive-error.mk

Log Message:
make(1): demonstrate irrelevant message about warnings as errors


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/directive-error.exp
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/directive-error.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/directive-error.exp
diff -u src/usr.bin/make/unit-tests/directive-error.exp:1.1 src/usr.bin/make/unit-tests/directive-error.exp:1.2
--- src/usr.bin/make/unit-tests/directive-error.exp:1.1	Sun Aug 16 12:07:51 2020
+++ src/usr.bin/make/unit-tests/directive-error.exp	Tue Jan 26 23:51:20 2021
@@ -1 +1,5 @@
-exit status 0
+make: "directive-error.mk" line 11: message
+make: parsing warnings being treated as errors
+
+make: stopped in unit-tests
+exit status 1

Index: src/usr.bin/make/unit-tests/directive-error.mk
diff -u src/usr.bin/make/unit-tests/directive-error.mk:1.3 src/usr.bin/make/unit-tests/directive-error.mk:1.4
--- src/usr.bin/make/unit-tests/directive-error.mk:1.3	Sun Dec 13 01:07:54 2020
+++ src/usr.bin/make/unit-tests/directive-error.mk	Tue Jan 26 23:51:20 2021
@@ -1,4 +1,4 @@
-# $NetBSD: directive-error.mk,v 1.3 2020/12/13 01:07:54 rillig Exp $
+# $NetBSD: directive-error.mk,v 1.4 2021/01/26 23:51:20 rillig Exp $
 #
 # Tests for the .error directive, which prints an error message and exits
 # immediately, unlike other "fatal" parse errors, which continue to parse
@@ -6,5 +6,6 @@
 
 # TODO: Implementation
 
-all:
-	@:;
+# FIXME: The "parsing warnings being treated as errors" is irrelevant.
+.MAKEFLAGS: -W
+.error message



CVS commit: src/usr.bin/make/unit-tests

2021-01-24 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jan 24 19:48:11 UTC 2021

Modified Files:
src/usr.bin/make/unit-tests: directive-for-escape.exp
directive-for-escape.mk

Log Message:
make(1): describe expansion of nested variables in .for values

These edge cases are not documented anywhere, and their behavior is
non-intuitive.  For now, just describe them, don't try to fix them.
There may be people out there relying on exactly this behavior.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/directive-for-escape.exp \
src/usr.bin/make/unit-tests/directive-for-escape.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/directive-for-escape.exp
diff -u src/usr.bin/make/unit-tests/directive-for-escape.exp:1.4 src/usr.bin/make/unit-tests/directive-for-escape.exp:1.5
--- src/usr.bin/make/unit-tests/directive-for-escape.exp:1.4	Sun Jan 24 19:30:18 2021
+++ src/usr.bin/make/unit-tests/directive-for-escape.exp	Sun Jan 24 19:48:11 2021
@@ -27,25 +27,29 @@ make: "directive-for-escape.mk" line 41:
 For: end for 1
 For: loop body:
 .  info ${:U\${UNDEF\:U\\$\\$}
-make: "directive-for-escape.mk" line 52: ${UNDEF:U\$
+make: "directive-for-escape.mk" line 55: ${UNDEF:U\$
 For: loop body:
 .  info ${:U{{\}\}}
-make: "directive-for-escape.mk" line 52: {{}}
+make: "directive-for-escape.mk" line 55: {{}}
 For: loop body:
 .  info ${:Uend\}}
-make: "directive-for-escape.mk" line 52: end}
+make: "directive-for-escape.mk" line 55: end}
+For: end for 1
+For: loop body:
+.  info ${:Ubegin<${UNDEF:Ufallback:N{{{>end}
+make: "directive-for-escape.mk" line 66: beginend
 For: end for 1
 For: loop body:
 .  info ${:U\$}
-make: "directive-for-escape.mk" line 60: $
+make: "directive-for-escape.mk" line 74: $
 For: end for 1
 For: loop body:
 .  info ${NUMBERS} ${:Ureplaced}
-make: "directive-for-escape.mk" line 68: one two three replaced
+make: "directive-for-escape.mk" line 82: one two three replaced
 For: end for 1
 For: loop body:
 .  info ${:Ureplaced}
-make: "directive-for-escape.mk" line 78: replaced
+make: "directive-for-escape.mk" line 92: replaced
 For: end for 1
 For: loop body:
 .  info .$$i: ${:Uinner}
@@ -58,14 +62,14 @@ For: loop body:
 .  info . $${i2}: ${i2}
 .  info . $${i,}: ${i,}
 .  info .  adjacent: ${:Uinner}${:Uinner}${:Uinner:M*}${:Uinner}
-make: "directive-for-escape.mk" line 86: .$i: inner
-make: "directive-for-escape.mk" line 87: .  ${i}: inner
-make: "directive-for-escape.mk" line 88: .   ${i:M*}: inner
-make: "directive-for-escape.mk" line 89: .  $(i): inner
-make: "directive-for-escape.mk" line 90: .   $(i:M*): inner
-make: "directive-for-escape.mk" line 91: . ${i${:U}}: outer
-make: "directive-for-escape.mk" line 92: .${i\}}: inner}
-make: "directive-for-escape.mk" line 93: . ${i2}: two
-make: "directive-for-escape.mk" line 94: . ${i,}: comma
-make: "directive-for-escape.mk" line 95: .  adjacent: innerinnerinnerinner
+make: "directive-for-escape.mk" line 100: .$i: inner
+make: "directive-for-escape.mk" line 101: .  ${i}: inner
+make: "directive-for-escape.mk" line 102: .   ${i:M*}: inner
+make: "directive-for-escape.mk" line 103: .  $(i): inner
+make: "directive-for-escape.mk" line 104: .   $(i:M*): inner
+make: "directive-for-escape.mk" line 105: . ${i${:U}}: outer
+make: "directive-for-escape.mk" line 106: .${i\}}: inner}
+make: "directive-for-escape.mk" line 107: . ${i2}: two
+make: "directive-for-escape.mk" line 108: . ${i,}: comma
+make: "directive-for-escape.mk" line 109: .  adjacent: innerinnerinnerinner
 exit status 0
Index: src/usr.bin/make/unit-tests/directive-for-escape.mk
diff -u src/usr.bin/make/unit-tests/directive-for-escape.mk:1.4 src/usr.bin/make/unit-tests/directive-for-escape.mk:1.5
--- src/usr.bin/make/unit-tests/directive-for-escape.mk:1.4	Sun Jan 24 19:30:18 2021
+++ src/usr.bin/make/unit-tests/directive-for-escape.mk	Sun Jan 24 19:48:11 2021
@@ -1,4 +1,4 @@
-# $NetBSD: directive-for-escape.mk,v 1.4 2021/01/24 19:30:18 rillig Exp $
+# $NetBSD: directive-for-escape.mk,v 1.5 2021/01/24 19:48:11 rillig Exp $
 #
 # Test escaping of special characters in the iteration values of a .for loop.
 # These values get expanded later using the :U variable modifier, and this
@@ -41,17 +41,31 @@ VALUES=		$$ $${V} $${V:=-with-modifier} 
 .  info $i
 .endfor
 
-# Cover the code for nested '{}' in for_var_len.
+# Try to cover the code for nested '{}' in for_var_len, without success.
 #
-# The value of VALUES is not a variable expression.  Instead, it is meant to
-# represent dollar, lbrace, "UNDEF:U", backslash, dollar, backslash, dollar,
-# space, nested braces, space, "end}".
+# The value of VALUES is not meant to be a variable expression.  Instead, it
+# is meant to represent dollar, lbrace, "UNDEF:U", backslash, dollar,
+# backslash, d

CVS commit: src/usr.bin/make/unit-tests

2021-01-24 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jan 24 19:30:18 UTC 2021

Modified Files:
src/usr.bin/make/unit-tests: directive-for-escape.exp
directive-for-escape.mk

Log Message:
make(1): let the test directive-for-escape exit successfully

There is no reason for a non-zero exit status here.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/directive-for-escape.exp \
src/usr.bin/make/unit-tests/directive-for-escape.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/directive-for-escape.exp
diff -u src/usr.bin/make/unit-tests/directive-for-escape.exp:1.3 src/usr.bin/make/unit-tests/directive-for-escape.exp:1.4
--- src/usr.bin/make/unit-tests/directive-for-escape.exp:1.3	Thu Dec 31 14:26:37 2020
+++ src/usr.bin/make/unit-tests/directive-for-escape.exp	Sun Jan 24 19:30:18 2021
@@ -68,7 +68,4 @@ make: "directive-for-escape.mk" line 92:
 make: "directive-for-escape.mk" line 93: . ${i2}: two
 make: "directive-for-escape.mk" line 94: . ${i,}: comma
 make: "directive-for-escape.mk" line 95: .  adjacent: innerinnerinnerinner
-make: no target to make.
-
-make: stopped in unit-tests
-exit status 2
+exit status 0
Index: src/usr.bin/make/unit-tests/directive-for-escape.mk
diff -u src/usr.bin/make/unit-tests/directive-for-escape.mk:1.3 src/usr.bin/make/unit-tests/directive-for-escape.mk:1.4
--- src/usr.bin/make/unit-tests/directive-for-escape.mk:1.3	Thu Dec 31 14:26:37 2020
+++ src/usr.bin/make/unit-tests/directive-for-escape.mk	Sun Jan 24 19:30:18 2021
@@ -1,4 +1,4 @@
-# $NetBSD: directive-for-escape.mk,v 1.3 2020/12/31 14:26:37 rillig Exp $
+# $NetBSD: directive-for-escape.mk,v 1.4 2021/01/24 19:30:18 rillig Exp $
 #
 # Test escaping of special characters in the iteration values of a .for loop.
 # These values get expanded later using the :U variable modifier, and this
@@ -94,3 +94,5 @@ i,=		comma
 .  info . $${i,}: ${i,}
 .  info .  adjacent: $i${i}${i:M*}$i
 .endfor
+
+all:



CVS commit: src/usr.bin/make/unit-tests

2021-01-22 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Jan 23 07:34:00 UTC 2021

Modified Files:
src/usr.bin/make/unit-tests: Makefile

Log Message:
make(1): fix unit tests for dash and bash 5.1


To generate a diff of this commit:
cvs rdiff -u -r1.261 -r1.262 src/usr.bin/make/unit-tests/Makefile

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.261 src/usr.bin/make/unit-tests/Makefile:1.262
--- src/usr.bin/make/unit-tests/Makefile:1.261	Tue Jan 19 05:49:33 2021
+++ src/usr.bin/make/unit-tests/Makefile	Sat Jan 23 07:34:00 2021
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.261 2021/01/19 05:49:33 rillig Exp $
+# $NetBSD: Makefile,v 1.262 2021/01/23 07:34:00 rillig Exp $
 #
 # Unit tests for make(1)
 #
@@ -557,18 +557,26 @@ STD_SED_CMDS.hide-from-output= \
 # $shell -c '...'
 #	NetBSD sh	...: not found
 #	NetBSD ksh	ksh: ...: not found
-#	bash 5		bash: line 1: ...: command not found
+#	bash 5.0.18	bash: ...: command not found
+#	bash 5.1.0	bash: line 1: ...: command not found
 #	dash		dash: 1: ...: not found
 #
 # $shell -c '< /nonexistent'
 #	NetBSD sh	sh: cannot open /nonexistent: no such file
 #	NetBSD ksh	ksh: cannot open /nonexistent: No such file or directory
-#	bash 5		bash: line 1: /nonexistent: No such file or directory
+#	bash 5.0.18	bash: /nonexistent: No such file or directory
+#	bash 5.1.0	bash: line 1: /nonexistent: No such file or directory
 #	dash		dash: 1: cannot open /nonexistent: No such file
 #
+# echo '< /nonexistent' | $shell
+#	NetBSD sh	sh: cannot open /nonexistent: no such file
+#	NetBSD ksh	ksh: [1]: cannot open /nonexistent: No such file or directory
+#	bash 5.0.18	bash: line 1: /nonexistent: No such file or directory
+#	bash 5.1.0	bash: line 1: /nonexistent: No such file or directory
+#	dash		dash: 1: cannot open /nonexistent: No such file
 #
-STD_SED_CMDS.shell+=		-e 's,^${.SHELL:T}: line [0-9][0-9]*:,,'
-STD_SED_CMDS.shell+=		-e 's,^${.SHELL:T}: [0-9][0-9]*:,,'
+STD_SED_CMDS.shell+=		-e 's,^${.SHELL:T}: line [0-9][0-9]*: ,,'
+STD_SED_CMDS.shell+=		-e 's,^${.SHELL:T}: [0-9][0-9]*: ,,'
 STD_SED_CMDS.shell+=		-e 's,^${.SHELL:T}: ,,'
 
 # End of the configuration helpers section.



CVS commit: src/usr.bin/make/unit-tests

2021-01-22 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Jan 22 22:54:53 UTC 2021

Modified Files:
src/usr.bin/make/unit-tests: varmod-assign.mk

Log Message:
make(1): remove outdated comment from test

It was fixed in var.c 1.472 from 2020-08-25.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 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/varmod-assign.mk
diff -u src/usr.bin/make/unit-tests/varmod-assign.mk:1.8 src/usr.bin/make/unit-tests/varmod-assign.mk:1.9
--- src/usr.bin/make/unit-tests/varmod-assign.mk:1.8	Sun Oct 18 21:37:24 2020
+++ src/usr.bin/make/unit-tests/varmod-assign.mk	Fri Jan 22 22:54:53 2021
@@ -1,4 +1,4 @@
-# $NetBSD: varmod-assign.mk,v 1.8 2020/10/18 21:37:24 rillig Exp $
+# $NetBSD: varmod-assign.mk,v 1.9 2021/01/22 22:54:53 rillig Exp $
 #
 # Tests for the obscure ::= variable modifiers, which perform variable
 # assignments during evaluation, just like the = operator in C.
@@ -88,7 +88,6 @@ mod-assign-shell-error:
 	@${SH_OK::!= echo word; true } echo ok=${SH_OK}
 
 	# If the command fails, the variable keeps its previous value.
-	# FIXME: the error message says: "previous" returned non-zero status
 	@${SH_ERR::=previous}
 	@${SH_ERR::!= echo word; false } echo err=${SH_ERR}
 



CVS commit: src/usr.bin/make/unit-tests

2021-01-21 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Jan 22 00:44:55 UTC 2021

Modified Files:
src/usr.bin/make/unit-tests: include-main.mk

Log Message:
make(1): fix test for .INCLUDEDFROMFILE

The test did not test the intended variable before.

If the implementation of the .INCLUDEDFROMFILE had been wrong before,
the test would have succeeded nevertheless since it tested whether the
variable named "include-main.mk" was defined, which was obviously never
the case since that's the value of the variable, not the name.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/include-main.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/include-main.mk
diff -u src/usr.bin/make/unit-tests/include-main.mk:1.5 src/usr.bin/make/unit-tests/include-main.mk:1.6
--- src/usr.bin/make/unit-tests/include-main.mk:1.5	Sat Sep  5 18:18:05 2020
+++ src/usr.bin/make/unit-tests/include-main.mk	Fri Jan 22 00:44:55 2021
@@ -1,4 +1,4 @@
-# $NetBSD: include-main.mk,v 1.5 2020/09/05 18:18:05 rillig Exp $
+# $NetBSD: include-main.mk,v 1.6 2021/01/22 00:44:55 rillig Exp $
 #
 # Until 2020-09-05, the .INCLUDEDFROMFILE magic variable did not behave
 # as described in the manual page.
@@ -17,7 +17,7 @@
 .endif
 
 .for i in once
-.  if !defined(${.INCLUDEDFROMFILE})
+.  if !defined(.INCLUDEDFROMFILE)
 .info main-before-for-ok
 .  else
 .warning main-before-for-fail(${.INCLUDEDFROMFILE})
@@ -33,7 +33,7 @@
 .endif
 
 .for i in once
-.  if !defined(${.INCLUDEDFROMFILE})
+.  if !defined(.INCLUDEDFROMFILE)
 .info main-after-for-ok
 .  else
 .warning main-after-for-fail(${.INCLUDEDFROMFILE})



CVS commit: src/usr.bin/make/unit-tests

2021-01-21 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu Jan 21 23:03:41 UTC 2021

Modified Files:
src/usr.bin/make/unit-tests: directive-ifdef.exp directive-ifdef.mk

Log Message:
make(1): add tests for string literals in .ifdef


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/directive-ifdef.exp
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/directive-ifdef.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/directive-ifdef.exp
diff -u src/usr.bin/make/unit-tests/directive-ifdef.exp:1.2 src/usr.bin/make/unit-tests/directive-ifdef.exp:1.3
--- src/usr.bin/make/unit-tests/directive-ifdef.exp:1.2	Sun Nov  8 22:38:28 2020
+++ src/usr.bin/make/unit-tests/directive-ifdef.exp	Thu Jan 21 23:03:41 2021
@@ -1,2 +1,4 @@
 make: "directive-ifdef.mk" line 12: Function calls in .ifdef are possible.
+make: "directive-ifdef.mk" line 23: String literals are tested for emptiness.
+make: "directive-ifdef.mk" line 27: String literals are tested for emptiness.  Whitespace is non-empty.
 exit status 0

Index: src/usr.bin/make/unit-tests/directive-ifdef.mk
diff -u src/usr.bin/make/unit-tests/directive-ifdef.mk:1.3 src/usr.bin/make/unit-tests/directive-ifdef.mk:1.4
--- src/usr.bin/make/unit-tests/directive-ifdef.mk:1.3	Sun Nov  8 22:38:28 2020
+++ src/usr.bin/make/unit-tests/directive-ifdef.mk	Thu Jan 21 23:03:41 2021
@@ -1,4 +1,4 @@
-# $NetBSD: directive-ifdef.mk,v 1.3 2020/11/08 22:38:28 rillig Exp $
+# $NetBSD: directive-ifdef.mk,v 1.4 2021/01/21 23:03:41 rillig Exp $
 #
 # Tests for the .ifdef directive.
 
@@ -14,5 +14,20 @@ DEFINED=	defined
 .  error
 .endif
 
+# String literals are handled the same in all variants of the .if directive.
+# They evaluate to true if they are not empty.  Whitespace counts as non-empty
+# as well.
+.ifdef ""
+.  error
+.else
+.  info String literals are tested for emptiness.
+.endif
+
+.ifdef " "
+.  info String literals are tested for emptiness.  Whitespace is non-empty.
+.else
+.  error
+.endif
+
 all:
 	@:;



CVS commit: src/usr.bin/make/unit-tests

2021-01-21 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu Jan 21 13:52:32 UTC 2021

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

Log Message:
make(1): add test case for bare word containing quotes


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/cond-token-plain.exp
cvs rdiff -u -r1.8 -r1.9 src/usr.bin/make/unit-tests/cond-token-plain.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-token-plain.exp
diff -u src/usr.bin/make/unit-tests/cond-token-plain.exp:1.5 src/usr.bin/make/unit-tests/cond-token-plain.exp:1.6
--- src/usr.bin/make/unit-tests/cond-token-plain.exp:1.5	Thu Jan 21 13:32:17 2021
+++ src/usr.bin/make/unit-tests/cond-token-plain.exp	Thu Jan 21 13:52:32 2021
@@ -47,6 +47,8 @@ CondParser_Eval: \\
 make: "cond-token-plain.mk" line 163: The variable '\\' is not defined.
 CondParser_Eval: \\
 make: "cond-token-plain.mk" line 168: Now the variable '\\' is defined.
+CondParser_Eval: "unquoted\"quoted" != unquoted"quoted
+lhs = "unquoted"quoted", rhs = "unquoted"quoted", op = !=
 make: Fatal errors encountered -- cannot continue
 make: stopped in unit-tests
 exit status 1

Index: src/usr.bin/make/unit-tests/cond-token-plain.mk
diff -u src/usr.bin/make/unit-tests/cond-token-plain.mk:1.8 src/usr.bin/make/unit-tests/cond-token-plain.mk:1.9
--- src/usr.bin/make/unit-tests/cond-token-plain.mk:1.8	Thu Jan 21 13:32:17 2021
+++ src/usr.bin/make/unit-tests/cond-token-plain.mk	Thu Jan 21 13:52:32 2021
@@ -1,4 +1,4 @@
-# $NetBSD: cond-token-plain.mk,v 1.8 2021/01/21 13:32:17 rillig Exp $
+# $NetBSD: cond-token-plain.mk,v 1.9 2021/01/21 13:52:32 rillig Exp $
 #
 # Tests for plain tokens (that is, string literals without quotes)
 # in .if conditions.
@@ -170,6 +170,13 @@ ${:U}=	backslash
 .  error
 .endif
 
+# Anything that doesn't start with a double quote is considered a "bare word".
+# Strangely, a bare word may contain double quotes inside.  Nobody should ever
+# depend on this since it may well be unintended.  See CondParser_String.
+.if "unquoted\"quoted" != unquoted"quoted
+.  error
+.endif
+
 # See cond-token-string.mk for similar tests where the condition is enclosed
 # in "quotes".
 



CVS commit: src/usr.bin/make/unit-tests

2021-01-21 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu Jan 21 13:32:17 UTC 2021

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

Log Message:
make(1): add more tests for edge cases in conditionals


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/cond-token-plain.exp
cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/unit-tests/cond-token-plain.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-token-plain.exp
diff -u src/usr.bin/make/unit-tests/cond-token-plain.exp:1.4 src/usr.bin/make/unit-tests/cond-token-plain.exp:1.5
--- src/usr.bin/make/unit-tests/cond-token-plain.exp:1.4	Thu Jan 21 00:38:28 2021
+++ src/usr.bin/make/unit-tests/cond-token-plain.exp	Thu Jan 21 13:32:17 2021
@@ -38,4 +38,15 @@ CondParser_Eval: 0${:Ux00}
 make: "cond-token-plain.mk" line 130: Numbers can be composed from literals and variable expressions.
 CondParser_Eval: 0${:Ux01}
 make: "cond-token-plain.mk" line 134: Numbers can be composed from literals and variable expressions.
-exit status 0
+CondParser_Eval: "" ==
+make: "cond-token-plain.mk" line 140: warning: Missing right-hand-side of operator
+make: "cond-token-plain.mk" line 140: Malformed conditional ("" ==)
+CondParser_Eval: == ""
+make: "cond-token-plain.mk" line 148: Malformed conditional (== "")
+CondParser_Eval: \\
+make: "cond-token-plain.mk" line 163: The variable '\\' is not defined.
+CondParser_Eval: \\
+make: "cond-token-plain.mk" line 168: Now the variable '\\' is defined.
+make: Fatal errors encountered -- cannot continue
+make: stopped in unit-tests
+exit status 1

Index: src/usr.bin/make/unit-tests/cond-token-plain.mk
diff -u src/usr.bin/make/unit-tests/cond-token-plain.mk:1.7 src/usr.bin/make/unit-tests/cond-token-plain.mk:1.8
--- src/usr.bin/make/unit-tests/cond-token-plain.mk:1.7	Thu Jan 21 00:38:28 2021
+++ src/usr.bin/make/unit-tests/cond-token-plain.mk	Thu Jan 21 13:32:17 2021
@@ -1,4 +1,4 @@
-# $NetBSD: cond-token-plain.mk,v 1.7 2021/01/21 00:38:28 rillig Exp $
+# $NetBSD: cond-token-plain.mk,v 1.8 2021/01/21 13:32:17 rillig Exp $
 #
 # Tests for plain tokens (that is, string literals without quotes)
 # in .if conditions.
@@ -136,6 +136,40 @@ VAR=	defined
 .  error
 .endif
 
+# If the right-hand side is missing, it's a parse error.
+.if "" ==
+.  error
+.else
+.  error
+.endif
+
+# If the left-hand side is missing, it's a parse error as well, but without
+# a specific error message.
+.if == ""
+.  error
+.else
+.  error
+.endif
+
+# The '\\' is not a line continuation.  Neither is it an unquoted string
+# literal.  Instead, it is parsed as a function argument (ParseFuncArg),
+# and in that context, the backslash is just an ordinary character. The
+# function argument thus stays '\\' (2 backslashes).  This string is passed
+# to FuncDefined, and since there is no variable named '\\', the condition
+# evaluates to false.
+.if \\
+.  error
+.else
+.  info The variable '\\' is not defined.
+.endif
+
+${:U}=	backslash
+.if \\
+.  info Now the variable '\\' is defined.
+.else
+.  error
+.endif
+
 # See cond-token-string.mk for similar tests where the condition is enclosed
 # in "quotes".
 



CVS commit: src/usr.bin/make/unit-tests

2021-01-20 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu Jan 21 00:38:28 UTC 2021

Modified Files:
src/usr.bin/make/unit-tests: cond-token-plain.exp cond-token-plain.mk
cond-token-string.exp cond-token-string.mk

Log Message:
make(1): add more tests for tokens in conditionals


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/cond-token-plain.exp \
src/usr.bin/make/unit-tests/cond-token-string.mk
cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/cond-token-plain.mk
cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/cond-token-string.exp

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-token-plain.exp
diff -u src/usr.bin/make/unit-tests/cond-token-plain.exp:1.3 src/usr.bin/make/unit-tests/cond-token-plain.exp:1.4
--- src/usr.bin/make/unit-tests/cond-token-plain.exp:1.3	Sat Sep 12 17:47:24 2020
+++ src/usr.bin/make/unit-tests/cond-token-plain.exp	Thu Jan 21 00:38:28 2021
@@ -26,4 +26,16 @@ CondParser_Eval: ${:Uvar}&&name != "var&
 lhs = "var&&name", rhs = "var&&name", op = !=
 CondParser_Eval: ${:Uvar}||name != "var||name"
 lhs = "var||name", rhs = "var||name", op = !=
+CondParser_Eval: bare
+make: "cond-token-plain.mk" line 102: A bare word is treated like defined(...), and the variable 'bare' is not defined.
+CondParser_Eval: VAR
+make: "cond-token-plain.mk" line 107: A bare word is treated like defined(...).
+CondParser_Eval: V${:UA}R
+make: "cond-token-plain.mk" line 114: ok
+CondParser_Eval: V${UNDEF}AR
+make: "cond-token-plain.mk" line 122: Undefined variables in bare words expand to an empty string.
+CondParser_Eval: 0${:Ux00}
+make: "cond-token-plain.mk" line 130: Numbers can be composed from literals and variable expressions.
+CondParser_Eval: 0${:Ux01}
+make: "cond-token-plain.mk" line 134: Numbers can be composed from literals and variable expressions.
 exit status 0
Index: src/usr.bin/make/unit-tests/cond-token-string.mk
diff -u src/usr.bin/make/unit-tests/cond-token-string.mk:1.3 src/usr.bin/make/unit-tests/cond-token-string.mk:1.4
--- src/usr.bin/make/unit-tests/cond-token-string.mk:1.3	Tue Nov 10 22:23:37 2020
+++ src/usr.bin/make/unit-tests/cond-token-string.mk	Thu Jan 21 00:38:28 2021
@@ -1,6 +1,10 @@
-# $NetBSD: cond-token-string.mk,v 1.3 2020/11/10 22:23:37 rillig Exp $
+# $NetBSD: cond-token-string.mk,v 1.4 2021/01/21 00:38:28 rillig Exp $
 #
-# Tests for quoted and unquoted string literals in .if conditions.
+# Tests for quoted string literals in .if conditions.
+#
+# See also:
+#	cond-token-plain.mk
+#		Covers string literals without quotes (called "bare words").
 
 # TODO: Implementation
 
@@ -35,5 +39,44 @@
 .  error
 .endif
 
+.MAKEFLAGS: -dc
+
+# A string in quotes is checked whether it is not empty.
+.if "UNDEF"
+.  info The string literal "UNDEF" is not empty.
+.else
+.  error
+.endif
+
+# A space is not empty as well.
+# This differs from many other places where whitespace is trimmed.
+.if " "
+.  info The string literal " " is not empty, even though it consists of $\
+	whitespace only.
+.else
+.  error
+.endif
+
+.if "${UNDEF}"
+.  error
+.else
+.  info An undefined variable in quotes expands to an empty string, which $\
+	then evaluates to false.
+.endif
+
+.if "${:Uvalue}"
+.  info A nonempty variable expression evaluates to true.
+.else
+.  error
+.endif
+
+.if "${:U}"
+.  error
+.else
+.  info An empty variable evaluates to false.
+.endif
+
+.MAKEFLAGS: -d0
+
 all:
 	@:;

Index: src/usr.bin/make/unit-tests/cond-token-plain.mk
diff -u src/usr.bin/make/unit-tests/cond-token-plain.mk:1.6 src/usr.bin/make/unit-tests/cond-token-plain.mk:1.7
--- src/usr.bin/make/unit-tests/cond-token-plain.mk:1.6	Sun Nov 15 14:58:14 2020
+++ src/usr.bin/make/unit-tests/cond-token-plain.mk	Thu Jan 21 00:38:28 2021
@@ -1,4 +1,4 @@
-# $NetBSD: cond-token-plain.mk,v 1.6 2020/11/15 14:58:14 rillig Exp $
+# $NetBSD: cond-token-plain.mk,v 1.7 2021/01/21 00:38:28 rillig Exp $
 #
 # Tests for plain tokens (that is, string literals without quotes)
 # in .if conditions.
@@ -93,5 +93,51 @@
 .  error
 .endif
 
+# A bare word may appear alone in a condition, without any comparison
+# operator.  It is implicitly converted into defined(bare).
+.if bare
+.  error
+.else
+.  info A bare word is treated like defined(...), and the variable $\
+	'bare' is not defined.
+.endif
+
+VAR=	defined
+.if VAR
+.  info A bare word is treated like defined(...).
+.else
+.  error
+.endif
+
+# Bare words may be intermixed with variable expressions.
+.if V${:UA}R
+.  info ok
+.else
+.  error
+.endif
+
+# In bare words, even undefined variables are allowed.  Without the bare
+# words, undefined variables are not allowed.  That feels inconsistent.
+.if V${UNDEF}AR
+.  info Undefined variables in bare words expand to an empty string.
+.else
+.  error
+.endif
+
+.if 0${:Ux00}
+.  error
+.else
+.  info Numbers can be composed from literals and va

CVS commit: src/usr.bin/make/unit-tests

2021-01-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Jan 19 19:54:57 UTC 2021

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

Log Message:
make(1): add test for unsupported relational string comparisons


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/usr.bin/make/unit-tests/cond-cmp-string.exp
cvs rdiff -u -r1.13 -r1.14 src/usr.bin/make/unit-tests/cond-cmp-string.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-cmp-string.exp
diff -u src/usr.bin/make/unit-tests/cond-cmp-string.exp:1.8 src/usr.bin/make/unit-tests/cond-cmp-string.exp:1.9
--- src/usr.bin/make/unit-tests/cond-cmp-string.exp:1.8	Sun Nov 15 14:07:53 2020
+++ src/usr.bin/make/unit-tests/cond-cmp-string.exp	Tue Jan 19 19:54:57 2021
@@ -3,6 +3,14 @@ make: "cond-cmp-string.mk" line 42: Malf
 make: "cond-cmp-string.mk" line 49: warning: String comparison operator must be either == or !=
 make: "cond-cmp-string.mk" line 49: Malformed conditional (!("value" = "value"))
 make: "cond-cmp-string.mk" line 56: Malformed conditional (!("value" === "value"))
+make: "cond-cmp-string.mk" line 113: warning: String comparison operator must be either == or !=
+make: "cond-cmp-string.mk" line 113: Malformed conditional ("string" < "string")
+make: "cond-cmp-string.mk" line 120: warning: String comparison operator must be either == or !=
+make: "cond-cmp-string.mk" line 120: Malformed conditional ("string" <= "string")
+make: "cond-cmp-string.mk" line 127: warning: String comparison operator must be either == or !=
+make: "cond-cmp-string.mk" line 127: Malformed conditional ("string" > "string")
+make: "cond-cmp-string.mk" line 134: warning: String comparison operator must be either == or !=
+make: "cond-cmp-string.mk" line 134: Malformed conditional ("string" >= "string")
 make: Fatal errors encountered -- cannot continue
 make: stopped in unit-tests
 exit status 1

Index: src/usr.bin/make/unit-tests/cond-cmp-string.mk
diff -u src/usr.bin/make/unit-tests/cond-cmp-string.mk:1.13 src/usr.bin/make/unit-tests/cond-cmp-string.mk:1.14
--- src/usr.bin/make/unit-tests/cond-cmp-string.mk:1.13	Sun Nov 15 14:07:53 2020
+++ src/usr.bin/make/unit-tests/cond-cmp-string.mk	Tue Jan 19 19:54:57 2021
@@ -1,4 +1,4 @@
-# $NetBSD: cond-cmp-string.mk,v 1.13 2020/11/15 14:07:53 rillig Exp $
+# $NetBSD: cond-cmp-string.mk,v 1.14 2021/01/19 19:54:57 rillig Exp $
 #
 # Tests for string comparisons in .if conditions.
 
@@ -108,3 +108,31 @@
 .if 12345.0 == "12345"
 .  error
 .endif
+
+# Strings cannot be compared relationally, only for equality.
+.if "string" < "string"
+.  error
+.else
+.  error
+.endif
+
+# Strings cannot be compared relationally, only for equality.
+.if "string" <= "string"
+.  error
+.else
+.  error
+.endif
+
+# Strings cannot be compared relationally, only for equality.
+.if "string" > "string"
+.  error
+.else
+.  error
+.endif
+
+# Strings cannot be compared relationally, only for equality.
+.if "string" >= "string"
+.  error
+.else
+.  error
+.endif



CVS commit: src/usr.bin/make/unit-tests

2021-01-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Jan 19 18:09:12 UTC 2021

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

Log Message:
make(1): demonstrate missing error handling for malformed conditions


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/unit-tests/cond-op.exp
cvs rdiff -u -r1.10 -r1.11 src/usr.bin/make/unit-tests/cond-op.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-op.exp
diff -u src/usr.bin/make/unit-tests/cond-op.exp:1.7 src/usr.bin/make/unit-tests/cond-op.exp:1.8
--- src/usr.bin/make/unit-tests/cond-op.exp:1.7	Sun Nov 15 14:58:14 2020
+++ src/usr.bin/make/unit-tests/cond-op.exp	Tue Jan 19 18:09:12 2021
@@ -11,6 +11,10 @@ make: "cond-op.mk" line 93: 1 0 0   =>  
 make: "cond-op.mk" line 93: 1 0 1   =>   1   1 1
 make: "cond-op.mk" line 93: 1 1 0   =>   0   1 1
 make: "cond-op.mk" line 93: 1 1 1   =>   1   1 1
+make: "cond-op.mk" line 104: Malformed conditional (1 &&)
+make: "cond-op.mk" line 115: Missing argument for ".error"
+make: "cond-op.mk" line 121: Missing argument for ".error"
+make: "cond-op.mk" line 129: Malformed conditional (0 ||)
 make: Fatal errors encountered -- cannot continue
 make: stopped in unit-tests
 exit status 1

Index: src/usr.bin/make/unit-tests/cond-op.mk
diff -u src/usr.bin/make/unit-tests/cond-op.mk:1.10 src/usr.bin/make/unit-tests/cond-op.mk:1.11
--- src/usr.bin/make/unit-tests/cond-op.mk:1.10	Sun Nov 15 14:58:14 2020
+++ src/usr.bin/make/unit-tests/cond-op.mk	Tue Jan 19 18:09:12 2021
@@ -1,4 +1,4 @@
-# $NetBSD: cond-op.mk,v 1.10 2020/11/15 14:58:14 rillig Exp $
+# $NetBSD: cond-op.mk,v 1.11 2021/01/19 18:09:12 rillig Exp $
 #
 # Tests for operators like &&, ||, ! in .if conditions.
 #
@@ -98,5 +98,39 @@
 .  endfor
 .endfor
 
+# This condition is obviously malformed.  It is properly detected and also
+# was properly detected before 2021-01-19, but only because the left hand
+# side of the '&&' evaluated to true.
+.if 1 &&
+.  error
+.else
+.  error
+.endif
+
+# FIXME: Don't accept this condition as syntactically valid.
+# FIXME: CondParser_Factor, (void).
+.if 0 &&
+.  error
+.else
+.  error
+.endif
+
+# FIXME: Don't accept this condition as syntactically valid.
+# FIXME: CondParser_Expr, (void).
+.if 1 ||
+.  error
+.else
+.  error
+.endif
+
+# This condition is obviously malformed.  It is properly detected and also
+# was properly detected before 2021-01-19, but only because the left hand
+# side of the '||' evaluated to false.
+.if 0 ||
+.  error
+.else
+.  error
+.endif
+
 all:
 	@:;



CVS commit: src/usr.bin/make/unit-tests

2021-01-18 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Jan 19 05:49:33 UTC 2021

Modified Files:
src/usr.bin/make/unit-tests: Makefile

Log Message:
make(1): normalize shell error messages in tests

Newly supported is bash, which outputs "bash: line 123".


To generate a diff of this commit:
cvs rdiff -u -r1.260 -r1.261 src/usr.bin/make/unit-tests/Makefile

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.260 src/usr.bin/make/unit-tests/Makefile:1.261
--- src/usr.bin/make/unit-tests/Makefile:1.260	Thu Dec 31 03:05:12 2020
+++ src/usr.bin/make/unit-tests/Makefile	Tue Jan 19 05:49:33 2021
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.260 2020/12/31 03:05:12 rillig Exp $
+# $NetBSD: Makefile,v 1.261 2021/01/19 05:49:33 rillig Exp $
 #
 # Unit tests for make(1)
 #
@@ -504,10 +504,9 @@ SED_CMDS.sh-flags=		${STD_SED_CMDS.hide-
 SED_CMDS.suff-main+=		${STD_SED_CMDS.dg1}
 SED_CMDS.suff-main-several+=	${STD_SED_CMDS.dg1}
 SED_CMDS.suff-transform-debug+=	${STD_SED_CMDS.dg1}
-SED_CMDS.var-op-shell+=	\
-	-e 's,^${.SHELL:T}: [ 0-9:]*,,' \
-	-e '/command/s,No such.*,not found,'
-SED_CMDS.vardebug+=	-e 's,${.SHELL},,'
+SED_CMDS.var-op-shell+=		${STD_SED_CMDS.shell}
+SED_CMDS.var-op-shell+=		-e '/command/s,No such.*,not found,'
+SED_CMDS.vardebug+=		-e 's,${.SHELL},,'
 SED_CMDS.varmod-subst-regex+= \
 			-e 's,\(Regex compilation error:\).*,\1 (details omitted),'
 SED_CMDS.varname-dot-parsedir=	-e '/in some cases/ s,^make: "[^"]*,make: ",'
@@ -553,6 +552,25 @@ STD_SED_CMDS.hide-from-output= \
 	-e 's,hide-from-output ,,' \
 	-e 's,hide-from-output,,'
 
+# Normalize the output for error messages from the shell.
+#
+# $shell -c '...'
+#	NetBSD sh	...: not found
+#	NetBSD ksh	ksh: ...: not found
+#	bash 5		bash: line 1: ...: command not found
+#	dash		dash: 1: ...: not found
+#
+# $shell -c '< /nonexistent'
+#	NetBSD sh	sh: cannot open /nonexistent: no such file
+#	NetBSD ksh	ksh: cannot open /nonexistent: No such file or directory
+#	bash 5		bash: line 1: /nonexistent: No such file or directory
+#	dash		dash: 1: cannot open /nonexistent: No such file
+#
+#
+STD_SED_CMDS.shell+=		-e 's,^${.SHELL:T}: line [0-9][0-9]*:,,'
+STD_SED_CMDS.shell+=		-e 's,^${.SHELL:T}: [0-9][0-9]*:,,'
+STD_SED_CMDS.shell+=		-e 's,^${.SHELL:T}: ,,'
+
 # End of the configuration helpers section.
 
 .MAIN: all



CVS commit: src/usr.bin/make/unit-tests

2021-01-18 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Jan 19 05:26:34 UTC 2021

Modified Files:
src/usr.bin/make/unit-tests: varmod-gmtime.exp varmod-gmtime.mk
varmod-localtime.exp varmod-localtime.mk

Log Message:
make(1): fix tests for :gmtime and :localtime for 32-bit time_t

The comparison operator had accidentally been '!=' instead of '=='.

While here, proofread the documentation and add references for where the
32-bit time_t is defined on Linux and FreeBSD.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/usr.bin/make/unit-tests/varmod-gmtime.exp
cvs rdiff -u -r1.9 -r1.10 src/usr.bin/make/unit-tests/varmod-gmtime.mk
cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/unit-tests/varmod-localtime.exp \
src/usr.bin/make/unit-tests/varmod-localtime.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/varmod-gmtime.exp
diff -u src/usr.bin/make/unit-tests/varmod-gmtime.exp:1.10 src/usr.bin/make/unit-tests/varmod-gmtime.exp:1.11
--- src/usr.bin/make/unit-tests/varmod-gmtime.exp:1.10	Mon Dec 21 21:04:18 2020
+++ src/usr.bin/make/unit-tests/varmod-gmtime.exp	Tue Jan 19 05:26:34 2021
@@ -1,13 +1,13 @@
-make: "varmod-gmtime.mk" line 60: Invalid time value: ${:U1593536400}} != "mtime=11593536400}"
-make: "varmod-gmtime.mk" line 60: Malformed conditional (${%Y:L:gmtime=${:U1593536400}} != "mtime=11593536400}")
-make: "varmod-gmtime.mk" line 70: Invalid time value: -1} != ""
-make: "varmod-gmtime.mk" line 70: Malformed conditional (${:L:gmtime=-1} != "")
-make: "varmod-gmtime.mk" line 79: Invalid time value:  1} != ""
-make: "varmod-gmtime.mk" line 79: Malformed conditional (${:L:gmtime= 1} != "")
-make: "varmod-gmtime.mk" line 118: Invalid time value: 1000} != ""
-make: "varmod-gmtime.mk" line 118: Malformed conditional (${:L:gmtime=1000} != "")
-make: "varmod-gmtime.mk" line 129: Invalid time value: error} != ""
-make: "varmod-gmtime.mk" line 129: Malformed conditional (${:L:gmtime=error} != "")
+make: "varmod-gmtime.mk" line 57: Invalid time value: ${:U1593536400}} != "mtime=11593536400}"
+make: "varmod-gmtime.mk" line 57: Malformed conditional (${%Y:L:gmtime=${:U1593536400}} != "mtime=11593536400}")
+make: "varmod-gmtime.mk" line 67: Invalid time value: -1} != ""
+make: "varmod-gmtime.mk" line 67: Malformed conditional (${:L:gmtime=-1} != "")
+make: "varmod-gmtime.mk" line 76: Invalid time value:  1} != ""
+make: "varmod-gmtime.mk" line 76: Malformed conditional (${:L:gmtime= 1} != "")
+make: "varmod-gmtime.mk" line 119: Invalid time value: 1000} != ""
+make: "varmod-gmtime.mk" line 119: Malformed conditional (${:L:gmtime=1000} != "")
+make: "varmod-gmtime.mk" line 130: Invalid time value: error} != ""
+make: "varmod-gmtime.mk" line 130: Malformed conditional (${:L:gmtime=error} != "")
 make: Fatal errors encountered -- cannot continue
 make: stopped in unit-tests
 exit status 1

Index: src/usr.bin/make/unit-tests/varmod-gmtime.mk
diff -u src/usr.bin/make/unit-tests/varmod-gmtime.mk:1.9 src/usr.bin/make/unit-tests/varmod-gmtime.mk:1.10
--- src/usr.bin/make/unit-tests/varmod-gmtime.mk:1.9	Tue Dec 22 07:22:39 2020
+++ src/usr.bin/make/unit-tests/varmod-gmtime.mk	Tue Jan 19 05:26:34 2021
@@ -1,4 +1,4 @@
-# $NetBSD: varmod-gmtime.mk,v 1.9 2020/12/22 07:22:39 rillig Exp $
+# $NetBSD: varmod-gmtime.mk,v 1.10 2021/01/19 05:26:34 rillig Exp $
 #
 # Tests for the :gmtime variable modifier, which formats a timestamp
 # using strftime(3) in UTC.
@@ -54,9 +54,6 @@
 #
 # If ApplyModifier_Gmtime were to pass its argument through
 # ParseModifierPart, this would work.
-#
-# XXX: Where does the empty line 4 in varmod-gmtime.exp come from?
-# TODO: Remove the \n from "Invalid time value: %s\n" in var.c.
 .if ${%Y:L:gmtime=${:U1593536400}} != "mtime=11593536400}"
 .  error
 .endif
@@ -74,8 +71,8 @@
 .endif
 
 
-# Spaces were allowed before var.c 1.631, not because it would make sense
-# but just as a side-effect from using strtoul.
+# Spaces were allowed before var.c 1.631 from 2020-10-31 21:40:20, not
+# because it would make sense but just as a side-effect from using strtoul.
 .if ${:L:gmtime= 1} != ""
 .  error
 .endif
@@ -102,8 +99,12 @@
 
 .if ${:L:gmtime=2147483648} == "Tue Jan 19 03:14:08 2038"
 # All systems that have unsigned time_t or 64-bit time_t.
-.elif ${:L:gmtime=2147483648} != "Fri Dec 13 20:45:52 1901"
-# FreeBSD-12.0-i386 still has 32-bit signed time_t.
+.elif ${:L:gmtime=2147483648} == "Fri Dec 13 20:45:52 1901"
+# FreeBSD-12.0-i386 still has 32-bit signed time_t, see
+# sys/x86/include/_types.h, __LP64__.
+#
+# Linux on 32-bit systems may still have 32-bit signed time_t, see
+# sysdeps/unix/sysv/linux/generic/bits/typesizes.h, __TIMESIZE.
 .else
 .  error
 .endif
@@ -122,7 +123,7 @@
 .endif
 
 # Before var.c 1.631 from 2020-10-31, there was no

CVS commit: src/usr.bin/make/unit-tests

2021-01-07 Thread Simon J. Gerraty
Module Name:src
Committed By:   sjg
Date:   Thu Jan  7 18:11:23 UTC 2021

Modified Files:
src/usr.bin/make/unit-tests: jobs-error-nested-make.exp
jobs-error-nested-make.mk

Log Message:
Remove .MAKE from nested target which is not a sub-make

This does not fix the issue, just makes the unit-test more accurate.

PR: 55578
Reviewed by: rillig


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 \
src/usr.bin/make/unit-tests/jobs-error-nested-make.exp \
src/usr.bin/make/unit-tests/jobs-error-nested-make.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/jobs-error-nested-make.exp
diff -u src/usr.bin/make/unit-tests/jobs-error-nested-make.exp:1.1 src/usr.bin/make/unit-tests/jobs-error-nested-make.exp:1.2
--- src/usr.bin/make/unit-tests/jobs-error-nested-make.exp:1.1	Tue Dec  1 17:50:04 2020
+++ src/usr.bin/make/unit-tests/jobs-error-nested-make.exp	Thu Jan  7 18:11:23 2021
@@ -1,3 +1,9 @@
 make -f jobs-error-nested-make.mk nested
 false
+*** [nested] Error code 1
+
+make: stopped in unit-tests
+1 error
+
+make: stopped in unit-tests
 exit status 2
Index: src/usr.bin/make/unit-tests/jobs-error-nested-make.mk
diff -u src/usr.bin/make/unit-tests/jobs-error-nested-make.mk:1.1 src/usr.bin/make/unit-tests/jobs-error-nested-make.mk:1.2
--- src/usr.bin/make/unit-tests/jobs-error-nested-make.mk:1.1	Tue Dec  1 17:50:04 2020
+++ src/usr.bin/make/unit-tests/jobs-error-nested-make.mk	Thu Jan  7 18:11:23 2021
@@ -1,4 +1,4 @@
-# $NetBSD: jobs-error-nested-make.mk,v 1.1 2020/12/01 17:50:04 rillig Exp $
+# $NetBSD: jobs-error-nested-make.mk,v 1.2 2021/01/07 18:11:23 sjg Exp $
 #
 # Ensure that in jobs mode, when a command fails, the current directory is
 # printed, to aid in debugging, even if the target is marked as .MAKE.
@@ -16,5 +16,5 @@
 all: .PHONY .MAKE
 	${MAKE} -f ${MAKEFILE} nested
 
-nested: .PHONY .MAKE
+nested: .PHONY
 	false



CVS commit: src/usr.bin/make/unit-tests

2021-01-01 Thread Simon J. Gerraty
Module Name:src
Committed By:   sjg
Date:   Fri Jan  1 23:07:49 UTC 2021

Modified Files:
src/usr.bin/make/unit-tests: var-op-expand.mk

Log Message:
var-op-expand needs MAKE.SAVE_DOLLARS=yes


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/usr.bin/make/unit-tests/var-op-expand.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/var-op-expand.mk
diff -u src/usr.bin/make/unit-tests/var-op-expand.mk:1.10 src/usr.bin/make/unit-tests/var-op-expand.mk:1.11
--- src/usr.bin/make/unit-tests/var-op-expand.mk:1.10	Mon Dec 28 00:19:41 2020
+++ src/usr.bin/make/unit-tests/var-op-expand.mk	Fri Jan  1 23:07:48 2021
@@ -1,8 +1,9 @@
-# $NetBSD: var-op-expand.mk,v 1.10 2020/12/28 00:19:41 rillig Exp $
+# $NetBSD: var-op-expand.mk,v 1.11 2021/01/01 23:07:48 sjg Exp $
 #
 # Tests for the := variable assignment operator, which expands its
 # right-hand side.
 
+.MAKE.SAVE_DOLLARS:=  yes
 
 # If the right-hand side does not contain a dollar sign, the ':=' assignment
 # operator has the same effect as the '=' assignment operator.



CVS commit: src/usr.bin/make/unit-tests

2020-12-31 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu Dec 31 14:26:37 UTC 2020

Modified Files:
src/usr.bin/make/unit-tests: directive-for-escape.exp
directive-for-escape.mk

Log Message:
make(1): add test for common and edge cases in .for loop expansion


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/directive-for-escape.exp \
src/usr.bin/make/unit-tests/directive-for-escape.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/directive-for-escape.exp
diff -u src/usr.bin/make/unit-tests/directive-for-escape.exp:1.2 src/usr.bin/make/unit-tests/directive-for-escape.exp:1.3
--- src/usr.bin/make/unit-tests/directive-for-escape.exp:1.2	Thu Dec 31 13:23:43 2020
+++ src/usr.bin/make/unit-tests/directive-for-escape.exp	Thu Dec 31 14:26:37 2020
@@ -46,6 +46,28 @@ For: end for 1
 For: loop body:
 .  info ${:Ureplaced}
 make: "directive-for-escape.mk" line 78: replaced
+For: end for 1
+For: loop body:
+.  info .$$i: ${:Uinner}
+.  info .  $${i}: ${:Uinner}
+.  info .   $${i:M*}: ${:Uinner:M*}
+.  info .  $$(i): $(:Uinner)
+.  info .   $$(i:M*): $(:Uinner:M*)
+.  info . $${i$${:U}}: ${i${:U}}
+.  info .$${i\}}: ${:Uinner\}}	# XXX: unclear why SubstVarLong needs this
+.  info . $${i2}: ${i2}
+.  info . $${i,}: ${i,}
+.  info .  adjacent: ${:Uinner}${:Uinner}${:Uinner:M*}${:Uinner}
+make: "directive-for-escape.mk" line 86: .$i: inner
+make: "directive-for-escape.mk" line 87: .  ${i}: inner
+make: "directive-for-escape.mk" line 88: .   ${i:M*}: inner
+make: "directive-for-escape.mk" line 89: .  $(i): inner
+make: "directive-for-escape.mk" line 90: .   $(i:M*): inner
+make: "directive-for-escape.mk" line 91: . ${i${:U}}: outer
+make: "directive-for-escape.mk" line 92: .${i\}}: inner}
+make: "directive-for-escape.mk" line 93: . ${i2}: two
+make: "directive-for-escape.mk" line 94: . ${i,}: comma
+make: "directive-for-escape.mk" line 95: .  adjacent: innerinnerinnerinner
 make: no target to make.
 
 make: stopped in unit-tests
Index: src/usr.bin/make/unit-tests/directive-for-escape.mk
diff -u src/usr.bin/make/unit-tests/directive-for-escape.mk:1.2 src/usr.bin/make/unit-tests/directive-for-escape.mk:1.3
--- src/usr.bin/make/unit-tests/directive-for-escape.mk:1.2	Thu Dec 31 13:23:43 2020
+++ src/usr.bin/make/unit-tests/directive-for-escape.mk	Thu Dec 31 14:26:37 2020
@@ -1,4 +1,4 @@
-# $NetBSD: directive-for-escape.mk,v 1.2 2020/12/31 13:23:43 rillig Exp $
+# $NetBSD: directive-for-escape.mk,v 1.3 2020/12/31 14:26:37 rillig Exp $
 #
 # Test escaping of special characters in the iteration values of a .for loop.
 # These values get expanded later using the :U variable modifier, and this
@@ -77,3 +77,20 @@ EXT=		.c
 .for BASENAME}${EXT in replaced
 .  info ${BASENAME}${EXT}
 .endfor
+
+# Demonstrate the various ways to refer to the iteration variable.
+i=		outer
+i2=		two
+i,=		comma
+.for i in inner
+.  info .$$i: $i
+.  info .  $${i}: ${i}
+.  info .   $${i:M*}: ${i:M*}
+.  info .  $$(i): $(i)
+.  info .   $$(i:M*): $(i:M*)
+.  info . $${i$${:U}}: ${i${:U}}
+.  info .$${i\}}: ${i\}}	# XXX: unclear why SubstVarLong needs this
+.  info . $${i2}: ${i2}
+.  info . $${i,}: ${i,}
+.  info .  adjacent: $i${i}${i:M*}$i
+.endfor



CVS commit: src/usr.bin/make/unit-tests

2020-12-31 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu Dec 31 13:23:43 UTC 2020

Modified Files:
src/usr.bin/make/unit-tests: directive-for-escape.exp
directive-for-escape.mk

Log Message:
make(1): add tests for extreme edge cases of .for loop expansion


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/directive-for-escape.exp \
src/usr.bin/make/unit-tests/directive-for-escape.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/directive-for-escape.exp
diff -u src/usr.bin/make/unit-tests/directive-for-escape.exp:1.1 src/usr.bin/make/unit-tests/directive-for-escape.exp:1.2
--- src/usr.bin/make/unit-tests/directive-for-escape.exp:1.1	Thu Dec 31 03:05:12 2020
+++ src/usr.bin/make/unit-tests/directive-for-escape.exp	Thu Dec 31 13:23:43 2020
@@ -38,6 +38,14 @@ For: end for 1
 For: loop body:
 .  info ${:U\$}
 make: "directive-for-escape.mk" line 60: $
+For: end for 1
+For: loop body:
+.  info ${NUMBERS} ${:Ureplaced}
+make: "directive-for-escape.mk" line 68: one two three replaced
+For: end for 1
+For: loop body:
+.  info ${:Ureplaced}
+make: "directive-for-escape.mk" line 78: replaced
 make: no target to make.
 
 make: stopped in unit-tests
Index: src/usr.bin/make/unit-tests/directive-for-escape.mk
diff -u src/usr.bin/make/unit-tests/directive-for-escape.mk:1.1 src/usr.bin/make/unit-tests/directive-for-escape.mk:1.2
--- src/usr.bin/make/unit-tests/directive-for-escape.mk:1.1	Thu Dec 31 03:05:12 2020
+++ src/usr.bin/make/unit-tests/directive-for-escape.mk	Thu Dec 31 13:23:43 2020
@@ -1,4 +1,4 @@
-# $NetBSD: directive-for-escape.mk,v 1.1 2020/12/31 03:05:12 rillig Exp $
+# $NetBSD: directive-for-escape.mk,v 1.2 2020/12/31 13:23:43 rillig Exp $
 #
 # Test escaping of special characters in the iteration values of a .for loop.
 # These values get expanded later using the :U variable modifier, and this
@@ -59,3 +59,21 @@ VALUES=		$${UNDEF:U\$$\$$ {{}} end}
 .for i in ${:U\$}
 .  info ${i}
 .endfor
+
+# As of 2020-12-31, the name of the iteration variable can even contain
+# colons, which then affects variable expressions having this exact modifier.
+# This is clearly an unintended side effect of the implementation.
+NUMBERS=	one two three
+.for NUMBERS:M*e in replaced
+.  info ${NUMBERS} ${NUMBERS:M*e}
+.endfor
+
+# As of 2020-12-31, the name of the iteration variable can contain braces,
+# which gets even more surprising than colons, since it allows to replace
+# sequences of variable expressions.  There is no practical use case for
+# this, though.
+BASENAME=	one
+EXT=		.c
+.for BASENAME}${EXT in replaced
+.  info ${BASENAME}${EXT}
+.endfor



CVS commit: src/usr.bin/make/unit-tests

2020-12-27 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Dec 28 00:19:42 UTC 2020

Modified Files:
src/usr.bin/make/unit-tests: var-op-expand.mk

Log Message:
make(1): extend test for modifier parts in ':=' assignments


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/usr.bin/make/unit-tests/var-op-expand.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/var-op-expand.mk
diff -u src/usr.bin/make/unit-tests/var-op-expand.mk:1.9 src/usr.bin/make/unit-tests/var-op-expand.mk:1.10
--- src/usr.bin/make/unit-tests/var-op-expand.mk:1.9	Sun Dec 27 23:25:33 2020
+++ src/usr.bin/make/unit-tests/var-op-expand.mk	Mon Dec 28 00:19:41 2020
@@ -1,4 +1,4 @@
-# $NetBSD: var-op-expand.mk,v 1.9 2020/12/27 23:25:33 rillig Exp $
+# $NetBSD: var-op-expand.mk,v 1.10 2020/12/28 00:19:41 rillig Exp $
 #
 # Tests for the := variable assignment operator, which expands its
 # right-hand side.
@@ -118,22 +118,32 @@ VAR:=		top:$$ ${:Unest1\:\$\$} ${:Unest2
 
 # In variable assignments using the ':=' operator, there may be expressions
 # containing variable modifiers, and these modifiers may refer to other
-# variables.
+# variables.  These referred-to variables are expanded at the time of
+# assignment.  The undefined variables are kept as-is and are later expanded
+# when evaluating the condition.
 #
 # Contrary to the assignment operator '=', the assignment operator ':='
 # consumes the '$' from modifier parts.
 REF.word=	1:$$ 2: 4:
-VAR:=		${:Uword:@word@${REF.${word}}@}, direct: ${REF.word}
-.if ${VAR} != "1:2:\$ 4:\$\$, direct: 1:\$ 2:\$\$ 4:\$\$\$\$"
+.undef REF.undef
+VAR:=		${:Uword undef:@word@${REF.${word}}@}, direct: ${REF.word} ${REF.undef}
+REF.word=	word.after
+REF.undef=	undef.after
+.if ${VAR} != "1:2:\$ 4:\$\$ undef.after, direct: 1:\$ 2:\$\$ 4:\$\$\$\$ undef.after"
 .  error
 .endif
 
-
 # Just for comparison, the previous example using the assignment operator '='
-# instead of ':='.
+# instead of ':='.  The right-hand side of the assignment is not evaluated at
+# the time of assignment but only later, when ${VAR} appears in the condition.
+#
+# At that point, both REF.word and REF.undef are defined.
 REF.word=	1:$$ 2: 4:
-VAR=		${:Uword:@word@${REF.${word}}@}, direct: ${REF.word}
-.if ${VAR} != "1:\$ 2:\$\$ 4:\$\$\$\$, direct: 1:\$ 2:\$\$ 4:\$\$\$\$"
+.undef REF.undef
+VAR=		${:Uword undef:@word@${REF.${word}}@}, direct: ${REF.word} ${REF.undef}
+REF.word=	word.after
+REF.undef=	undef.after
+.if ${VAR} != "word.after undef.after, direct: word.after undef.after"
 .  error
 .endif
 



CVS commit: src/usr.bin/make/unit-tests

2020-12-27 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Dec 27 23:25:33 UTC 2020

Modified Files:
src/usr.bin/make/unit-tests: var-op-expand.mk

Log Message:
make(1): add test for modifier parts in ':=' assignments


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/usr.bin/make/unit-tests/var-op-expand.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/var-op-expand.mk
diff -u src/usr.bin/make/unit-tests/var-op-expand.mk:1.8 src/usr.bin/make/unit-tests/var-op-expand.mk:1.9
--- src/usr.bin/make/unit-tests/var-op-expand.mk:1.8	Sun Dec 27 22:29:37 2020
+++ src/usr.bin/make/unit-tests/var-op-expand.mk	Sun Dec 27 23:25:33 2020
@@ -1,4 +1,4 @@
-# $NetBSD: var-op-expand.mk,v 1.8 2020/12/27 22:29:37 rillig Exp $
+# $NetBSD: var-op-expand.mk,v 1.9 2020/12/27 23:25:33 rillig Exp $
 #
 # Tests for the := variable assignment operator, which expands its
 # right-hand side.
@@ -116,6 +116,28 @@ VAR:=		top:$$ ${:Unest1\:\$\$} ${:Unest2
 .endif
 
 
+# In variable assignments using the ':=' operator, there may be expressions
+# containing variable modifiers, and these modifiers may refer to other
+# variables.
+#
+# Contrary to the assignment operator '=', the assignment operator ':='
+# consumes the '$' from modifier parts.
+REF.word=	1:$$ 2: 4:
+VAR:=		${:Uword:@word@${REF.${word}}@}, direct: ${REF.word}
+.if ${VAR} != "1:2:\$ 4:\$\$, direct: 1:\$ 2:\$\$ 4:\$\$\$\$"
+.  error
+.endif
+
+
+# Just for comparison, the previous example using the assignment operator '='
+# instead of ':='.
+REF.word=	1:$$ 2: 4:
+VAR=		${:Uword:@word@${REF.${word}}@}, direct: ${REF.word}
+.if ${VAR} != "1:\$ 2:\$\$ 4:\$\$\$\$, direct: 1:\$ 2:\$\$ 4:\$\$\$\$"
+.  error
+.endif
+
+
 # Between var.c 1.42 from 2000-05-11 and before parse.c 1.520 from 2020-12-27,
 # if the variable name in a ':=' assignment referred to an undefined variable,
 # there were actually 2 assignments to different variables:



CVS commit: src/usr.bin/make/unit-tests

2020-12-27 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Dec 27 21:31:28 UTC 2020

Modified Files:
src/usr.bin/make/unit-tests: var-op-expand.exp var-op-expand.mk

Log Message:
make(1): move test result of var-op-expand.mk from exp to mk

This makes it easier to run this test in older versions of make.  Empty
output means success.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/var-op-expand.exp
cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/var-op-expand.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/var-op-expand.exp
diff -u src/usr.bin/make/unit-tests/var-op-expand.exp:1.2 src/usr.bin/make/unit-tests/var-op-expand.exp:1.3
--- src/usr.bin/make/unit-tests/var-op-expand.exp:1.2	Sun Nov  8 13:46:15 2020
+++ src/usr.bin/make/unit-tests/var-op-expand.exp	Sun Dec 27 21:31:27 2020
@@ -1,10 +1 @@
-Var_Parse: ${UNDEF} with VARE_WANTRES
-Global:VAR_ASSIGN_ = undef value
-Var_Parse: ${UNDEF} with VARE_WANTRES
-Var_Parse: ${UNDEF} with VARE_WANTRES
-Global:VAR_SUBST_${UNDEF} = 
-Var_Parse: ${UNDEF} with VARE_WANTRES
-Global:VAR_SUBST_ = undef value
-Global:.MAKEFLAGS =  -r -k -d v -d
-Global:.MAKEFLAGS =  -r -k -d v -d 0
 exit status 0

Index: src/usr.bin/make/unit-tests/var-op-expand.mk
diff -u src/usr.bin/make/unit-tests/var-op-expand.mk:1.6 src/usr.bin/make/unit-tests/var-op-expand.mk:1.7
--- src/usr.bin/make/unit-tests/var-op-expand.mk:1.6	Sun Dec 27 21:19:13 2020
+++ src/usr.bin/make/unit-tests/var-op-expand.mk	Sun Dec 27 21:31:27 2020
@@ -1,4 +1,4 @@
-# $NetBSD: var-op-expand.mk,v 1.6 2020/12/27 21:19:13 rillig Exp $
+# $NetBSD: var-op-expand.mk,v 1.7 2020/12/27 21:31:27 rillig Exp $
 #
 # Tests for the := variable assignment operator, which expands its
 # right-hand side.
@@ -130,10 +130,17 @@ VAR:=		top:$$ ${:Unest1\:\$\$} ${:Unest2
 # to an empty string.  This way, 2 variables are created using a single
 # variable assignment.  It's magic. :-/
 .undef UNDEF
-.MAKEFLAGS: -dv
-VAR_ASSIGN_${UNDEF}=	undef value
-VAR_SUBST_${UNDEF}:=	undef value
-.MAKEFLAGS: -d0
+VAR_ASSIGN_${UNDEF}=	assigned by '='
+VAR_SUBST_${UNDEF}:=	assigned by ':='
+.if ${VAR_ASSIGN_} != "assigned by '='"
+.  error
+.endif
+.if ${${:UVAR_SUBST_\${UNDEF\}}} != ""
+.  error
+.endif
+.if ${VAR_SUBST_} != "assigned by ':='"
+.  error
+.endif
 
 all:
 	@:;



CVS commit: src/usr.bin/make/unit-tests

2020-12-27 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Dec 27 21:19:13 UTC 2020

Modified Files:
src/usr.bin/make/unit-tests: var-op-expand.mk

Log Message:
make(1): add more tests for ':=' assignments


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/var-op-expand.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/var-op-expand.mk
diff -u src/usr.bin/make/unit-tests/var-op-expand.mk:1.5 src/usr.bin/make/unit-tests/var-op-expand.mk:1.6
--- src/usr.bin/make/unit-tests/var-op-expand.mk:1.5	Sun Dec 27 20:45:52 2020
+++ src/usr.bin/make/unit-tests/var-op-expand.mk	Sun Dec 27 21:19:13 2020
@@ -1,4 +1,4 @@
-# $NetBSD: var-op-expand.mk,v 1.5 2020/12/27 20:45:52 rillig Exp $
+# $NetBSD: var-op-expand.mk,v 1.6 2020/12/27 21:19:13 rillig Exp $
 #
 # Tests for the := variable assignment operator, which expands its
 # right-hand side.
@@ -86,6 +86,36 @@ UNDEF=		Uwas undefined
 .endif
 
 
+# In variable assignments using the ':=' operator, undefined variables are
+# preserved, no matter how indirectly they are referenced.
+.undef REF3
+REF2=		<${REF3}>
+REF=		${REF2}
+VAR:=		${REF}
+REF3=		too late
+.if ${VAR} != ""
+.  error
+.endif
+
+
+# In variable assignments using the ':=' operator, '$$' are preserved, no
+# matter how indirectly they are referenced.
+REF2=		REF2:$$ 
+REF=		REF:$$  ${REF2}
+VAR:=		VAR:$$  ${REF}
+.if ${VAR} != "VAR:\$ \$\$ REF:\$ \$\$ REF2:\$ \$\$"
+.  error
+.endif
+
+
+# In variable assignments using the ':=' operator, '$$' are preserved in the
+# expressions of the top level, but not in expressions that are nested.
+VAR:=		top:$$ ${:Unest1\:\$\$} ${:Unest2${:U\:\$\$}}
+.if ${VAR} != "top:\$ nest1:\$ nest2:\$"
+.  error
+.endif
+
+
 # XXX: edge case: When a variable name refers to an undefined variable, the
 # behavior differs between the '=' and the ':=' assignment operators.
 # This bug exists since var.c 1.42 from 2000-05-11.



CVS commit: src/usr.bin/make/unit-tests

2020-12-27 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Dec 27 20:45:52 UTC 2020

Modified Files:
src/usr.bin/make/unit-tests: var-op-expand.mk

Log Message:
make(1): add tests for variable assignments using the ':=' operator


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/var-op-expand.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/var-op-expand.mk
diff -u src/usr.bin/make/unit-tests/var-op-expand.mk:1.4 src/usr.bin/make/unit-tests/var-op-expand.mk:1.5
--- src/usr.bin/make/unit-tests/var-op-expand.mk:1.4	Sun Nov  8 14:00:52 2020
+++ src/usr.bin/make/unit-tests/var-op-expand.mk	Sun Dec 27 20:45:52 2020
@@ -1,9 +1,90 @@
-# $NetBSD: var-op-expand.mk,v 1.4 2020/11/08 14:00:52 rillig Exp $
+# $NetBSD: var-op-expand.mk,v 1.5 2020/12/27 20:45:52 rillig Exp $
 #
 # Tests for the := variable assignment operator, which expands its
 # right-hand side.
 
-# TODO: Implementation
+
+# If the right-hand side does not contain a dollar sign, the ':=' assignment
+# operator has the same effect as the '=' assignment operator.
+VAR:=			value
+.if ${VAR} != "value"
+.  error
+.endif
+
+# When a ':=' assignment is performed, its right-hand side is evaluated and
+# expanded as far as possible.  Contrary to other situations, '$$' and
+# variable expressions based on undefined variables are preserved though.
+#
+# Whether a variable expression is undefined or not is determined at the end
+# of evaluating the expression.  The consequence is that ${:Ufallback} expands
+# to "fallback"; initially this expression is undefined since it is based on
+# the variable named "", which is guaranteed to be never defined, but at the
+# end of evaluating the expression ${:Ufallback}, the modifier ':U' has turned
+# the expression into a defined expression.
+
+
+# literal dollar signs
+VAR:=		$$  
+.if ${VAR} != "\$ \$\$ \$\$\$\$"
+.  error
+.endif
+
+
+# reference to a variable containing a literal dollar sign
+REF=		$$  
+VAR:=		${REF}
+REF=		too late
+.if ${VAR} != "\$ \$\$ \$\$\$\$"
+.  error
+.endif
+
+
+# reference to an undefined variable
+.undef UNDEF
+VAR:=		<${UNDEF}>
+UNDEF=		after
+.if ${VAR} != ""
+.  error
+.endif
+
+
+# reference to a variable whose name is computed from another variable
+REF2=		referred to
+REF=		REF2
+VAR:=		${${REF}}
+REF=		too late
+.if ${VAR} != "referred to"
+.  error
+.endif
+
+
+# expression with an indirect modifier referring to an undefined variable
+.undef UNDEF
+VAR:=		${:${UNDEF}}
+UNDEF=		Uwas undefined
+.if ${VAR} != "was undefined"
+.  error
+.endif
+
+
+# expression with an indirect modifier referring to another variable that
+# in turn refers to an undefined variable
+#
+# XXX: Even though this is a ':=' assignment, the '${UNDEF}' in the part of
+# the variable modifier is not preserved.  To preserve it, ParseModifierPart
+# would have to call VarSubstExpr somehow since this is the only piece of
+# code that takes care of this global variable.
+.undef UNDEF
+REF=		U${UNDEF}
+#.MAKEFLAGS: -dv
+VAR:=		${:${REF}}
+#.MAKEFLAGS: -d0
+REF=		too late
+UNDEF=		Uwas undefined
+.if ${VAR} != ""
+.  error
+.endif
+
 
 # XXX: edge case: When a variable name refers to an undefined variable, the
 # behavior differs between the '=' and the ':=' assignment operators.
@@ -18,6 +99,7 @@
 # preserveUndefined in VarAssign_EvalSubst), in the other expansion it expands
 # to an empty string.  This way, 2 variables are created using a single
 # variable assignment.  It's magic. :-/
+.undef UNDEF
 .MAKEFLAGS: -dv
 VAR_ASSIGN_${UNDEF}=	undef value
 VAR_SUBST_${UNDEF}:=	undef value



CVS commit: src/usr.bin/make/unit-tests

2020-12-27 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Dec 27 18:20:26 UTC 2020

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

Log Message:
make(1): add test for ParseDependencyTargetWord


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/deptgt.exp
cvs rdiff -u -r1.9 -r1.10 src/usr.bin/make/unit-tests/deptgt.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/deptgt.exp
diff -u src/usr.bin/make/unit-tests/deptgt.exp:1.5 src/usr.bin/make/unit-tests/deptgt.exp:1.6
--- src/usr.bin/make/unit-tests/deptgt.exp:1.5	Sun Nov 15 11:57:00 2020
+++ src/usr.bin/make/unit-tests/deptgt.exp	Sun Dec 27 18:20:26 2020
@@ -8,6 +8,7 @@ ParseDoDependency(: empty-source)
 ParseReadLine (37): '	: command for empty targets list'
 ParseReadLine (38): '.MAKEFLAGS: -d0'
 ParseDoDependency(.MAKEFLAGS: -d0)
+make: "deptgt.mk" line 46: Unknown modifier 'Z'
 make: Fatal errors encountered -- cannot continue
 make: stopped in unit-tests
 exit status 1

Index: src/usr.bin/make/unit-tests/deptgt.mk
diff -u src/usr.bin/make/unit-tests/deptgt.mk:1.9 src/usr.bin/make/unit-tests/deptgt.mk:1.10
--- src/usr.bin/make/unit-tests/deptgt.mk:1.9	Sun Nov 15 11:57:00 2020
+++ src/usr.bin/make/unit-tests/deptgt.mk	Sun Dec 27 18:20:26 2020
@@ -1,4 +1,4 @@
-# $NetBSD: deptgt.mk,v 1.9 2020/11/15 11:57:00 rillig Exp $
+# $NetBSD: deptgt.mk,v 1.10 2020/12/27 18:20:26 rillig Exp $
 #
 # Tests for special targets like .BEGIN or .SUFFIXES in dependency
 # declarations.
@@ -37,5 +37,13 @@ ${:U}: empty-source
 	: command for empty targets list
 .MAKEFLAGS: -d0
 
+# Just to show that a malformed expression is only expanded once in
+# ParseDependencyTargetWord.  The only way to produce an expression that
+# is well-formed on the first expansion and ill-formed on the second
+# expansion would be to use the variable modifier '::=' to modify the
+# targets.  This in turn would be such an extreme and unreliable edge case
+# that nobody uses it.
+{:U:Z}:
+
 all:
 	@:;



CVS commit: src/usr.bin/make/unit-tests

2020-12-27 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Dec 27 17:32:25 UTC 2020

Modified Files:
src/usr.bin/make/unit-tests: varmod-indirect.exp varmod-indirect.mk

Log Message:
make(1): split test for indirect modifiers into paragraphs


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/varmod-indirect.exp
cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/varmod-indirect.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/varmod-indirect.exp
diff -u src/usr.bin/make/unit-tests/varmod-indirect.exp:1.5 src/usr.bin/make/unit-tests/varmod-indirect.exp:1.6
--- src/usr.bin/make/unit-tests/varmod-indirect.exp:1.5	Sun Dec 27 17:17:46 2020
+++ src/usr.bin/make/unit-tests/varmod-indirect.exp	Sun Dec 27 17:32:25 2020
@@ -8,11 +8,11 @@ make: "varmod-indirect.mk" line 120: aft
 make: "varmod-indirect.mk" line 124: Unknown modifier 'Z'
 make: "varmod-indirect.mk" line 125: before
 make: "varmod-indirect.mk" line 125: after
-ParseReadLine (133): '_:=	before ${UNDEF} after'
+ParseReadLine (134): '_:=	before ${UNDEF} after'
 Global:_ = 
 Var_Parse: ${UNDEF} after with VARE_WANTRES|VARE_KEEP_DOLLAR
 Global:_ = before ${UNDEF} after
-ParseReadLine (135): '_:=	before ${UNDEF:${:US,a,a,}} after'
+ParseReadLine (137): '_:=	before ${UNDEF:${:US,a,a,}} after'
 Var_Parse: ${UNDEF:${:US,a,a,}} after with VARE_WANTRES|VARE_KEEP_DOLLAR
 Var_Parse: ${:US,a,a,}} after with VARE_WANTRES|VARE_KEEP_DOLLAR
 Applying ${:U...} to "" (VARE_WANTRES|VARE_KEEP_DOLLAR, none, VEF_UNDEF)
@@ -27,7 +27,7 @@ Var_Parse: ${:US,a,a,}} after with VARE_
 Applying ${:U...} to "" (VARE_WANTRES|VARE_KEEP_DOLLAR, none, VEF_UNDEF)
 Result of ${:US,a,a,} is "S,a,a," (VARE_WANTRES|VARE_KEEP_DOLLAR, none, VEF_UNDEF|VEF_DEF)
 Global:_ = before ${UNDEF:S,a,a,} after
-ParseReadLine (143): '_:=	before ${UNDEF:${:U}} after'
+ParseReadLine (147): '_:=	before ${UNDEF:${:U}} after'
 Var_Parse: ${UNDEF:${:U}} after with VARE_WANTRES|VARE_KEEP_DOLLAR
 Var_Parse: ${:U}} after with VARE_WANTRES|VARE_KEEP_DOLLAR
 Applying ${:U} to "" (VARE_WANTRES|VARE_KEEP_DOLLAR, none, VEF_UNDEF)
@@ -37,20 +37,20 @@ Var_Parse: ${:U}} after with VARE_WANTRE
 Applying ${:U} to "" (VARE_WANTRES|VARE_KEEP_DOLLAR, none, VEF_UNDEF)
 Result of ${:U} is "" (VARE_WANTRES|VARE_KEEP_DOLLAR, none, VEF_UNDEF|VEF_DEF)
 Global:_ = before ${UNDEF:} after
-ParseReadLine (147): '_:=	before ${UNDEF:${:UZ}} after'
+ParseReadLine (152): '_:=	before ${UNDEF:${:UZ}} after'
 Var_Parse: ${UNDEF:${:UZ}} after with VARE_WANTRES|VARE_KEEP_DOLLAR
 Var_Parse: ${:UZ}} after with VARE_WANTRES|VARE_KEEP_DOLLAR
 Applying ${:U...} to "" (VARE_WANTRES|VARE_KEEP_DOLLAR, none, VEF_UNDEF)
 Result of ${:UZ} is "Z" (VARE_WANTRES|VARE_KEEP_DOLLAR, none, VEF_UNDEF|VEF_DEF)
 Indirect modifier "Z" from "${:UZ}"
 Applying ${UNDEF:Z} to "" (VARE_WANTRES|VARE_KEEP_DOLLAR, none, VEF_UNDEF)
-make: "varmod-indirect.mk" line 147: Unknown modifier 'Z'
+make: "varmod-indirect.mk" line 152: Unknown modifier 'Z'
 Result of ${UNDEF:Z} is error (VARE_WANTRES|VARE_KEEP_DOLLAR, none, VEF_UNDEF)
 Var_Parse: ${:UZ}} after with VARE_WANTRES|VARE_KEEP_DOLLAR
 Applying ${:U...} to "" (VARE_WANTRES|VARE_KEEP_DOLLAR, none, VEF_UNDEF)
 Result of ${:UZ} is "Z" (VARE_WANTRES|VARE_KEEP_DOLLAR, none, VEF_UNDEF|VEF_DEF)
 Global:_ = before ${UNDEF:Z} after
-ParseReadLine (148): '.MAKEFLAGS: -d0'
+ParseReadLine (154): '.MAKEFLAGS: -d0'
 ParseDoDependency(.MAKEFLAGS: -d0)
 Global:.MAKEFLAGS =  -r -k -d 0 -d pv -d
 Global:.MAKEFLAGS =  -r -k -d 0 -d pv -d 0

Index: src/usr.bin/make/unit-tests/varmod-indirect.mk
diff -u src/usr.bin/make/unit-tests/varmod-indirect.mk:1.4 src/usr.bin/make/unit-tests/varmod-indirect.mk:1.5
--- src/usr.bin/make/unit-tests/varmod-indirect.mk:1.4	Sun Dec 27 17:17:46 2020
+++ src/usr.bin/make/unit-tests/varmod-indirect.mk	Sun Dec 27 17:32:25 2020
@@ -1,4 +1,4 @@
-# $NetBSD: varmod-indirect.mk,v 1.4 2020/12/27 17:17:46 rillig Exp $
+# $NetBSD: varmod-indirect.mk,v 1.5 2020/12/27 17:32:25 rillig Exp $
 #
 # Tests for indirect variable modifiers, such as in ${VAR:${M_modifiers}}.
 # These can be used for very basic purposes like converting a string to either
@@ -129,22 +129,28 @@ M_NoPrimes=	${PRIMES:${M_ListToSkip}}
 # Another slightly different evaluation context is the right-hand side of
 # a variable assignment using ':='.
 .MAKEFLAGS: -dpv
+
 # The undefined variable expression is kept as-is.
 _:=	before ${UNDEF} after
+
 # The undefined variable expression is kept as-is.
 _:=	before ${UNDEF:${:US,a,a,}} after
+
 # XXX: The subexpression ${:U} is fully defined, therefore it is expanded.
 # This results in ${UNDEF:}, which can lead to tricky parse errors later,
 # when the variable '_' is expanded further.
+#
 # XXX: What should be the correct strategy here?  One possibility is to
-# expand the defined subexpression and replace them with ${:U...}, just like
+# expand t

CVS commit: src/usr.bin/make/unit-tests

2020-12-27 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Dec 27 17:17:47 UTC 2020

Modified Files:
src/usr.bin/make/unit-tests: varmod-indirect.exp varmod-indirect.mk

Log Message:
make(1): add tests for parsing indirect modifiers in nested expressions


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/varmod-indirect.exp
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/varmod-indirect.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/varmod-indirect.exp
diff -u src/usr.bin/make/unit-tests/varmod-indirect.exp:1.4 src/usr.bin/make/unit-tests/varmod-indirect.exp:1.5
--- src/usr.bin/make/unit-tests/varmod-indirect.exp:1.4	Sun Dec 27 16:31:58 2020
+++ src/usr.bin/make/unit-tests/varmod-indirect.exp	Sun Dec 27 17:17:46 2020
@@ -1,8 +1,59 @@
 make: "varmod-indirect.mk" line 13: Unknown modifier '$'
-make: "varmod-indirect.mk" line 106: before
-make: "varmod-indirect.mk" line 106: after
-make: "varmod-indirect.mk" line 112: before
-make: "varmod-indirect.mk" line 112: after
+make: "varmod-indirect.mk" line 108: before
+make: "varmod-indirect.mk" line 108: after
+make: "varmod-indirect.mk" line 114: before
+make: "varmod-indirect.mk" line 114: after
+make: "varmod-indirect.mk" line 120: before
+make: "varmod-indirect.mk" line 120: after
+make: "varmod-indirect.mk" line 124: Unknown modifier 'Z'
+make: "varmod-indirect.mk" line 125: before
+make: "varmod-indirect.mk" line 125: after
+ParseReadLine (133): '_:=	before ${UNDEF} after'
+Global:_ = 
+Var_Parse: ${UNDEF} after with VARE_WANTRES|VARE_KEEP_DOLLAR
+Global:_ = before ${UNDEF} after
+ParseReadLine (135): '_:=	before ${UNDEF:${:US,a,a,}} after'
+Var_Parse: ${UNDEF:${:US,a,a,}} after with VARE_WANTRES|VARE_KEEP_DOLLAR
+Var_Parse: ${:US,a,a,}} after with VARE_WANTRES|VARE_KEEP_DOLLAR
+Applying ${:U...} to "" (VARE_WANTRES|VARE_KEEP_DOLLAR, none, VEF_UNDEF)
+Result of ${:US,a,a,} is "S,a,a," (VARE_WANTRES|VARE_KEEP_DOLLAR, none, VEF_UNDEF|VEF_DEF)
+Indirect modifier "S,a,a," from "${:US,a,a,}"
+Applying ${UNDEF:S...} to "" (VARE_WANTRES|VARE_KEEP_DOLLAR, none, VEF_UNDEF)
+Modifier part: "a"
+Modifier part: "a"
+ModifyWords: split "" into 1 words
+Result of ${UNDEF:S,a,a,} is "" (VARE_WANTRES|VARE_KEEP_DOLLAR, none, VEF_UNDEF)
+Var_Parse: ${:US,a,a,}} after with VARE_WANTRES|VARE_KEEP_DOLLAR
+Applying ${:U...} to "" (VARE_WANTRES|VARE_KEEP_DOLLAR, none, VEF_UNDEF)
+Result of ${:US,a,a,} is "S,a,a," (VARE_WANTRES|VARE_KEEP_DOLLAR, none, VEF_UNDEF|VEF_DEF)
+Global:_ = before ${UNDEF:S,a,a,} after
+ParseReadLine (143): '_:=	before ${UNDEF:${:U}} after'
+Var_Parse: ${UNDEF:${:U}} after with VARE_WANTRES|VARE_KEEP_DOLLAR
+Var_Parse: ${:U}} after with VARE_WANTRES|VARE_KEEP_DOLLAR
+Applying ${:U} to "" (VARE_WANTRES|VARE_KEEP_DOLLAR, none, VEF_UNDEF)
+Result of ${:U} is "" (VARE_WANTRES|VARE_KEEP_DOLLAR, none, VEF_UNDEF|VEF_DEF)
+Indirect modifier "" from "${:U}"
+Var_Parse: ${:U}} after with VARE_WANTRES|VARE_KEEP_DOLLAR
+Applying ${:U} to "" (VARE_WANTRES|VARE_KEEP_DOLLAR, none, VEF_UNDEF)
+Result of ${:U} is "" (VARE_WANTRES|VARE_KEEP_DOLLAR, none, VEF_UNDEF|VEF_DEF)
+Global:_ = before ${UNDEF:} after
+ParseReadLine (147): '_:=	before ${UNDEF:${:UZ}} after'
+Var_Parse: ${UNDEF:${:UZ}} after with VARE_WANTRES|VARE_KEEP_DOLLAR
+Var_Parse: ${:UZ}} after with VARE_WANTRES|VARE_KEEP_DOLLAR
+Applying ${:U...} to "" (VARE_WANTRES|VARE_KEEP_DOLLAR, none, VEF_UNDEF)
+Result of ${:UZ} is "Z" (VARE_WANTRES|VARE_KEEP_DOLLAR, none, VEF_UNDEF|VEF_DEF)
+Indirect modifier "Z" from "${:UZ}"
+Applying ${UNDEF:Z} to "" (VARE_WANTRES|VARE_KEEP_DOLLAR, none, VEF_UNDEF)
+make: "varmod-indirect.mk" line 147: Unknown modifier 'Z'
+Result of ${UNDEF:Z} is error (VARE_WANTRES|VARE_KEEP_DOLLAR, none, VEF_UNDEF)
+Var_Parse: ${:UZ}} after with VARE_WANTRES|VARE_KEEP_DOLLAR
+Applying ${:U...} to "" (VARE_WANTRES|VARE_KEEP_DOLLAR, none, VEF_UNDEF)
+Result of ${:UZ} is "Z" (VARE_WANTRES|VARE_KEEP_DOLLAR, none, VEF_UNDEF|VEF_DEF)
+Global:_ = before ${UNDEF:Z} after
+ParseReadLine (148): '.MAKEFLAGS: -d0'
+ParseDoDependency(.MAKEFLAGS: -d0)
+Global:.MAKEFLAGS =  -r -k -d 0 -d pv -d
+Global:.MAKEFLAGS =  -r -k -d 0 -d pv -d 0
 make: Fatal errors encountered -- cannot continue
 make: stopped in unit-tests
 exit status 1

Index: src/usr.bin/make/unit-tests/varmod-indirect.mk
diff -u src/usr.bin/make/unit-tests/varmod-indirect.mk:1.3 src/usr.bin/make/unit-tests/varmod-indirect.mk:1.4
--- src/usr.bin/make/unit-tests/varmod-indirect.mk:1.3	Sun Dec 27 16:31:58 2020
+++ src/usr.bin/make/unit-tests/varmod-indirect.mk	Sun Dec 27 17:17:46 2020
@@ -1,4 +1,4 @@
-# $NetBSD: varmod-indirect.mk,v 1.3 2020/12/27 16:31:58 rillig Exp $
+# $NetBSD: varmod-indirect.mk,v 1.4 2020/12/27 17:17:46 rillig Exp $
 #
 # Tests for indirect variable modifiers, such as in ${VAR:${M_modifiers}}.
 # These can be used for very basic purposes like converting a str

CVS commit: src/usr.bin/make/unit-tests

2020-12-27 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Dec 27 09:58:35 UTC 2020

Modified Files:
src/usr.bin/make/unit-tests: directive-for.exp directive-for.mk

Log Message:
make(1): add test for missing error handling in .for loop


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/unit-tests/directive-for.exp
cvs rdiff -u -r1.9 -r1.10 src/usr.bin/make/unit-tests/directive-for.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/directive-for.exp
diff -u src/usr.bin/make/unit-tests/directive-for.exp:1.7 src/usr.bin/make/unit-tests/directive-for.exp:1.8
--- src/usr.bin/make/unit-tests/directive-for.exp:1.7	Sun Nov 15 20:20:58 2020
+++ src/usr.bin/make/unit-tests/directive-for.exp	Sun Dec 27 09:58:35 2020
@@ -16,4 +16,9 @@ make: "directive-for.mk" line 140: ][ ][
 make: "directive-for.mk" line 140: }{ }{ }{
 make: "directive-for.mk" line 148: outer value value
 make: "directive-for.mk" line 148: outer "quoted" \"quoted\"
-exit status 0
+make: "directive-for.mk" line 154: Unknown modifier 'Z'
+make: "directive-for.mk" line 155: XXX: Not reached word1
+make: "directive-for.mk" line 155: XXX: Not reached word3
+make: Fatal errors encountered -- cannot continue
+make: stopped in unit-tests
+exit status 1

Index: src/usr.bin/make/unit-tests/directive-for.mk
diff -u src/usr.bin/make/unit-tests/directive-for.mk:1.9 src/usr.bin/make/unit-tests/directive-for.mk:1.10
--- src/usr.bin/make/unit-tests/directive-for.mk:1.9	Sun Nov 15 20:20:58 2020
+++ src/usr.bin/make/unit-tests/directive-for.mk	Sun Dec 27 09:58:35 2020
@@ -1,4 +1,4 @@
-# $NetBSD: directive-for.mk,v 1.9 2020/11/15 20:20:58 rillig Exp $
+# $NetBSD: directive-for.mk,v 1.10 2020/12/27 09:58:35 rillig Exp $
 #
 # Tests for the .for directive.
 #
@@ -148,5 +148,12 @@ var=	outer
 .  info ${var} ${var:Q} ${var:Q:Q}
 .endfor
 
+
+# XXX: A parse error or evaluation error in the items of the .for loop
+# should skip the whole loop.  As of 2020-12-27, the loop is expanded twice.
+.for var in word1 ${:Uword2:Z} word3
+.  info XXX: Not reached ${var}
+.endfor
+
 all:
 	@:;



CVS commit: src/usr.bin/make/unit-tests

2020-12-22 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Dec 22 19:38:44 UTC 2020

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

Log Message:
make(1): add test for undefined variable in dependency declaration


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/depsrc.exp
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/depsrc.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/depsrc.exp
diff -u src/usr.bin/make/unit-tests/depsrc.exp:1.1 src/usr.bin/make/unit-tests/depsrc.exp:1.2
--- src/usr.bin/make/unit-tests/depsrc.exp:1.1	Sun Aug 16 12:07:51 2020
+++ src/usr.bin/make/unit-tests/depsrc.exp	Tue Dec 22 19:38:44 2020
@@ -1 +1,4 @@
+: 'Undefined variables are expanded directly in the dependency'
+: 'declaration.  They are not preserved and maybe expanded later.'
+: 'This is in contrast to local variables such as ${.TARGET}.'
 exit status 0

Index: src/usr.bin/make/unit-tests/depsrc.mk
diff -u src/usr.bin/make/unit-tests/depsrc.mk:1.3 src/usr.bin/make/unit-tests/depsrc.mk:1.4
--- src/usr.bin/make/unit-tests/depsrc.mk:1.3	Sun Nov 15 20:20:58 2020
+++ src/usr.bin/make/unit-tests/depsrc.mk	Tue Dec 22 19:38:44 2020
@@ -1,4 +1,4 @@
-# $NetBSD: depsrc.mk,v 1.3 2020/11/15 20:20:58 rillig Exp $
+# $NetBSD: depsrc.mk,v 1.4 2020/12/22 19:38:44 rillig Exp $
 #
 # Tests for special sources (those starting with a dot, followed by
 # uppercase letters) in dependency declarations, such as .PHONY.
@@ -7,5 +7,20 @@
 
 # TODO: Test 'target: ${:U.SILENT}'
 
+# Demonstrate when exactly undefined variables are expanded in a dependency
+# declaration.
+target: .PHONY source-${DEFINED_LATER}
+#
+DEFINED_LATER=	later
+#
+source-: .PHONY
+	: 'Undefined variables are expanded directly in the dependency'
+	: 'declaration.  They are not preserved and maybe expanded later.'
+	: 'This is in contrast to local variables such as $${.TARGET}.'
+source-later: .PHONY
+	: 'Undefined variables are tried to be expanded in a dependency'
+	: 'declaration.  If that fails because the variable is undefined,'
+	: 'the expression is preserved and tried to be expanded later.'
+
 all:
 	@:;



CVS commit: src/usr.bin/make/unit-tests

2020-12-22 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Dec 22 08:57:23 UTC 2020

Modified Files:
src/usr.bin/make/unit-tests: opt-file.mk

Log Message:
make(1): fix comment in test about null bytes in makefiles


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/usr.bin/make/unit-tests/opt-file.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/opt-file.mk
diff -u src/usr.bin/make/unit-tests/opt-file.mk:1.10 src/usr.bin/make/unit-tests/opt-file.mk:1.11
--- src/usr.bin/make/unit-tests/opt-file.mk:1.10	Tue Dec 22 08:51:30 2020
+++ src/usr.bin/make/unit-tests/opt-file.mk	Tue Dec 22 08:57:23 2020
@@ -1,4 +1,4 @@
-# $NetBSD: opt-file.mk,v 1.10 2020/12/22 08:51:30 rillig Exp $
+# $NetBSD: opt-file.mk,v 1.11 2020/12/22 08:57:23 rillig Exp $
 #
 # Tests for the -f command line option.
 
@@ -54,9 +54,9 @@ line-with-trailing-whitespace: .PHONY
 	@${MAKE} -r -f opt-file-trailing-whitespace -V VAR
 	@rm opt-file-trailing-whitespace
 
-# If a file contains null bytes, the rest of the line is skipped, and parsing
-# continues in the next line.  Throughout the history of make, the behavior
-# has changed several times, sometimes knowingly, sometimes by accident.
+# If a makefile contains null bytes, it is an error.  Throughout the history
+# of make, the behavior has changed several times, sometimes intentionally,
+# sometimes by accident.
 #
 #	echo 'VAR=value' | tr 'l' '\0' > zero-byte.in
 #	printf '%s\n' 'all:' ': VAR=${VAR:Q}' >> zero-byte.in



CVS commit: src/usr.bin/make/unit-tests

2020-12-22 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Dec 22 08:23:12 UTC 2020

Modified Files:
src/usr.bin/make/unit-tests: opt-file.mk

Log Message:
make(1): clean up after test opt-file


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/usr.bin/make/unit-tests/opt-file.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/opt-file.mk
diff -u src/usr.bin/make/unit-tests/opt-file.mk:1.8 src/usr.bin/make/unit-tests/opt-file.mk:1.9
--- src/usr.bin/make/unit-tests/opt-file.mk:1.8	Tue Dec 22 08:05:08 2020
+++ src/usr.bin/make/unit-tests/opt-file.mk	Tue Dec 22 08:23:12 2020
@@ -1,4 +1,4 @@
-# $NetBSD: opt-file.mk,v 1.8 2020/12/22 08:05:08 rillig Exp $
+# $NetBSD: opt-file.mk,v 1.9 2020/12/22 08:23:12 rillig Exp $
 #
 # Tests for the -f command line option.
 
@@ -43,6 +43,7 @@ file-ending-in-backslash: .PHONY
 file-ending-in-backslash-mmap: .PHONY
 	@printf '%s' 'VAR=value\' > opt-file-backslash
 	@${MAKE} -r -f opt-file-backslash -V VAR
+	@rm opt-file-backslash
 
 # If a file contains null bytes, the rest of the line is skipped, and parsing
 # continues in the next line.  Throughout the history of make, the behavior



CVS commit: src/usr.bin/make/unit-tests

2020-12-21 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Dec 22 07:22:39 UTC 2020

Modified Files:
src/usr.bin/make/unit-tests: varmod-gmtime.mk varmod-localtime.mk

Log Message:
make(1): fix commit number in tests for :gmtime and :localtime


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/usr.bin/make/unit-tests/varmod-gmtime.mk
cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/varmod-localtime.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/varmod-gmtime.mk
diff -u src/usr.bin/make/unit-tests/varmod-gmtime.mk:1.8 src/usr.bin/make/unit-tests/varmod-gmtime.mk:1.9
--- src/usr.bin/make/unit-tests/varmod-gmtime.mk:1.8	Mon Dec 21 20:47:29 2020
+++ src/usr.bin/make/unit-tests/varmod-gmtime.mk	Tue Dec 22 07:22:39 2020
@@ -1,4 +1,4 @@
-# $NetBSD: varmod-gmtime.mk,v 1.8 2020/12/21 20:47:29 rillig Exp $
+# $NetBSD: varmod-gmtime.mk,v 1.9 2020/12/22 07:22:39 rillig Exp $
 #
 # Tests for the :gmtime variable modifier, which formats a timestamp
 # using strftime(3) in UTC.
@@ -114,14 +114,14 @@
 # ULONG_MAX, which got converted to -1.  This resulted in a time stamp of
 # the second before 1970.
 #
-# Since var.c 1.613, the overflow is detected and produces a parse error.
+# Since var.c 1.631, the overflow is detected and produces a parse error.
 .if ${:L:gmtime=1000} != ""
 .  error
 .else
 .  error
 .endif
 
-# Before var.c 1.613 from 2020-10-31, there was no error handling while
+# Before var.c 1.631 from 2020-10-31, there was no error handling while
 # parsing the :gmtime modifier, thus no error message is printed.  Parsing
 # stopped after the '=', and the remaining string was parsed for more variable
 # modifiers.  Because of the unknown modifier 'e' from the 'error', the whole

Index: src/usr.bin/make/unit-tests/varmod-localtime.mk
diff -u src/usr.bin/make/unit-tests/varmod-localtime.mk:1.6 src/usr.bin/make/unit-tests/varmod-localtime.mk:1.7
--- src/usr.bin/make/unit-tests/varmod-localtime.mk:1.6	Mon Dec 21 20:47:29 2020
+++ src/usr.bin/make/unit-tests/varmod-localtime.mk	Tue Dec 22 07:22:39 2020
@@ -1,4 +1,4 @@
-# $NetBSD: varmod-localtime.mk,v 1.6 2020/12/21 20:47:29 rillig Exp $
+# $NetBSD: varmod-localtime.mk,v 1.7 2020/12/22 07:22:39 rillig Exp $
 #
 # Tests for the :localtime variable modifier, which formats a timestamp
 # using strftime(3) in local time.
@@ -114,14 +114,14 @@
 # ULONG_MAX, which got converted to -1.  This resulted in a time stamp of
 # the second before 1970.
 #
-# Since var.c 1.613, the overflow is detected and produces a parse error.
+# Since var.c 1.631, the overflow is detected and produces a parse error.
 .if ${:L:localtime=1000} != ""
 .  error
 .else
 .  error
 .endif
 
-# Before var.c 1.613 from 2020-10-31, there was no error handling while
+# Before var.c 1.631 from 2020-10-31, there was no error handling while
 # parsing the :localtime modifier, thus no error message is printed.  Parsing
 # stopped after the '=', and the remaining string was parsed for more variable
 # modifiers.  Because of the unknown modifier 'e' from the 'error', the whole



CVS commit: src/usr.bin/make/unit-tests

2020-12-21 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Dec 21 20:47:29 UTC 2020

Modified Files:
src/usr.bin/make/unit-tests: Makefile varmod-gmtime.exp
varmod-gmtime.mk varmod-localtime.exp varmod-localtime.mk

Log Message:
make(1): align tests for :localtime with those for :gmtime

These tests had been almost the same before, now they are as similar as
possible again.


To generate a diff of this commit:
cvs rdiff -u -r1.255 -r1.256 src/usr.bin/make/unit-tests/Makefile
cvs rdiff -u -r1.8 -r1.9 src/usr.bin/make/unit-tests/varmod-gmtime.exp
cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/unit-tests/varmod-gmtime.mk
cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/varmod-localtime.exp \
src/usr.bin/make/unit-tests/varmod-localtime.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.255 src/usr.bin/make/unit-tests/Makefile:1.256
--- src/usr.bin/make/unit-tests/Makefile:1.255	Mon Dec 21 20:35:17 2020
+++ src/usr.bin/make/unit-tests/Makefile	Mon Dec 21 20:47:29 2020
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.255 2020/12/21 20:35:17 rillig Exp $
+# $NetBSD: Makefile,v 1.256 2020/12/21 20:47:29 rillig Exp $
 #
 # Unit tests for make(1)
 #
@@ -503,9 +503,6 @@ SED_CMDS.var-op-shell+=	\
 	-e 's,^${.SHELL:T}: [ 0-9:]*,,' \
 	-e '/command/s,No such.*,not found,'
 SED_CMDS.vardebug+=	-e 's,${.SHELL},,'
-SED_CMDS.varmod-localtime+=	-e 's,Tue Jan 19 04:14:08 2038,,'
-SED_CMDS.varmod-localtime+=	${:D FreeBSD i386 still has 32-bit time_t. }
-SED_CMDS.varmod-localtime+=	-e 's,Fri Dec 13 21:45:52 1901,,'
 SED_CMDS.varmod-subst-regex+= \
 			-e 's,\(Regex compilation error:\).*,\1 (details omitted),'
 SED_CMDS.varname-dot-parsedir=	-e '/in some cases/ s,^make: "[^"]*,make: ",'

Index: src/usr.bin/make/unit-tests/varmod-gmtime.exp
diff -u src/usr.bin/make/unit-tests/varmod-gmtime.exp:1.8 src/usr.bin/make/unit-tests/varmod-gmtime.exp:1.9
--- src/usr.bin/make/unit-tests/varmod-gmtime.exp:1.8	Mon Dec 21 20:35:17 2020
+++ src/usr.bin/make/unit-tests/varmod-gmtime.exp	Mon Dec 21 20:47:29 2020
@@ -1,18 +1,18 @@
-make: "varmod-gmtime.mk" line 57: Invalid time value: ${:U1593536400}} != "mtime=11593536400}"
+make: "varmod-gmtime.mk" line 60: Invalid time value: ${:U1593536400}} != "mtime=11593536400}"
 
-make: "varmod-gmtime.mk" line 57: Malformed conditional (${%Y:L:gmtime=${:U1593536400}} != "mtime=11593536400}")
-make: "varmod-gmtime.mk" line 67: Invalid time value: -1} != ""
+make: "varmod-gmtime.mk" line 60: Malformed conditional (${%Y:L:gmtime=${:U1593536400}} != "mtime=11593536400}")
+make: "varmod-gmtime.mk" line 70: Invalid time value: -1} != ""
 
-make: "varmod-gmtime.mk" line 67: Malformed conditional (${:L:gmtime=-1} != "")
-make: "varmod-gmtime.mk" line 76: Invalid time value:  1} != ""
+make: "varmod-gmtime.mk" line 70: Malformed conditional (${:L:gmtime=-1} != "")
+make: "varmod-gmtime.mk" line 79: Invalid time value:  1} != ""
 
-make: "varmod-gmtime.mk" line 76: Malformed conditional (${:L:gmtime= 1} != "")
-make: "varmod-gmtime.mk" line 115: Invalid time value: 1000} != ""
+make: "varmod-gmtime.mk" line 79: Malformed conditional (${:L:gmtime= 1} != "")
+make: "varmod-gmtime.mk" line 118: Invalid time value: 1000} != ""
 
-make: "varmod-gmtime.mk" line 115: Malformed conditional (${:L:gmtime=1000} != "")
-make: "varmod-gmtime.mk" line 126: Invalid time value: error} != ""
+make: "varmod-gmtime.mk" line 118: Malformed conditional (${:L:gmtime=1000} != "")
+make: "varmod-gmtime.mk" line 129: Invalid time value: error} != ""
 
-make: "varmod-gmtime.mk" line 126: Malformed conditional (${:L:gmtime=error} != "")
+make: "varmod-gmtime.mk" line 129: Malformed conditional (${:L:gmtime=error} != "")
 make: Fatal errors encountered -- cannot continue
 make: stopped in unit-tests
 exit status 1

Index: src/usr.bin/make/unit-tests/varmod-gmtime.mk
diff -u src/usr.bin/make/unit-tests/varmod-gmtime.mk:1.7 src/usr.bin/make/unit-tests/varmod-gmtime.mk:1.8
--- src/usr.bin/make/unit-tests/varmod-gmtime.mk:1.7	Mon Dec 21 20:35:17 2020
+++ src/usr.bin/make/unit-tests/varmod-gmtime.mk	Mon Dec 21 20:47:29 2020
@@ -1,8 +1,11 @@
-# $NetBSD: varmod-gmtime.mk,v 1.7 2020/12/21 20:35:17 rillig Exp $
+# $NetBSD: varmod-gmtime.mk,v 1.8 2020/12/21 20:47:29 rillig Exp $
 #
 # Tests for the :gmtime variable modifier, which formats a timestamp
 # using strftime(3) in UTC.
 
+.if ${TZ:Uundefined} != "undefined"	# see unit-tests/Makefile
+.  error
+.endif
 
 # Test for the default time format, %c.  Since the time always varies, it's
 # only possible to check for the general format here.  The names of the

Index: src/usr.bin/make/unit-tests/varmod-localtime.exp
diff -u src/usr.bin/make/unit-tests/varmod-localtime.exp:1.5 src/usr.bin/make/unit-test

CVS commit: src/usr.bin/make/unit-tests

2020-12-21 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Dec 21 20:35:17 UTC 2020

Modified Files:
src/usr.bin/make/unit-tests: Makefile varmod-gmtime.exp
varmod-gmtime.mk

Log Message:
make(1): move tests for :gmtime to parse time

It's easier to have both the expressions and the expected values in a
single file.  This also allows for flexible handling of multiple
acceptable outputs, in this case for 32-bit time_t.


To generate a diff of this commit:
cvs rdiff -u -r1.254 -r1.255 src/usr.bin/make/unit-tests/Makefile
cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/unit-tests/varmod-gmtime.exp
cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/varmod-gmtime.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.254 src/usr.bin/make/unit-tests/Makefile:1.255
--- src/usr.bin/make/unit-tests/Makefile:1.254	Mon Dec 21 18:22:31 2020
+++ src/usr.bin/make/unit-tests/Makefile	Mon Dec 21 20:35:17 2020
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.254 2020/12/21 18:22:31 sjg Exp $
+# $NetBSD: Makefile,v 1.255 2020/12/21 20:35:17 rillig Exp $
 #
 # Unit tests for make(1)
 #
@@ -503,9 +503,6 @@ SED_CMDS.var-op-shell+=	\
 	-e 's,^${.SHELL:T}: [ 0-9:]*,,' \
 	-e '/command/s,No such.*,not found,'
 SED_CMDS.vardebug+=	-e 's,${.SHELL},,'
-SED_CMDS.varmod-gmtime+=	-e 's,Tue Jan 19 03:14:08 2038,,'
-SED_CMDS.varmod-gmtime+=	${:D FreeBSD i386 still has 32-bit time_t. }
-SED_CMDS.varmod-gmtime+=	-e 's,Fri Dec 13 20:45:52 1901,,'
 SED_CMDS.varmod-localtime+=	-e 's,Tue Jan 19 04:14:08 2038,,'
 SED_CMDS.varmod-localtime+=	${:D FreeBSD i386 still has 32-bit time_t. }
 SED_CMDS.varmod-localtime+=	-e 's,Fri Dec 13 21:45:52 1901,,'

Index: src/usr.bin/make/unit-tests/varmod-gmtime.exp
diff -u src/usr.bin/make/unit-tests/varmod-gmtime.exp:1.7 src/usr.bin/make/unit-tests/varmod-gmtime.exp:1.8
--- src/usr.bin/make/unit-tests/varmod-gmtime.exp:1.7	Mon Nov 30 21:10:15 2020
+++ src/usr.bin/make/unit-tests/varmod-gmtime.exp	Mon Dec 21 20:35:17 2020
@@ -1,27 +1,18 @@
-mod-gmtime:
-%Y
-2020
-%Y
-localtime == localtime
-mod-gmtime-indirect:
-make: Invalid time value: ${:U1593536400}}
+make: "varmod-gmtime.mk" line 57: Invalid time value: ${:U1593536400}} != "mtime=11593536400}"
 
-mtime=1593536400}
-parse-errors:
-make: Invalid time value: -1}.
+make: "varmod-gmtime.mk" line 57: Malformed conditional (${%Y:L:gmtime=${:U1593536400}} != "mtime=11593536400}")
+make: "varmod-gmtime.mk" line 67: Invalid time value: -1} != ""
 
-: -1 becomes mtime=-1}.
-make: Invalid time value:  1}.
+make: "varmod-gmtime.mk" line 67: Malformed conditional (${:L:gmtime=-1} != "")
+make: "varmod-gmtime.mk" line 76: Invalid time value:  1} != ""
 
-: space 1 becomes mtime= 1}.
-: 0 becomes ok.
-: 1 becomes Thu Jan  1 00:00:01 1970.
-: INT32_MAX becomes Tue Jan 19 03:14:07 2038.
-: INT32_MAX + 1 becomes .
-make: Invalid time value: 1000}.
+make: "varmod-gmtime.mk" line 76: Malformed conditional (${:L:gmtime= 1} != "")
+make: "varmod-gmtime.mk" line 115: Invalid time value: 1000} != ""
 
-: overflow becomes mtime=1000}.
-make: Invalid time value: error}.
+make: "varmod-gmtime.mk" line 115: Malformed conditional (${:L:gmtime=1000} != "")
+make: "varmod-gmtime.mk" line 126: Invalid time value: error} != ""
 
-: letter becomes mtime=error}.
-exit status 0
+make: "varmod-gmtime.mk" line 126: Malformed conditional (${:L:gmtime=error} != "")
+make: Fatal errors encountered -- cannot continue
+make: stopped in unit-tests
+exit status 1

Index: src/usr.bin/make/unit-tests/varmod-gmtime.mk
diff -u src/usr.bin/make/unit-tests/varmod-gmtime.mk:1.6 src/usr.bin/make/unit-tests/varmod-gmtime.mk:1.7
--- src/usr.bin/make/unit-tests/varmod-gmtime.mk:1.6	Sat Oct 31 20:30:06 2020
+++ src/usr.bin/make/unit-tests/varmod-gmtime.mk	Mon Dec 21 20:35:17 2020
@@ -1,11 +1,8 @@
-# $NetBSD: varmod-gmtime.mk,v 1.6 2020/10/31 20:30:06 rillig Exp $
+# $NetBSD: varmod-gmtime.mk,v 1.7 2020/12/21 20:35:17 rillig Exp $
 #
 # Tests for the :gmtime variable modifier, which formats a timestamp
 # using strftime(3) in UTC.
 
-all:	mod-gmtime
-all:	mod-gmtime-indirect
-all:	parse-errors
 
 # Test for the default time format, %c.  Since the time always varies, it's
 # only possible to check for the general format here.  The names of the
@@ -15,73 +12,122 @@ all:	parse-errors
 .  error
 .endif
 
-mod-gmtime:
-	@echo $@:
 
-	# modifier name too short
-	@echo ${%Y:L:gmtim=1593536400}
+# modifier name too short, falling back to the SysV modifier.
+.if ${%Y:L:gmtim=1593536400} != "%Y"
+.  error
+.endif
+
+
+# 2020-07-01T00:00:00Z
+.if ${%Y:L:gmtime=1593536400} != "2020"
+.  error
+.endif
+
+
+# modifier name too long, falling back to the SysV modifier.
+.if ${%Y:L:gmtimer=1593536400} != "%Y"
+.  error
+.endif
+
+
+# If the m

CVS commit: src/usr.bin/make/unit-tests

2020-12-21 Thread Simon J. Gerraty
Module Name:src
Committed By:   sjg
Date:   Mon Dec 21 18:22:31 UTC 2020

Modified Files:
src/usr.bin/make/unit-tests: Makefile

Log Message:
Set default for .MAKE.OS once


To generate a diff of this commit:
cvs rdiff -u -r1.253 -r1.254 src/usr.bin/make/unit-tests/Makefile

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.253 src/usr.bin/make/unit-tests/Makefile:1.254
--- src/usr.bin/make/unit-tests/Makefile:1.253	Sun Dec 20 19:37:23 2020
+++ src/usr.bin/make/unit-tests/Makefile	Mon Dec 21 18:22:31 2020
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.253 2020/12/20 19:37:23 rillig Exp $
+# $NetBSD: Makefile,v 1.254 2020/12/21 18:22:31 sjg Exp $
 #
 # Unit tests for make(1)
 #
@@ -31,7 +31,8 @@
 # src/tests/usr.bin/make/t_make.sh.
 #
 
-# we use this below but we might be an older make
+# we use these below but we might be an older make
+.MAKE.OS?= ${uname -s:L:sh}
 .MAKE.UID?= ${id -u:L:sh}
 
 # Each test is in a sub-makefile.
@@ -587,7 +588,7 @@ LANG=		C
 
 MAKE_TEST_ENV?=	MALLOC_OPTIONS="JA"	# for jemalloc
 
-.if ${.MAKE.OS:U${uname -s:L:sh}} == "NetBSD"
+.if ${.MAKE.OS} == "NetBSD"
 LIMIT_RESOURCES?=	ulimit -v 20
 .endif
 LIMIT_RESOURCES?=	:



CVS commit: src/usr.bin/make/unit-tests

2020-12-20 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Dec 20 23:29:50 UTC 2020

Modified Files:
src/usr.bin/make/unit-tests: varmod-to-many-words.mk
varmod-to-one-word.mk

Log Message:
make(1): add tests for :tW and :tw modifiers


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/varmod-to-many-words.mk \
src/usr.bin/make/unit-tests/varmod-to-one-word.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/varmod-to-many-words.mk
diff -u src/usr.bin/make/unit-tests/varmod-to-many-words.mk:1.2 src/usr.bin/make/unit-tests/varmod-to-many-words.mk:1.3
--- src/usr.bin/make/unit-tests/varmod-to-many-words.mk:1.2	Sun Aug 16 14:25:16 2020
+++ src/usr.bin/make/unit-tests/varmod-to-many-words.mk	Sun Dec 20 23:29:50 2020
@@ -1,9 +1,21 @@
-# $NetBSD: varmod-to-many-words.mk,v 1.2 2020/08/16 14:25:16 rillig Exp $
+# $NetBSD: varmod-to-many-words.mk,v 1.3 2020/12/20 23:29:50 rillig Exp $
 #
 # Tests for the :tw modifier, which treats the variable as many words,
 # to undo a previous :tW modifier.
 
-# TODO: Implementation
+SENTENCE=	The quick brown fox jumps over the lazy brown dog.
+
+.if ${SENTENCE:tw:[#]} != 10
+.  error
+.endif
+.if ${SENTENCE:tW:[#]} != 1
+.  error
+.endif
+
+# Protect against accidental freeing of the variable value.
+.if ${SENTENCE} != "The quick brown fox jumps over the lazy brown dog."
+.  error
+.endif
 
 all:
 	@:;
Index: src/usr.bin/make/unit-tests/varmod-to-one-word.mk
diff -u src/usr.bin/make/unit-tests/varmod-to-one-word.mk:1.2 src/usr.bin/make/unit-tests/varmod-to-one-word.mk:1.3
--- src/usr.bin/make/unit-tests/varmod-to-one-word.mk:1.2	Sun Aug 16 14:25:16 2020
+++ src/usr.bin/make/unit-tests/varmod-to-one-word.mk	Sun Dec 20 23:29:50 2020
@@ -1,9 +1,21 @@
-# $NetBSD: varmod-to-one-word.mk,v 1.2 2020/08/16 14:25:16 rillig Exp $
+# $NetBSD: varmod-to-one-word.mk,v 1.3 2020/12/20 23:29:50 rillig Exp $
 #
 # Tests for the :tW variable modifier, which treats the variable value
 # as a single word, for all following modifiers.
 
-# TODO: Implementation
+SENTENCE=	The quick brown fox jumps over the lazy brown dog.
+
+.if ${SENTENCE:tW:[#]} != 1
+.  error
+.endif
+.if ${SENTENCE:tw:[#]} != 10
+.  error
+.endif
+
+# Protect against accidental freeing of the variable value.
+.if ${SENTENCE} != "The quick brown fox jumps over the lazy brown dog."
+.  error
+.endif
 
 all:
 	@:;



CVS commit: src/usr.bin/make/unit-tests

2020-12-20 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Dec 20 22:57:40 UTC 2020

Modified Files:
src/usr.bin/make/unit-tests: varmod-extension.exp varmod-extension.mk
varmod-head.exp varmod-head.mk varmod-root.exp varmod-root.mk
varmod-tail.exp varmod-tail.mk

Log Message:
make(1): add tests for variable modifiers on trailing slashes


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/varmod-extension.exp \
src/usr.bin/make/unit-tests/varmod-head.exp \
src/usr.bin/make/unit-tests/varmod-root.exp \
src/usr.bin/make/unit-tests/varmod-tail.exp
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/varmod-extension.mk \
src/usr.bin/make/unit-tests/varmod-head.mk \
src/usr.bin/make/unit-tests/varmod-root.mk \
src/usr.bin/make/unit-tests/varmod-tail.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/varmod-extension.exp
diff -u src/usr.bin/make/unit-tests/varmod-extension.exp:1.2 src/usr.bin/make/unit-tests/varmod-extension.exp:1.3
--- src/usr.bin/make/unit-tests/varmod-extension.exp:1.2	Sun Aug 23 15:09:15 2020
+++ src/usr.bin/make/unit-tests/varmod-extension.exp	Sun Dec 20 22:57:40 2020
@@ -7,4 +7,5 @@ extension of 'a.a' is 'a'
 extension of '.gitignore' is 'gitignore'
 extension of 'a' is ''
 extension of 'a.a' is 'a'
+extension of 'trailing/' is ''
 exit status 0
Index: src/usr.bin/make/unit-tests/varmod-head.exp
diff -u src/usr.bin/make/unit-tests/varmod-head.exp:1.2 src/usr.bin/make/unit-tests/varmod-head.exp:1.3
--- src/usr.bin/make/unit-tests/varmod-head.exp:1.2	Sun Aug 23 15:09:15 2020
+++ src/usr.bin/make/unit-tests/varmod-head.exp	Sun Dec 20 22:57:40 2020
@@ -7,4 +7,5 @@ head (dirname) of 'a.a' is '.'
 head (dirname) of '.gitignore' is '.'
 head (dirname) of 'a' is '.'
 head (dirname) of 'a.a' is '.'
+head (dirname) of 'trailing/' is 'trailing'
 exit status 0
Index: src/usr.bin/make/unit-tests/varmod-root.exp
diff -u src/usr.bin/make/unit-tests/varmod-root.exp:1.2 src/usr.bin/make/unit-tests/varmod-root.exp:1.3
--- src/usr.bin/make/unit-tests/varmod-root.exp:1.2	Sun Aug 23 15:09:15 2020
+++ src/usr.bin/make/unit-tests/varmod-root.exp	Sun Dec 20 22:57:40 2020
@@ -7,4 +7,5 @@ root of 'a.a' is 'a'
 root of '.gitignore' is ''
 root of 'a' is 'a'
 root of 'a.a' is 'a'
+root of 'trailing/' is 'trailing/'
 exit status 0
Index: src/usr.bin/make/unit-tests/varmod-tail.exp
diff -u src/usr.bin/make/unit-tests/varmod-tail.exp:1.2 src/usr.bin/make/unit-tests/varmod-tail.exp:1.3
--- src/usr.bin/make/unit-tests/varmod-tail.exp:1.2	Sun Aug 23 15:09:15 2020
+++ src/usr.bin/make/unit-tests/varmod-tail.exp	Sun Dec 20 22:57:40 2020
@@ -7,4 +7,5 @@ tail (basename) of 'a.a' is 'a.a'
 tail (basename) of '.gitignore' is '.gitignore'
 tail (basename) of 'a' is 'a'
 tail (basename) of 'a.a' is 'a.a'
+tail (basename) of 'trailing/' is ''
 exit status 0

Index: src/usr.bin/make/unit-tests/varmod-extension.mk
diff -u src/usr.bin/make/unit-tests/varmod-extension.mk:1.3 src/usr.bin/make/unit-tests/varmod-extension.mk:1.4
--- src/usr.bin/make/unit-tests/varmod-extension.mk:1.3	Sun Aug 23 15:09:15 2020
+++ src/usr.bin/make/unit-tests/varmod-extension.mk	Sun Dec 20 22:57:40 2020
@@ -1,9 +1,9 @@
-# $NetBSD: varmod-extension.mk,v 1.3 2020/08/23 15:09:15 rillig Exp $
+# $NetBSD: varmod-extension.mk,v 1.4 2020/12/20 22:57:40 rillig Exp $
 #
 # Tests for the :E variable modifier, which returns the filename extension
 # of each word in the variable.
 
 all:
-.for path in a/b/c def a.b.c a.b/c a a.a .gitignore a a.a
+.for path in a/b/c def a.b.c a.b/c a a.a .gitignore a a.a trailing/
 	@echo "extension of '"${path:Q}"' is '"${path:E:Q}"'"
 .endfor
Index: src/usr.bin/make/unit-tests/varmod-head.mk
diff -u src/usr.bin/make/unit-tests/varmod-head.mk:1.3 src/usr.bin/make/unit-tests/varmod-head.mk:1.4
--- src/usr.bin/make/unit-tests/varmod-head.mk:1.3	Sun Aug 23 15:09:15 2020
+++ src/usr.bin/make/unit-tests/varmod-head.mk	Sun Dec 20 22:57:40 2020
@@ -1,9 +1,9 @@
-# $NetBSD: varmod-head.mk,v 1.3 2020/08/23 15:09:15 rillig Exp $
+# $NetBSD: varmod-head.mk,v 1.4 2020/12/20 22:57:40 rillig Exp $
 #
 # Tests for the :H variable modifier, which returns the dirname of
 # each of the words in the variable value.
 
 all:
-.for path in a/b/c def a.b.c a.b/c a a.a .gitignore a a.a
+.for path in a/b/c def a.b.c a.b/c a a.a .gitignore a a.a trailing/
 	@echo "head (dirname) of '"${path:Q}"' is '"${path:H:Q}"'"
 .endfor
Index: src/usr.bin/make/unit-tests/varmod-root.mk
diff -u src/usr.bin/make/unit-tests/varmod-root.mk:1.3 src/usr.bin/make/unit-tests/varmod-root.mk:1.4
--- src/usr.bin/make/unit-tests/varmod-root.mk:1.3	Sun Aug 23 15:09:15 2020
+++ src/usr.bin/make/unit-tests/varmod-root.mk	Sun Dec 20 22:57:40 2020
@@ -1,9 +1,9 @@
-# $NetBSD: varmod-root.mk,v 1.3 2020/08/23 15:09:15 rillig Exp $
+# $NetBSD: varmod-root.mk,v 1.4 2020/12/20 22:57:40 

CVS commit: src/usr.bin/make/unit-tests

2020-12-20 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Dec 20 19:37:23 UTC 2020

Modified Files:
src/usr.bin/make/unit-tests: Makefile varmod-edge.exp

Log Message:
make(1): include line numbers in output of test varmod-edge.mk

Suppressing the line numbers does not provide much benefit, given that
the test file doesn't change often.


To generate a diff of this commit:
cvs rdiff -u -r1.252 -r1.253 src/usr.bin/make/unit-tests/Makefile
cvs rdiff -u -r1.8 -r1.9 src/usr.bin/make/unit-tests/varmod-edge.exp

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.252 src/usr.bin/make/unit-tests/Makefile:1.253
--- src/usr.bin/make/unit-tests/Makefile:1.252	Sat Dec 19 16:00:17 2020
+++ src/usr.bin/make/unit-tests/Makefile	Sun Dec 20 19:37:23 2020
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.252 2020/12/19 16:00:17 rillig Exp $
+# $NetBSD: Makefile,v 1.253 2020/12/20 19:37:23 rillig Exp $
 #
 # Unit tests for make(1)
 #
@@ -502,7 +502,6 @@ SED_CMDS.var-op-shell+=	\
 	-e 's,^${.SHELL:T}: [ 0-9:]*,,' \
 	-e '/command/s,No such.*,not found,'
 SED_CMDS.vardebug+=	-e 's,${.SHELL},,'
-SED_CMDS.varmod-edge+=	-e 's, line [0-9]*:, line omitted:,'
 SED_CMDS.varmod-gmtime+=	-e 's,Tue Jan 19 03:14:08 2038,,'
 SED_CMDS.varmod-gmtime+=	${:D FreeBSD i386 still has 32-bit time_t. }
 SED_CMDS.varmod-gmtime+=	-e 's,Fri Dec 13 20:45:52 1901,,'

Index: src/usr.bin/make/unit-tests/varmod-edge.exp
diff -u src/usr.bin/make/unit-tests/varmod-edge.exp:1.8 src/usr.bin/make/unit-tests/varmod-edge.exp:1.9
--- src/usr.bin/make/unit-tests/varmod-edge.exp:1.8	Sat Aug  8 13:27:42 2020
+++ src/usr.bin/make/unit-tests/varmod-edge.exp	Sun Dec 20 19:37:23 2020
@@ -1,22 +1,22 @@
-make: "varmod-edge.mk" line omitted: ok M-paren
-make: "varmod-edge.mk" line omitted: ok M-mixed
-make: "varmod-edge.mk" line omitted: ok M-unescape
+make: "varmod-edge.mk" line 166: ok M-paren
+make: "varmod-edge.mk" line 166: ok M-mixed
+make: "varmod-edge.mk" line 166: ok M-unescape
 make: Unclosed variable specification (expecting '}') for "" (value "*)") modifier U
-make: "varmod-edge.mk" line omitted: ok M-nest-mix
-make: "varmod-edge.mk" line omitted: ok M-nest-brk
-make: "varmod-edge.mk" line omitted: ok M-pat-err
-make: "varmod-edge.mk" line omitted: ok M-bsbs
-make: "varmod-edge.mk" line omitted: ok M-bs1-par
-make: "varmod-edge.mk" line omitted: ok M-bs2-par
-make: "varmod-edge.mk" line omitted: ok M-128
-make: "varmod-edge.mk" line omitted: ok eq-ext
-make: "varmod-edge.mk" line omitted: ok eq-q
-make: "varmod-edge.mk" line omitted: ok eq-bs
+make: "varmod-edge.mk" line 166: ok M-nest-mix
+make: "varmod-edge.mk" line 166: ok M-nest-brk
+make: "varmod-edge.mk" line 166: ok M-pat-err
+make: "varmod-edge.mk" line 166: ok M-bsbs
+make: "varmod-edge.mk" line 166: ok M-bs1-par
+make: "varmod-edge.mk" line 166: ok M-bs2-par
+make: "varmod-edge.mk" line 166: ok M-128
+make: "varmod-edge.mk" line 166: ok eq-ext
+make: "varmod-edge.mk" line 166: ok eq-q
+make: "varmod-edge.mk" line 166: ok eq-bs
 make: Unfinished modifier for INP.eq-esc ('=' missing)
-make: "varmod-edge.mk" line omitted: ok eq-esc
-make: "varmod-edge.mk" line omitted: ok colon
+make: "varmod-edge.mk" line 166: ok eq-esc
+make: "varmod-edge.mk" line 166: ok colon
 make: Unknown modifier ':'
 make: Unknown modifier ':'
-make: "varmod-edge.mk" line omitted: ok colons
+make: "varmod-edge.mk" line 166: ok colons
 ok
 exit status 0



CVS commit: src/usr.bin/make/unit-tests

2020-12-20 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Dec 20 19:29:06 UTC 2020

Modified Files:
src/usr.bin/make/unit-tests: modmisc.exp modmisc.mk varmod-indirect.exp
varmod-indirect.mk

Log Message:
make(1): move tests for indirect modifiers around

The next commit will error out on unknown modifiers and influence the
exit status.  The test modmisc.mk contains both parse time tests and run
time tests.  To prevent the latter from being run, the parse error is
moved to varmod-indirect.mk, which only contains parse time tests.


To generate a diff of this commit:
cvs rdiff -u -r1.46 -r1.47 src/usr.bin/make/unit-tests/modmisc.exp
cvs rdiff -u -r1.51 -r1.52 src/usr.bin/make/unit-tests/modmisc.mk
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/varmod-indirect.exp \
src/usr.bin/make/unit-tests/varmod-indirect.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/modmisc.exp
diff -u src/usr.bin/make/unit-tests/modmisc.exp:1.46 src/usr.bin/make/unit-tests/modmisc.exp:1.47
--- src/usr.bin/make/unit-tests/modmisc.exp:1.46	Sun Aug 23 15:18:43 2020
+++ src/usr.bin/make/unit-tests/modmisc.exp	Sun Dec 20 19:29:06 2020
@@ -1,4 +1,3 @@
-make: Unknown modifier '$'
 path=':/bin:/tmp::/:.:/no/such/dir:.'
 path='/bin:/tmp:/:/no/such/dir'
 path='/bin:/tmp:/:/no/such/dir'

Index: src/usr.bin/make/unit-tests/modmisc.mk
diff -u src/usr.bin/make/unit-tests/modmisc.mk:1.51 src/usr.bin/make/unit-tests/modmisc.mk:1.52
--- src/usr.bin/make/unit-tests/modmisc.mk:1.51	Sun Nov 15 20:20:58 2020
+++ src/usr.bin/make/unit-tests/modmisc.mk	Sun Dec 20 19:29:06 2020
@@ -1,4 +1,4 @@
-# $NetBSD: modmisc.mk,v 1.51 2020/11/15 20:20:58 rillig Exp $
+# $NetBSD: modmisc.mk,v 1.52 2020/12/20 19:29:06 rillig Exp $
 #
 # miscellaneous modifier tests
 
@@ -63,30 +63,3 @@ mod-quote:
 # Cover the bmake_realloc in Str_Words.
 mod-break-many-words:
 	@echo $@: ${UNDEF:U:range=500:[#]}
-
-# To apply a modifier indirectly via another variable, the whole
-# modifier must be put into a single variable expression.
-.if ${value:L:${:US}${:U,value,replacement,}} != "S,value,replacement,}"
-.  warning unexpected
-.endif
-
-# Adding another level of indirection (the 2 nested :U expressions) helps.
-.if ${value:L:${:U${:US}${:U,value,replacement,}}} != "replacement"
-.  warning unexpected
-.endif
-
-# Multiple indirect modifiers can be applied one after another as long as
-# they are separated with colons.
-.if ${value:L:${:US,a,A,}:${:US,e,E,}} != "vAluE"
-.  warning unexpected
-.endif
-
-# An indirect variable that evaluates to the empty string is allowed though.
-# This makes it possible to define conditional modifiers, like this:
-#
-# M.little-endian=	S,1234,4321,
-# M.big-endian=		# none
-.if ${value:L:${:Dempty}S,a,A,} != "vAlue"
-.  warning unexpected
-.endif
-

Index: src/usr.bin/make/unit-tests/varmod-indirect.exp
diff -u src/usr.bin/make/unit-tests/varmod-indirect.exp:1.1 src/usr.bin/make/unit-tests/varmod-indirect.exp:1.2
--- src/usr.bin/make/unit-tests/varmod-indirect.exp:1.1	Tue Dec  1 22:16:36 2020
+++ src/usr.bin/make/unit-tests/varmod-indirect.exp	Sun Dec 20 19:29:06 2020
@@ -1 +1,2 @@
+make: Unknown modifier '$'
 exit status 0
Index: src/usr.bin/make/unit-tests/varmod-indirect.mk
diff -u src/usr.bin/make/unit-tests/varmod-indirect.mk:1.1 src/usr.bin/make/unit-tests/varmod-indirect.mk:1.2
--- src/usr.bin/make/unit-tests/varmod-indirect.mk:1.1	Tue Dec  1 22:16:36 2020
+++ src/usr.bin/make/unit-tests/varmod-indirect.mk	Sun Dec 20 19:29:06 2020
@@ -1,4 +1,4 @@
-# $NetBSD: varmod-indirect.mk,v 1.1 2020/12/01 22:16:36 rillig Exp $
+# $NetBSD: varmod-indirect.mk,v 1.2 2020/12/20 19:29:06 rillig Exp $
 #
 # Tests for indirect variable modifiers, such as in ${VAR:${M_modifiers}}.
 # These can be used for very basic purposes like converting a string to either
@@ -8,6 +8,36 @@
 # TODO: Since when are indirect modifiers supported?
 
 
+# To apply a modifier indirectly via another variable, the whole
+# modifier must be put into a single variable expression.
+.if ${value:L:${:US}${:U,value,replacement,}} != "S,value,replacement,}"
+.  warning unexpected
+.endif
+
+
+# Adding another level of indirection (the 2 nested :U expressions) helps.
+.if ${value:L:${:U${:US}${:U,value,replacement,}}} != "replacement"
+.  warning unexpected
+.endif
+
+
+# Multiple indirect modifiers can be applied one after another as long as
+# they are separated with colons.
+.if ${value:L:${:US,a,A,}:${:US,e,E,}} != "vAluE"
+.  warning unexpected
+.endif
+
+
+# An indirect variable that evaluates to the empty string is allowed though.
+# This makes it possible to define conditional modifiers, like this:
+#
+# M.little-endian=	S,1234,4321,
+# M.big-endian=		# none
+.if ${value:L:${:Dempty}S,a,A,} != "vAlue"
+.  warning unexpected
+.endif
+
+
 # The nested variable expression expands to "tu", and this is interpreted as
 # a variable modifi

CVS commit: src/usr.bin/make/unit-tests

2020-12-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Dec 19 20:35:39 UTC 2020

Modified Files:
src/usr.bin/make/unit-tests: directive-undef.mk

Log Message:
make(1): add tests for undefining variables with exotic names


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/directive-undef.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/directive-undef.mk
diff -u src/usr.bin/make/unit-tests/directive-undef.mk:1.6 src/usr.bin/make/unit-tests/directive-undef.mk:1.7
--- src/usr.bin/make/unit-tests/directive-undef.mk:1.6	Sun Dec 13 01:07:54 2020
+++ src/usr.bin/make/unit-tests/directive-undef.mk	Sat Dec 19 20:35:39 2020
@@ -1,4 +1,4 @@
-# $NetBSD: directive-undef.mk,v 1.6 2020/12/13 01:07:54 rillig Exp $
+# $NetBSD: directive-undef.mk,v 1.7 2020/12/19 20:35:39 rillig Exp $
 #
 # Tests for the .undef directive.
 #
@@ -16,7 +16,34 @@
 .  warning $1$2$3
 .endif
 
+# Without any arguments, .undef tries to delete the variable with the empty
+# name, which never exists; see varname-empty.mk.
 .undef# oops: missing argument
 
+
+# It must be possible to undefine variables whose name includes spaces.
+SPACE=		${:U }
+${SPACE}=	space
+.if !defined(${SPACE})
+.  error
+.endif
+.undef ${SPACE}
+.if defined(${SPACE})
+.  error
+.endif
+
+
+# It must be possible to undefine variables whose name includes dollars.
+DOLLAR=		$$
+${DOLLAR}=	dollar
+.if !defined(${DOLLAR})
+.  error
+.endif
+.undef ${DOLLAR}
+.if defined(${DOLLAR})
+.  error
+.endif
+
+
 all:
 	@:;



CVS commit: src/usr.bin/make/unit-tests

2020-12-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Dec 19 19:49:01 UTC 2020

Modified Files:
src/usr.bin/make/unit-tests: directive-elif.exp directive-elif.mk

Log Message:
make(1): rewrite tests for misspelled .elif directive

Put the simple tests at the top, demonstrating that there are already
some cases in which the misspelled directive is detected.  It's not
detected though if the surrounding conditional branch is skipped.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/directive-elif.exp
cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/directive-elif.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/directive-elif.exp
diff -u src/usr.bin/make/unit-tests/directive-elif.exp:1.5 src/usr.bin/make/unit-tests/directive-elif.exp:1.6
--- src/usr.bin/make/unit-tests/directive-elif.exp:1.5	Thu Nov 12 19:46:36 2020
+++ src/usr.bin/make/unit-tests/directive-elif.exp	Sat Dec 19 19:49:01 2020
@@ -1,17 +1,21 @@
-make: "directive-elif.mk" line 7: begin .elif misspellings tests, part 1
-make: "directive-elif.mk" line 9: 1-then
-make: "directive-elif.mk" line 18: begin .elif misspellings tests, part 2
-make: "directive-elif.mk" line 29: begin .elif misspellings tests, part 3
-make: "directive-elif.mk" line 41: which branch is taken on misspelling after false?
-make: "directive-elif.mk" line 49: else
-make: "directive-elif.mk" line 52: which branch is taken on misspelling after true?
-make: "directive-elif.mk" line 54: 1-then
-make: "directive-elif.mk" line 55: Unknown directive "elsif"
-make: "directive-elif.mk" line 56: 1-elsif
-make: "directive-elif.mk" line 57: Unknown directive "elsif"
-make: "directive-elif.mk" line 58: 2-elsif
-make: "directive-elif.mk" line 64: if-less elif
-make: "directive-elif.mk" line 69: warning: extra elif
+make: "directive-elif.mk" line 47: Unknown directive "elsif"
+make: "directive-elif.mk" line 52: This branch is taken.
+make: "directive-elif.mk" line 60: Unknown directive "elsif"
+make: "directive-elif.mk" line 63: This branch is taken.
+make: "directive-elif.mk" line 69: This branch is taken.
+make: "directive-elif.mk" line 89: Unknown directive "elsif"
+make: "directive-elif.mk" line 90: This misspelling is detected.
+make: "directive-elif.mk" line 91: This branch is taken because of the .else.
+make: "directive-elif.mk" line 109: What happens on misspelling in a skipped branch?
+make: "directive-elif.mk" line 119: else
+make: "directive-elif.mk" line 122: What happens on misspelling in a taken branch?
+make: "directive-elif.mk" line 124: 1-then
+make: "directive-elif.mk" line 125: Unknown directive "elsif"
+make: "directive-elif.mk" line 126: 1-elsif
+make: "directive-elif.mk" line 127: Unknown directive "elsif"
+make: "directive-elif.mk" line 128: 2-elsif
+make: "directive-elif.mk" line 134: if-less elif
+make: "directive-elif.mk" line 139: warning: extra elif
 make: Fatal errors encountered -- cannot continue
 make: stopped in unit-tests
 exit status 1

Index: src/usr.bin/make/unit-tests/directive-elif.mk
diff -u src/usr.bin/make/unit-tests/directive-elif.mk:1.6 src/usr.bin/make/unit-tests/directive-elif.mk:1.7
--- src/usr.bin/make/unit-tests/directive-elif.mk:1.6	Thu Nov 12 19:46:36 2020
+++ src/usr.bin/make/unit-tests/directive-elif.mk	Sat Dec 19 19:49:01 2020
@@ -1,55 +1,125 @@
-# $NetBSD: directive-elif.mk,v 1.6 2020/11/12 19:46:36 rillig Exp $
+# $NetBSD: directive-elif.mk,v 1.7 2020/12/19 19:49:01 rillig Exp $
 #
 # Tests for the .elif directive.
+#
+# Misspellings of the .elif directive are not always detected.  They are only
+# detected if the conditional branch directly above it is taken.  In all other
+# cases, make skips over the skipped branch as fast as possible, looking only
+# at the initial '.' of the line and whether the directive is one of the known
+# conditional directives.  All other directives are silently ignored, as they
+# could be variable assignments or dependency declarations as well, and
+# deciding this would cost time.
+
 
 # TODO: Implementation
 
-.info begin .elif misspellings tests, part 1
-.if 1
-.  info 1-then
-.elif 1# ok
-.  info 1-elif
-.elsif 1			# oops: misspelled
-.  info 1-elsif
-.elseif 1			# oops: misspelled
-.  info 1-elseif
+
+# Misspelling '.elsif' below an .if branch that is not taken.
+.if 0
+.  info This branch is not taken.
+# As of 2020-12-19, the misspelling is not recognized as a conditional
+# directive and is thus silently skipped.
+#
+# Since the .if condition evaluated to false, this whole branch is not taken.
+.elsif 0
+.  info XXX: This misspelling is not detected.
+.  info This branch is not taken.
+# Even if the misspelling were detected, the branch would not be taken
+# since the condition of the '.elsif' evaluates to false as well.
 .endif
 
-.info begin .elif misspellings tests, part 2
+
+# Misspelling '.elsif' below an .if bran

CVS commit: src/usr.bin/make/unit-tests

2020-12-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Dec 19 12:40:01 UTC 2020

Modified Files:
src/usr.bin/make/unit-tests: directive-for-lines.exp
directive-for-lines.mk directive-info.exp directive-info.mk

Log Message:
make(1): add test for backslash continuation lines in .for loops

This ensures that the line numbers for messages are the expected onces
in .for loops.

While experimenting with the backslash continuation lines, I noticed
that the reported line numbers for these are based on the number of
completely parsed physical lines, which nicely cancels out the + 1 that
has to be added for producing human-readable 1-based line numbers.  It
would be more correct to report the parse errors on the first affected
line.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/directive-for-lines.exp \
src/usr.bin/make/unit-tests/directive-for-lines.mk
cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/directive-info.exp
cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/directive-info.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/directive-for-lines.exp
diff -u src/usr.bin/make/unit-tests/directive-for-lines.exp:1.2 src/usr.bin/make/unit-tests/directive-for-lines.exp:1.3
--- src/usr.bin/make/unit-tests/directive-for-lines.exp:1.2	Sat Dec 19 12:24:46 2020
+++ src/usr.bin/make/unit-tests/directive-for-lines.exp	Sat Dec 19 12:40:00 2020
@@ -1,9 +1,9 @@
-make: "directive-for-lines.mk" line 18: expect 18
-make: "directive-for-lines.mk" line 18: expect 18
-make: "directive-for-lines.mk" line 24: expect 24
-make: "directive-for-lines.mk" line 18: expect 18
-make: "directive-for-lines.mk" line 18: expect 18
-make: "directive-for-lines.mk" line 24: expect 24
+make: "directive-for-lines.mk" line 23: expect 23
+make: "directive-for-lines.mk" line 23: expect 23
+make: "directive-for-lines.mk" line 30: expect 30
+make: "directive-for-lines.mk" line 23: expect 23
+make: "directive-for-lines.mk" line 23: expect 23
+make: "directive-for-lines.mk" line 30: expect 30
 make: no target to make.
 
 make: stopped in unit-tests
Index: src/usr.bin/make/unit-tests/directive-for-lines.mk
diff -u src/usr.bin/make/unit-tests/directive-for-lines.mk:1.2 src/usr.bin/make/unit-tests/directive-for-lines.mk:1.3
--- src/usr.bin/make/unit-tests/directive-for-lines.mk:1.2	Sat Dec 19 12:24:46 2020
+++ src/usr.bin/make/unit-tests/directive-for-lines.mk	Sat Dec 19 12:40:00 2020
@@ -1,4 +1,4 @@
-# $NetBSD: directive-for-lines.mk,v 1.2 2020/12/19 12:24:46 rillig Exp $
+# $NetBSD: directive-for-lines.mk,v 1.3 2020/12/19 12:40:00 rillig Exp $
 #
 # Tests for the line numbers that are reported in .for loops.
 #
@@ -9,18 +9,24 @@
 
 .for outer in a b
 
-# comment
+# comment \
+# continued comment
 
 .for inner in 1 2
 
-# comment
+# comment \
+# continued comment
 
-.info expect 18
+VAR= \
+	multi-line
+
+.info expect 23
 
 .endfor
 
-# comment
+# comment \
+# continued comment
 
-.info expect 24
+.info expect 30
 
 .endfor

Index: src/usr.bin/make/unit-tests/directive-info.exp
diff -u src/usr.bin/make/unit-tests/directive-info.exp:1.4 src/usr.bin/make/unit-tests/directive-info.exp:1.5
--- src/usr.bin/make/unit-tests/directive-info.exp:1.4	Sun Dec 13 01:07:54 2020
+++ src/usr.bin/make/unit-tests/directive-info.exp	Sat Dec 19 12:40:00 2020
@@ -9,6 +9,7 @@ make: "directive-info.mk" line 18: Unkno
 make: "directive-info.mk" line 19: Unknown directive "info"
 make: "directive-info.mk" line 22: Unknown directive "info-message"
 make: "directive-info.mk" line 23: no-target: no-source
+make: "directive-info.mk" line 32: expect line 30 for multi-line message
 make: Fatal errors encountered -- cannot continue
 make: stopped in unit-tests
 exit status 1

Index: src/usr.bin/make/unit-tests/directive-info.mk
diff -u src/usr.bin/make/unit-tests/directive-info.mk:1.6 src/usr.bin/make/unit-tests/directive-info.mk:1.7
--- src/usr.bin/make/unit-tests/directive-info.mk:1.6	Sun Dec 13 01:10:22 2020
+++ src/usr.bin/make/unit-tests/directive-info.mk	Sat Dec 19 12:40:00 2020
@@ -1,4 +1,4 @@
-# $NetBSD: directive-info.mk,v 1.6 2020/12/13 01:10:22 rillig Exp $
+# $NetBSD: directive-info.mk,v 1.7 2020/12/19 12:40:00 rillig Exp $
 #
 # Tests for the .info directive.
 
@@ -23,5 +23,13 @@
 .info no-target: no-source	# This is a .info directive, not a dependency.
 # See directive.mk for more tests of this kind.
 
+# Since at least 2002-01-01, the line number that is used in error messages
+# and the .info directives is the number of completely read lines.  For the
+# following multi-line directive, this means that the reported line number is
+# the one of the last line, not the first line.
+.info expect line 30 for\
+	multi$\
+	-line message
+
 all:
 	@:;



CVS commit: src/usr.bin/make/unit-tests

2020-12-14 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Dec 14 21:02:25 UTC 2020

Modified Files:
src/usr.bin/make/unit-tests: directive-if.exp directive-if.mk

Log Message:
make(1): add tests for parsing .if conditions


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/directive-if.exp
cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/unit-tests/directive-if.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/directive-if.exp
diff -u src/usr.bin/make/unit-tests/directive-if.exp:1.6 src/usr.bin/make/unit-tests/directive-if.exp:1.7
--- src/usr.bin/make/unit-tests/directive-if.exp:1.6	Sun Nov 15 20:20:58 2020
+++ src/usr.bin/make/unit-tests/directive-if.exp	Mon Dec 14 21:02:25 2020
@@ -10,6 +10,8 @@ make: "directive-if.mk" line 57: Quotes 
 make: "directive-if.mk" line 66: Don't do this, always put a space after a directive.
 make: "directive-if.mk" line 70: Don't do this, always put a space after a directive.
 make: "directive-if.mk" line 76: Don't do this, always put a space around comparison operators.
+make: "directive-if.mk" line 82: Don't do this, always put a space after a directive.
+make: "directive-if.mk" line 86: Don't do this, always put a space after a directive.
 make: Fatal errors encountered -- cannot continue
 make: stopped in unit-tests
 exit status 1

Index: src/usr.bin/make/unit-tests/directive-if.mk
diff -u src/usr.bin/make/unit-tests/directive-if.mk:1.7 src/usr.bin/make/unit-tests/directive-if.mk:1.8
--- src/usr.bin/make/unit-tests/directive-if.mk:1.7	Sun Nov 15 20:20:58 2020
+++ src/usr.bin/make/unit-tests/directive-if.mk	Mon Dec 14 21:02:25 2020
@@ -1,4 +1,4 @@
-# $NetBSD: directive-if.mk,v 1.7 2020/11/15 20:20:58 rillig Exp $
+# $NetBSD: directive-if.mk,v 1.8 2020/12/14 21:02:25 rillig Exp $
 #
 # Tests for the .if directive.
 #
@@ -78,4 +78,12 @@
 .  error
 .endif
 
+.if(1)
+.  info Don't do this, always put a space after a directive.
+.endif
+
+.if!0
+.  info Don't do this, always put a space after a directive.
+.endif
+
 all:



CVS commit: src/usr.bin/make/unit-tests

2020-12-14 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Dec 14 20:57:32 UTC 2020

Modified Files:
src/usr.bin/make/unit-tests: directive-endif.exp directive-endif.mk

Log Message:
make(1): add more tests for parsing .endif


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/directive-endif.exp
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/directive-endif.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/directive-endif.exp
diff -u src/usr.bin/make/unit-tests/directive-endif.exp:1.1 src/usr.bin/make/unit-tests/directive-endif.exp:1.2
--- src/usr.bin/make/unit-tests/directive-endif.exp:1.1	Sun Aug 16 12:07:51 2020
+++ src/usr.bin/make/unit-tests/directive-endif.exp	Mon Dec 14 20:57:31 2020
@@ -1 +1,4 @@
-exit status 0
+make: "directive-endif.mk" line 42: Unknown directive "endifx"
+make: Fatal errors encountered -- cannot continue
+make: stopped in unit-tests
+exit status 1

Index: src/usr.bin/make/unit-tests/directive-endif.mk
diff -u src/usr.bin/make/unit-tests/directive-endif.mk:1.3 src/usr.bin/make/unit-tests/directive-endif.mk:1.4
--- src/usr.bin/make/unit-tests/directive-endif.mk:1.3	Thu Nov 12 22:40:11 2020
+++ src/usr.bin/make/unit-tests/directive-endif.mk	Mon Dec 14 20:57:31 2020
@@ -1,4 +1,4 @@
-# $NetBSD: directive-endif.mk,v 1.3 2020/11/12 22:40:11 rillig Exp $
+# $NetBSD: directive-endif.mk,v 1.4 2020/12/14 20:57:31 rillig Exp $
 #
 # Tests for the .endif directive.
 #
@@ -23,5 +23,24 @@
 .if 2
 .endif # comment
 
+# Only whitespace and comments are allowed after an '.endif', but nothing
+# else.
+# XXX: Missing error message
+.if 1
+.endif0
+
+# Only whitespace and comments are allowed after an '.endif', but nothing
+# else.
+# XXX: Missing error message
+.if 1
+.endif/
+
+# After an '.endif', no other letter must occur.  This 'endifx' is not
+# parsed as an 'endif', therefore another '.endif' must follow to balance
+# the directives.
+.if 1
+.endifx
+.endif # to close the preceding '.if'
+
 all:
 	@:;



CVS commit: src/usr.bin/make/unit-tests

2020-12-14 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Dec 14 20:28:09 UTC 2020

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

Log Message:
make(1): add test for variable expressions after a parse error

These variable expressions don't need to be expanded, and they aren't.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/cond-eof.exp \
src/usr.bin/make/unit-tests/cond-eof.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-eof.exp
diff -u src/usr.bin/make/unit-tests/cond-eof.exp:1.1 src/usr.bin/make/unit-tests/cond-eof.exp:1.2
--- src/usr.bin/make/unit-tests/cond-eof.exp:1.1	Mon Dec 14 20:23:50 2020
+++ src/usr.bin/make/unit-tests/cond-eof.exp	Mon Dec 14 20:28:09 2020
@@ -1,9 +1,9 @@
 side effect
-make: "cond-eof.mk" line 14: Malformed conditional (0 ${SIDE_EFFECT})
+make: "cond-eof.mk" line 15: Malformed conditional (0 ${SIDE_EFFECT} ${SIDE_EFFECT2})
 side effect
-make: "cond-eof.mk" line 16: Malformed conditional (1 ${SIDE_EFFECT})
+make: "cond-eof.mk" line 17: Malformed conditional (1 ${SIDE_EFFECT} ${SIDE_EFFECT2})
 side effect
-make: "cond-eof.mk" line 18: Malformed conditional ((0) ${SIDE_EFFECT})
+make: "cond-eof.mk" line 19: Malformed conditional ((0) ${SIDE_EFFECT} ${SIDE_EFFECT2})
 make: Fatal errors encountered -- cannot continue
 make: stopped in unit-tests
 exit status 1
Index: src/usr.bin/make/unit-tests/cond-eof.mk
diff -u src/usr.bin/make/unit-tests/cond-eof.mk:1.1 src/usr.bin/make/unit-tests/cond-eof.mk:1.2
--- src/usr.bin/make/unit-tests/cond-eof.mk:1.1	Mon Dec 14 20:23:50 2020
+++ src/usr.bin/make/unit-tests/cond-eof.mk	Mon Dec 14 20:28:09 2020
@@ -1,9 +1,10 @@
-# $NetBSD: cond-eof.mk,v 1.1 2020/12/14 20:23:50 rillig Exp $
+# $NetBSD: cond-eof.mk,v 1.2 2020/12/14 20:28:09 rillig Exp $
 #
 # Tests for parsing conditions, especially the end of such conditions, which
 # are represented as the token TOK_EOF.
 
 SIDE_EFFECT=	${:!echo 'side effect' 1>&2!}
+SIDE_EFFECT2=	${:!echo 'side effect 2' 1>&2!}
 
 # In the following conditions, ${SIDE_EFFECT} is the position of the first
 # parse error.  It is always fully evaluated, even if it were not necessary
@@ -11,9 +12,9 @@ SIDE_EFFECT=	${:!echo 'side effect' 1>&2
 # an edge case that does not occur during normal operation, therefore there
 # is no need to optimize for this case, and it would slow down the common
 # case as well.
-.if 0 ${SIDE_EFFECT}
+.if 0 ${SIDE_EFFECT} ${SIDE_EFFECT2}
 .endif
-.if 1 ${SIDE_EFFECT}
+.if 1 ${SIDE_EFFECT} ${SIDE_EFFECT2}
 .endif
-.if (0) ${SIDE_EFFECT}
+.if (0) ${SIDE_EFFECT} ${SIDE_EFFECT2}
 .endif



CVS commit: src/usr.bin/make/unit-tests

2020-12-13 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Dec 13 19:08:20 UTC 2020

Modified Files:
src/usr.bin/make/unit-tests: compat-error.exp compat-error.mk
varname-make_print_var_on_error-jobs.exp
varname-make_print_var_on_error-jobs.mk
varname-make_print_var_on_error.exp
varname-make_print_var_on_error.mk

Log Message:
make(1): add tests for variable expansion in .ERROR handling


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/compat-error.exp \
src/usr.bin/make/unit-tests/compat-error.mk \
src/usr.bin/make/unit-tests/varname-make_print_var_on_error-jobs.exp \
src/usr.bin/make/unit-tests/varname-make_print_var_on_error-jobs.mk
cvs rdiff -u -r1.2 -r1.3 \
src/usr.bin/make/unit-tests/varname-make_print_var_on_error.exp
cvs rdiff -u -r1.4 -r1.5 \
src/usr.bin/make/unit-tests/varname-make_print_var_on_error.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/compat-error.exp
diff -u src/usr.bin/make/unit-tests/compat-error.exp:1.1 src/usr.bin/make/unit-tests/compat-error.exp:1.2
--- src/usr.bin/make/unit-tests/compat-error.exp:1.1	Sun Dec 13 17:44:31 2020
+++ src/usr.bin/make/unit-tests/compat-error.exp	Sun Dec 13 19:08:20 2020
@@ -1,15 +1,15 @@
 : Making success1 out of nothing.
 : Making fail1 out of nothing.
-false
+false 'fail1' '${.TARGET}' '$${.TARGET}'
 *** Error code 1 (continuing)
 : Making success2 out of nothing.
 : Making fail2 out of nothing.
-false
+false 'fail2' '${.TARGET}' '$${.TARGET}'
 *** Error code 1 (continuing)
 : Making success3 out of nothing.
 
 Stop.
 make: stopped in unit-tests
-target: success3
-command:
+.ERROR target: 
+.ERROR command: <>
 exit status 1
Index: src/usr.bin/make/unit-tests/compat-error.mk
diff -u src/usr.bin/make/unit-tests/compat-error.mk:1.1 src/usr.bin/make/unit-tests/compat-error.mk:1.2
--- src/usr.bin/make/unit-tests/compat-error.mk:1.1	Sun Dec 13 17:44:31 2020
+++ src/usr.bin/make/unit-tests/compat-error.mk	Sun Dec 13 19:08:20 2020
@@ -1,4 +1,4 @@
-# $NetBSD: compat-error.mk,v 1.1 2020/12/13 17:44:31 rillig Exp $
+# $NetBSD: compat-error.mk,v 1.2 2020/12/13 19:08:20 rillig Exp $
 #
 # Test detailed error handling in compat mode.
 #
@@ -26,8 +26,8 @@ success1 success2 success3:
 
 fail1 fail2:
 	: Making ${.TARGET} out of nothing.
-	false
+	false '${.TARGET}' '$${.TARGET}' '{.TARGET}'
 
 .ERROR:
-	@echo target: ${.ERROR_TARGET}
-	@echo command: ${.ERROR_CMD}
+	@echo ${.TARGET} target: '<'${.ERROR_TARGET:Q}'>'
+	@echo ${.TARGET} command: '<'${.ERROR_CMD:Q}'>'
Index: src/usr.bin/make/unit-tests/varname-make_print_var_on_error-jobs.exp
diff -u src/usr.bin/make/unit-tests/varname-make_print_var_on_error-jobs.exp:1.1 src/usr.bin/make/unit-tests/varname-make_print_var_on_error-jobs.exp:1.2
--- src/usr.bin/make/unit-tests/varname-make_print_var_on_error-jobs.exp:1.1	Fri Oct 23 06:18:23 2020
+++ src/usr.bin/make/unit-tests/varname-make_print_var_on_error-jobs.exp	Sun Dec 13 19:08:20 2020
@@ -1,7 +1,8 @@
-fail
+echo fail all; false 'all' '${.TARGET}' '$${.TARGET}'
+fail all
 *** [all] Error code 1
 
 make: stopped in unit-tests
 .ERROR_TARGET='all'
-.ERROR_CMD='@: command before @echo fail; false @: command after, with variable expressions expanded'
+.ERROR_CMD='@: before '${.TARGET}' '${.TARGET}' '$${.TARGET}' echo fail ${.TARGET}; false '${.TARGET}' '${.TARGET}' '$${.TARGET}' @: after '${.TARGET}' '${.TARGET}' '$${.TARGET}''
 exit status 1
Index: src/usr.bin/make/unit-tests/varname-make_print_var_on_error-jobs.mk
diff -u src/usr.bin/make/unit-tests/varname-make_print_var_on_error-jobs.mk:1.1 src/usr.bin/make/unit-tests/varname-make_print_var_on_error-jobs.mk:1.2
--- src/usr.bin/make/unit-tests/varname-make_print_var_on_error-jobs.mk:1.1	Fri Oct 23 06:18:23 2020
+++ src/usr.bin/make/unit-tests/varname-make_print_var_on_error-jobs.mk	Sun Dec 13 19:08:20 2020
@@ -1,4 +1,4 @@
-# $NetBSD: varname-make_print_var_on_error-jobs.mk,v 1.1 2020/10/23 06:18:23 rillig Exp $
+# $NetBSD: varname-make_print_var_on_error-jobs.mk,v 1.2 2020/12/13 19:08:20 rillig Exp $
 #
 # Tests for the special MAKE_PRINT_VAR_ON_ERROR variable, which prints the
 # values of selected variables on error.
@@ -9,6 +9,13 @@
 # The commands in .ERROR_CMD are space-separated.  Since each command usually
 # contains spaces as well, this value is only intended as a first hint to what
 # happened.  For more details, use the debug options -de, -dj, -dl, -dn, -dx.
+#
+# See also:
+#	compat-error.mk
+
+# XXX: As of 2020-12-13, PrintOnError calls Var_Subst with VAR_GLOBAL, which
+# does not expand the node-local variables like .TARGET.  This results in the
+# double '${.TARGET}' in the output.
 
 # As of 2020-10-23, .ERROR_CMD only works in parallel mode.
 .MAKEFLAGS: -j1
@@ -16,6 +23,6 @@
 MAKE_PRINT_VAR_ON_ERROR=	.ERROR_TARGET .ERROR_CMD
 
 all:
-	@: command before
-	@e

CVS commit: src/usr.bin/make/unit-tests

2020-12-12 Thread Simon J. Gerraty
Module Name:src
Committed By:   sjg
Date:   Sun Dec 13 05:13:38 UTC 2020

Modified Files:
src/usr.bin/make/unit-tests: Makefile sh-errctl.exp

Log Message:
Prune job debug output that may appear out of order.

A race between child and parent means that we cannot
guarantee whether all child output is seen before we call
JobClosePipes, thus intervening debug output can appear
before or after the last child output.


To generate a diff of this commit:
cvs rdiff -u -r1.247 -r1.248 src/usr.bin/make/unit-tests/Makefile
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/sh-errctl.exp

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.247 src/usr.bin/make/unit-tests/Makefile:1.248
--- src/usr.bin/make/unit-tests/Makefile:1.247	Sun Dec 13 02:09:33 2020
+++ src/usr.bin/make/unit-tests/Makefile	Sun Dec 13 05:13:38 2020
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.247 2020/12/13 02:09:33 sjg Exp $
+# $NetBSD: Makefile,v 1.248 2020/12/13 05:13:38 sjg Exp $
 #
 # Unit tests for make(1)
 #
@@ -537,11 +537,10 @@ STD_SED_CMDS.dg1+=	-e 's,^\(MAKE *=\) .*
 
 # Omit details such as process IDs from the output of the -dj option.
 STD_SED_CMDS.dj= \
+	-e '/Process/d;/JobFinish:/d' \
 	-e 's,^\(Job_TokenWithdraw\)([0-9]*),\1(),' \
 	-e 's,^([0-9][0-9]*) \(withdrew token\),() \1,' \
 	-e 's, \(pid\) [0-9][0-9]*, \1 ,' \
-	-e 's,^\(Process\) [0-9][0-9]*,\1 ,' \
-	-e 's,^\(JobFinish:\) [0-9][0-9]*,\1 ,' \
 	-e 's,^\(	Command:\) .*,\1 ,'
 
 # Reduce the noise for tests running with the -n option, since there is no

Index: src/usr.bin/make/unit-tests/sh-errctl.exp
diff -u src/usr.bin/make/unit-tests/sh-errctl.exp:1.1 src/usr.bin/make/unit-tests/sh-errctl.exp:1.2
--- src/usr.bin/make/unit-tests/sh-errctl.exp:1.1	Sat Dec 12 15:06:11 2020
+++ src/usr.bin/make/unit-tests/sh-errctl.exp	Sun Dec 13 05:13:38 2020
@@ -22,8 +22,6 @@ job 0, status 3, flags ---, pid 
 silent
 ignerr
 always
-Process  exited/stopped status 0.
-JobFinish:  [all], status 0
 Job_TokenWithdraw(): aborting 0, running 0
 () withdrew token
 exit status 0



  1   2   3   4   5   6   7   >