aboutsummaryrefslogtreecommitdiff
path: root/lundump.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2002-10-09 10:42:01 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2002-10-09 10:42:01 -0300
commit46b063ef59c7b334f8f36a9ab5dfd76d094e70d7 (patch)
tree3d7aa7300a4478278515fa274cc0b7ee7076512c /lundump.c
parente1d5153a33d278ac9db18f5bcc142a75e48606de (diff)
downloadlua-46b063ef59c7b334f8f36a9ab5dfd76d094e70d7.tar.gz
lua-46b063ef59c7b334f8f36a9ab5dfd76d094e70d7.tar.bz2
lua-46b063ef59c7b334f8f36a9ab5dfd76d094e70d7.zip
`undump' also uses private buffer
Diffstat (limited to 'lundump.c')
-rw-r--r--lundump.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/lundump.c b/lundump.c
index a555f97a..f4940239 100644
--- a/lundump.c
+++ b/lundump.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lundump.c,v 1.53 2002/09/19 13:03:53 roberto Exp roberto $ 2** $Id: lundump.c,v 1.54 2002/10/08 18:46:08 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*/
@@ -19,6 +19,7 @@
19typedef struct { 19typedef struct {
20 lua_State* L; 20 lua_State* L;
21 ZIO* Z; 21 ZIO* Z;
22 Mbuffer *buff;
22 int swap; 23 int swap;
23 const char* name; 24 const char* name;
24} LoadState; 25} LoadState;
@@ -99,7 +100,7 @@ static TString* LoadString (LoadState* S)
99 return NULL; 100 return NULL;
100 else 101 else
101 { 102 {
102 char* s=luaZ_openspace(S->L,&G(S->L)->buff,size); 103 char* s=luaZ_openspace(S->L,S->buff,size);
103 ezread(S,s,size); 104 ezread(S,s,size);
104 return luaS_newlstr(S->L,s,size-1); /* remove trailing '\0' */ 105 return luaS_newlstr(S->L,s,size-1); /* remove trailing '\0' */
105 } 106 }
@@ -245,7 +246,7 @@ static Proto* LoadChunk (LoadState* S)
245/* 246/*
246** load one chunk from a file or buffer 247** load one chunk from a file or buffer
247*/ 248*/
248Proto* luaU_undump (lua_State* L, ZIO* Z) 249Proto* luaU_undump (lua_State* L, ZIO* Z, Mbuffer *buff)
249{ 250{
250 LoadState S; 251 LoadState S;
251 Proto* f; 252 Proto* f;
@@ -258,6 +259,7 @@ Proto* luaU_undump (lua_State* L, ZIO* Z)
258 S.name=s; 259 S.name=s;
259 S.L=L; 260 S.L=L;
260 S.Z=Z; 261 S.Z=Z;
262 S.buff=buff;
261 f=LoadChunk(&S); 263 f=LoadChunk(&S);
262 if (zgetc(Z)!=EOZ) 264 if (zgetc(Z)!=EOZ)
263 luaG_runerror(L,"%s apparently contains more than one chunk",S.name); 265 luaG_runerror(L,"%s apparently contains more than one chunk",S.name);