--- src/usr.bin/make/var.c 2005/02/06 23:22:04 1.61 +++ src/usr.bin/make/var.c 2005/02/06 23:54:55 1.62 @@ -908,58 +908,7 @@ Var_Parse(char *str, GNode *ctxt, Boolea * It is assumed that Var_Parse() is called with str[0] == '$' */ - if (str[1] != OPEN_PAREN && str[1] != OPEN_BRACKET) { - /* - * If it's not bounded by braces of some sort, life is much simpler. - * We just need to check for the first character and return the - * value if it exists. - */ - char name[2]; - - name[0] = str[1]; - name[1] = '\0'; - - v = VarFind(name, ctxt, FIND_ENV | FIND_GLOBAL | FIND_CMD); - if (v == (Var *)NULL) { - if (str[1] != '\0') - *lengthPtr = 2; - else - *lengthPtr = 1; - - if ((ctxt == VAR_CMD) || (ctxt == VAR_GLOBAL)) { - /* - * If substituting a local variable in a non-local context, - * assume it's for dynamic source stuff. We have to handle - * this specially and return the longhand for the variable - * with the dollar sign escaped so it makes it back to the - * caller. Only four of the local variables are treated - * specially as they are the only four that will be set - * when dynamic sources are expanded. - */ - /* XXX: It looks like $% and $! are reversed here */ - switch (str[1]) { - case '@': - return ("$(.TARGET)"); - case '%': - return ("$(.ARCHIVE)"); - case '*': - return ("$(.PREFIX)"); - case '!': - return ("$(.MEMBER)"); - default: - break; - } - } - /* - * Error - */ - return (err ? var_Error : varNoError); - } else { - haveModifier = FALSE; - tstr = &str[1]; - endc = str[1]; - } - } else { + if (str[1] == OPEN_PAREN || str[1] == OPEN_BRACKET) { /* build up expanded variable name in this buffer */ Buffer *buf = Buf_Init(MAKE_BSIZE); @@ -1105,7 +1054,14 @@ Var_Parse(char *str, GNode *ctxt, Boolea } } - if (!haveModifier) { + if (haveModifier) { + /* + * Still need to get to the end of the variable specification, + * so kludge up a Var structure for the modifications + */ + v = VarCreate(str, NULL, VAR_JUNK); + + } else { /* * No modifiers -- have specification length so we can return * now. @@ -1123,15 +1079,61 @@ Var_Parse(char *str, GNode *ctxt, Boolea Buf_Destroy(buf, TRUE); return (err ? var_Error : varNoError); } - } else { + } + } + Buf_Destroy(buf, TRUE); + + } else { + /* + * If it's not bounded by braces of some sort, life is much simpler. + * We just need to check for the first character and return the + * value if it exists. + */ + char name[2]; + + name[0] = str[1]; + name[1] = '\0'; + + v = VarFind(name, ctxt, FIND_ENV | FIND_GLOBAL | FIND_CMD); + if (v == (Var *)NULL) { + if (str[1] != '\0') + *lengthPtr = 2; + else + *lengthPtr = 1; + + if ((ctxt == VAR_CMD) || (ctxt == VAR_GLOBAL)) { /* - * Still need to get to the end of the variable specification, - * so kludge up a Var structure for the modifications + * If substituting a local variable in a non-local context, + * assume it's for dynamic source stuff. We have to handle + * this specially and return the longhand for the variable + * with the dollar sign escaped so it makes it back to the + * caller. Only four of the local variables are treated + * specially as they are the only four that will be set + * when dynamic sources are expanded. */ - v = VarCreate(str, NULL, VAR_JUNK); + /* XXX: It looks like $% and $! are reversed here */ + switch (str[1]) { + case '@': + return ("$(.TARGET)"); + case '%': + return ("$(.ARCHIVE)"); + case '*': + return ("$(.PREFIX)"); + case '!': + return ("$(.MEMBER)"); + default: + break; + } } + /* + * Error + */ + return (err ? var_Error : varNoError); + } else { + haveModifier = FALSE; + tstr = &str[1]; + endc = str[1]; } - Buf_Destroy(buf, TRUE); } if (v->flags & VAR_IN_USE) {