From: Martin Mares Date: Sun, 6 Oct 2002 15:45:45 +0000 (+0000) Subject: bdirect_read_prepare() now returns 0 instead of EOF. X-Git-Tag: holmes-import~1327 X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=7de317f0204214032e41d210c8b4d01f7871342f;p=libucw.git bdirect_read_prepare() now returns 0 instead of EOF. --- diff --git a/lib/fastbuf.c b/lib/fastbuf.c index 11571942..b7be624b 100644 --- a/lib/fastbuf.c +++ b/lib/fastbuf.c @@ -290,7 +290,7 @@ bbcopy_slow(struct fastbuf *f, struct fastbuf *t, uns l) uns favail, tavail, n; favail = bdirect_read_prepare(f, &fptr); - if (favail == (uns)EOF) + if (!favail) die("bbcopy: source exhausted"); tavail = bdirect_write_prepare(t, &tptr); n = MIN(l, favail); diff --git a/lib/fastbuf.h b/lib/fastbuf.h index 5ee23d48..ebc69955 100644 --- a/lib/fastbuf.h +++ b/lib/fastbuf.h @@ -65,7 +65,7 @@ struct fastbuf { int (*config)(struct fastbuf *, uns, int); /* Configure the stream */ }; -/* FastIO on standard files */ +/* FastIO on standard files (specify buffer size 0 to enable mmaping) */ struct fastbuf *bopen(byte *name, uns mode, uns buffer); struct fastbuf *bopen_tmp(uns buffer); @@ -315,11 +315,11 @@ bbcopy(struct fastbuf *f, struct fastbuf *t, uns l) /* Direct I/O on buffers */ -static inline int +static inline uns bdirect_read_prepare(struct fastbuf *f, byte **buf) { if (f->bptr == f->bstop && !f->refill(f)) - return EOF; + return 0; *buf = f->bptr; return f->bstop - f->bptr; } @@ -330,7 +330,7 @@ bdirect_read_commit(struct fastbuf *f, byte *pos) f->bptr = pos; } -static inline int +static inline uns bdirect_write_prepare(struct fastbuf *f, byte **buf) { if (f->bptr == f->bufend)