From 8953ecec306536cd0b18c9de316461ad4c35166f Mon Sep 17 00:00:00 2001 From: Li Jin Date: Mon, 29 Nov 2021 14:42:36 +0800 Subject: fix issue #70. --- src/yue.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/yue.cpp') diff --git a/src/yue.cpp b/src/yue.cpp index 1704b57..133a081 100644 --- a/src/yue.cpp +++ b/src/yue.cpp @@ -37,7 +37,12 @@ int luaopen_yue(lua_State* L); static void openlibs(void* state) { lua_State* L = static_cast(state); luaL_openlibs(L); +#if LUA_VERSION_NUM > 501 luaL_requiref(L, "yue", luaopen_yue, 1); +#else + lua_pushcfunction(L, luaopen_yue); + lua_call(L, 0, 0); +#endif lua_pop(L, 1); } @@ -238,7 +243,14 @@ int main(int narg, const char** args) { if (success) { if (retCount > 1) { for (int i = 1; i < retCount; ++i) { +#if LUA_VERSION_NUM > 501 std::cout << Val << luaL_tolstring(L, -retCount + i, nullptr) << Stop; +#else // LUA_VERSION_NUM + lua_getglobal(L, "tostring"); + lua_pushvalue(L, -retCount + i - 1); + lua_call(L, 1, 1); + std::cout << Val << lua_tostring(L, -1) << Stop; +#endif // LUA_VERSION_NUM lua_pop(L, 1); } } -- cgit v1.2.3-55-g6feb