diff options
author | harti <harti@FreeBSD.org> | 2005-03-21 07:40:33 +0000 |
---|---|---|
committer | harti <harti@FreeBSD.org> | 2005-03-21 07:40:33 +0000 |
commit | 47633d30dcb070a831e72d6f17f9c028f1b1c901 (patch) | |
tree | eed94caa477a6398849460807f77b8054c6f0650 /usr.bin/make/var.c | |
parent | 677dba2c50dd1c74f69ce0884d597d8acc791637 (diff) | |
download | FreeBSD-src-47633d30dcb070a831e72d6f17f9c028f1b1c901.zip FreeBSD-src-47633d30dcb070a831e72d6f17f9c028f1b1c901.tar.gz |
Reduce the number of explicit parameters passed to VarParse()
by passing them through struct VarParser.
Patch: 7.127
Submitted by: Max Okumoto <okumoto@ucsd.edu>
Diffstat (limited to 'usr.bin/make/var.c')
-rw-r--r-- | usr.bin/make/var.c | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/usr.bin/make/var.c b/usr.bin/make/var.c index e119980..8e7909c 100644 --- a/usr.bin/make/var.c +++ b/usr.bin/make/var.c @@ -105,10 +105,11 @@ __FBSDID("$FreeBSD$"); */ typedef struct VarParser { const char *const input; /* pointer to input string */ + const char *ptr; /* current parser pos in input str */ GNode *ctxt; Boolean err; } VarParser; -static char *VarParse(const char [], VarParser *, size_t *, Boolean *); +static char *VarParse(VarParser *, size_t *, Boolean *); /* * This is a harmless return value for Var_Parse that can be used by Var_Subst @@ -1919,26 +1920,31 @@ VarParseShort(const char input[], VarParser *vp, } static char * -VarParse(const char input[], VarParser *vp, size_t *consumed, Boolean *freeResult) +VarParse(VarParser *vp, size_t *consumed, Boolean *freeResult) { - /* assert(input[0] == '$'); */ + char *value; + + /* assert(vp->ptr[0] == '$'); */ - *consumed += 1; /* consume '$' */ - input += 1; + vp->ptr += 1; /* consume '$' */ - if (input[0] == '\0') { + if (vp->ptr[0] == '\0') { + *consumed += 1; /* consume '$' */ /* Error, there is only a dollar sign in the input string. */ *freeResult = FALSE; - return (vp->err ? var_Error : varNoError); + value = vp->err ? var_Error : varNoError; - } else if (input[0] == OPEN_PAREN || input[0] == OPEN_BRACE) { + } else if (vp->ptr[0] == OPEN_PAREN || vp->ptr[0] == OPEN_BRACE) { + *consumed += 1; /* consume '$' */ /* multi letter variable name */ - return (VarParseLong(input, vp, consumed, freeResult)); + value = VarParseLong(vp->ptr, vp, consumed, freeResult); } else { + *consumed += 1; /* consume '$' */ /* single letter variable name */ - return (VarParseShort(input, vp, consumed, freeResult)); + value = VarParseShort(vp->ptr, vp, consumed, freeResult); } + return (value); } /*- @@ -1971,11 +1977,12 @@ Var_Parse(const char input[], GNode *ctxt, Boolean err, { VarParser vp = { input, + input, ctxt, err }; - return VarParse(input, &vp, consumed, freeResult); + return VarParse(&vp, consumed, freeResult); } /*- |