diff options
-rw-r--r-- | lapi.c | 8 | ||||
-rw-r--r-- | lua.h | 7 | ||||
-rw-r--r-- | lundump.h | 5 | ||||
-rw-r--r-- | lzio.c | 13 | ||||
-rw-r--r-- | lzio.h | 3 |
5 files changed, 25 insertions, 11 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lapi.c,v 1.193 2002/05/27 20:35:40 roberto Exp roberto $ | 2 | ** $Id: lapi.c,v 1.194 2002/06/03 17:46:34 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 | */ |
@@ -564,13 +564,15 @@ LUA_API int lua_pcall (lua_State *L, int nargs, int nresults, int errf) { | |||
564 | 564 | ||
565 | 565 | ||
566 | LUA_API int lua_load (lua_State *L, lua_Getblock getblock, void *ud, | 566 | LUA_API int lua_load (lua_State *L, lua_Getblock getblock, void *ud, |
567 | int binary, const char *chunkname) { | 567 | const char *chunkname) { |
568 | ZIO z; | 568 | ZIO z; |
569 | int status; | 569 | int status; |
570 | int c; | ||
570 | lua_lock(L); | 571 | lua_lock(L); |
571 | if (!chunkname) chunkname = "?"; | 572 | if (!chunkname) chunkname = "?"; |
572 | luaZ_init(&z, getblock, ud, chunkname); | 573 | luaZ_init(&z, getblock, ud, chunkname); |
573 | status = luaD_protectedparser(L, &z, binary); | 574 | c = luaZ_lookahead(&z); |
575 | status = luaD_protectedparser(L, &z, (c == LUA_SIGNATURE[0])); | ||
574 | lua_unlock(L); | 576 | lua_unlock(L); |
575 | return status; | 577 | return status; |
576 | } | 578 | } |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lua.h,v 1.134 2002/05/23 20:29:05 roberto Exp roberto $ | 2 | ** $Id: lua.h,v 1.135 2002/06/03 17:46:34 roberto Exp roberto $ |
3 | ** Lua - An Extensible Extension Language | 3 | ** Lua - An Extensible Extension Language |
4 | ** Tecgraf: Grupo de Tecnologia em Computacao Grafica, PUC-Rio, Brazil | 4 | ** Tecgraf: Grupo de Tecnologia em Computacao Grafica, PUC-Rio, Brazil |
5 | ** e-mail: info@lua.org | 5 | ** e-mail: info@lua.org |
@@ -182,7 +182,7 @@ LUA_API void lua_setmetatable (lua_State *L, int objindex); | |||
182 | LUA_API void lua_rawcall (lua_State *L, int nargs, int nresults); | 182 | LUA_API void lua_rawcall (lua_State *L, int nargs, int nresults); |
183 | LUA_API int lua_pcall (lua_State *L, int nargs, int nresults, int errf); | 183 | LUA_API int lua_pcall (lua_State *L, int nargs, int nresults, int errf); |
184 | LUA_API int lua_load (lua_State *L, lua_Getblock getblock, void *ud, | 184 | LUA_API int lua_load (lua_State *L, lua_Getblock getblock, void *ud, |
185 | int binary, const char *chunkname); | 185 | const char *chunkname); |
186 | 186 | ||
187 | 187 | ||
188 | /* | 188 | /* |
@@ -291,9 +291,6 @@ LUA_API int lua_pushupvalues (lua_State *L); | |||
291 | ** ======================================================================= | 291 | ** ======================================================================= |
292 | */ | 292 | */ |
293 | 293 | ||
294 | /* binary files start with <esc>Lua */ | ||
295 | #define LUA_SIGNATURE "\033Lua" | ||
296 | |||
297 | /* formats for Lua numbers */ | 294 | /* formats for Lua numbers */ |
298 | #ifndef LUA_NUMBER_SCAN | 295 | #ifndef LUA_NUMBER_SCAN |
299 | #define LUA_NUMBER_SCAN "%lf" | 296 | #define LUA_NUMBER_SCAN "%lf" |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lundump.h,v 1.23 2001/07/12 19:34:03 roberto Exp roberto $ | 2 | ** $Id: lundump.h,v 1.24 2002/06/03 17:46:34 roberto Exp roberto $ |
3 | ** load pre-compiled Lua chunks | 3 | ** load pre-compiled Lua chunks |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -24,4 +24,7 @@ int luaU_endianness (void); | |||
24 | /* multiplying by 1E8 gives non-trivial integer values */ | 24 | /* multiplying by 1E8 gives non-trivial integer values */ |
25 | #define TEST_NUMBER 3.14159265358979323846E8 | 25 | #define TEST_NUMBER 3.14159265358979323846E8 |
26 | 26 | ||
27 | /* binary files start with <esc>Lua */ | ||
28 | #define LUA_SIGNATURE "\033Lua" | ||
29 | |||
27 | #endif | 30 | #endif |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lzio.c,v 1.16 2002/04/29 12:37:41 roberto Exp roberto $ | 2 | ** $Id: lzio.c,v 1.17 2002/06/03 17:46:34 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 | */ |
@@ -24,6 +24,17 @@ int luaZ_fill (ZIO *z) { | |||
24 | } | 24 | } |
25 | 25 | ||
26 | 26 | ||
27 | int luaZ_lookahead (ZIO *z) { | ||
28 | if (z->n == 0) { | ||
29 | int c = luaZ_fill(z); | ||
30 | if (c == EOZ) return c; | ||
31 | z->n++; | ||
32 | z->p--; | ||
33 | } | ||
34 | return *z->p; | ||
35 | } | ||
36 | |||
37 | |||
27 | void luaZ_init (ZIO *z, lua_Getblock getblock, void *ud, const char *name) { | 38 | void luaZ_init (ZIO *z, lua_Getblock getblock, void *ud, const char *name) { |
28 | z->getblock = getblock; | 39 | z->getblock = getblock; |
29 | z->ud = ud; | 40 | z->ud = ud; |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lzio.h,v 1.9 2002/04/29 12:37:41 roberto Exp roberto $ | 2 | ** $Id: lzio.h,v 1.10 2002/06/03 17:46:34 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 | */ |
@@ -26,6 +26,7 @@ typedef struct zio ZIO; | |||
26 | 26 | ||
27 | void luaZ_init (ZIO *z, lua_Getblock getblock, void *ud, const char *name); | 27 | void luaZ_init (ZIO *z, lua_Getblock getblock, void *ud, const char *name); |
28 | size_t luaZ_zread (ZIO* z, void* b, size_t n); /* read next n bytes */ | 28 | size_t luaZ_zread (ZIO* z, void* b, size_t n); /* read next n bytes */ |
29 | int luaZ_lookahead (ZIO *z); | ||
29 | 30 | ||
30 | 31 | ||
31 | /* --------- Private Part ------------------ */ | 32 | /* --------- Private Part ------------------ */ |