2 * UCW Library -- Fast Buffered I/O: Strings on stack
4 * (c) 2008 Michal Vaner <vorner@ucw.cz>
6 * Code taken from ff-string.c by:
8 * (c) 1997--2006 Martin Mares <mj@ucw.cz>
9 * (c) 2006 Pavel Charvat <pchar@ucw.cz>
11 * This software may be freely distributed and used according to the terms
12 * of the GNU Lesser General Public License.
16 #include <ucw/fastbuf.h>
19 bgets_stk_init(struct bgets_stk_struct *s)
21 s->src_len = bdirect_read_prepare(s->f, &s->src);
35 bgets_stk_step(struct bgets_stk_struct *s)
37 byte *buf = s->cur_buf;
38 uns buf_len = s->cur_len;
41 memcpy( s->cur_buf, s->old_buf, s->old_len);
43 buf_len -= s->old_len;
47 uns cnt = MIN(s->src_len, buf_len);
48 for (uns i = cnt; i--;)
53 bdirect_read_commit(s->f, s->src);
58 if (cnt == s->src_len)
60 bdirect_read_commit(s->f, s->src);
61 s->src_len = bdirect_read_prepare(s->f, &s->src);
67 s->old_len = s->cur_len;
68 s->old_buf = s->cur_buf;