From 42f973f85ba7e3934111aa53588b43049c123a56 Mon Sep 17 00:00:00 2001 From: Li Jin Date: Thu, 14 Sep 2023 16:44:18 +0800 Subject: fixing issue #148. --- src/yue_wasm.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/yue_wasm.cpp b/src/yue_wasm.cpp index 1b614e3..4a054e6 100644 --- a/src/yue_wasm.cpp +++ b/src/yue_wasm.cpp @@ -140,15 +140,16 @@ std::string exec(const std::string& codes) { execStr(R"yuescript( _G.__output = {} _G.print = (...)-> - len = select "#", ... - strs = {} - for i = 1, len - strs[#strs + 1] = tostring select i, ... - _G.__output[#_G.__output + 1] = table.concat strs, "\n" + _G.__output[] = table.concat [tostring select i, ... for i = 1, select "#", ...], " " + _G.__output[] = "\n" +_io_write = io.write +_G.io.write = (...)-> + _G.__output[] = table.concat [tostring select i, ... for i = 1, select "#", ...] + _io_write ... )yuescript"); std::string res2 = execStr(codes); std::string res1 = execStr(R"yuescript( -res = table.concat _G.__output, "\n" +res = table.concat _G.__output return res if res ~= "" )yuescript"); if (res1.empty()) { -- cgit v1.2.3-55-g6feb