diff options
author | Hartmut Brandt <harti@FreeBSD.org> | 2004-01-12 10:35:46 +0000 |
---|---|---|
committer | Hartmut Brandt <harti@FreeBSD.org> | 2004-01-12 10:35:46 +0000 |
commit | 10a527618c9a02afdebbfb6204ad0923b6651144 (patch) | |
tree | b7bea4996bc9154c544334d1c5e168aafdc2f15c /usr.bin/make | |
parent | 45a0b23e06c15093835f9ef474b08159209ef1b5 (diff) | |
download | src-10a527618c9a02afdebbfb6204ad0923b6651144.tar.gz src-10a527618c9a02afdebbfb6204ad0923b6651144.zip |
Allow variable substitutions in SYSV variable substitutions like
$(SRC:.c=$O). This brings us closer to other makes.
Reviewed by: ru
Obtained from: NetBSD
Notes
Notes:
svn path=/head/; revision=124420
Diffstat (limited to 'usr.bin/make')
-rw-r--r-- | usr.bin/make/var.c | 55 |
1 files changed, 33 insertions, 22 deletions
diff --git a/usr.bin/make/var.c b/usr.bin/make/var.c index 716c14791075..3499e2a7ff3c 100644 --- a/usr.bin/make/var.c +++ b/usr.bin/make/var.c @@ -1592,37 +1592,48 @@ Var_Parse(char *str, GNode *ctxt, Boolean err, int *lengthPtr, Boolean *freePtr) * Now we break this sucker into the lhs and * rhs. We must null terminate them of course. */ - for (cp = tstr; *cp != '='; cp++) - continue; - pattern.lhs = tstr; - pattern.leftLen = cp - tstr; - *cp++ = '\0'; - - pattern.rhs = cp; - cnt = 1; - while (cnt) { - if (*cp == endc) - cnt--; - else if (*cp == startc) - cnt++; - if (cnt) - cp++; + cp = tstr; + + delim = '='; + if ((pattern.lhs = VarGetPattern(ctxt, + err, &cp, delim, &pattern.flags, &pattern.leftLen, + NULL)) == NULL) { + /* was: goto cleanup */ + *lengthPtr = cp - start + 1; + if (*freePtr) + free(str); + if (delim != '\0') + Fatal("Unclosed substitution for %s (%c missing)", + v->name, delim); + return (var_Error); + } + + delim = endc; + if ((pattern.rhs = VarGetPattern(ctxt, + err, &cp, delim, NULL, &pattern.rightLen, + &pattern)) == NULL) { + /* was: goto cleanup */ + *lengthPtr = cp - start + 1; + if (*freePtr) + free(str); + if (delim != '\0') + Fatal("Unclosed substitution for %s (%c missing)", + v->name, delim); + return (var_Error); } - pattern.rightLen = cp - pattern.rhs; - *cp = '\0'; /* * SYSV modifications happen through the whole * string. Note the pattern is anchored at the end. */ + termc = *--cp; + delim = '\0'; newStr = VarModify(str, VarSYSVMatch, (void *)&pattern); - /* - * Restore the nulled characters - */ - pattern.lhs[pattern.leftLen] = '='; - pattern.rhs[pattern.rightLen] = endc; + free(pattern.lhs); + free(pattern.rhs); + termc = endc; } else #endif |