From 0385618f3f6f051c738a86a58eb107f24639a0f9 Mon Sep 17 00:00:00 2001 From: Pawel Kolodziejski Date: Wed, 12 Jan 2005 22:10:12 +0000 Subject: [PATCH] fixed some lua warnings --- lua/lbuiltin.cpp | 12 +++++------ lua/liolib.cpp | 6 +++--- lua/llex.cpp | 4 ++-- lua/lmathlib.cpp | 4 ++-- lua/lstrlib.cpp | 8 ++++---- lua/lundump.cpp | 53 +++--------------------------------------------- lua/lundump.h | 31 +++------------------------- lua/lzio.cpp | 2 +- 8 files changed, 24 insertions(+), 96 deletions(-) diff --git a/lua/lbuiltin.cpp b/lua/lbuiltin.cpp index d6c62908c32..f913bb878d2 100644 --- a/lua/lbuiltin.cpp +++ b/lua/lbuiltin.cpp @@ -205,7 +205,7 @@ static void luaI_type (void) static void tonumber (void) { - int base = luaL_opt_number(2, 10); + int base = (int)luaL_opt_number(2, 10); if (base == 10) { /* standard conversion */ lua_Object o = lua_getparam(1); if (lua_isnumber(o)) @@ -276,7 +276,7 @@ static int getnarg (lua_Object table) lua_Object temp; /* temp = table.n */ lua_pushobject(table); lua_pushstring("n"); temp = lua_rawgettable(); - return (lua_isnumber(temp) ? lua_getnumber(temp) : MAX_INT); + return (lua_isnumber(temp) ? (int)lua_getnumber(temp) : MAX_INT); } static void luaI_call (void) @@ -326,7 +326,7 @@ static void settag (void) { lua_Object o = luaL_tablearg(1); lua_pushobject(o); - lua_settag(luaL_check_number(2)); + lua_settag((int)luaL_check_number(2)); lua_pushobject(o); /* returns first argument */ } @@ -339,8 +339,8 @@ static void newtag (void) static void copytagmethods (void) { - lua_pushnumber(lua_copytagmethods(luaL_check_number(1), - luaL_check_number(2))); + lua_pushnumber(lua_copytagmethods((int)luaL_check_number(1), + (int)luaL_check_number(2))); } @@ -387,7 +387,7 @@ static void seterrormethod (void) static void luaI_collectgarbage (void) { - lua_pushnumber(lua_collectgarbage(luaL_opt_number(1, 0))); + lua_pushnumber(lua_collectgarbage((long int)luaL_opt_number(1, 0))); } diff --git a/lua/liolib.cpp b/lua/liolib.cpp index c37d14ffc4d..f3211e8f241 100644 --- a/lua/liolib.cpp +++ b/lua/liolib.cpp @@ -51,7 +51,7 @@ int pclose(); static int gettag (int i) { - return lua_getnumber(lua_getparam(i)); + return (int)lua_getnumber(lua_getparam(i)); } @@ -266,7 +266,7 @@ static void io_write (void) char *s; long l; while ((s = luaL_opt_lstr(arg++, NULL, &l)) != NULL) - status = status && (fwrite(s, 1, l, f) == l); + status = status && (fwrite(s, 1, l, f) == (unsigned long)l); pushresult(status); } @@ -424,7 +424,7 @@ static void openwithtags (void) { int iotag = lua_newtag(); int closedtag = lua_newtag(); - int i; + unsigned int i; for (i=0; ihead.marked = FIRST_RESERVED+i; /* reserved word (always > 255) */ @@ -59,7 +59,7 @@ void luaX_error (LexState *ls, char *s) { } -void luaX_token2str (LexState *ls, int token, char *s) { +void luaX_token2str (LexState * /*ls*/, int token, char *s) { if (token < 255) { s[0] = token; s[1] = 0; diff --git a/lua/lmathlib.cpp b/lua/lmathlib.cpp index 7b38075636f..685ec22da08 100644 --- a/lua/lmathlib.cpp +++ b/lua/lmathlib.cpp @@ -122,7 +122,7 @@ static void math_frexp (void) { } static void math_ldexp (void) { - lua_pushnumber(ldexp(luaL_check_number(1), luaL_check_number(2))); + lua_pushnumber(ldexp(luaL_check_number(1), (int)luaL_check_number(2))); } @@ -168,7 +168,7 @@ static void math_random (void) static void math_randomseed (void) { - srand(luaL_check_number(1)); + srand((unsigned int)luaL_check_number(1)); } diff --git a/lua/lstrlib.cpp b/lua/lstrlib.cpp index 9c2ab117e8f..d2caba0663c 100644 --- a/lua/lstrlib.cpp +++ b/lua/lstrlib.cpp @@ -49,8 +49,8 @@ static void str_sub (void) { long l; char *s = luaL_check_lstr(1, &l); - long start = posrelat(luaL_check_number(2), l); - long end = posrelat(luaL_opt_number(3, -1), l); + long start = posrelat((int)luaL_check_number(2), l); + long end = posrelat((int)luaL_opt_number(3, -1), l); if (1 <= start && start <= end && end <= l) lua_pushlstring(s+start-1, end-start+1); else lua_pushstring(""); @@ -96,7 +96,7 @@ static void str_byte (void) { long l; char *s = luaL_check_lstr(1, &l); - long pos = posrelat(luaL_opt_number(2, 1), l); + long pos = posrelat((int)luaL_opt_number(2, 1), l); luaL_arg_check(0 - #define LoadBlock(b,size,Z) ezread(Z,b,size) #define LoadNative(t,Z) LoadBlock(&t,sizeof(t),Z) -#if (SDL_BYTEORDER == SDL_LIL_ENDIAN) - #define doLoadNumber(f,Z) LoadNative(f,Z) -#else - #define doLoadNumber(f,Z) f=LoadNumber(Z) -#endif +#define doLoadNumber(f,Z) LoadNative(f,Z) -static float conv_float(const char *data) { - const unsigned char *udata = (const unsigned char *)(data); - unsigned char fdata[4]; - fdata[0] = udata[3]; - fdata[1] = udata[2]; - fdata[2] = udata[1]; - fdata[3] = udata[0]; - return *(const float *)(fdata); -} - static void unexpectedEOZ(ZIO* Z) { luaL_verror("unexpected end of file in %s",zname(Z)); @@ -67,39 +51,6 @@ static unsigned long LoadLong(ZIO* Z) return (hi<<16)|lo; } -#if ID_NUMBER==ID_REAL4 -/* LUA_NUMBER */ -/* assumes sizeof(long)==4 and sizeof(float)==4 (IEEE) */ -static float LoadFloat(ZIO* Z) -{ - unsigned long l=LoadLong(Z); - return conv_float((const char *)&l); -} -#endif - -#if ID_NUMBER==ID_REAL8 -/* LUA_NUMBER */ -/* assumes sizeof(long)==4 and sizeof(double)==8 (IEEE) */ -static double LoadDouble(ZIO* Z) -{ - unsigned long l[2]; - double f; - int x=1; - if (*(char*)&x==1) /* little-endian */ - { - l[1]=LoadLong(Z); - l[0]=LoadLong(Z); - } - else /* big-endian */ - { - l[0]=LoadLong(Z); - l[1]=LoadLong(Z); - } - memcpy(&f,l,sizeof(f)); - return f; -} -#endif - static Byte* LoadCode(ZIO* Z) { unsigned long size=LoadLong(Z); @@ -223,7 +174,9 @@ static void LoadSignature(ZIO* Z) static void LoadHeader(ZIO* Z) { int version,id,sizeofR; +#if 0 real f=(real)-TEST_NUMBER,tf=(real)TEST_NUMBER; +#endif LoadSignature(Z); version=ezgetc(Z); if (version>VERSION) diff --git a/lua/lundump.h b/lua/lundump.h index f21a559536e..e695264bc2f 100644 --- a/lua/lundump.h +++ b/lua/lundump.h @@ -44,35 +44,10 @@ TProtoFunc* luaU_undump1(ZIO* Z); /* load one chunk */ * dump and undump routines. */ -#ifndef ID_NUMBER #define ID_NUMBER ID_REAL4 -#endif - -#if 0 -#define ID_NUMBER ID_INT4 -#define ID_NUMBER ID_REAL4 -#define ID_NUMBER ID_REAL8 -#define ID_NUMBER ID_NATIVE -#endif #endif -#if ID_NUMBER==ID_REAL4 - #define DumpNumber DumpFloat - #define LoadNumber LoadFloat - #define SIZEOF_NUMBER 4 -#elif ID_NUMBER==ID_REAL8 - #define DumpNumber DumpDouble - #define LoadNumber LoadDouble - #define SIZEOF_NUMBER 8 -#elif ID_NUMBER==ID_INT4 - #define DumpNumber DumpLong - #define LoadNumber LoadLong - #define SIZEOF_NUMBER 4 -#elif ID_NUMBER==ID_NATIVE - #define DumpNumber DumpNative - #define LoadNumber LoadNative - #define SIZEOF_NUMBER sizeof(real) -#else - #error bad ID_NUMBER -#endif +#define DumpNumber DumpFloat +#define SIZEOF_NUMBER 4 + diff --git a/lua/lzio.cpp b/lua/lzio.cpp index 16f131bee91..682ac731d24 100644 --- a/lua/lzio.cpp +++ b/lua/lzio.cpp @@ -15,7 +15,7 @@ /* ----------------------------------------------------- memory buffers --- */ -static int zmfilbuf (ZIO* z) +static int zmfilbuf (ZIO* /*z*/) { return EOZ; }