Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/make The parser used to break dependency lines at '; ...
details: https://anonhg.NetBSD.org/src/rev/80c0d088a476
branches: trunk
changeset: 747975:80c0d088a476
user: sjg <sjg%NetBSD.org@localhost>
date: Wed Oct 07 16:40:30 2009 +0000
description:
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:
usr.bin/make/parse.c | 35 +++++++++++++++++++++++++----------
usr.bin/make/unit-tests/Makefile | 3 ++-
usr.bin/make/unit-tests/forsubst | 10 ++++++++++
usr.bin/make/unit-tests/test.exp | 1 +
4 files changed, 38 insertions(+), 11 deletions(-)
diffs (106 lines):
diff -r a541f0fca835 -r 80c0d088a476 usr.bin/make/parse.c
--- a/usr.bin/make/parse.c Wed Oct 07 16:19:51 2009 +0000
+++ b/usr.bin/make/parse.c Wed Oct 07 16:40:30 2009 +0000
@@ -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 @@
/*
* 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 ';' */
diff -r a541f0fca835 -r 80c0d088a476 usr.bin/make/unit-tests/Makefile
--- a/usr.bin/make/unit-tests/Makefile Wed Oct 07 16:19:51 2009 +0000
+++ b/usr.bin/make/unit-tests/Makefile Wed Oct 07 16:40:30 2009 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.23 2008/10/25 22:27:39 apb Exp $
+# $NetBSD: Makefile,v 1.24 2009/10/07 16:40:30 sjg Exp $
#
# Unit tests for make(1)
# The main targets are:
@@ -24,6 +24,7 @@
export \
export-all \
dotwait \
+ forsubst \
moderrs \
modmatch \
modmisc \
diff -r a541f0fca835 -r 80c0d088a476 usr.bin/make/unit-tests/forsubst
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.bin/make/unit-tests/forsubst Wed Oct 07 16:40:30 2009 +0000
@@ -0,0 +1,10 @@
+# $Id: forsubst,v 1.1 2009/10/07 16:40:30 sjg Exp $
+
+all: for-subst
+
+here := ${.PARSEDIR}
+# this should not run foul of the parser
+.for file in ${.PARSEFILE}
+for-subst: ${file:S;^;${here}/;g}
+ @echo ".for with :S;... OK"
+.endfor
diff -r a541f0fca835 -r 80c0d088a476 usr.bin/make/unit-tests/test.exp
--- a/usr.bin/make/unit-tests/test.exp Wed Oct 07 16:19:51 2009 +0000
+++ b/usr.bin/make/unit-tests/test.exp Wed Oct 07 16:40:30 2009 +0000
@@ -67,6 +67,7 @@
make: Graph cycles through `cycle.2.97'
cycle.1.99
cycle.1.99
+.for with :S;... OK
Expect: Unknown modifier 'Z'
make: Unknown modifier 'Z'
VAR:Z=
Home |
Main Index |
Thread Index |
Old Index