fix buf and buf_getc
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
diff --git a/libkc3/buf.c b/libkc3/buf.c
index cb5d31b..3078663 100644
--- a/libkc3/buf.c
+++ b/libkc3/buf.c
@@ -995,6 +995,12 @@ sw buf_refill_compact (s_buf *buf)
if (min_rpos == buf->wpos) {
buf->rpos = 0;
buf->wpos = 0;
+ save = buf->save;
+ while (save) {
+ save->rpos -= min_rpos;
+ save->wpos -= min_rpos;
+ save = save->next;
+ }
}
else {
size = buf->wpos - min_rpos;
@@ -1011,9 +1017,8 @@ sw buf_refill_compact (s_buf *buf)
}
buf->wpos = size;
}
- return 1;
}
- return 0;
+ return 1;
}
s_str * buf_slice_to_str (const s_buf *buf, uw start, uw end,
diff --git a/libkc3/buf_getc.c b/libkc3/buf_getc.c
index 37d46a1..28b98d1 100644
--- a/libkc3/buf_getc.c
+++ b/libkc3/buf_getc.c
@@ -61,7 +61,8 @@ sw buf_getc_refill (s_buf *buf)
c != '\n' &&
(c = getc(fp)) != EOF &&
c <= 255) {
- buf_write_u8(buf, c);
+ if (buf_write_u8(buf, c) < 0)
+ return -1;
result++;
}
return result;