]> mj.ucw.cz Git - libucw.git/blobdiff - ucw/fb-buffer.c
Signals: Document differences against strsignal()
[libucw.git] / ucw / fb-buffer.c
index 7fff1a1cfd94574bf4c1ce7f554c2cc0e827f471..9fc92277b2248ee99a33fa3e34ae9d1652b9bec0 100644 (file)
@@ -7,16 +7,18 @@
  *     of the GNU Lesser General Public License.
  */
 
-#include "ucw/lib.h"
-#include "ucw/fastbuf.h"
+#include <ucw/lib.h>
+#include <ucw/fastbuf.h>
 
 #include <stdio.h>
 #include <stdlib.h>
 
 static int
-fbbuf_refill(struct fastbuf *f UNUSED)
+fbbuf_refill(struct fastbuf *f)
 {
-  return 0;
+  f->bstop = f->bufend;
+  f->pos = f->bstop - f->buffer;
+  return f->bptr < f->bstop;
 }
 
 static int
@@ -26,7 +28,8 @@ fbbuf_seek(struct fastbuf *f, ucw_off_t pos, int whence)
   ucw_off_t len = f->bufend - f->buffer;
   if (whence == SEEK_END)
     pos += len;
-  ASSERT(pos >= 0 && pos <= len);
+  if (pos < 0 || pos > len)
+    bthrow(f, "seek", "Seek out of range");
   f->bptr = f->buffer + pos;
   f->bstop = f->bufend;
   f->pos = len;
@@ -51,7 +54,7 @@ fbbuf_init_read(struct fastbuf *f, byte *buf, uns size, uns can_overwrite)
 static void
 fbbuf_spout(struct fastbuf *f)
 {
-  bthrow(f, "fb.write", "fbbuf: buffer overflow on write");
+  bthrow(f, "write", "fbbuf: buffer overflow on write");
 }
 
 void