aboutsummaryrefslogtreecommitdiff
path: root/contrib/bmake/var.c
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/bmake/var.c')
-rw-r--r--contrib/bmake/var.c69
1 files changed, 37 insertions, 32 deletions
diff --git a/contrib/bmake/var.c b/contrib/bmake/var.c
index e15c301cf9cf..0b7e88eb8752 100644
--- a/contrib/bmake/var.c
+++ b/contrib/bmake/var.c
@@ -1,4 +1,4 @@
-/* $NetBSD: var.c,v 1.192 2015/05/05 21:51:09 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.192 2015/05/05 21:51:09 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.192 2015/05/05 21:51:09 sjg Exp $");
+__RCSID("$NetBSD: var.c,v 1.186 2014/06/20 06:13:45 sjg Exp $");
#endif
#endif /* not lint */
#endif
@@ -3261,7 +3261,7 @@ ApplyModifiers(char *nstr, const char *tstr,
termc = *--cp;
delim = '\0';
- if (Cond_EvalExpression(NULL, v->name, &value, 0, FALSE)
+ if (Cond_EvalExpression(NULL, v->name, &value, 0)
== COND_INVALID) {
Error("Bad conditional expression `%s' in %s?%s:%s",
v->name, v->name, pattern.lhs, pattern.rhs);
@@ -3600,13 +3600,14 @@ Var_Parse(const char *str, GNode *ctxt, Boolean errnum, int *lengthPtr,
* expanding it in a non-local context. This
* is done to support dynamic sources. The
* result is just the invocation, unaltered */
- const char *extramodifiers; /* extra modifiers to apply first */
+ Var_Parse_State parsestate; /* Flags passed to helper functions */
char name[2];
*freePtr = NULL;
- extramodifiers = NULL;
dynamic = FALSE;
start = str;
+ parsestate.oneBigWord = FALSE;
+ parsestate.varSpace = ' '; /* word separator */
startc = str[1];
if (startc != PROPEN && startc != BROPEN) {
@@ -3734,7 +3735,7 @@ Var_Parse(const char *str, GNode *ctxt, Boolean errnum, int *lengthPtr,
*/
if ((v == NULL) && (ctxt != VAR_CMD) && (ctxt != VAR_GLOBAL) &&
(vlen == 2) && (str[1] == 'F' || str[1] == 'D') &&
- strchr("@%?*!<>", str[0]) != NULL) {
+ strchr("@%*!<>", str[0]) != NULL) {
/*
* Well, it's local -- go look for it.
*/
@@ -3743,12 +3744,29 @@ Var_Parse(const char *str, GNode *ctxt, Boolean errnum, int *lengthPtr,
v = VarFind(name, ctxt, 0);
if (v != NULL) {
+ /*
+ * No need for nested expansion or anything, as we're
+ * the only one who sets these things and we sure don't
+ * but nested invocations in them...
+ */
+ nstr = Buf_GetAll(&v->val, NULL);
+
if (str[1] == 'D') {
- extramodifiers = "H:";
- }
- else { /* F */
- extramodifiers = "T:";
+ nstr = VarModify(ctxt, &parsestate, nstr, VarHead,
+ NULL);
+ } else {
+ nstr = VarModify(ctxt, &parsestate, nstr, VarTail,
+ NULL);
}
+ /*
+ * Resulting string is dynamically allocated, so
+ * tell caller to free it.
+ */
+ *freePtr = nstr;
+ *lengthPtr = tstr-start+1;
+ Buf_Destroy(&buf, TRUE);
+ VarFreeEnv(v, TRUE);
+ return nstr;
}
}
@@ -3843,29 +3861,16 @@ Var_Parse(const char *str, GNode *ctxt, Boolean errnum, int *lengthPtr,
v->flags &= ~VAR_IN_USE;
- if ((nstr != NULL) && (haveModifier || extramodifiers != NULL)) {
- void *extraFree;
+ if ((nstr != NULL) && haveModifier) {
int used;
+ /*
+ * Skip initial colon.
+ */
+ tstr++;
- extraFree = NULL;
- if (extramodifiers != NULL) {
- nstr = ApplyModifiers(nstr, extramodifiers, '(', ')',
- v, ctxt, errnum, &used, &extraFree);
- }
-
- if (haveModifier) {
- /* Skip initial colon. */
- tstr++;
-
- nstr = ApplyModifiers(nstr, tstr, startc, endc,
- v, ctxt, errnum, &used, freePtr);
- tstr += used;
- if (extraFree) {
- free(extraFree);
- }
- } else {
- *freePtr = extraFree;
- }
+ nstr = ApplyModifiers(nstr, tstr, startc, endc,
+ v, ctxt, errnum, &used, freePtr);
+ tstr += used;
}
if (*tstr) {
*lengthPtr = tstr - start + 1;