aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lapi.c4
-rw-r--r--lzio.c7
-rw-r--r--lzio.h5
3 files changed, 9 insertions, 7 deletions
diff --git a/lapi.c b/lapi.c
index 2a8283a4..966f72ec 100644
--- a/lapi.c
+++ b/lapi.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lapi.c,v 1.241 2003/08/15 13:48:53 roberto Exp roberto $ 2** $Id: lapi.c,v 1.242 2003/08/25 19:51:54 roberto Exp roberto $
3** Lua API 3** Lua API
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -718,7 +718,7 @@ LUA_API int lua_load (lua_State *L, lua_Chunkreader reader, void *data,
718 int c; 718 int c;
719 lua_lock(L); 719 lua_lock(L);
720 if (!chunkname) chunkname = "?"; 720 if (!chunkname) chunkname = "?";
721 luaZ_init(&z, reader, data); 721 luaZ_init(L, &z, reader, data);
722 c = luaZ_lookahead(&z); 722 c = luaZ_lookahead(&z);
723 status = luaD_protectedparser(L, &z, (c == LUA_SIGNATURE[0]), chunkname); 723 status = luaD_protectedparser(L, &z, (c == LUA_SIGNATURE[0]), chunkname);
724 lua_unlock(L); 724 lua_unlock(L);
diff --git a/lzio.c b/lzio.c
index 4ce47161..f3e1dcf6 100644
--- a/lzio.c
+++ b/lzio.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lzio.c,v 1.24 2003/03/20 16:00:56 roberto Exp roberto $ 2** $Id: lzio.c,v 1.25 2003/08/25 19:51:54 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*/
@@ -18,7 +18,7 @@
18 18
19int luaZ_fill (ZIO *z) { 19int luaZ_fill (ZIO *z) {
20 size_t size; 20 size_t size;
21 const char *buff = z->reader(NULL, z->data, &size); 21 const char *buff = z->reader(z->L, z->data, &size);
22 if (buff == NULL || size == 0) return EOZ; 22 if (buff == NULL || size == 0) return EOZ;
23 z->n = size - 1; 23 z->n = size - 1;
24 z->p = buff; 24 z->p = buff;
@@ -37,7 +37,8 @@ int luaZ_lookahead (ZIO *z) {
37} 37}
38 38
39 39
40void luaZ_init (ZIO *z, lua_Chunkreader reader, void *data) { 40void luaZ_init (lua_State *L, ZIO *z, lua_Chunkreader reader, void *data) {
41 z->L = L;
41 z->reader = reader; 42 z->reader = reader;
42 z->data = data; 43 z->data = data;
43 z->n = 0; 44 z->n = 0;
diff --git a/lzio.h b/lzio.h
index d2a99071..bcf11e45 100644
--- a/lzio.h
+++ b/lzio.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lzio.h,v 1.15 2003/03/20 16:00:56 roberto Exp roberto $ 2** $Id: lzio.h,v 1.16 2003/08/25 19:51:54 roberto Exp roberto $
3** Buffered streams 3** Buffered streams
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -20,7 +20,7 @@ typedef struct Zio ZIO;
20 20
21#define zgetc(z) (((z)->n--)>0 ? char2int(*(z)->p++) : luaZ_fill(z)) 21#define zgetc(z) (((z)->n--)>0 ? char2int(*(z)->p++) : luaZ_fill(z))
22 22
23void luaZ_init (ZIO *z, lua_Chunkreader reader, void *data); 23void luaZ_init (lua_State *L, ZIO *z, lua_Chunkreader reader, void *data);
24size_t luaZ_read (ZIO* z, void* b, size_t n); /* read next n bytes */ 24size_t luaZ_read (ZIO* z, void* b, size_t n); /* read next n bytes */
25int luaZ_lookahead (ZIO *z); 25int luaZ_lookahead (ZIO *z);
26 26
@@ -53,6 +53,7 @@ struct Zio {
53 const char *p; /* current position in buffer */ 53 const char *p; /* current position in buffer */
54 lua_Chunkreader reader; 54 lua_Chunkreader reader;
55 void* data; /* additional data */ 55 void* data; /* additional data */
56 lua_State *L; /* Lua state (for reader) */
56}; 57};
57 58
58 59