align luaL_len with 5.3

This commit is contained in:
Francois Perrad 2017-05-06 10:45:59 +02:00
parent af45163001
commit 3d54cb7f32
3 changed files with 5 additions and 5 deletions

View File

@ -90,7 +90,7 @@ LUALIB_API void (luaL_pushmodule) (lua_State *L, const char *modname,
int sizehint); int sizehint);
LUALIB_API void *(luaL_testudata) (lua_State *L, int ud, const char *tname); LUALIB_API void *(luaL_testudata) (lua_State *L, int ud, const char *tname);
LUALIB_API void (luaL_setmetatable) (lua_State *L, const char *tname); LUALIB_API void (luaL_setmetatable) (lua_State *L, const char *tname);
LUALIB_API int (luaL_len) (lua_State *L, int idx); LUALIB_API lua_Integer (luaL_len) (lua_State *L, int idx);
/* /*

View File

@ -1221,12 +1221,12 @@ LUALIB_API int luaL_callmeta(lua_State *L, int idx, const char *field)
return 0; return 0;
} }
LUALIB_API int luaL_len(lua_State *L, int idx) LUALIB_API lua_Integer luaL_len(lua_State *L, int idx)
{ {
int l; lua_Integer l;
int isnum; int isnum;
lua_len(L, idx); lua_len(L, idx);
l = (int)lua_tointegerx(L, -1, &isnum); l = lua_tointegerx(L, -1, &isnum);
if (!isnum) if (!isnum)
luaL_error(L, "object length is not a number"); luaL_error(L, "object length is not a number");
lua_pop(L, 1); /* remove object */ lua_pop(L, 1); /* remove object */

View File

@ -274,7 +274,7 @@ static int pushargs(lua_State *L)
lua_getglobal(L, "arg"); lua_getglobal(L, "arg");
if (!lua_istable(L, -1)) if (!lua_istable(L, -1))
luaL_error(L, "'arg' is not a table"); luaL_error(L, "'arg' is not a table");
n = luaL_len(L, -1); n = (int)luaL_len(L, -1);
luaL_checkstack(L, n + 3, "too many arguments to script"); luaL_checkstack(L, n + 3, "too many arguments to script");
for (i = 1; i <= n; i++) for (i = 1; i <= n; i++)
lua_rawgeti(L, -i, i); lua_rawgeti(L, -i, i);