Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/make Var_Parse: endc only counts when at the correct...
details: https://anonhg.NetBSD.org/src/rev/4fbe6de88e27
branches: trunk
changeset: 329330:4fbe6de88e27
user: sjg <sjg%NetBSD.org@localhost>
date: Mon May 19 22:09:58 2014 +0000
description:
Var_Parse: endc only counts when at the correct nesting depth.
This ensures we correctly detect errors like:
.if empty(VAR && !empty(FOO)
Var_Subst: if Var_Parse returns var_Error it is an error.
This ensures we detect errors like:
VAR:= ${FOO.${GOO}
diffstat:
usr.bin/make/var.c | 28 ++++++++++++++++++++--------
1 files changed, 20 insertions(+), 8 deletions(-)
diffs (78 lines):
diff -r 354d75ded3cf -r 4fbe6de88e27 usr.bin/make/var.c
--- a/usr.bin/make/var.c Mon May 19 21:01:48 2014 +0000
+++ b/usr.bin/make/var.c Mon May 19 22:09:58 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: var.c,v 1.184 2013/09/04 15:38:26 sjg Exp $ */
+/* $NetBSD: var.c,v 1.185 2014/05/19 22:09:58 sjg Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.184 2013/09/04 15:38:26 sjg Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.185 2014/05/19 22:09:58 sjg 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.184 2013/09/04 15:38:26 sjg Exp $");
+__RCSID("$NetBSD: var.c,v 1.185 2014/05/19 22:09:58 sjg Exp $");
#endif
#endif /* not lint */
#endif
@@ -3660,6 +3660,7 @@
}
} else {
Buffer buf; /* Holds the variable name */
+ int depth = 1;
endc = startc == PROPEN ? PRCLOSE : BRCLOSE;
Buf_Init(&buf, 0);
@@ -3667,11 +3668,22 @@
/*
* Skip to the end character or a colon, whichever comes first.
*/
- for (tstr = str + 2;
- *tstr != '\0' && *tstr != endc && *tstr != ':';
- tstr++)
+ for (tstr = str + 2; *tstr != '\0'; tstr++)
{
/*
+ * Track depth so we can spot parse errors.
+ */
+ if (*tstr == startc) {
+ depth++;
+ }
+ if (*tstr == endc) {
+ if (--depth == 0)
+ break;
+ }
+ if (depth == 1 && *tstr == ':') {
+ break;
+ }
+ /*
* A variable inside a variable, expand
*/
if (*tstr == '$') {
@@ -3690,7 +3702,7 @@
}
if (*tstr == ':') {
haveModifier = TRUE;
- } else if (*tstr != '\0') {
+ } else if (*tstr == endc) {
haveModifier = FALSE;
} else {
/*
@@ -4040,7 +4052,7 @@
*/
if (oldVars) {
str += length;
- } else if (undefErr) {
+ } else if (undefErr || val == var_Error) {
/*
* If variable is undefined, complain and skip the
* variable. The complaint will stop us from doing anything
Home |
Main Index |
Thread Index |
Old Index