aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2001-07-24 18:57:19 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2001-07-24 18:57:19 -0300
commit04320e04bf6d6649e4dffe2233ebc72d5bbb6965 (patch)
treeabfd7d678d6473a55b2a1df0d51d37f6ff120074
parent5d2d2b17527534e3b3e1da60b27663c6fbd58126 (diff)
downloadlua-04320e04bf6d6649e4dffe2233ebc72d5bbb6965.tar.gz
lua-04320e04bf6d6649e4dffe2233ebc72d5bbb6965.tar.bz2
lua-04320e04bf6d6649e4dffe2233ebc72d5bbb6965.zip
warnings from Visual C++ (plus small details)
-rw-r--r--lundump.c51
1 files changed, 26 insertions, 25 deletions
diff --git a/lundump.c b/lundump.c
index 0e09513c..f608730b 100644
--- a/lundump.c
+++ b/lundump.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lundump.c,v 1.35 2001/06/28 13:55:17 lhf Exp lhf $ 2** $Id: lundump.c,v 1.36 2001/07/19 14:34:06 lhf Exp lhf $
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*/
@@ -18,6 +18,7 @@
18#include "lundump.h" 18#include "lundump.h"
19 19
20#define LoadByte ezgetc 20#define LoadByte ezgetc
21#define LoadShort (short) LoadInt
21 22
22static const l_char* ZNAME (ZIO* Z) 23static const l_char* ZNAME (ZIO* Z)
23{ 24{
@@ -137,7 +138,7 @@ static void LoadLines (lua_State* L, Proto* f, ZIO* Z, int swap)
137 LoadVector(L,f->lineinfo,n,sizeof(*f->lineinfo),Z,swap); 138 LoadVector(L,f->lineinfo,n,sizeof(*f->lineinfo),Z,swap);
138} 139}
139 140
140static Proto* LoadFunction (lua_State* L, ZIO* Z, int swap); 141static Proto* LoadFunction (lua_State* L, TString* p, ZIO* Z, int swap);
141 142
142static void LoadConstants (lua_State* L, Proto* f, ZIO* Z, int swap) 143static void LoadConstants (lua_State* L, Proto* f, ZIO* Z, int swap)
143{ 144{
@@ -165,24 +166,24 @@ static void LoadConstants (lua_State* L, Proto* f, ZIO* Z, int swap)
165 n=LoadInt(L,Z,swap); 166 n=LoadInt(L,Z,swap);
166 f->p=luaM_newvector(L,n,Proto*); 167 f->p=luaM_newvector(L,n,Proto*);
167 f->sizep=n; 168 f->sizep=n;
168 for (i=0; i<n; i++) f->p[i]=LoadFunction(L,Z,swap); 169 for (i=0; i<n; i++) f->p[i]=LoadFunction(L,f->source,Z,swap);
169} 170}
170 171
171static Proto* LoadFunction (lua_State* L, ZIO* Z, int swap) 172static Proto* LoadFunction (lua_State* L, TString* p, ZIO* Z, int swap)
172{ 173{
173 Proto* f=luaF_newproto(L); 174 Proto* f=luaF_newproto(L);
174 f->source=LoadString(L,Z,swap); 175 f->source=LoadString(L,Z,swap); if (f->source==NULL) f->source=p;
175 f->lineDefined=LoadInt(L,Z,swap); 176 f->lineDefined=LoadInt(L,Z,swap);
176 f->nupvalues=LoadInt(L,Z,swap); 177 f->nupvalues=LoadShort(L,Z,swap);
177 f->numparams=LoadInt(L,Z,swap); 178 f->numparams=LoadShort(L,Z,swap);
178 f->is_vararg=LoadByte(L,Z); 179 f->is_vararg=LoadShort(L,Z,swap);
179 f->maxstacksize=LoadInt(L,Z,swap); 180 f->maxstacksize=LoadShort(L,Z,swap);
180 LoadLocals(L,f,Z,swap); 181 LoadLocals(L,f,Z,swap);
181 LoadLines(L,f,Z,swap); 182 LoadLines(L,f,Z,swap);
182 LoadConstants(L,f,Z,swap); 183 LoadConstants(L,f,Z,swap);
183 LoadCode(L,f,Z,swap); 184 LoadCode(L,f,Z,swap);
184#ifndef TRUST_BINARIES 185#ifndef TRUST_BINARIES
185 if (luaG_checkcode(f)==0) luaO_verror(L,l_s("bad code in `%.99s'"),ZNAME(Z)); 186 if (!luaG_checkcode(f)) luaO_verror(L,l_s("bad code in `%.99s'"),ZNAME(Z));
186#endif 187#endif
187 return f; 188 return f;
188} 189}
@@ -197,21 +198,21 @@ static void LoadSignature (lua_State* L, ZIO* Z)
197 198
198static void TestSize (lua_State* L, int s, const l_char* what, ZIO* Z) 199static void TestSize (lua_State* L, int s, const l_char* what, ZIO* Z)
199{ 200{
200 int r=ezgetc(L,Z); 201 int r=LoadByte(L,Z);
201 if (r!=s) 202 if (r!=s)
202 luaO_verror(L,l_s("virtual machine mismatch in `%.99s':\n") 203 luaO_verror(L,l_s("virtual machine mismatch in `%.99s':\n")
203 l_s(" %.20s is %d but read %d"),ZNAME(Z),what,s,r); 204 l_s(" size of %.20s is %d but read %d"),ZNAME(Z),what,s,r);
204} 205}
205 206
206#define TESTSIZE(s) TestSize(L,s,#s,Z) 207#define TESTSIZE(s,w) TestSize(L,s,w,Z)
207#define V(v) v/16,v%16 208#define V(v) v/16,v%16
208 209
209static int LoadHeader (lua_State* L, ZIO* Z) 210static int LoadHeader (lua_State* L, ZIO* Z)
210{ 211{
211 int version,swap; 212 int version,swap;
212 lua_Number x=0,tx=TEST_NUMBER; 213 lua_Number x=0,tx=TEST_NUMBER;
213 LoadSignature(L,Z); 214 LoadSignature(L,Z);
214 version=ezgetc(L,Z); 215 version=LoadByte(L,Z);
215 if (version>VERSION) 216 if (version>VERSION)
216 luaO_verror(L,l_s("`%.99s' too new:\n") 217 luaO_verror(L,l_s("`%.99s' too new:\n")
217 l_s(" read version %d.%d; expected at most %d.%d"), 218 l_s(" read version %d.%d; expected at most %d.%d"),
@@ -220,15 +221,15 @@ static int LoadHeader (lua_State* L, ZIO* Z)
220 luaO_verror(L,l_s("`%.99s' too old:\n") 221 luaO_verror(L,l_s("`%.99s' too old:\n")
221 l_s(" read version %d.%d; expected at least %d.%d"), 222 l_s(" read version %d.%d; expected at least %d.%d"),
222 ZNAME(Z),V(version),V(VERSION)); 223 ZNAME(Z),V(version),V(VERSION));
223 swap=(luaU_endianness()!=ezgetc(L,Z)); /* need to swap bytes? */ 224 swap=(luaU_endianness()!=LoadByte(L,Z)); /* need to swap bytes? */
224 TESTSIZE(sizeof(int)); 225 TESTSIZE(sizeof(int),l_s("int"));
225 TESTSIZE(sizeof(size_t)); 226 TESTSIZE(sizeof(size_t), l_s("size_t"));
226 TESTSIZE(sizeof(Instruction)); 227 TESTSIZE(sizeof(Instruction), l_s("size_t"));
227 TESTSIZE(SIZE_OP); 228 TESTSIZE(SIZE_OP, l_s("OP"));
228 TESTSIZE(SIZE_A); 229 TESTSIZE(SIZE_A, l_s("A"));
229 TESTSIZE(SIZE_B); 230 TESTSIZE(SIZE_B, l_s("B"));
230 TESTSIZE(SIZE_C); 231 TESTSIZE(SIZE_C, l_s("C"));
231 TESTSIZE(sizeof(lua_Number)); 232 TESTSIZE(sizeof(lua_Number), l_s("number"));
232 x=LoadNumber(L,Z,swap); 233 x=LoadNumber(L,Z,swap);
233 if ((long)x!=(long)tx) /* disregard errors in last bits of fraction */ 234 if ((long)x!=(long)tx) /* disregard errors in last bits of fraction */
234 luaO_verror(L,l_s("unknown number format in `%.99s':\n") 235 luaO_verror(L,l_s("unknown number format in `%.99s':\n")
@@ -239,7 +240,7 @@ static int LoadHeader (lua_State* L, ZIO* Z)
239 240
240static Proto* LoadChunk (lua_State* L, ZIO* Z) 241static Proto* LoadChunk (lua_State* L, ZIO* Z)
241{ 242{
242 return LoadFunction(L,Z,LoadHeader(L,Z)); 243 return LoadFunction(L,NULL,Z,LoadHeader(L,Z));
243} 244}
244 245
245/* 246/*