> 2009/3/17 erik quanstrom <quans...@quanstro.net>: > > it is unreasonable to expect to be able to generate tokens > > that are bigger than 8k. > > i'm not sure i agree. they're not just tokens, they're strings, > and there are lots of reasons why one might wish to > have a string longer than 8k read from a file. i've certainly done so > in inferno's sh, which doesn't have this restriction.
you win. couple of notes - * same changes to haven't fork, omitted for clarity * erealloc should be in subr.c and declared in rc.h and should be supported by Realloc in (plan9 unix win32)^.c * there are two other calls to realloc that should be addressed, too. * the if guarding efree prevents a "free 0" whine. havefork.c:67,81 - /n/dump/2009/0316/sys/src/cmd/rc/havefork.c:67,72 } } - char* - erealloc(char *p, long n) - { - p = realloc(p, n); /* botch, should be Realloc */ - if(p==0) - panic("Can't realloc %d bytes\n", n); - return p; - } - /* * Who should wait for the exit from the fork? */ havefork.c:82,89 - /n/dump/2009/0316/sys/src/cmd/rc/havefork.c:73,81 void Xbackq(void) { - int c, l; - char *s, *wd, *ewd, *stop; + char wd[8193]; + int c; + char *s, *ewd=&wd[8192], *stop; struct io *f; var *ifs = vlook("ifs"); word *v, *nextv; havefork.c:108,127 - /n/dump/2009/0316/sys/src/cmd/rc/havefork.c:100,115 default: close(pfd[PWR]); f = openfd(pfd[PRD]); - s = wd = ewd = 0; + s = wd; v = 0; while((c = rchr(f))!=EOF){ - if(s==ewd){ - l = s-wd; - wd = erealloc(wd, l+100); - ewd = wd+l+100-1; - s = wd+l; + if(strchr(stop, c) || s==ewd){ + if(s!=wd){ + *s='\0'; + v = newword(wd, v); + s = wd; + } } - if(strchr(stop, c) && s!=wd){ - *s='\0'; - v = newword(wd, v); - s = wd; - } else *s++=c; } if(s!=wd){ havefork.c:128,135 - /n/dump/2009/0316/sys/src/cmd/rc/havefork.c:116,121 *s='\0'; v = newword(wd, v); } - if(wd) - efree(wd); closeio(f); Waitfor(pid, 0); /* v points to reversed arglist -- reverse it onto argv */ - erik