diff --git a/upb/bindings/lua/upb.c b/upb/bindings/lua/upb.c index 87b39e647a..9629314d6d 100644 --- a/upb/bindings/lua/upb.c +++ b/upb/bindings/lua/upb.c @@ -53,7 +53,7 @@ static size_t lupb_msgdef_sizeof(); * compatibility code can help hide the difference. Not too many people still * use Lua 5.1 but LuaJIT uses the Lua 5.1 API in some ways. */ -#if lua_version_num == 501 +#if LUA_VERSION_NUM == 501 /* taken from lua 5.2's source. */ void *luaL_testudata(lua_State *L, int ud, const char *tname) { diff --git a/upb/bindings/lua/upb.lua b/upb/bindings/lua/upb.lua index 4090b37a6f..8b32cff664 100644 --- a/upb/bindings/lua/upb.lua +++ b/upb/bindings/lua/upb.lua @@ -14,7 +14,10 @@ -- This has to happen *before* the require call, because if the module -- is loaded RTLD_LOCAL first, a subsequent load as RTLD_GLOBAL won't -- have the proper effect, at least on some platforms. -package.loadlib(package.searchpath("upb_c", package.cpath), "*") +local so = package.searchpath and package.searchpath("upb_c", package.cpath) +if so then + package.loadlib(so, "*") +end local upb = require("upb_c") diff --git a/upb/pb/textprinter.c b/upb/pb/textprinter.c index b772af33f4..269881b91b 100644 --- a/upb/pb/textprinter.c +++ b/upb/pb/textprinter.c @@ -112,7 +112,7 @@ bool putf(upb_textprinter *p, const char *fmt, ...) { /* Run once to get the length of the string. */ va_copy(args_copy, args); - len = vsprintf(NULL, fmt, args_copy); + len = _upb_vsnprintf(NULL, 0, fmt, args_copy); va_end(args_copy); /* + 1 for NULL terminator (vsprintf() requires it even if we don't). */ diff --git a/upb/table.c b/upb/table.c index cee2cf82e9..943290e0c6 100644 --- a/upb/table.c +++ b/upb/table.c @@ -439,14 +439,16 @@ size_t upb_inttable_count(const upb_inttable *t) { static void check(upb_inttable *t) { UPB_UNUSED(t); #if defined(UPB_DEBUG_TABLE) && !defined(NDEBUG) - /* This check is very expensive (makes inserts/deletes O(N)). */ - size_t count = 0; - upb_inttable_iter i; - upb_inttable_begin(&i, t); - for(; !upb_inttable_done(&i); upb_inttable_next(&i), count++) { - assert(upb_inttable_lookup(t, upb_inttable_iter_key(&i), NULL)); + { + /* This check is very expensive (makes inserts/deletes O(N)). */ + size_t count = 0; + upb_inttable_iter i; + upb_inttable_begin(&i, t); + for(; !upb_inttable_done(&i); upb_inttable_next(&i), count++) { + assert(upb_inttable_lookup(t, upb_inttable_iter_key(&i), NULL)); + } + assert(count == upb_inttable_count(t)); } - assert(count == upb_inttable_count(t)); #endif }