Module Name: src
Committed By: rillig
Date: Sat Dec 5 13:01:33 UTC 2020
Modified Files:
src/usr.bin/make: var.c
src/usr.bin/make/unit-tests: varmod-sysv.exp varmod-sysv.mk
Log Message:
make(1): improve explanation of tests for the SysV modifier
To generate a diff of this commit:
cvs rdiff -u -r1.701 -r1.702 src/usr.bin/make/var.c
cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/varmod-sysv.exp
cvs rdiff -u -r1.11 -r1.12 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/var.c
diff -u src/usr.bin/make/var.c:1.701 src/usr.bin/make/var.c:1.702
--- src/usr.bin/make/var.c:1.701 Fri Dec 4 22:47:57 2020
+++ src/usr.bin/make/var.c Sat Dec 5 13:01:33 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: var.c,v 1.701 2020/12/04 22:47:57 rillig Exp $ */
+/* $NetBSD: var.c,v 1.702 2020/12/05 13:01:33 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -130,7 +130,7 @@
#include "metachar.h"
/* "@(#)var.c 8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.701 2020/12/04 22:47:57 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.702 2020/12/05 13:01:33 rillig Exp $");
#define VAR_DEBUG1(fmt, arg1) DEBUG1(VAR, fmt, arg1)
#define VAR_DEBUG2(fmt, arg1, arg2) DEBUG2(VAR, fmt, arg1, arg2)
@@ -1195,7 +1195,7 @@ SysVMatch(const char *word, const char *
percent = strchr(p, '%');
if (percent != NULL) { /* ${VAR:...%...=...} */
*out_hasPercent = TRUE;
- if (*w == '\0')
+ if (w[0] == '\0')
return NULL; /* empty word does not match pattern */
/* check that the prefix matches */
Index: src/usr.bin/make/unit-tests/varmod-sysv.exp
diff -u src/usr.bin/make/unit-tests/varmod-sysv.exp:1.5 src/usr.bin/make/unit-tests/varmod-sysv.exp:1.6
--- src/usr.bin/make/unit-tests/varmod-sysv.exp:1.5 Sun Nov 1 22:28:52 2020
+++ src/usr.bin/make/unit-tests/varmod-sysv.exp Sat Dec 5 13:01:33 2020
@@ -1,5 +1,5 @@
-make: Unfinished modifier for word203 ('=' missing)
-make: "varmod-sysv.mk" line 210: Malformed conditional (${word203:L:from${:D=}to})
+make: Unfinished modifier for word214 ('=' missing)
+make: "varmod-sysv.mk" line 214: Malformed conditional (${word214:L:from${:D=}to})
make: Fatal errors encountered -- cannot continue
make: stopped in unit-tests
exit status 1
Index: src/usr.bin/make/unit-tests/varmod-sysv.mk
diff -u src/usr.bin/make/unit-tests/varmod-sysv.mk:1.11 src/usr.bin/make/unit-tests/varmod-sysv.mk:1.12
--- src/usr.bin/make/unit-tests/varmod-sysv.mk:1.11 Sun Nov 1 22:28:52 2020
+++ src/usr.bin/make/unit-tests/varmod-sysv.mk Sat Dec 5 13:01:33 2020
@@ -1,4 +1,4 @@
-# $NetBSD: varmod-sysv.mk,v 1.11 2020/11/01 22:28:52 rillig Exp $
+# $NetBSD: varmod-sysv.mk,v 1.12 2020/12/05 13:01:33 rillig Exp $
#
# Tests for the ${VAR:from=to} variable modifier, which replaces the suffix
# "from" with "to". It can also use '%' as a wildcard.
@@ -77,13 +77,16 @@
# If the variable value is empty, it is debatable whether it consists of a
# single empty word, or no word at all. The :from=to modifier treats it as
# no word at all.
+#
+# See SysVMatch, which doesn't handle w_len == p_len specially.
.if ${:L:=suffix} != ""
. error
.endif
# If the variable value is empty, it is debatable whether it consists of a
-# single empty word, or no word at all. The :from=to modifier treats it as
-# no word at all.
+# single empty word (before 2020-05-06), or no word at all (since 2020-05-06).
+#
+# See SysVMatch, percent != NULL && w[0] == '\0'.
.if ${:L:%=suffix} != ""
. error
.endif
@@ -205,9 +208,10 @@
# This is not a SysV modifier since the nested variable expression expands
# to an empty string. The '=' in it should be irrelevant during parsing.
-# As of 2020-11-01, this seemingly correct modifier leads to a parse error.
-# XXX
-.if ${word203:L:from${:D=}to}
+# XXX: As of 2020-12-05, this expression generates an "Unfinished modifier"
+# error, while the correct error message would be "Unknown modifier" since
+# there is no modifier named "fromto".
+.if ${word214:L:from${:D=}to}
. error
.endif