From b8945d536710b55075e864178aa706d72464e376 Mon Sep 17 00:00:00 2001 From: Alexey Kopytov Date: Sun, 2 Apr 2017 14:28:44 +0300 Subject: [PATCH] Merge akopytov/LuaJIT up to commit a0b15c7. This is to cherry-pick the following commit from the Tarantool LuaJIT branch: commit 0615898d294847677ce8c652f3a67956a48e0ee1 Author: Nick Zavaritsky Date: Thu Jul 28 14:24:58 2016 +0300 Automatically try *.so if *.dylib is missing (osx). --- third_party/luajit/luajit/src/lib_package.c | 14 ++++++++++++++ third_party/luajit/luajit/src/lj_state.c | 1 - 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/third_party/luajit/luajit/src/lib_package.c b/third_party/luajit/luajit/src/lib_package.c index b7655c6..5457743 100644 --- a/third_party/luajit/luajit/src/lib_package.c +++ b/third_party/luajit/luajit/src/lib_package.c @@ -299,9 +299,23 @@ static const char *searchpath (lua_State *L, const char *name, const char *filename = luaL_gsub(L, lua_tostring(L, -1), LUA_PATH_MARK, name); lua_remove(L, -2); /* remove path template */ + goto check_readable; /* suppress "unused label" warning */ +check_readable: if (readable(filename)) /* does file exist and is readable? */ return filename; /* return that file name */ lua_pushfstring(L, "\n\tno file " LUA_QS, filename); +#if LJ_TARGET_OSX || LJ_TARGET_IOS + /* if *.dylib is missing, try *.so */ + size_t len = strlen(filename); + if (len > 6 && strcmp(filename + len - 6, ".dylib") == 0) { + luaL_addvalue(&msg); /* concatenate error msg. entry */ + lua_pushlstring(L, filename, len - 6); + filename = lua_pushfstring(L, "%s.so", lua_tostring(L, -1)); + lua_insert(L, -3); /* sink new filename below old one */ + lua_pop(L, 2); + goto check_readable; + } +#endif lua_remove(L, -2); /* remove file name */ luaL_addvalue(&msg); /* concatenate error msg. entry */ } diff --git a/third_party/luajit/luajit/src/lj_state.c b/third_party/luajit/luajit/src/lj_state.c index 813cfda..4826636 100644 --- a/third_party/luajit/luajit/src/lj_state.c +++ b/third_party/luajit/luajit/src/lj_state.c @@ -246,7 +246,6 @@ LUA_API lua_State *lua_newstate(lua_Alloc f, void *ud) G2J(g)->range = range; G2J(g)->allocbase = allocbase; #endif - return L; }