mirror of
https://github.com/lua/lua
synced 2025-03-25 07:02:51 +03:00
`undump' also uses private buffer
This commit is contained in:
parent
e1d5153a33
commit
46b063ef59
5
ldo.c
5
ldo.c
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** $Id: ldo.c,v 1.194 2002/09/02 20:00:41 roberto Exp roberto $
|
||||
** $Id: ldo.c,v 1.195 2002/10/08 18:46:08 roberto Exp roberto $
|
||||
** Stack and Call structure of Lua
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
@ -426,7 +426,8 @@ struct SParser { /* data to `f_parser' */
|
||||
|
||||
static void f_parser (lua_State *L, void *ud) {
|
||||
struct SParser *p = cast(struct SParser *, ud);
|
||||
Proto *tf = p->bin ? luaU_undump(L, p->z) : luaY_parser(L, p->z, &p->buff);
|
||||
Proto *tf = p->bin ? luaU_undump(L, p->z, &p->buff) :
|
||||
luaY_parser(L, p->z, &p->buff);
|
||||
Closure *cl = luaF_newLclosure(L, 0, gt(L));
|
||||
cl->l.p = tf;
|
||||
setclvalue(L->top, cl);
|
||||
|
@ -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
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
@ -19,6 +19,7 @@
|
||||
typedef struct {
|
||||
lua_State* L;
|
||||
ZIO* Z;
|
||||
Mbuffer *buff;
|
||||
int swap;
|
||||
const char* name;
|
||||
} LoadState;
|
||||
@ -99,7 +100,7 @@ static TString* LoadString (LoadState* S)
|
||||
return NULL;
|
||||
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);
|
||||
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
|
||||
*/
|
||||
Proto* luaU_undump (lua_State* L, ZIO* Z)
|
||||
Proto* luaU_undump (lua_State* L, ZIO* Z, Mbuffer *buff)
|
||||
{
|
||||
LoadState S;
|
||||
Proto* f;
|
||||
@ -258,6 +259,7 @@ Proto* luaU_undump (lua_State* L, ZIO* Z)
|
||||
S.name=s;
|
||||
S.L=L;
|
||||
S.Z=Z;
|
||||
S.buff=buff;
|
||||
f=LoadChunk(&S);
|
||||
if (zgetc(Z)!=EOZ)
|
||||
luaG_runerror(L,"%s apparently contains more than one chunk",S.name);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** $Id: lundump.h,v 1.26 2002/08/07 00:36:03 lhf Exp $
|
||||
** $Id: lundump.h,v 1.27 2002/08/12 13:37:19 roberto Exp roberto $
|
||||
** load pre-compiled Lua chunks
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
@ -13,7 +13,7 @@
|
||||
typedef int (*Writer)(const void* p, size_t size, void* u);
|
||||
|
||||
/* load one chunk; from lundump.c */
|
||||
Proto* luaU_undump (lua_State* L, ZIO* Z);
|
||||
Proto* luaU_undump (lua_State* L, ZIO* Z, Mbuffer *buff);
|
||||
|
||||
/* find byte order; from lundump.c */
|
||||
int luaU_endianness (void);
|
||||
|
Loading…
x
Reference in New Issue
Block a user