diff --git a/common/lualib.c b/common/lualib.c index ab0b3bad6..a53aa5cab 100644 --- a/common/lualib.c +++ b/common/lualib.c @@ -53,7 +53,7 @@ void luaA_dumpstack(lua_State *L) break; default: fprintf(stderr, "%d: %s\t#%d\t%p\n", i, lua_typename(L, t), - (int) lua_objlen(L, i), + (int) luaA_rawlen(L, i), lua_topointer(L, i)); break; } diff --git a/dbus.c b/dbus.c index 8a6bf497f..30e280928 100644 --- a/dbus.c +++ b/dbus.c @@ -276,7 +276,7 @@ a_dbus_convert_value(lua_State *L, int idx, DBusMessageIter *iter) type + 1, &subiter); - int arraylen = lua_objlen(L, idx + 1); + int arraylen = luaA_rawlen(L, idx + 1); if(arraylen % 2 != 0) { diff --git a/luaa.h b/luaa.h index 68d2412a7..4a44ea32f 100644 --- a/luaa.h +++ b/luaa.h @@ -94,6 +94,16 @@ luaA_setuservalue(lua_State *L, int idx) #endif } +static inline size_t +luaA_rawlen(lua_State *L, int idx) +{ +#if LUA_VERSION_NUM >= 502 + return lua_rawlen(L, idx); +#else + return lua_objlen(L, idx); +#endif +} + static inline bool luaA_checkboolean(lua_State *L, int n) { diff --git a/objects/key.c b/objects/key.c index a37f0eb82..af0d7076c 100644 --- a/objects/key.c +++ b/objects/key.c @@ -142,7 +142,7 @@ uint16_t luaA_tomodifiers(lua_State *L, int ud) { luaA_checktable(L, ud); - ssize_t len = lua_objlen(L, ud); + ssize_t len = luaA_rawlen(L, ud); uint16_t mod = XCB_NONE; for(int i = 1; i <= len; i++) {