summaryrefslogtreecommitdiff
path: root/usr.bin/make/for.c
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2000-11-24 14:29:57 +0000
committerMarc Espie <espie@cvs.openbsd.org>2000-11-24 14:29:57 +0000
commit2cee9a585ea175c769b7222ead016577e476d8e3 (patch)
tree3f31792b9c962502497dc062cf3a7c54af822fec /usr.bin/make/for.c
parente5ab92938083a6aa61fa10053610274794fb5f91 (diff)
Take advantage of VarModifiers_Apply, which can parse a variable spec
and expand it directly, without needing a variable context. Use it in Var_SubstVar, so that .for loops values don't need to be entered into any context nor looked up. This speeds up .for loops some, and avoids nasty variable capture side-effects. Ok'd millert@, miod@, naddy@ (naddy spotted a problem with the first version of that change).
Diffstat (limited to 'usr.bin/make/for.c')
-rw-r--r--usr.bin/make/for.c14
1 files changed, 4 insertions, 10 deletions
diff --git a/usr.bin/make/for.c b/usr.bin/make/for.c
index b2b0fc11c37..fb37dadb9ae 100644
--- a/usr.bin/make/for.c
+++ b/usr.bin/make/for.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: for.c,v 1.22 2000/09/14 13:35:38 espie Exp $ */
+/* $OpenBSD: for.c,v 1.23 2000/11/24 14:29:55 espie Exp $ */
/* $NetBSD: for.c,v 1.4 1996/11/06 17:59:05 christos Exp $ */
/*
@@ -83,7 +83,7 @@
static char sccsid[] = "@(#)for.c 8.1 (Berkeley) 6/6/93";
#else
UNUSED
-static char rcsid[] = "$OpenBSD: for.c,v 1.22 2000/09/14 13:35:38 espie Exp $";
+static char rcsid[] = "$OpenBSD: for.c,v 1.23 2000/11/24 14:29:55 espie Exp $";
#endif
#endif /* not lint */
@@ -270,16 +270,10 @@ ForExec(namep, argp)
char *name = (char *)namep;
For *arg = (For *)argp;
- Buf_Init(&arg->buf, arg->guess);
- Var_Set(arg->var, name, VAR_GLOBAL);
if (DEBUG(FOR))
(void)fprintf(stderr, "--- %s = %s\n", arg->var, name);
- Var_SubstVar(&arg->buf, arg->text, arg->var, VAR_GLOBAL);
- if (Buf_Size(&arg->buf) >= arg->guess)
- arg->guess = Buf_Size(&arg->buf) + GUESS_EXPANSION;
-
- Parse_FromString(Buf_Retrieve(&arg->buf), arg->lineno);
- Var_Delete(arg->var, VAR_GLOBAL);
+ Parse_FromString(Var_SubstVar(arg->text, arg->var, name,
+ arg->guess), arg->lineno);
}