]> mj.ucw.cz Git - libucw.git/blobdiff - lib/fastbuf.c
Added REV_COMPARE(x,y) which is equivalent to COMPARE(y,x), but it's
[libucw.git] / lib / fastbuf.c
index 50b869a88ff39b086f5e09a952703f7ddb494a48..bf887a18f86acd33ae61603a62486b5a2fbf34b5 100644 (file)
@@ -1,7 +1,7 @@
 /*
  *     Sherlock Library -- Fast Buffered I/O
  *
- *     (c) 1997--2000 Martin Mares <mj@ucw.cz>
+ *     (c) 1997--2004 Martin Mares <mj@ucw.cz>
  *
  *     This software may be freely distributed and used according to the terms
  *     of the GNU Lesser General Public License.
@@ -314,14 +314,19 @@ bbcopy_slow(struct fastbuf *f, struct fastbuf *t, uns l)
 
       favail = bdirect_read_prepare(f, &fptr);
       if (!favail)
-       die("bbcopy: source exhausted");
+       {
+         if (l == ~0U)
+           return;
+         die("bbcopy: source exhausted");
+       }
       tavail = bdirect_write_prepare(t, &tptr);
       n = MIN(l, favail);
       n = MIN(n, tavail);
       memcpy(tptr, fptr, n);
       bdirect_read_commit(f, fptr + n);
       bdirect_write_commit(t, tptr + n);
-      l -= n;
+      if (l != ~0U)
+       l -= n;
     }
 }
 
@@ -330,3 +335,10 @@ bconfig(struct fastbuf *f, uns item, int value)
 {
   return f->config ? f->config(f, item, value) : -1;
 }
+
+void
+brewind(struct fastbuf *f)
+{
+  bflush(f);
+  bsetpos(f, 0);
+}