diff options
author | Hartmut Brandt <harti@FreeBSD.org> | 2005-03-30 15:14:22 +0000 |
---|---|---|
committer | Hartmut Brandt <harti@FreeBSD.org> | 2005-03-30 15:14:22 +0000 |
commit | f43eb6f83ba19a3567e5d005cc23f08d878b0247 (patch) | |
tree | 9e651fde00117c1906c524287584e79986900788 /usr.bin | |
parent | 4d2743aec5db5875080f6ba02d81af0889429a17 (diff) | |
download | src-f43eb6f83ba19a3567e5d005cc23f08d878b0247.tar.gz src-f43eb6f83ba19a3567e5d005cc23f08d878b0247.zip |
Fix a bug introduced in a previous commit: ParseModifier() consumes
characters so it is not safe to move around code from
before it to after it. This should fix problems with building the
documentation.
Patch: 7.170
Submitted by: Max Okumoto <okumoto@ucsd.edu>
Notes
Notes:
svn path=/head/; revision=144340
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/make/var.c | 45 |
1 files changed, 30 insertions, 15 deletions
diff --git a/usr.bin/make/var.c b/usr.bin/make/var.c index 6bfdceee8079..d47971d2a0bf 100644 --- a/usr.bin/make/var.c +++ b/usr.bin/make/var.c @@ -1304,8 +1304,20 @@ ParseRestModifier(VarParser *vp, char startc, Buffer *buf, Boolean *freeResult) } if ((vp->ctxt == VAR_CMD) || (vp->ctxt == VAR_GLOBAL)) { - size_t consumed = vp->ptr - vp->input + 1; + size_t consumed; + /* + * Still need to get to the end of the variable + * specification, so kludge up a Var structure for the + * modifications + */ + v = VarCreate(vname, NULL, VAR_JUNK); + value = ParseModifier(vp, startc, v, freeResult); + if (*freeResult) { + free(value); + } + VarDestroy(v, TRUE); + consumed = vp->ptr - vp->input + 1; /* * If substituting a local variable in a non-local context, * assume it's for dynamic source stuff. We have to handle @@ -1341,6 +1353,9 @@ ParseRestModifier(VarParser *vp, char startc, Buffer *buf, Boolean *freeResult) return (value); } } + + *freeResult = FALSE; + return (vp->err ? var_Error : varNoError); } else { /* * Check for D and F forms of local variables since we're in @@ -1360,22 +1375,22 @@ ParseRestModifier(VarParser *vp, char startc, Buffer *buf, Boolean *freeResult) return (value); } } - } - /* - * Still need to get to the end of the variable - * specification, so kludge up a Var structure for the - * modifications - */ - v = VarCreate(vname, NULL, VAR_JUNK); - value = ParseModifier(vp, startc, v, freeResult); - if (*freeResult) { - free(value); - } - VarDestroy(v, TRUE); + /* + * Still need to get to the end of the variable + * specification, so kludge up a Var structure for the + * modifications + */ + v = VarCreate(vname, NULL, VAR_JUNK); + value = ParseModifier(vp, startc, v, freeResult); + if (*freeResult) { + free(value); + } + VarDestroy(v, TRUE); - *freeResult = FALSE; - return (vp->err ? var_Error : varNoError); + *freeResult = FALSE; + return (vp->err ? var_Error : varNoError); + } } static char * |