summaryrefslogtreecommitdiffstats
path: root/contrib/bmake/var.c
diff options
context:
space:
mode:
authorsjg <sjg@FreeBSD.org>2014-07-08 22:27:50 +0000
committersjg <sjg@FreeBSD.org>2014-07-08 22:27:50 +0000
commit8a8bdedf3516cfc13d63e3d424375679d4fe2a5c (patch)
tree4c5229352cca8f44795e8423807a3ec5d9f482ed /contrib/bmake/var.c
parent26d6f0488543168ab53e731b626612a7d1028552 (diff)
downloadFreeBSD-src-8a8bdedf3516cfc13d63e3d424375679d4fe2a5c.zip
FreeBSD-src-8a8bdedf3516cfc13d63e3d424375679d4fe2a5c.tar.gz
Update to bmake-20140620
Main change is detection of malformed variable references. Reviewed by: obrien
Diffstat (limited to 'contrib/bmake/var.c')
-rw-r--r--contrib/bmake/var.c30
1 files changed, 21 insertions, 9 deletions
diff --git a/contrib/bmake/var.c b/contrib/bmake/var.c
index ef71a81..0b7e88e 100644
--- a/contrib/bmake/var.c
+++ b/contrib/bmake/var.c
@@ -1,4 +1,4 @@
-/* $NetBSD: var.c,v 1.184 2013/09/04 15:38:26 sjg Exp $ */
+/* $NetBSD: var.c,v 1.186 2014/06/20 06:13:45 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.186 2014/06/20 06:13:45 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.186 2014/06/20 06:13:45 sjg Exp $");
#endif
#endif /* not lint */
#endif
@@ -2637,7 +2637,7 @@ ApplyModifiers(char *nstr, const char *tstr,
break;
}
free(UNCONST(pattern.rhs));
- newStr = var_Error;
+ newStr = varNoError;
break;
}
goto default_case; /* "::<unrecognised>" */
@@ -3661,6 +3661,7 @@ Var_Parse(const char *str, GNode *ctxt, Boolean errnum, int *lengthPtr,
}
} else {
Buffer buf; /* Holds the variable name */
+ int depth = 1;
endc = startc == PROPEN ? PRCLOSE : BRCLOSE;
Buf_Init(&buf, 0);
@@ -3668,11 +3669,22 @@ Var_Parse(const char *str, GNode *ctxt, Boolean errnum, int *lengthPtr,
/*
* 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 == '$') {
@@ -3691,7 +3703,7 @@ Var_Parse(const char *str, GNode *ctxt, Boolean errnum, int *lengthPtr,
}
if (*tstr == ':') {
haveModifier = TRUE;
- } else if (*tstr != '\0') {
+ } else if (*tstr == endc) {
haveModifier = FALSE;
} else {
/*
@@ -4041,7 +4053,7 @@ Var_Subst(const char *var, const char *str, GNode *ctxt, Boolean undefErr)
*/
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
OpenPOWER on IntegriCloud