From: Martin Mares Date: Tue, 20 Feb 2001 22:32:06 +0000 (+0000) Subject: Added bgets0(). X-Git-Tag: holmes-import~1544 X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=8d7ea15cf2d519e6f6cae540bdaeeee7fbc82acc;p=libucw.git Added bgets0(). --- diff --git a/lib/fastbuf.c b/lib/fastbuf.c index 2d00bf05..00fa51bc 100644 --- a/lib/fastbuf.c +++ b/lib/fastbuf.c @@ -256,6 +256,28 @@ bgets(struct fastbuf *f, byte *b, uns l) die("%s: Line too long", f->name); } +byte * +bgets0(struct fastbuf *f, byte *b, uns l) +{ + byte *e = b + l - 1; + int k; + + k = bgetc(f); + if (k == EOF) + return NULL; + while (b < e) + { + if (!k || k == EOF) + { + *b = 0; + return b; + } + *b++ = k; + k = bgetc(f); + } + die("%s: Line too long", f->name); +} + int bdirect_read(struct fastbuf *f, byte **buf) { diff --git a/lib/fastbuf.h b/lib/fastbuf.h index 15bfed5a..d831ed36 100644 --- a/lib/fastbuf.h +++ b/lib/fastbuf.h @@ -306,6 +306,7 @@ static inline void bwrite(struct fastbuf *f, void *b, uns l) } byte *bgets(struct fastbuf *f, byte *b, uns l); /* Non-std */ +byte *bgets0(struct fastbuf *f, byte *b, uns l); static inline void bputs(struct fastbuf *f, byte *b)