From 8381f1a8cfbf5f23e4d7eb30e0615bc5c9c67316 Mon Sep 17 00:00:00 2001 From: Christian Ege Date: Sat, 27 Apr 2013 21:23:08 +0200 Subject: [PATCH] handling of luaposix for dynamic environments added loading of luaposix in case of none static linking of lua --- src/gui/luainstance.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/gui/luainstance.cpp b/src/gui/luainstance.cpp index d893ad4dd..4f9f29fb9 100644 --- a/src/gui/luainstance.cpp +++ b/src/gui/luainstance.cpp @@ -302,6 +302,13 @@ const luaL_Reg CLuaInstance::methods[] = /* hack: we link against luaposix, which is included in our * custom built lualib */ extern "C" { LUAMOD_API int (luaopen_posix_c) (lua_State *L); } +#else +static int dolibrary (lua_State *L, const char *name) +{ + lua_getglobal(L, "require"); + lua_pushstring(L, name); + return report(L, lua_pcall(L, 1, 0, 0)); +} #endif /* load basic functions and register our own C callbacks */ void CLuaInstance::registerFunctions() @@ -314,6 +321,8 @@ void CLuaInstance::registerFunctions() #ifndef DYNAMIC_LUAPOSIX luaopen_posix_c(lua); #endif + dolibrary(lua,"posix"); +#endif lua_newtable(lua); int methodtable = lua_gettop(lua);