summaryrefslogtreecommitdiff
path: root/usr.bin/make/parse.c
diff options
context:
space:
mode:
authorsjg <sjg@NetBSD.org>2009-10-07 16:40:30 +0000
committersjg <sjg@NetBSD.org>2009-10-07 16:40:30 +0000
commitbaca35f4e0aea36d4ee69d4df681599aabb6b3d0 (patch)
treefcd9b9ac2e6dadea20d68bb212c999821885e870 /usr.bin/make/parse.c
parent7affbacab9bd5b509bcf92dddc4a53cd447fef4c (diff)
The parser used to break dependency lines at ';' without regard
for substitution patterns. This (perhaps coupled with the new handling of .for variables in ${:U<value>...) caused interesting results for lines like: .for file in ${LIST} for-subst: ${file:S;^;${here}/;g} add a unit-test to keep an eye on this.
Diffstat (limited to 'usr.bin/make/parse.c')
-rw-r--r--usr.bin/make/parse.c35
1 files changed, 25 insertions, 10 deletions
diff --git a/usr.bin/make/parse.c b/usr.bin/make/parse.c
index 1232d4dbd58..26a9c0cccc5 100644
--- a/usr.bin/make/parse.c
+++ b/usr.bin/make/parse.c
@@ -1,4 +1,4 @@
-/* $NetBSD: parse.c,v 1.157 2009/01/23 21:26:30 dsl Exp $ */
+/* $NetBSD: parse.c,v 1.158 2009/10/07 16:40:30 sjg Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: parse.c,v 1.157 2009/01/23 21:26:30 dsl Exp $";
+static char rcsid[] = "$NetBSD: parse.c,v 1.158 2009/10/07 16:40:30 sjg Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)parse.c 8.3 (Berkeley) 3/19/94";
#else
-__RCSID("$NetBSD: parse.c,v 1.157 2009/01/23 21:26:30 dsl Exp $");
+__RCSID("$NetBSD: parse.c,v 1.158 2009/10/07 16:40:30 sjg Exp $");
#endif
#endif /* not lint */
#endif
@@ -2590,15 +2590,30 @@ Parse_File(const char *name, int fd)
/*
* For some reason - probably to make the parser impossible -
* a ';' can be used to separate commands from dependencies.
- * No attempt is made to avoid ';' inside substitution patterns.
+ * Attempt to avoid ';' inside substitution patterns.
*/
- for (cp = line; *cp != 0; cp++) {
- if (*cp == '\\' && cp[1] != 0) {
- cp++;
- continue;
+ {
+ int level = 0;
+
+ for (cp = line; *cp != 0; cp++) {
+ if (*cp == '\\' && cp[1] != 0) {
+ cp++;
+ continue;
+ }
+ if (*cp == '$' &&
+ (cp[1] == '(' || cp[1] == '{')) {
+ level++;
+ continue;
+ }
+ if (level > 0) {
+ if (*cp == ')' || *cp == '}') {
+ level--;
+ continue;
+ }
+ } else if (*cp == ';') {
+ break;
+ }
}
- if (*cp == ';')
- break;
}
if (*cp != 0)
/* Terminate the dependency list at the ';' */