diff --git a/lua/def.c b/lua/def.c index 90161ec819..a7a26c89c0 100644 --- a/lua/def.c +++ b/lua/def.c @@ -617,7 +617,11 @@ const upb_FileDef* lupb_FileDef_check(lua_State* L, int narg) { static int lupb_FileDef_Dependency(lua_State* L) { const upb_FileDef* f = lupb_FileDef_check(L, 1); +#if defined(LUA_VERSION_NUM) && LUA_VERSION_NUM >= 501 + int index = luaL_checkinteger(L, 2); +#else int index = luaL_checkint(L, 2); +#endif const upb_FileDef* dep = upb_FileDef_Dependency(f, index); lupb_wrapper_pushwrapper(L, 1, dep, LUPB_FILEDEF); return 1; @@ -631,7 +635,11 @@ static int lupb_FileDef_DependencyCount(lua_State* L) { static int lupb_FileDef_enum(lua_State* L) { const upb_FileDef* f = lupb_FileDef_check(L, 1); +#if defined(LUA_VERSION_NUM) && LUA_VERSION_NUM >= 501 + int index = luaL_checkinteger(L, 2); +#else int index = luaL_checkint(L, 2); +#endif const upb_EnumDef* e = upb_FileDef_TopLevelEnum(f, index); lupb_wrapper_pushwrapper(L, 1, e, LUPB_ENUMDEF); return 1; @@ -645,7 +653,11 @@ static int lupb_FileDef_enumcount(lua_State* L) { static int lupb_FileDef_msg(lua_State* L) { const upb_FileDef* f = lupb_FileDef_check(L, 1); +#if defined(LUA_VERSION_NUM) && LUA_VERSION_NUM >= 501 + int index = luaL_checkinteger(L, 2); +#else int index = luaL_checkint(L, 2); +#endif const upb_MessageDef* m = upb_FileDef_TopLevelMessage(f, index); lupb_wrapper_pushwrapper(L, 1, m, LUPB_MSGDEF); return 1; diff --git a/lua/upb.c b/lua/upb.c index 8c73e5fb7f..f6ff01114d 100644 --- a/lua/upb.c +++ b/lua/upb.c @@ -61,11 +61,13 @@ /* Lua compatibility code *****************************************************/ /* Shims for upcoming Lua 5.3 functionality. */ +#if LUA_VERSION_NUM < 503 static bool lua_isinteger(lua_State* L, int argn) { LUPB_UNUSED(L); LUPB_UNUSED(argn); return false; } +#endif /* Utility functions **********************************************************/ diff --git a/lua/upbc.cc b/lua/upbc.cc index e857f7aae9..8efb491d0e 100644 --- a/lua/upbc.cc +++ b/lua/upbc.cc @@ -79,7 +79,7 @@ static void PrintString(int max_cols, absl::string_view* str, } else if (ch == '\'') { printer->PrintRaw("\\'"); max_cols--; - } else if (isprint(ch)) { + } else if (isprint(static_cast(static_cast(ch)))) { printer->WriteRaw(&ch, 1); max_cols--; } else { diff --git a/upb/text/encode.c b/upb/text/encode.c index c694088fc2..33438be30b 100644 --- a/upb/text/encode.c +++ b/upb/text/encode.c @@ -308,7 +308,7 @@ static void txtenc_map(txtenc* e, const upb_Map* map, const upb_FieldDef* f) { #define CHK(x) \ do { \ if (!(x)) { \ - return false; \ + return NULL; \ } \ } while (0)