X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;ds=sidebyside;f=lib%2Ffb-grow.c;h=f9a654a4b2eeb29f69af3b54c273c47bf4f26c78;hb=90afcc18dbf7cb6c682e1efb994007f03e304422;hp=0b04817fcc1caa6855845700ec175a911e4e4aab;hpb=06e407148505bb6f8fb92592d8484062362256ef;p=libucw.git diff --git a/lib/fb-grow.c b/lib/fb-grow.c index 0b04817f..f9a654a4 100644 --- a/lib/fb-grow.c +++ b/lib/fb-grow.c @@ -10,6 +10,7 @@ #include "lib/lib.h" #include "lib/fastbuf.h" +#include #include struct fb_gbuf { @@ -45,7 +46,7 @@ fbgrow_spout(struct fastbuf *b) } } -static void +static int fbgrow_seek(struct fastbuf *b, sh_off_t pos, int whence) { ASSERT(FB_GBUF(b)->last_written); /* Seeks allowed only in read mode */ @@ -56,6 +57,7 @@ fbgrow_seek(struct fastbuf *b, sh_off_t pos, int whence) b->bptr = b->buffer + pos; b->bstop = FB_GBUF(b)->last_written; b->pos = len; + return 1; } static void @@ -107,12 +109,12 @@ fbgrow_rewind(struct fastbuf *b) int main(void) { struct fastbuf *f; - int t; + uns t; f = fbgrow_create(3); for (uns i=0; i<5; i++) { - fbgrow_write(f); + fbgrow_reset(f); bwrite(f, "12345", 5); bwrite(f, "12345", 5); printf("<%d>", (int)btell(f)); @@ -120,13 +122,13 @@ int main(void) printf("<%d>", (int)btell(f)); fbgrow_rewind(f); printf("<%d>", (int)btell(f)); - while ((t = bgetc(f)) >= 0) + while ((t = bgetc(f)) != ~0U) putchar(t); printf("<%d>", (int)btell(f)); fbgrow_rewind(f); bseek(f, -1, SEEK_END); printf("<%d>", (int)btell(f)); - while ((t = bgetc(f)) >= 0) + while ((t = bgetc(f)) != ~0U) putchar(t); printf("<%d>\n", (int)btell(f)); }