X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;ds=inline;f=ucw%2Fff-string.c;h=d3aff87ce9ee7f1c792ce00e98d41af1e56d6e35;hb=ba63c40936d99652f5ffe7f57a34dd79c7c8a74d;hp=366092bf7568a90193bf0f55e097ecfc5dcacbec;hpb=1cf8ac51f5495ccd5187dc220ffc69e95d6e0cfc;p=libucw.git diff --git a/ucw/ff-string.c b/ucw/ff-string.c index 366092bf..d3aff87c 100644 --- a/ucw/ff-string.c +++ b/ucw/ff-string.c @@ -8,23 +8,23 @@ * of the GNU Lesser General Public License. */ -#include "ucw/lib.h" -#include "ucw/fastbuf.h" -#include "ucw/mempool.h" -#include "ucw/bbuf.h" +#include +#include +#include +#include char * /* Non-standard */ -bgets(struct fastbuf *f, char *b, uns l) +bgets(struct fastbuf *f, char *b, uint l) { ASSERT(l); byte *src; - uns src_len = bdirect_read_prepare(f, &src); + uint src_len = bdirect_read_prepare(f, &src); if (!src_len) return NULL; do { - uns cnt = MIN(l, src_len); - for (uns i = cnt; i--;) + uint cnt = MIN(l, src_len); + for (uint i = cnt; i--;) { byte v = *src++; if (v == '\n') @@ -35,7 +35,7 @@ bgets(struct fastbuf *f, char *b, uns l) *b++ = v; } if (unlikely(cnt == l)) - die("%s: Line too long", f->name); + bthrow(f, "toolong", "%s: Line too long", f->name); l -= cnt; bdirect_read_commit(f, src); src_len = bdirect_read_prepare(f, &src); @@ -47,17 +47,17 @@ exit: } int -bgets_nodie(struct fastbuf *f, char *b, uns l) +bgets_nodie(struct fastbuf *f, char *b, uint l) { ASSERT(l); byte *src, *start = b; - uns src_len = bdirect_read_prepare(f, &src); + uint src_len = bdirect_read_prepare(f, &src); if (!src_len) return 0; do { - uns cnt = MIN(l, src_len); - for (uns i = cnt; i--;) + uint cnt = MIN(l, src_len); + for (uint i = cnt; i--;) { byte v = *src++; if (v == '\n') @@ -79,21 +79,21 @@ exit: return b - (char *)start; } -uns -bgets_bb(struct fastbuf *f, struct bb_t *bb, uns limit) +uint +bgets_bb(struct fastbuf *f, struct bb_t *bb, uint limit) { ASSERT(limit); byte *src; - uns src_len = bdirect_read_prepare(f, &src); + uint src_len = bdirect_read_prepare(f, &src); if (!src_len) return 0; bb_grow(bb, 1); byte *buf = bb->ptr; - uns len = 0, buf_len = MIN(bb->len, limit); + uint len = 0, buf_len = MIN(bb->len, limit); do { - uns cnt = MIN(src_len, buf_len); - for (uns i = cnt; i--;) + uint cnt = MIN(src_len, buf_len); + for (uint i = cnt; i--;) { byte v = *src++; if (v == '\n') @@ -114,7 +114,7 @@ bgets_bb(struct fastbuf *f, struct bb_t *bb, uns limit) if (cnt == buf_len) { if (unlikely(len == limit)) - die("%s: Line too long", f->name); + bthrow(f, "toolong", "%s: Line too long", f->name); bb_do_grow(bb, len + 1); buf = bb->ptr + len; buf_len = MIN(bb->len, limit) - len; @@ -132,7 +132,7 @@ char * bgets_mp(struct fastbuf *f, struct mempool *mp) { byte *src; - uns src_len = bdirect_read_prepare(f, &src); + uint src_len = bdirect_read_prepare(f, &src); if (!src_len) return NULL; #define BLOCK_SIZE (4096 - sizeof(void *)) @@ -140,13 +140,13 @@ bgets_mp(struct fastbuf *f, struct mempool *mp) struct block *prev; byte data[BLOCK_SIZE]; } *blocks = NULL; - uns sum = 0, buf_len = BLOCK_SIZE, cnt; + uint sum = 0, buf_len = BLOCK_SIZE, cnt; struct block first_block, *new_block = &first_block; byte *buf = new_block->data; do { cnt = MIN(src_len, buf_len); - for (uns i = cnt; i--;) + for (uint i = cnt; i--;) { byte v = *src++; if (v == '\n') @@ -176,7 +176,7 @@ bgets_mp(struct fastbuf *f, struct mempool *mp) } while (src_len); exit: ; - uns len = buf - new_block->data; + uint len = buf - new_block->data; byte *result = mp_alloc(mp, sum + len + 1) + sum; result[len] = 0; memcpy(result, new_block->data, len); @@ -191,17 +191,17 @@ exit: ; } char * -bgets0(struct fastbuf *f, char *b, uns l) +bgets0(struct fastbuf *f, char *b, uint l) { ASSERT(l); byte *src; - uns src_len = bdirect_read_prepare(f, &src); + uint src_len = bdirect_read_prepare(f, &src); if (!src_len) return NULL; do { - uns cnt = MIN(l, src_len); - for (uns i = cnt; i--;) + uint cnt = MIN(l, src_len); + for (uint i = cnt; i--;) { *b = *src++; if (!*b) @@ -212,7 +212,7 @@ bgets0(struct fastbuf *f, char *b, uns l) b++; } if (unlikely(cnt == l)) - die("%s: Line too long", f->name); + bthrow(f, "toolong", "%s: Line too long", f->name); l -= cnt; bdirect_read_commit(f, src); src_len = bdirect_read_prepare(f, &src);