diff options
author | ru <ru@FreeBSD.org> | 2008-03-24 12:33:28 +0000 |
---|---|---|
committer | ru <ru@FreeBSD.org> | 2008-03-24 12:33:28 +0000 |
commit | 98fbc814ae21210ec2e68611af7195f66c41e37c (patch) | |
tree | e0cb09d02da64eac6d197744fcd6973ddfebf608 /usr.bin/make/for.c | |
parent | 430a85c91d6a78679a1d3d2ecfdaac378de35f11 (diff) | |
download | FreeBSD-src-98fbc814ae21210ec2e68611af7195f66c41e37c.zip FreeBSD-src-98fbc814ae21210ec2e68611af7195f66c41e37c.tar.gz |
Fix splitting into words of the .for expression to allow for
spaces in values. Without this change, the following valid
call broke due to parsing of .MAKEFLAGS in bsd.symver.mk:
cd /usr/src/lib/libc && make -n DEBUG_FLAGS="-DFOO -DBAR"
Spotted by: Igor Sysoev
Submitted by: Maxim Dounin, ru
MFC after: 1 week
Diffstat (limited to 'usr.bin/make/for.c')
-rw-r--r-- | usr.bin/make/for.c | 30 |
1 files changed, 8 insertions, 22 deletions
diff --git a/usr.bin/make/for.c b/usr.bin/make/for.c index 15372b6..b035238 100644 --- a/usr.bin/make/for.c +++ b/usr.bin/make/for.c @@ -56,6 +56,7 @@ __FBSDID("$FreeBSD$"); #include "lst.h" #include "make.h" #include "parse.h" +#include "str.h" #include "util.h" #include "var.h" @@ -97,6 +98,8 @@ For_For(char *line) char *sub; Buffer *buf; size_t varlen; + int i; + ArgArray words; ptr = line; @@ -148,33 +151,16 @@ For_For(char *line) /* * Make a list with the remaining words - * XXX should use brk_string here. */ sub = Buf_Peel(Var_Subst(ptr, VAR_CMD, FALSE)); - for (ptr = sub; *ptr != '\0' && isspace((u_char)*ptr); ptr++) - ; - + brk_string(&words, sub, FALSE); Lst_Init(&forLst); - buf = Buf_Init(0); - for (wrd = ptr; *ptr != '\0'; ptr++) { - if (isspace((u_char)*ptr)) { - Buf_AppendRange(buf, wrd, ptr); - Lst_AtFront(&forLst, Buf_Peel(buf)); - - buf = Buf_Init(0); - while (*ptr != '\0' && isspace((u_char)*ptr)) - ptr++; - wrd = ptr--; - } + for (i = 1; i < words.argc; i++) { + if (words.argv[i][0] != '\0') + Lst_AtFront(&forLst, estrdup(words.argv[i])); } + ArgArray_Done(&words); DEBUGF(FOR, ("For: Iterator %s List %s\n", forVar, sub)); - - if (ptr - wrd > 0) { - Buf_AppendRange(buf, wrd, ptr); - Lst_AtFront(&forLst, Buf_Peel(buf)); - } else { - Buf_Destroy(buf, TRUE); - } free(sub); forBuf = Buf_Init(0); |