]> mj.ucw.cz Git - libucw.git/blobdiff - lib/fastbuf.c
In some cases, nextprime(x) could have been equal to x (reported by Milan).
[libucw.git] / lib / fastbuf.c
index 2631be06c1d7bf4c143228dba6a19ee331a58005..b7be624b5645d5ac34e1e52ca83b1ce2a951be62 100644 (file)
@@ -24,13 +24,10 @@ void bclose(struct fastbuf *f)
 
 void bflush(struct fastbuf *f)
 {
-  if (f->bptr != f->buffer)
-    {                                  /* Have something to flush */
-      if (f->bstop > f->buffer)                /* Read data? */
-       f->bptr = f->bstop = f->buffer;
-      else                             /* Write data... */
-       f->spout(f);
-    }
+  if (f->bptr > f->bstop)
+    f->spout(f);
+  else if (f->bstop > f->buffer)
+    f->bptr = f->bstop = f->buffer;
 }
 
 inline void bsetpos(struct fastbuf *f, sh_off_t pos)
@@ -293,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);
@@ -304,3 +301,9 @@ bbcopy_slow(struct fastbuf *f, struct fastbuf *t, uns l)
       l -= n;
     }
 }
+
+int
+bconfig(struct fastbuf *f, uns item, int value)
+{
+  return f->config ? f->config(f, item, value) : -1;
+}