Browse Source

`undump' also uses private buffer

Roberto Ierusalimschy 23 years ago
parent
commit
46b063ef59
3 changed files with 10 additions and 7 deletions
  1. 3 2
      ldo.c
  2. 5 3
      lundump.c
  3. 2 2
      lundump.h

+ 3 - 2
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
 ** Stack and Call structure of Lua
 ** See Copyright Notice in lua.h
 ** 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) {
 static void f_parser (lua_State *L, void *ud) {
   struct SParser *p = cast(struct SParser *, 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));
   Closure *cl = luaF_newLclosure(L, 0, gt(L));
   cl->l.p = tf;
   cl->l.p = tf;
   setclvalue(L->top, cl);
   setclvalue(L->top, cl);

+ 5 - 3
lundump.c

@@ -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);

+ 2 - 2
lundump.h

@@ -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
 ** load pre-compiled Lua chunks
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -13,7 +13,7 @@
 typedef int (*Writer)(const void* p, size_t size, void* u);
 typedef int (*Writer)(const void* p, size_t size, void* u);
 
 
 /* load one chunk; from lundump.c */
 /* 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 */
 /* find byte order; from lundump.c */
 int luaU_endianness (void);
 int luaU_endianness (void);