Skip to content

Commit afbc009

Browse files
committed
5.3 compat: short functions to long functions
checkint -> checkinteger optint -> optinteger Also removes `< 503` check for creating pushunsigned. Older lua versions had redundant functions, but one with a shorter name than the other. Newer Lua versions only retain the long version. one is an alias of the other, but one was removed in 5.3+, so it's better to use the common function across all versions.
1 parent 42f7a28 commit afbc009

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

lua_cmsgpack.c

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,10 @@
3737
#define BITS_32 0
3838
#endif
3939

40-
#if LUA_VERSION_NUM < 503
41-
#if BITS_32
42-
#define lua_pushunsigned(L, n) lua_pushnumber(L, n)
43-
#else
44-
#define lua_pushunsigned(L, n) lua_pushinteger(L, n)
45-
#endif
40+
#if BITS_32
41+
#define lua_pushunsigned(L, n) lua_pushnumber(L, n)
42+
#else
43+
#define lua_pushunsigned(L, n) lua_pushinteger(L, n)
4644
#endif
4745

4846
/* =============================================================================
@@ -836,15 +834,15 @@ static int mp_unpack(lua_State *L) {
836834
}
837835

838836
static int mp_unpack_one(lua_State *L) {
839-
int offset = luaL_optint(L, 2, 0);
837+
int offset = luaL_optinteger(L, 2, 0);
840838
/* Variable pop because offset may not exist */
841839
lua_pop(L, lua_gettop(L)-1);
842840
return mp_unpack_full(L, 1, offset);
843841
}
844842

845843
static int mp_unpack_limit(lua_State *L) {
846-
int limit = luaL_checkint(L, 2);
847-
int offset = luaL_optint(L, 3, 0);
844+
int limit = luaL_checkinteger(L, 2);
845+
int offset = luaL_optinteger(L, 3, 0);
848846
/* Variable pop because offset may not exist */
849847
lua_pop(L, lua_gettop(L)-1);
850848

0 commit comments

Comments
 (0)