aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/mk/word.c
diff options
context:
space:
mode:
authorrsc <devnull@localhost>2007-03-26 17:27:08 +0000
committerrsc <devnull@localhost>2007-03-26 17:27:08 +0000
commit6c4c5c5b959ec8a2e85510bdf85339582f638f36 (patch)
tree29e27c708e67bf46d8ee4f5580a09dbc06f34ae6 /src/cmd/mk/word.c
parentedd308cfa28421761db073542ecd538a13949d13 (diff)
downloadplan9port-6c4c5c5b959ec8a2e85510bdf85339582f638f36.tar.gz
plan9port-6c4c5c5b959ec8a2e85510bdf85339582f638f36.tar.bz2
plan9port-6c4c5c5b959ec8a2e85510bdf85339582f638f36.zip
fix empty string interpolation bugs (Michael Teichgräber)
Diffstat (limited to 'src/cmd/mk/word.c')
-rw-r--r--src/cmd/mk/word.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/cmd/mk/word.c b/src/cmd/mk/word.c
index b0e344ea..f94c4fd7 100644
--- a/src/cmd/mk/word.c
+++ b/src/cmd/mk/word.c
@@ -97,12 +97,15 @@ nextword(char **s)
Word *head, *tail, *w;
Rune r;
char *cp;
+ int empty;
cp = *s;
b = newbuf();
+restart:
head = tail = 0;
while(*cp == ' ' || *cp == '\t') /* leading white space */
cp++;
+ empty = 1;
while(*cp){
cp += chartorune(&r, cp);
switch(r)
@@ -114,6 +117,7 @@ nextword(char **s)
case '\\':
case '\'':
case '"':
+ empty = 0;
cp = shellt->expandquote(cp, r, b);
if(cp == 0){
fprint(2, "missing closing quote: %s\n", *s);
@@ -122,8 +126,12 @@ nextword(char **s)
break;
case '$':
w = varsub(&cp);
- if(w == 0)
+ if(w == 0){
+ if(empty)
+ goto restart;
break;
+ }
+ empty = 0;
if(b->current != b->start){
bufcpy(b, w->s, strlen(w->s));
insert(b, 0);
@@ -147,6 +155,7 @@ nextword(char **s)
tail = tail->next;
break;
default:
+ empty = 0;
rinsert(b, r);
break;
}