From: Max Okumoto Date: Fri, 18 Feb 2005 01:23:22 +0000 (+0000) Subject: Make sure that length variable is set to zero before Var_Parse() is X-Git-Tag: v2.0.1~8707 X-Git-Url: https://gitweb.dragonflybsd.org/dragonfly.git/commitdiff_plain/904b437088b7257651694561fe13e24a037ef876?hp=d9c58307df5a0f506294e5e3ac56d6d00bdecc74 Make sure that length variable is set to zero before Var_Parse() is invoked. This is in preperation for accumilating the changes to the length, sub-routines called and just update it to reflect how many characters they consumed. --- diff --git a/usr.bin/make/arch.c b/usr.bin/make/arch.c index 9d9e3f42a7..a6591e60ec 100644 --- a/usr.bin/make/arch.c +++ b/usr.bin/make/arch.c @@ -37,7 +37,7 @@ * * @(#)arch.c 8.2 (Berkeley) 1/2/94 * $FreeBSD: src/usr.bin/make/arch.c,v 1.48 2005/02/10 14:39:05 harti Exp $ - * $DragonFly: src/usr.bin/make/arch.c,v 1.33 2005/02/15 01:01:17 okumoto Exp $ + * $DragonFly: src/usr.bin/make/arch.c,v 1.34 2005/02/18 01:23:22 okumoto Exp $ */ /*- @@ -168,7 +168,7 @@ Arch_ParseArchive(char **linePtr, Lst *nodeLst, GNode *ctxt) * Variable spec, so call the Var module to parse the puppy * so we can safely advance beyond it... */ - size_t length; + size_t length = 0; Boolean freeIt; char *result; @@ -214,7 +214,7 @@ Arch_ParseArchive(char **linePtr, Lst *nodeLst, GNode *ctxt) * Variable spec, so call the Var module to parse the puppy * so we can safely advance beyond it... */ - size_t length; + size_t length = 0; Boolean freeIt; char *result; diff --git a/usr.bin/make/cond.c b/usr.bin/make/cond.c index 705ca4e9fd..a4350ba821 100644 --- a/usr.bin/make/cond.c +++ b/usr.bin/make/cond.c @@ -38,7 +38,7 @@ * * @(#)cond.c 8.2 (Berkeley) 1/2/94 * $FreeBSD: src/usr.bin/make/cond.c,v 1.39 2005/02/07 07:49:16 harti Exp $ - * $DragonFly: src/usr.bin/make/cond.c,v 1.29 2005/02/15 01:01:17 okumoto Exp $ + * $DragonFly: src/usr.bin/make/cond.c,v 1.30 2005/02/18 01:23:22 okumoto Exp $ */ /*- @@ -233,7 +233,7 @@ CondGetArg(char **linePtr, char **argPtr, const char *func, Boolean parens) * though perhaps we should... */ char *cp2; - size_t len; + size_t len = 0; Boolean doFree; cp2 = Var_Parse(cp, VAR_CMD, TRUE, &len, &doFree); @@ -517,7 +517,7 @@ CondToken(Boolean doEval) char *lhs; char *rhs; const char *op; - size_t varSpecLen; + size_t varSpecLen = 0; Boolean doFree; /* @@ -629,8 +629,8 @@ do_string_compare: cp++; Buf_AddByte(buf, (Byte)*cp); } else if (*cp == '$') { - size_t len; - Boolean freeIt; + size_t len = 0; + Boolean freeIt; cp2 = Var_Parse(cp, VAR_CMD, doEval, &len, &freeIt); if (cp2 != var_Error) { @@ -681,7 +681,7 @@ do_string_compare: if (*CondCvtArg(lhs, &left) != '\0') goto do_string_compare; if (*rhs == '$') { - size_t len; + size_t len = 0; Boolean freeIt; string = Var_Parse(rhs, VAR_CMD, doEval, &len, &freeIt); @@ -802,9 +802,9 @@ error: * Use Var_Parse to parse the spec in parens and return * True if the resulting string is empty. */ - size_t length; - Boolean doFree; - char *val; + size_t length; + Boolean doFree; + char *val; condExpr += 5; @@ -814,6 +814,7 @@ error: continue; if (condExpr[arglen] != '\0') { + length = 0; val = Var_Parse(&condExpr[arglen - 1], VAR_CMD, FALSE, &length, &doFree); if (val == var_Error) { diff --git a/usr.bin/make/parse.c b/usr.bin/make/parse.c index 643f97149f..6257540fa7 100644 --- a/usr.bin/make/parse.c +++ b/usr.bin/make/parse.c @@ -37,7 +37,7 @@ * * @(#)parse.c 8.3 (Berkeley) 3/19/94 * $FreeBSD: src/usr.bin/make/parse.c,v 1.75 2005/02/07 11:27:47 harti Exp $ - * $DragonFly: src/usr.bin/make/parse.c,v 1.46 2005/02/15 01:01:18 okumoto Exp $ + * $DragonFly: src/usr.bin/make/parse.c,v 1.47 2005/02/18 01:23:22 okumoto Exp $ */ /*- @@ -709,7 +709,7 @@ ParseDoDependency(char *line) * no errors in this, as they would have been discovered * in the initial Var_Subst and we wouldn't be here. */ - size_t length; + size_t length = 0; Boolean freeIt; char *result; diff --git a/usr.bin/make/suff.c b/usr.bin/make/suff.c index 22ce4017a5..017d8cc1c2 100644 --- a/usr.bin/make/suff.c +++ b/usr.bin/make/suff.c @@ -37,7 +37,7 @@ * * @(#)suff.c 8.4 (Berkeley) 3/21/94 * $FreeBSD: src/usr.bin/make/suff.c,v 1.43 2005/02/04 13:23:39 harti Exp $ - * $DragonFly: src/usr.bin/make/suff.c,v 1.33 2005/02/15 01:01:18 okumoto Exp $ + * $DragonFly: src/usr.bin/make/suff.c,v 1.34 2005/02/18 01:23:22 okumoto Exp $ */ /*- @@ -1366,7 +1366,7 @@ SuffExpandChildren(void *cgnp, void *pgnp) * to find the end so we can skip over it. */ char *junk; - size_t len; + size_t len = 0; Boolean doFree; junk = Var_Parse(cp, pgn, TRUE, &len, &doFree); diff --git a/usr.bin/make/var.c b/usr.bin/make/var.c index 244e64de77..3f61d8edbd 100644 --- a/usr.bin/make/var.c +++ b/usr.bin/make/var.c @@ -37,7 +37,7 @@ * * @(#)var.c 8.3 (Berkeley) 3/19/94 * $FreeBSD: src/usr.bin/make/var.c,v 1.83 2005/02/11 10:49:01 harti Exp $ - * $DragonFly: src/usr.bin/make/var.c,v 1.106 2005/02/18 01:21:52 okumoto Exp $ + * $DragonFly: src/usr.bin/make/var.c,v 1.107 2005/02/18 01:23:22 okumoto Exp $ */ /*- @@ -747,6 +747,7 @@ VarGetPattern(GNode *ctxt, int err, char **tstr, int delim, int *flags, * delimiter, assume it's a variable * substitution and recurse. */ + len = 0; cp2 = Var_Parse(cp, ctxt, err, &len, &freeIt); Buf_Append(buf, cp2); if (freeIt) @@ -1042,6 +1043,7 @@ ParseModifier(const char input[], char tstr[], size_t len; Boolean freeIt; + len = 0; cp2 = Var_Parse(cp, ctxt, err, &len, &freeIt); Buf_Append(buf, cp2); if (freeIt) { @@ -1106,6 +1108,7 @@ ParseModifier(const char input[], char tstr[], size_t len; Boolean freeIt; + len = 0; cp2 = Var_Parse(cp, ctxt, err, &len, &freeIt); Buf_Append(buf, cp2); cp += len - 1; @@ -1542,6 +1545,7 @@ VarParseLong(char foo[], GNode *ctxt, Boolean err, size_t *lengthPtr, Boolean rfree; char *rval; + rlen = 0; rval = Var_Parse(tstr, ctxt, err, &rlen, &rfree); if (rval == var_Error) { Fatal("Error expanding embedded variable."); @@ -1932,6 +1936,7 @@ Var_Subst(const char *var, const char *str, GNode *ctxt, Boolean undefErr) continue; } + length = 0; val = Var_Parse(str, ctxt, undefErr, &length, &doFree); /*