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);
51 Berror(bp, "read error: %r");
54 * end of file with no delim
56 memmove(bp->ebuf-i, bp->bbuf, i);
59 bp->gbuf = bp->ebuf-i;
64 ep = memchr(ip, delim, j);
68 * copy back up and reset everything
70 ip = (char*)bp->ebuf - i;
72 memmove(ip, bp->bbuf, i);
73 bp->gbuf = (uchar*)ip;
75 j = (ep - (char*)bp->bbuf) + 1;
84 * full buffer without finding
86 bp->rdline = bp->bsize;
87 bp->icount = -bp->bsize;
93 Blinelen(Biobufhdr *bp)