summaryrefslogtreecommitdiffstats
path: root/usr.bin
diff options
context:
space:
mode:
authorharti <harti@FreeBSD.org>2004-01-12 10:35:46 +0000
committerharti <harti@FreeBSD.org>2004-01-12 10:35:46 +0000
commit275c1489e921dd915053d098c1029b760758e67a (patch)
treeb7bea4996bc9154c544334d1c5e168aafdc2f15c /usr.bin
parent58a7725eaf7f7f39f8863317d2eacb1174c0ee36 (diff)
downloadFreeBSD-src-275c1489e921dd915053d098c1029b760758e67a.zip
FreeBSD-src-275c1489e921dd915053d098c1029b760758e67a.tar.gz
Allow variable substitutions in SYSV variable substitutions like
$(SRC:.c=$O). This brings us closer to other makes. Reviewed by: ru Obtained from: NetBSD
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/make/var.c55
1 files changed, 33 insertions, 22 deletions
diff --git a/usr.bin/make/var.c b/usr.bin/make/var.c
index 716c147..3499e2a 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
OpenPOWER on IntegriCloud