aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lmem.h7
-rw-r--r--lua.h8
-rw-r--r--lundump.c36
-rw-r--r--lundump.h4
4 files changed, 26 insertions, 29 deletions
diff --git a/lmem.h b/lmem.h
index 94e81515..4741b7f6 100644
--- a/lmem.h
+++ b/lmem.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lmem.h,v 1.4 1997/12/01 20:30:44 roberto Exp roberto $ 2** $Id: lmem.h,v 1.5 1997/12/17 20:48:58 roberto Exp roberto $
3** Interface to Memory Manager 3** Interface to Memory Manager
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -8,10 +8,7 @@
8#define lmem_h 8#define lmem_h
9 9
10 10
11#ifndef NULL 11#include <stdlib.h>
12#define NULL 0
13#endif
14
15 12
16/* memory error messages */ 13/* memory error messages */
17#define codeEM "code size overflow" 14#define codeEM "code size overflow"
diff --git a/lua.h b/lua.h
index fa2baaf3..993c8294 100644
--- a/lua.h
+++ b/lua.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lua.h,v 1.23 1998/06/18 16:51:53 roberto Exp roberto $ 2** $Id: lua.h,v 1.24 1998/08/21 17:43:44 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: lua@tecgraf.puc-rio.br 5** e-mail: lua@tecgraf.puc-rio.br
@@ -20,12 +20,12 @@
20 20
21#define LUA_ANYTAG (-1) 21#define LUA_ANYTAG (-1)
22 22
23typedef void (*lua_CFunction) (void);
24typedef unsigned int lua_Object;
25
26typedef struct lua_State lua_State; 23typedef struct lua_State lua_State;
27extern lua_State *lua_state; 24extern lua_State *lua_state;
28 25
26typedef void (*lua_CFunction) (void);
27typedef unsigned int lua_Object;
28
29void lua_open (void); 29void lua_open (void);
30void lua_close (void); 30void lua_close (void);
31lua_State *lua_setstate (lua_State *st); 31lua_State *lua_setstate (lua_State *st);
diff --git a/lundump.c b/lundump.c
index ed4bd19c..4af102b5 100644
--- a/lundump.c
+++ b/lundump.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lundump.c,v 1.10 1998/06/25 15:50:09 lhf Exp $ 2** $Id: lundump.c,v 1.4 1998/06/25 16:48:44 roberto Exp roberto $
3** load bytecodes from files 3** load bytecodes from files
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -20,32 +20,32 @@
20 #define doLoadNumber(f,Z) f=LoadNumber(Z) 20 #define doLoadNumber(f,Z) f=LoadNumber(Z)
21#endif 21#endif
22 22
23static void unexpectedEOZ(ZIO* Z) 23static void unexpectedEOZ (ZIO* Z)
24{ 24{
25 luaL_verror("unexpected end of file in %s",zname(Z)); 25 luaL_verror("unexpected end of file in %s",zname(Z));
26} 26}
27 27
28static int ezgetc(ZIO* Z) 28static int ezgetc (ZIO* Z)
29{ 29{
30 int c=zgetc(Z); 30 int c=zgetc(Z);
31 if (c==EOZ) unexpectedEOZ(Z); 31 if (c==EOZ) unexpectedEOZ(Z);
32 return c; 32 return c;
33} 33}
34 34
35static void ezread(ZIO* Z, void* b, int n) 35static void ezread (ZIO* Z, void* b, int n)
36{ 36{
37 int r=zread(Z,b,n); 37 int r=zread(Z,b,n);
38 if (r!=0) unexpectedEOZ(Z); 38 if (r!=0) unexpectedEOZ(Z);
39} 39}
40 40
41static unsigned int LoadWord(ZIO* Z) 41static unsigned int LoadWord (ZIO* Z)
42{ 42{
43 unsigned int hi=ezgetc(Z); 43 unsigned int hi=ezgetc(Z);
44 unsigned int lo=ezgetc(Z); 44 unsigned int lo=ezgetc(Z);
45 return (hi<<8)|lo; 45 return (hi<<8)|lo;
46} 46}
47 47
48static unsigned long LoadLong(ZIO* Z) 48static unsigned long LoadLong (ZIO* Z)
49{ 49{
50 unsigned long hi=LoadWord(Z); 50 unsigned long hi=LoadWord(Z);
51 unsigned long lo=LoadWord(Z); 51 unsigned long lo=LoadWord(Z);
@@ -55,7 +55,7 @@ static unsigned long LoadLong(ZIO* Z)
55#if ID_NUMBER==ID_REAL4 55#if ID_NUMBER==ID_REAL4
56/* LUA_NUMBER */ 56/* LUA_NUMBER */
57/* assumes sizeof(long)==4 and sizeof(float)==4 (IEEE) */ 57/* assumes sizeof(long)==4 and sizeof(float)==4 (IEEE) */
58static float LoadFloat(ZIO* Z) 58static float LoadFloat (ZIO* Z)
59{ 59{
60 unsigned long l=LoadLong(Z); 60 unsigned long l=LoadLong(Z);
61 float f=*(float*)&l; 61 float f=*(float*)&l;
@@ -66,7 +66,7 @@ static float LoadFloat(ZIO* Z)
66#if ID_NUMBER==ID_REAL8 66#if ID_NUMBER==ID_REAL8
67/* LUA_NUMBER */ 67/* LUA_NUMBER */
68/* assumes sizeof(long)==4 and sizeof(double)==8 (IEEE) */ 68/* assumes sizeof(long)==4 and sizeof(double)==8 (IEEE) */
69static double LoadDouble(ZIO* Z) 69static double LoadDouble (ZIO* Z)
70{ 70{
71 unsigned long l[2]; 71 unsigned long l[2];
72 double f; 72 double f;
@@ -86,7 +86,7 @@ static double LoadDouble(ZIO* Z)
86} 86}
87#endif 87#endif
88 88
89static Byte* LoadCode(ZIO* Z) 89static Byte* LoadCode (ZIO* Z)
90{ 90{
91 unsigned long size=LoadLong(Z); 91 unsigned long size=LoadLong(Z);
92 unsigned int s=size; 92 unsigned int s=size;
@@ -97,7 +97,7 @@ static Byte* LoadCode(ZIO* Z)
97 return b; 97 return b;
98} 98}
99 99
100static TaggedString* LoadTString(ZIO* Z) 100static TaggedString* LoadTString (ZIO* Z)
101{ 101{
102 int size=LoadWord(Z); 102 int size=LoadWord(Z);
103 if (size==0) 103 if (size==0)
@@ -110,7 +110,7 @@ static TaggedString* LoadTString(ZIO* Z)
110 } 110 }
111} 111}
112 112
113static void LoadLocals(TProtoFunc* tf, ZIO* Z) 113static void LoadLocals (TProtoFunc* tf, ZIO* Z)
114{ 114{
115 int i,n=LoadWord(Z); 115 int i,n=LoadWord(Z);
116 if (n==0) return; 116 if (n==0) return;
@@ -124,9 +124,9 @@ static void LoadLocals(TProtoFunc* tf, ZIO* Z)
124 tf->locvars[i].varname=NULL; 124 tf->locvars[i].varname=NULL;
125} 125}
126 126
127static TProtoFunc* LoadFunction(ZIO* Z); 127static TProtoFunc* LoadFunction (ZIO* Z);
128 128
129static void LoadConstants(TProtoFunc* tf, ZIO* Z) 129static void LoadConstants (TProtoFunc* tf, ZIO* Z)
130{ 130{
131 int i,n=LoadWord(Z); 131 int i,n=LoadWord(Z);
132 tf->nconsts=n; 132 tf->nconsts=n;
@@ -157,7 +157,7 @@ static void LoadConstants(TProtoFunc* tf, ZIO* Z)
157 } 157 }
158} 158}
159 159
160static TProtoFunc* LoadFunction(ZIO* Z) 160static TProtoFunc* LoadFunction (ZIO* Z)
161{ 161{
162 TProtoFunc* tf=luaF_newproto(); 162 TProtoFunc* tf=luaF_newproto();
163 tf->lineDefined=LoadWord(Z); 163 tf->lineDefined=LoadWord(Z);
@@ -168,7 +168,7 @@ static TProtoFunc* LoadFunction(ZIO* Z)
168 return tf; 168 return tf;
169} 169}
170 170
171static void LoadSignature(ZIO* Z) 171static void LoadSignature (ZIO* Z)
172{ 172{
173 char* s=SIGNATURE; 173 char* s=SIGNATURE;
174 while (*s!=0 && ezgetc(Z)==*s) 174 while (*s!=0 && ezgetc(Z)==*s)
@@ -176,7 +176,7 @@ static void LoadSignature(ZIO* Z)
176 if (*s!=0) luaL_verror("bad signature in %s",zname(Z)); 176 if (*s!=0) luaL_verror("bad signature in %s",zname(Z));
177} 177}
178 178
179static void LoadHeader(ZIO* Z) 179static void LoadHeader (ZIO* Z)
180{ 180{
181 int version,id,sizeofR; 181 int version,id,sizeofR;
182 real f=-TEST_NUMBER,tf=TEST_NUMBER; 182 real f=-TEST_NUMBER,tf=TEST_NUMBER;
@@ -205,7 +205,7 @@ static void LoadHeader(ZIO* Z)
205 zname(Z),(double)f,(double)tf); 205 zname(Z),(double)f,(double)tf);
206} 206}
207 207
208static TProtoFunc* LoadChunk(ZIO* Z) 208static TProtoFunc* LoadChunk (ZIO* Z)
209{ 209{
210 LoadHeader(Z); 210 LoadHeader(Z);
211 return LoadFunction(Z); 211 return LoadFunction(Z);
@@ -215,7 +215,7 @@ static TProtoFunc* LoadChunk(ZIO* Z)
215** load one chunk from a file or buffer 215** load one chunk from a file or buffer
216** return main if ok and NULL at EOF 216** return main if ok and NULL at EOF
217*/ 217*/
218TProtoFunc* luaU_undump1(ZIO* Z) 218TProtoFunc* luaU_undump1 (ZIO* Z)
219{ 219{
220 int c=zgetc(Z); 220 int c=zgetc(Z);
221 if (c==ID_CHUNK) 221 if (c==ID_CHUNK)
diff --git a/lundump.h b/lundump.h
index e9014d7b..c9c4c417 100644
--- a/lundump.h
+++ b/lundump.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lundump.h,v 1.7 1998/06/25 15:50:09 lhf Exp $ 2** $Id: lundump.h,v 1.4 1998/06/25 16:48:44 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*/
@@ -10,7 +10,7 @@
10#include "lobject.h" 10#include "lobject.h"
11#include "lzio.h" 11#include "lzio.h"
12 12
13TProtoFunc* luaU_undump1(ZIO* Z); /* load one chunk */ 13TProtoFunc *luaU_undump1 (ZIO* Z); /* load one chunk */
14 14
15#define SIGNATURE "Lua" 15#define SIGNATURE "Lua"
16#define VERSION 0x31 /* last format change was in 3.1 */ 16#define VERSION 0x31 /* last format change was in 3.1 */