mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-26 12:48:16 +00:00
fixed some lua warnings
This commit is contained in:
parent
6f91b5095f
commit
0385618f3f
@ -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)));
|
||||
}
|
||||
|
||||
|
||||
|
@ -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; i<sizeof(iolibtag)/sizeof(iolibtag[0]); i++) {
|
||||
/* put both tags as upvalues for these functions */
|
||||
lua_pushnumber(iotag);
|
||||
|
@ -37,7 +37,7 @@ char *reserved [] = {"and", "do", "else", "elseif", "end", "function",
|
||||
|
||||
void luaX_init (void)
|
||||
{
|
||||
int i;
|
||||
unsigned int i;
|
||||
for (i=0; i<(sizeof(reserved)/sizeof(reserved[0])); i++) {
|
||||
TaggedString *ts = luaS_new(reserved[i]);
|
||||
ts->head.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;
|
||||
|
@ -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));
|
||||
}
|
||||
|
||||
|
||||
|
@ -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<pos && pos<=l, 2, "out of range");
|
||||
lua_pushnumber((unsigned char)s[pos-1]);
|
||||
}
|
||||
@ -337,7 +337,7 @@ static void str_find (void)
|
||||
long l;
|
||||
char *s = luaL_check_lstr(1, &l);
|
||||
char *p = luaL_check_string(2);
|
||||
long init = posrelat(luaL_opt_number(3, 1), l) - 1;
|
||||
long init = posrelat((int)luaL_opt_number(3, 1), l) - 1;
|
||||
struct Capture cap;
|
||||
luaL_arg_check(0 <= init && init <= l, 3, "out of range");
|
||||
if (lua_getparam(4) != LUA_NOOBJECT ||
|
||||
|
@ -13,28 +13,12 @@
|
||||
#include "lstring.h"
|
||||
#include "lundump.h"
|
||||
|
||||
#include <SDL_byteorder.h>
|
||||
|
||||
#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)
|
||||
|
@ -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
|
||||
|
||||
|
@ -15,7 +15,7 @@
|
||||
|
||||
/* ----------------------------------------------------- memory buffers --- */
|
||||
|
||||
static int zmfilbuf (ZIO* z)
|
||||
static int zmfilbuf (ZIO* /*z*/)
|
||||
{
|
||||
return EOZ;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user