6 Brdline(Biobufhdr *bp, int delim)
16 if(bp->state != Bractive) {
17 if(bp->state == Bracteof)
26 * first try in remainder of buffer (gbuf doesn't change)
28 ip = (char*)bp->ebuf - i;
29 ep = memchr(ip, delim, i);
38 * copy data to beginning of buffer
41 memmove(bp->bbuf, ip, i);
45 * append to buffer looking for the delim
47 ip = (char*)bp->bbuf + i;
48 while(i < bp->bsize) {
49 j = read(bp->fid, ip, bp->bsize-i);
52 * end of file with no delim
54 memmove(bp->ebuf-i, bp->bbuf, i);
57 bp->gbuf = bp->ebuf-i;
62 ep = memchr(ip, delim, j);
66 * copy back up and reset everything
68 ip = (char*)bp->ebuf - i;
70 memmove(ip, bp->bbuf, i);
71 bp->gbuf = (uchar*)ip;
73 j = (ep - (char*)bp->bbuf) + 1;
82 * full buffer without finding
84 bp->rdline = bp->bsize;
85 bp->icount = -bp->bsize;
91 Blinelen(Biobufhdr *bp)