|
@@ -1,5 +1,5 @@
|
|
/*
|
|
/*
|
|
-** $Id: lundump.c,v 1.53 2002/09/19 13:03:53 roberto Exp roberto $
|
|
|
|
|
|
+** $Id: lundump.c,v 1.54 2002/10/08 18:46:08 roberto Exp roberto $
|
|
** load pre-compiled Lua chunks
|
|
** load pre-compiled Lua chunks
|
|
** See Copyright Notice in lua.h
|
|
** See Copyright Notice in lua.h
|
|
*/
|
|
*/
|
|
@@ -19,6 +19,7 @@
|
|
typedef struct {
|
|
typedef struct {
|
|
lua_State* L;
|
|
lua_State* L;
|
|
ZIO* Z;
|
|
ZIO* Z;
|
|
|
|
+ Mbuffer *buff;
|
|
int swap;
|
|
int swap;
|
|
const char* name;
|
|
const char* name;
|
|
} LoadState;
|
|
} LoadState;
|
|
@@ -99,7 +100,7 @@ static TString* LoadString (LoadState* S)
|
|
return NULL;
|
|
return NULL;
|
|
else
|
|
else
|
|
{
|
|
{
|
|
- char* s=luaZ_openspace(S->L,&G(S->L)->buff,size);
|
|
|
|
|
|
+ char* s=luaZ_openspace(S->L,S->buff,size);
|
|
ezread(S,s,size);
|
|
ezread(S,s,size);
|
|
return luaS_newlstr(S->L,s,size-1); /* remove trailing '\0' */
|
|
return luaS_newlstr(S->L,s,size-1); /* remove trailing '\0' */
|
|
}
|
|
}
|
|
@@ -245,7 +246,7 @@ static Proto* LoadChunk (LoadState* S)
|
|
/*
|
|
/*
|
|
** load one chunk from a file or buffer
|
|
** load one chunk from a file or buffer
|
|
*/
|
|
*/
|
|
-Proto* luaU_undump (lua_State* L, ZIO* Z)
|
|
|
|
|
|
+Proto* luaU_undump (lua_State* L, ZIO* Z, Mbuffer *buff)
|
|
{
|
|
{
|
|
LoadState S;
|
|
LoadState S;
|
|
Proto* f;
|
|
Proto* f;
|
|
@@ -258,6 +259,7 @@ Proto* luaU_undump (lua_State* L, ZIO* Z)
|
|
S.name=s;
|
|
S.name=s;
|
|
S.L=L;
|
|
S.L=L;
|
|
S.Z=Z;
|
|
S.Z=Z;
|
|
|
|
+ S.buff=buff;
|
|
f=LoadChunk(&S);
|
|
f=LoadChunk(&S);
|
|
if (zgetc(Z)!=EOZ)
|
|
if (zgetc(Z)!=EOZ)
|
|
luaG_runerror(L,"%s apparently contains more than one chunk",S.name);
|
|
luaG_runerror(L,"%s apparently contains more than one chunk",S.name);
|