From df968a09f08f8b398b72072d55255be7b0100d05 Mon Sep 17 00:00:00 2001 From: Nick Gasson Date: Tue, 8 Jun 2010 21:48:52 +0100 Subject: [PATCH] Load safe Lua libraries at startup --- src/LuaWrap.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/LuaWrap.cpp b/src/LuaWrap.cpp index 34f79a0..780bbee 100644 --- a/src/LuaWrap.cpp +++ b/src/LuaWrap.cpp @@ -23,6 +23,7 @@ extern "C" { #include #include +#include } static int lua_debug(lua_State *L) @@ -36,6 +37,10 @@ static int lua_debug(lua_State *L) static int lua_log(lua_State *L) { + const char *s = luaL_checkstring(L, -1); + if (s != NULL) + log() << s; + return 0; } @@ -68,6 +73,10 @@ LuaWrap::LuaWrap() if ((L = lua_open()) == NULL) throw runtime_error("Failed to initialise Lua"); + luaopen_base(L); + luaopen_string(L); + luaopen_table(L); + lua_pushvalue(L, LUA_GLOBALSINDEX); luaL_register(L, NULL, luaFuncs); lua_pop(L, 1); -- 2.39.2