Source-Changes-HG archive

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

[src/trunk]: src/usr.bin/make make(1): issue a parse error on unclosed variables



details:   https://anonhg.NetBSD.org/src/rev/50e6cd15c8e2
branches:  trunk
changeset: 936520:50e6cd15c8e2
user:      rillig <rillig%NetBSD.org@localhost>
date:      Tue Jul 28 17:18:40 2020 +0000

description:
make(1): issue a parse error on unclosed variables

These errors had not been detected before by make.
In pkgsrc, this task as been done by pkglint since 2019-04-07.

diffstat:

 usr.bin/make/unit-tests/varmisc.exp |  15 +++++++++++++++
 usr.bin/make/unit-tests/varmisc.mk  |  13 ++++++++++---
 usr.bin/make/var.c                  |   8 +++++---
 3 files changed, 30 insertions(+), 6 deletions(-)

diffs (93 lines):

diff -r ff017d3e1125 -r 50e6cd15c8e2 usr.bin/make/unit-tests/varmisc.exp
--- a/usr.bin/make/unit-tests/varmisc.exp       Tue Jul 28 16:45:56 2020 +0000
+++ b/usr.bin/make/unit-tests/varmisc.exp       Tue Jul 28 17:18:40 2020 +0000
@@ -47,9 +47,24 @@
 parse-dynamic: parse-dynamic parse-dynamic after
 parse-dynamic: parse-dynamic parse-dynamic after
 varerror-unclosed:begin
+make: Unclosed variable ""
 
+make: Unclosed variable "UNCLOSED"
+
+make: Unclosed variable "UNCLOSED"
+
+make: Unclosed variable "PATTERN"
 make: Unclosed variable specification (expecting '}') for "UNCLOSED" (value "") modifier M
 
+make: Unclosed variable "param"
+make: Unclosed variable "UNCLOSED."
+
+
+make: Unclosed variable "UNCLOSED.1"
+
+make: Unclosed variable "UNCLOSED.2"
+
+make: Unclosed variable "UNCLOSED.3"
 
 varerror-unclosed:end
 exit status 0
diff -r ff017d3e1125 -r 50e6cd15c8e2 usr.bin/make/unit-tests/varmisc.mk
--- a/usr.bin/make/unit-tests/varmisc.mk        Tue Jul 28 16:45:56 2020 +0000
+++ b/usr.bin/make/unit-tests/varmisc.mk        Tue Jul 28 17:18:40 2020 +0000
@@ -1,4 +1,4 @@
-# $Id: varmisc.mk,v 1.17 2020/07/26 21:46:10 rillig Exp $
+# $Id: varmisc.mk,v 1.18 2020/07/28 17:18:40 rillig Exp $
 #
 # Miscellaneous variable tests.
 
@@ -191,11 +191,18 @@
        @echo $@: ${GB_TARGET} ${GB_MEMBER} ${GB_PREFIX} ${GB_ARCHIVE} ${GB_ALLSRC}
        @echo $@: ${GL_TARGET} ${GL_MEMBER} ${GL_PREFIX} ${GL_ARCHIVE} ${GL_ALLSRC}
 
-# As of 2020-07-26, make does not complain about unclosed variables.
-# It does complain about unclosed variables when parsing modifiers though.
+# Since 2020-07-28, make complains about unclosed variables.
+# Before that, it had not complained about unclosed variables only when
+# parsing the modifiers, but not when parsing the variable name.
 varerror-unclosed:
        @echo $@:begin
+       @echo $(
+       @echo $(UNCLOSED
        @echo ${UNCLOSED
        @echo ${UNCLOSED:M${PATTERN
        @echo ${UNCLOSED.${param
+       @echo $
+.for i in 1 2 3
+       @echo ${UNCLOSED.${i}
+.endfor
        @echo $@:end
diff -r ff017d3e1125 -r 50e6cd15c8e2 usr.bin/make/var.c
--- a/usr.bin/make/var.c        Tue Jul 28 16:45:56 2020 +0000
+++ b/usr.bin/make/var.c        Tue Jul 28 17:18:40 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: var.c,v 1.352 2020/07/28 16:42:22 rillig Exp $ */
+/*     $NetBSD: var.c,v 1.353 2020/07/28 17:18:40 rillig Exp $ */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.352 2020/07/28 16:42:22 rillig Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.353 2020/07/28 17:18:40 rillig Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)var.c      8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: var.c,v 1.352 2020/07/28 16:42:22 rillig Exp $");
+__RCSID("$NetBSD: var.c,v 1.353 2020/07/28 17:18:40 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -3506,6 +3506,8 @@
        } else if (*tstr == endc) {
            haveModifier = FALSE;
        } else {
+           Parse_Error(PARSE_FATAL, "Unclosed variable \"%s\"",
+                       Buf_GetAll(&namebuf, NULL));
            /*
             * If we never did find the end character, return NULL
             * right now, setting the length to be the distance to



Home | Main Index | Thread Index | Old Index