Source-Changes-HG archive

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

[src/trunk]: src/usr.bin/make/unit-tests make: demonstrate wrong expression e...



details:   https://anonhg.NetBSD.org/src/rev/3732ae007b3b
branches:  trunk
changeset: 960301:3732ae007b3b
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Mar 14 10:45:51 2021 +0000

description:
make: demonstrate wrong expression evaluation in -dL mode

diffstat:

 usr.bin/make/unit-tests/Makefile           |  11 ++++++++---
 usr.bin/make/unit-tests/opt-debug-lint.exp |   1 +
 usr.bin/make/unit-tests/opt-debug-lint.mk  |  17 ++++++++++++++---
 3 files changed, 23 insertions(+), 6 deletions(-)

diffs (78 lines):

diff -r fafdd6b19ffb -r 3732ae007b3b usr.bin/make/unit-tests/Makefile
--- a/usr.bin/make/unit-tests/Makefile  Sun Mar 14 10:36:46 2021 +0000
+++ b/usr.bin/make/unit-tests/Makefile  Sun Mar 14 10:45:51 2021 +0000
@@ -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,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.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}: [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}
diff -r fafdd6b19ffb -r 3732ae007b3b usr.bin/make/unit-tests/opt-debug-lint.exp
--- a/usr.bin/make/unit-tests/opt-debug-lint.exp        Sun Mar 14 10:36:46 2021 +0000
+++ b/usr.bin/make/unit-tests/opt-debug-lint.exp        Sun Mar 14 10:45:51 2021 +0000
@@ -3,6 +3,7 @@
 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
diff -r fafdd6b19ffb -r 3732ae007b3b usr.bin/make/unit-tests/opt-debug-lint.mk
--- a/usr.bin/make/unit-tests/opt-debug-lint.mk Sun Mar 14 10:36:46 2021 +0000
+++ b/usr.bin/make/unit-tests/opt-debug-lint.mk Sun Mar 14 10:45:51 2021 +0000
@@ -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 @@
 .  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}



Home | Main Index | Thread Index | Old Index