#endif
}
-void bread_slow(struct fastbuf *f, void *b, uns l)
+uns bread_slow(struct fastbuf *f, void *b, uns l)
{
+ uns total = 0;
while (l)
{
uns k = f->bstop - f->bptr;
f->refill(f);
k = f->bstop - f->bptr;
if (!k)
- die("bread on %s: file exhausted", f->name);
+ break;
}
if (k > l)
k = l;
f->bptr += k;
b = (byte *)b + k;
l -= k;
+ total += k;
}
+ return total;
}
void bwrite_slow(struct fastbuf *f, void *b, uns l)
bput5_slow(f, l);
}
-void bread_slow(struct fastbuf *f, void *b, uns l);
-static inline void bread(struct fastbuf *f, void *b, uns l)
+uns bread_slow(struct fastbuf *f, void *b, uns l);
+static inline uns bread(struct fastbuf *f, void *b, uns l)
{
if (f->bptr + l <= f->bstop)
{
memcpy(b, f->bptr, l);
f->bptr += l;
+ return l;
}
else
- bread_slow(f, b, l);
+ return bread_slow(f, b, l);
}
void bwrite_slow(struct fastbuf *f, void *b, uns l);