summaryrefslogtreecommitdiff
path: root/usr.bin/make
diff options
context:
space:
mode:
authorjtc <jtc@NetBSD.org>1994-06-16 18:50:18 +0000
committerjtc <jtc@NetBSD.org>1994-06-16 18:50:18 +0000
commitac414e10cda4bb2e86f5cb01f2e168cb2b102670 (patch)
tree441df52d92fc343272d6d16c55eda4515fdcbe4a /usr.bin/make
parentc52cfbef5c9c8543d684dc4bd8f77ecff66dc930 (diff)
Christos' fix for quoting variable extraction properly.
Diffstat (limited to 'usr.bin/make')
-rw-r--r--usr.bin/make/str.c23
-rw-r--r--usr.bin/make/var.c49
2 files changed, 32 insertions, 40 deletions
diff --git a/usr.bin/make/str.c b/usr.bin/make/str.c
index ebb1325316a..86c8ba833bf 100644
--- a/usr.bin/make/str.c
+++ b/usr.bin/make/str.c
@@ -38,7 +38,7 @@
#ifndef lint
/* from: static char sccsid[] = "@(#)str.c 5.8 (Berkeley) 6/1/90"; */
-static char *rcsid = "$Id: str.c,v 1.7 1994/06/06 22:45:43 jtc Exp $";
+static char *rcsid = "$Id: str.c,v 1.8 1994/06/16 18:50:18 jtc Exp $";
#endif /* not lint */
#include "make.h"
@@ -131,9 +131,10 @@ str_concat(s1, s2, flags)
* the first word is always the value of the .MAKE variable.
*/
char **
-brk_string(str, store_argc)
+brk_string(str, store_argc, expand)
register char *str;
int *store_argc;
+ Boolean expand;
{
register int argc, ch;
register char inquote, *p, *start, *t;
@@ -173,20 +174,28 @@ brk_string(str, store_argc)
break;
}
}
+ if (!expand) {
+ if (!start)
+ start = t;
+ *t++ = ch;
+ }
continue;
case ' ':
case '\t':
+ case '\n':
if (inquote)
break;
if (!start)
continue;
/* FALLTHROUGH */
- case '\n':
case '\0':
/*
* end of a token -- make sure there's enough argv
* space and save off a pointer.
*/
+ if (!start)
+ goto done;
+
*t++ = '\0';
if (argc == argmax) {
argmax *= 2; /* ramp up fast */
@@ -200,6 +209,14 @@ brk_string(str, store_argc)
goto done;
continue;
case '\\':
+ if (!expand) {
+ if (!start)
+ start = t;
+ *t++ = '\\';
+ ch = *++p;
+ break;
+ }
+
switch (ch = *++p) {
case '\0':
case '\n':
diff --git a/usr.bin/make/var.c b/usr.bin/make/var.c
index 1f9ecbe38e3..0e3a1ae9990 100644
--- a/usr.bin/make/var.c
+++ b/usr.bin/make/var.c
@@ -38,7 +38,7 @@
#ifndef lint
/* from: static char sccsid[] = "@(#)var.c 5.7 (Berkeley) 6/1/90"; */
-static char *rcsid = "$Id: var.c,v 1.6 1994/06/06 22:45:49 jtc Exp $";
+static char *rcsid = "$Id: var.c,v 1.7 1994/06/16 18:50:20 jtc Exp $";
#endif /* not lint */
/*-
@@ -1060,49 +1060,24 @@ VarModify (str, modProc, datum)
ClientData datum; /* Datum to pass it */
{
Buffer buf; /* Buffer for the new string */
- register char *cp; /* Pointer to end of current word */
- char endc; /* Character that ended the word */
Boolean addSpace; /* TRUE if need to add a space to the
* buffer before adding the trimmed
* word */
-
+ char **av; /* word list [first word does not count] */
+ int ac, i;
+
buf = Buf_Init (0);
- cp = str;
addSpace = FALSE;
-
- for (;;) {
- /*
- * Skip to next word and place cp at its end.
- */
- while (isspace (*str)) {
- str++;
- }
- for (cp = str; *cp != '\0' && !isspace (*cp); cp++)
- continue;
- if (cp == str) {
- /*
- * If we didn't go anywhere, we must be done!
- */
- Buf_AddByte (buf, '\0');
- str = (char *)Buf_GetAll (buf, (int *)NULL);
- Buf_Destroy (buf, FALSE);
- return (str);
- }
- /*
- * Nuke terminating character, but save it in endc b/c if str was
- * some variable's value, it would not be good to screw it
- * over...
- */
- endc = *cp;
- *cp = '\0';
- addSpace = (* modProc) (str, addSpace, buf, datum);
+ av = brk_string(str, &ac, FALSE);
- if (endc) {
- *cp++ = endc;
- }
- str = cp;
- }
+ for (i = 1; i < ac; i++)
+ addSpace = (*modProc)(av[i], addSpace, buf, datum);
+
+ Buf_AddByte (buf, '\0');
+ str = (char *)Buf_GetAll (buf, (int *)NULL);
+ Buf_Destroy (buf, FALSE);
+ return (str);
}
/*-