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: <shell>,'
# The "-q" may be there or not, see jobs.c, variable shells.
SED_CMDS.opt-debug-jobs+= -e 's,^\(.Command: <shell>\) -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},</path/to/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: "<normalized>,'
SED_CMDS.varname-dot-parsefile= -e '/in some cases/ s,^make: "[^"]*,make: "<normalized>,'
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}