aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/rc
diff options
context:
space:
mode:
authorRuss Cox <rsc@swtch.com>2011-01-02 13:43:20 -0500
committerRuss Cox <rsc@swtch.com>2011-01-02 13:43:20 -0500
commit72f66c2d3ca556d35b818158e9de578c4bfa153e (patch)
treef7c94d56cd5e02f6d4a08f963548244c698f4a11 /src/cmd/rc
parentc4071243a591037f159e15618364521133b8d7ec (diff)
downloadplan9port-72f66c2d3ca556d35b818158e9de578c4bfa153e.tar.gz
plan9port-72f66c2d3ca556d35b818158e9de578c4bfa153e.tar.bz2
plan9port-72f66c2d3ca556d35b818158e9de578c4bfa153e.zip
rc: handle utf-8 in $ifs
R=rsc http://codereview.appspot.com/3798046
Diffstat (limited to 'src/cmd/rc')
-rw-r--r--src/cmd/rc/havefork.c24
1 files changed, 16 insertions, 8 deletions
diff --git a/src/cmd/rc/havefork.c b/src/cmd/rc/havefork.c
index 74abfe17..549b1966 100644
--- a/src/cmd/rc/havefork.c
+++ b/src/cmd/rc/havefork.c
@@ -112,13 +112,14 @@ Xbackq(void)
{
struct thread *p = runq;
char wd[8193];
- int c;
- char *s, *ewd=&wd[8192], *stop;
+ int c, n;
+ char *s, *ewd=&wd[8192], *stop, *q;
struct io *f;
var *ifs = vlook("ifs");
word *v, *nextv;
int pfd[2];
int pid;
+ Rune r;
stop = ifs->val?ifs->val->word:"";
if(pipe(pfd)<0){
Xerror("can't make pipe");
@@ -143,14 +144,21 @@ Xbackq(void)
s = wd;
v = 0;
while((c = rchr(f))!=EOF){
- if(strchr(stop, c) || s==ewd){
- if(s!=wd){
- *s='\0';
- v = newword(wd, v);
- s = wd;
+ if(s != ewd) {
+ *s++ = c;
+ for(q=stop; *q; q+=n) {
+ n = chartorune(&r, q);
+ if(s-wd >= n && memcmp(s-n, q, n) == 0) {
+ s -= n;
+ goto stop;
+ }
}
+ continue;
}
- else *s++=c;
+ stop:
+ *s = '\0';
+ v = newword(wd, v);
+ s = wd;
}
if(s!=wd){
*s='\0';