aboutsummaryrefslogtreecommitdiff
path: root/lzio.c
diff options
context:
space:
mode:
Diffstat (limited to 'lzio.c')
-rw-r--r--lzio.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/lzio.c b/lzio.c
index a09dbdad..24826f68 100644
--- a/lzio.c
+++ b/lzio.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lzio.c,v 1.30 2005/05/17 19:49:15 roberto Exp roberto $ 2** $Id: lzio.c,v 1.31 2005/06/03 20:15:29 roberto Exp roberto $
3** a generic input stream interface 3** a generic input stream interface
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -22,10 +22,14 @@ int luaZ_fill (ZIO *z) {
22 size_t size; 22 size_t size;
23 lua_State *L = z->L; 23 lua_State *L = z->L;
24 const char *buff; 24 const char *buff;
25 if (z->eoz) return EOZ;
25 lua_unlock(L); 26 lua_unlock(L);
26 buff = z->reader(L, z->data, &size); 27 buff = z->reader(L, z->data, &size);
27 lua_lock(L); 28 lua_lock(L);
28 if (buff == NULL || size == 0) return EOZ; 29 if (buff == NULL || size == 0) {
30 z->eoz = 1; /* avoid calling reader function next time */
31 return EOZ;
32 }
29 z->n = size - 1; 33 z->n = size - 1;
30 z->p = buff; 34 z->p = buff;
31 return char2int(*(z->p++)); 35 return char2int(*(z->p++));
@@ -51,6 +55,7 @@ void luaZ_init (lua_State *L, ZIO *z, lua_Reader reader, void *data) {
51 z->data = data; 55 z->data = data;
52 z->n = 0; 56 z->n = 0;
53 z->p = NULL; 57 z->p = NULL;
58 z->eoz = 0;
54} 59}
55 60
56 61