summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--buffer.c3
-rw-r--r--stream.c4
2 files changed, 4 insertions, 3 deletions
diff --git a/buffer.c b/buffer.c
index 0261522..c1a33a1 100644
--- a/buffer.c
+++ b/buffer.c
@@ -42,8 +42,9 @@ int buffer_prepare_at_least(int fd, struct buffer * in, int minimum_length)
if (0 < in->offset)
{
memmove(in->data, in->data + in->offset, in->length - in->offset);
- in->offset = 0;
in->length -= in->offset;
+ in->next -= in->offset;
+ in->offset = 0;
}
int length = read(fd, in->data + in->length, free_space);
diff --git a/stream.c b/stream.c
index eb1d0ea..c6d5bb2 100644
--- a/stream.c
+++ b/stream.c
@@ -173,8 +173,8 @@ int stream_readk(lua_State * L, int status, lua_KContext ctx)
if (-1 != offset)
{
lua_pushlstring(L, &s->in.data[s->in.offset], offset - s->in.offset);
- s->in.offset = offset + 1;
- s->in.next = offset + 1;
+ s->in.offset = offset + pattern_length;
+ s->in.next = offset + pattern_length;
}
else
{