warnings from Visual C++ (plus small details)

This commit is contained in:
Roberto Ierusalimschy 2001-07-24 18:57:19 -03:00
parent 5d2d2b1752
commit 04320e04bf
1 changed files with 26 additions and 25 deletions

View File

@ -1,5 +1,5 @@
/*
** $Id: lundump.c,v 1.35 2001/06/28 13:55:17 lhf Exp lhf $
** $Id: lundump.c,v 1.36 2001/07/19 14:34:06 lhf Exp lhf $
** load pre-compiled Lua chunks
** See Copyright Notice in lua.h
*/
@ -18,6 +18,7 @@
#include "lundump.h"
#define LoadByte ezgetc
#define LoadShort (short) LoadInt
static const l_char* ZNAME (ZIO* Z)
{
@ -137,7 +138,7 @@ static void LoadLines (lua_State* L, Proto* f, ZIO* Z, int swap)
LoadVector(L,f->lineinfo,n,sizeof(*f->lineinfo),Z,swap);
}
static Proto* LoadFunction (lua_State* L, ZIO* Z, int swap);
static Proto* LoadFunction (lua_State* L, TString* p, ZIO* Z, int swap);
static void LoadConstants (lua_State* L, Proto* f, ZIO* Z, int swap)
{
@ -165,24 +166,24 @@ static void LoadConstants (lua_State* L, Proto* f, ZIO* Z, int swap)
n=LoadInt(L,Z,swap);
f->p=luaM_newvector(L,n,Proto*);
f->sizep=n;
for (i=0; i<n; i++) f->p[i]=LoadFunction(L,Z,swap);
for (i=0; i<n; i++) f->p[i]=LoadFunction(L,f->source,Z,swap);
}
static Proto* LoadFunction (lua_State* L, ZIO* Z, int swap)
static Proto* LoadFunction (lua_State* L, TString* p, ZIO* Z, int swap)
{
Proto* f=luaF_newproto(L);
f->source=LoadString(L,Z,swap);
f->source=LoadString(L,Z,swap); if (f->source==NULL) f->source=p;
f->lineDefined=LoadInt(L,Z,swap);
f->nupvalues=LoadInt(L,Z,swap);
f->numparams=LoadInt(L,Z,swap);
f->is_vararg=LoadByte(L,Z);
f->maxstacksize=LoadInt(L,Z,swap);
f->nupvalues=LoadShort(L,Z,swap);
f->numparams=LoadShort(L,Z,swap);
f->is_vararg=LoadShort(L,Z,swap);
f->maxstacksize=LoadShort(L,Z,swap);
LoadLocals(L,f,Z,swap);
LoadLines(L,f,Z,swap);
LoadConstants(L,f,Z,swap);
LoadCode(L,f,Z,swap);
#ifndef TRUST_BINARIES
if (luaG_checkcode(f)==0) luaO_verror(L,l_s("bad code in `%.99s'"),ZNAME(Z));
if (!luaG_checkcode(f)) luaO_verror(L,l_s("bad code in `%.99s'"),ZNAME(Z));
#endif
return f;
}
@ -197,21 +198,21 @@ static void LoadSignature (lua_State* L, ZIO* Z)
static void TestSize (lua_State* L, int s, const l_char* what, ZIO* Z)
{
int r=ezgetc(L,Z);
int r=LoadByte(L,Z);
if (r!=s)
luaO_verror(L,l_s("virtual machine mismatch in `%.99s':\n")
l_s(" %.20s is %d but read %d"),ZNAME(Z),what,s,r);
l_s(" size of %.20s is %d but read %d"),ZNAME(Z),what,s,r);
}
#define TESTSIZE(s) TestSize(L,s,#s,Z)
#define V(v) v/16,v%16
#define TESTSIZE(s,w) TestSize(L,s,w,Z)
#define V(v) v/16,v%16
static int LoadHeader (lua_State* L, ZIO* Z)
{
int version,swap;
lua_Number x=0,tx=TEST_NUMBER;
LoadSignature(L,Z);
version=ezgetc(L,Z);
version=LoadByte(L,Z);
if (version>VERSION)
luaO_verror(L,l_s("`%.99s' too new:\n")
l_s(" read version %d.%d; expected at most %d.%d"),
@ -220,15 +221,15 @@ static int LoadHeader (lua_State* L, ZIO* Z)
luaO_verror(L,l_s("`%.99s' too old:\n")
l_s(" read version %d.%d; expected at least %d.%d"),
ZNAME(Z),V(version),V(VERSION));
swap=(luaU_endianness()!=ezgetc(L,Z)); /* need to swap bytes? */
TESTSIZE(sizeof(int));
TESTSIZE(sizeof(size_t));
TESTSIZE(sizeof(Instruction));
TESTSIZE(SIZE_OP);
TESTSIZE(SIZE_A);
TESTSIZE(SIZE_B);
TESTSIZE(SIZE_C);
TESTSIZE(sizeof(lua_Number));
swap=(luaU_endianness()!=LoadByte(L,Z)); /* need to swap bytes? */
TESTSIZE(sizeof(int),l_s("int"));
TESTSIZE(sizeof(size_t), l_s("size_t"));
TESTSIZE(sizeof(Instruction), l_s("size_t"));
TESTSIZE(SIZE_OP, l_s("OP"));
TESTSIZE(SIZE_A, l_s("A"));
TESTSIZE(SIZE_B, l_s("B"));
TESTSIZE(SIZE_C, l_s("C"));
TESTSIZE(sizeof(lua_Number), l_s("number"));
x=LoadNumber(L,Z,swap);
if ((long)x!=(long)tx) /* disregard errors in last bits of fraction */
luaO_verror(L,l_s("unknown number format in `%.99s':\n")
@ -239,7 +240,7 @@ static int LoadHeader (lua_State* L, ZIO* Z)
static Proto* LoadChunk (lua_State* L, ZIO* Z)
{
return LoadFunction(L,Z,LoadHeader(L,Z));
return LoadFunction(L,NULL,Z,LoadHeader(L,Z));
}
/*