mirror of
https://github.com/9fans/plan9port.git
synced 2025-01-27 11:52:03 +00:00
parent
c4071243a5
commit
72f66c2d3c
1 changed files with 16 additions and 8 deletions
|
@ -112,13 +112,14 @@ Xbackq(void)
|
||||||
{
|
{
|
||||||
struct thread *p = runq;
|
struct thread *p = runq;
|
||||||
char wd[8193];
|
char wd[8193];
|
||||||
int c;
|
int c, n;
|
||||||
char *s, *ewd=&wd[8192], *stop;
|
char *s, *ewd=&wd[8192], *stop, *q;
|
||||||
struct io *f;
|
struct io *f;
|
||||||
var *ifs = vlook("ifs");
|
var *ifs = vlook("ifs");
|
||||||
word *v, *nextv;
|
word *v, *nextv;
|
||||||
int pfd[2];
|
int pfd[2];
|
||||||
int pid;
|
int pid;
|
||||||
|
Rune r;
|
||||||
stop = ifs->val?ifs->val->word:"";
|
stop = ifs->val?ifs->val->word:"";
|
||||||
if(pipe(pfd)<0){
|
if(pipe(pfd)<0){
|
||||||
Xerror("can't make pipe");
|
Xerror("can't make pipe");
|
||||||
|
@ -143,14 +144,21 @@ Xbackq(void)
|
||||||
s = wd;
|
s = wd;
|
||||||
v = 0;
|
v = 0;
|
||||||
while((c = rchr(f))!=EOF){
|
while((c = rchr(f))!=EOF){
|
||||||
if(strchr(stop, c) || s==ewd){
|
if(s != ewd) {
|
||||||
if(s!=wd){
|
*s++ = c;
|
||||||
*s='\0';
|
for(q=stop; *q; q+=n) {
|
||||||
v = newword(wd, v);
|
n = chartorune(&r, q);
|
||||||
s = wd;
|
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){
|
if(s!=wd){
|
||||||
*s='\0';
|
*s='\0';
|
||||||
|
|
Loading…
Reference in a new issue