|
|
1.1 root 1: #include <libc.h>
2:
3: #define BUFSIZE 65536
4: static char buf[BUFSIZE], *next = &buf[BUFSIZE], *rnext = buf;
5: long cnt;
6:
7: rd(b, e)
8: register char **b, **e;
9: {
10: int n, m;
11:
12: if((*b == 0) || (*b == *e))
13: rnext = *b = *e = buf;
14: if(rnext == &buf[BUFSIZE]){
15: if(*b > buf){
16: if(next < *b){
17: /* fail(next, *b); */
18: }
19: memmove(buf, *b, n = rnext - *b);
20: rnext -= (*b - buf);
21: next = *b = buf;
22: }
23: }
24: if((n = read(0, rnext, &buf[BUFSIZE] - rnext)) <= 0){
25: return(n);
26: }
27: *e = (rnext += n);
28: return(1);
29: }
30:
31: match(b, e)
32: register char **b, **e;
33: {
34: char *s, *f;
35: int eoffset, n;
36:
37: cnt++;
38: for(s = *b; s >= buf;)
39: if(*--s == '\n')
40: break;
41: s++;
42: if(next != s){
43: /* fail(next, s); */
44: }
45: for(f = *e;;){
46: for(; f < rnext; f++)
47: if(*f == '\n')
48: goto done;
49: eoffset = f-s;
50: if((n = rd(&s, &f)) <= 0)
51: return(n);
52: f = s+eoffset;
53: }
54: done:
55: f++;
56: /* succ(s, f) */
57: next = *b = f;
58: *e = rnext;
59: return(1);
60: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.