From 42826585df204230983871a54fac5a7db73015c5 Mon Sep 17 00:00:00 2001 From: g012 Date: Thu, 28 Sep 2017 11:10:25 +0200 Subject: [PATCH] Fixed 64b build warnings. --- CMakeLists.txt | 2 +- embed.c | 4 ++-- lfs.c | 2 +- lpeg.c | 14 +++++++------- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 910d419..7d550f5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -92,7 +92,7 @@ set(L65_SCRIPTS ${L65_FILES} ) -add_executable(embed ${L65_SOURCE_DIR}/embed.c ${L65_SCRIPTS}) +add_executable(embed ${L65_SOURCE_DIR}/embed.c) add_custom_command( OUTPUT ${L65_BINARY_DIR}/scripts.h COMMAND embed -o ${L65_BINARY_DIR}/scripts.h ${L65_SCRIPTS} diff --git a/embed.c b/embed.c index b0eb05c..bc4234a 100644 --- a/embed.c +++ b/embed.c @@ -68,7 +68,7 @@ static int doargs(int argc, char* argv[]) #define FUNCTION "(function()end)();" -static int w_o; +static size_t w_o; static int writer(lua_State* L, const void* p, size_t size, void* f) { for (size_t i = 0; i < size; ++i) @@ -98,7 +98,7 @@ static int pmain(lua_State* L) char *name = malloc(1024); sprintf(name, "script_%s", ufname + fnix); free(ufname); - int fnl = strlen(filename); + int fnl = (int)strlen(filename); compile = fnl > 4 && !strcmp(".lua", filename + fnl - 4); if (compile) { diff --git a/lfs.c b/lfs.c index d3bf64b..2e14ef4 100644 --- a/lfs.c +++ b/lfs.c @@ -214,7 +214,7 @@ static int get_dir (lua_State *L) { path = realloc(path, size); if (!path) /* failed to allocate */ return pusherror(L, "get_dir realloc() failed"); - if (getcwd(path, size) != NULL) { + if (getcwd(path, (int)size) != NULL) { /* success, push the path to the Lua stack */ lua_pushstring(L, path); result = 1; diff --git a/lpeg.c b/lpeg.c index 44e3e9d..9b23f6a 100644 --- a/lpeg.c +++ b/lpeg.c @@ -2340,11 +2340,11 @@ static void newktable (lua_State *L, int n) { ** If new element is nil, does not add it to table (as it would be ** useless) and returns 0, as ktable[0] is always nil. */ -static int addtoktable (lua_State *L, int idx) { +static lua_Integer addtoktable (lua_State *L, int idx) { if (lua_isnil(L, idx)) /* nil value? */ return 0; else { - int n; + lua_Integer n; lua_getuservalue(L, -1); /* get ktable from pattern */ n = lua_rawlen(L, -1); if (n >= USHRT_MAX) @@ -2363,7 +2363,7 @@ static int addtoktable (lua_State *L, int idx) { ** a table. Treat it as an empty table. In Lua 5.1, assumes that ** the environment has no numeric indices (len == 0) */ -static int ktablelen (lua_State *L, int idx) { +static lua_Integer ktablelen (lua_State *L, int idx) { if (!lua_istable(L, idx)) return 0; else return lua_rawlen(L, idx); } @@ -2521,7 +2521,7 @@ static Pattern *getpattern (lua_State *L, int idx) { } -static int getsize (lua_State *L, int idx) { +static lua_Integer getsize (lua_State *L, int idx) { return (lua_rawlen(L, idx) - sizeof(Pattern)) / sizeof(TTree) + 1; } @@ -2539,7 +2539,7 @@ static TTree *gettree (lua_State *L, int idx, int *len) { ** metatable. (It could be any empty sequence; the metatable is at ** hand here, so we use it.) */ -static TTree *newtree (lua_State *L, int len) { +static TTree *newtree (lua_State *L, lua_Integer len) { size_t size = (len - 1) * sizeof(TTree) + sizeof(Pattern); Pattern *p = (Pattern *)lua_newuserdata(L, size); luaL_getmetatable(L, PATTERN_T); @@ -2632,7 +2632,7 @@ static TTree *getpatt (lua_State *L, int idx, int *len) { tree = newleaf(L, TTrue); /* always match */ else { tree = newtree(L, 2 * (slen - 1) + 1); - fillseq(tree, TChar, slen, s); /* sequence of 'slen' chars */ + fillseq(tree, TChar, (int)slen, s); /* sequence of 'slen' chars */ } break; } @@ -3252,7 +3252,7 @@ static void verifygrammar (lua_State *L, TTree *grammar) { */ static void initialrulename (lua_State *L, TTree *grammar, int frule) { if (sib1(grammar)->key == 0) { /* initial rule is not referenced? */ - int n = lua_rawlen(L, -1) + 1; /* index for name */ + lua_Integer n = lua_rawlen(L, -1) + 1; /* index for name */ lua_pushvalue(L, frule); /* rule's name */ lua_rawseti(L, -2, n); /* ktable was on the top of the stack */ sib1(grammar)->key = n;