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): fix parsing of nested braces in depend...
details: https://anonhg.NetBSD.org/src/rev/68e6d53b2f96
branches: trunk
changeset: 1012456:68e6d53b2f96
user: rillig <rillig%NetBSD.org@localhost>
date: Fri Jul 31 19:06:33 2020 +0000
description:
make(1): fix parsing of nested braces in dependency lines
Before, make could not parse {{thi,fou}r,fif}teen properly. It did
correctly split up the outer brace into "" + "{thi,fou}r,fif" + "teen",
but then, when expanding the inner braces, it interpreted the first
comma already as a separator, even though this comma was enclosed in
another set of braces.
This resulted in the wrong expansion "{thiteen", which produced the
error message. The next word "fouteen" was produced since the parser
stopped at the next closing brace. After this, parsing continued after
the closing brace, producing "rteen". Finally, the last expansion was
the correct "fifteen".
diffstat:
usr.bin/make/dir.c | 17 +++++++++--------
usr.bin/make/unit-tests/dir.exp | 6 ++----
2 files changed, 11 insertions(+), 12 deletions(-)
diffs (62 lines):
diff -r 774f633908f8 -r 68e6d53b2f96 usr.bin/make/dir.c
--- a/usr.bin/make/dir.c Fri Jul 31 17:41:35 2020 +0000
+++ b/usr.bin/make/dir.c Fri Jul 31 19:06:33 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dir.c,v 1.78 2020/07/31 17:41:35 rillig Exp $ */
+/* $NetBSD: dir.c,v 1.79 2020/07/31 19:06:33 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -70,14 +70,14 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: dir.c,v 1.78 2020/07/31 17:41:35 rillig Exp $";
+static char rcsid[] = "$NetBSD: dir.c,v 1.79 2020/07/31 19:06:33 rillig Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)dir.c 8.2 (Berkeley) 1/2/94";
#else
-__RCSID("$NetBSD: dir.c,v 1.78 2020/07/31 17:41:35 rillig Exp $");
+__RCSID("$NetBSD: dir.c,v 1.79 2020/07/31 19:06:33 rillig Exp $");
#endif
#endif /* not lint */
#endif
@@ -715,12 +715,13 @@
* Find the end of this piece of the clause.
*/
bracelevel = 0;
- while (*cp != ',') {
- if (*cp == '{') {
+ while (*cp != '\0') {
+ if ((*cp == ',' || *cp == '}') && bracelevel == 0)
+ break;
+ if (*cp == '{')
bracelevel++;
- } else if ((*cp == '}') && (bracelevel-- <= 0)) {
- break;
- }
+ if (*cp == '}')
+ bracelevel--;
cp++;
}
/*
diff -r 774f633908f8 -r 68e6d53b2f96 usr.bin/make/unit-tests/dir.exp
--- a/usr.bin/make/unit-tests/dir.exp Fri Jul 31 17:41:35 2020 +0000
+++ b/usr.bin/make/unit-tests/dir.exp Fri Jul 31 19:06:33 2020 +0000
@@ -1,11 +1,9 @@
-make: Unterminated {} clause "thiteen"
1
2
3
4
5
-make: don't know how to make fouteen (continuing)
-make: don't know how to make rteen (continuing)
+13
+14
15
-`all' not remade because of errors.
exit status 0
Home |
Main Index |
Thread Index |
Old Index