diff options
author | Li Jin <dragon-fly@qq.com> | 2023-09-14 16:44:18 +0800 |
---|---|---|
committer | Li Jin <dragon-fly@qq.com> | 2023-09-14 16:44:18 +0800 |
commit | 42f973f85ba7e3934111aa53588b43049c123a56 (patch) | |
tree | fee574b27aca27607972b0a35cffa3a77c4b9a22 /src/yue_wasm.cpp | |
parent | 103fd0646eb83898b37398731f90e2dc277ac2d8 (diff) | |
download | yuescript-42f973f85ba7e3934111aa53588b43049c123a56.tar.gz yuescript-42f973f85ba7e3934111aa53588b43049c123a56.tar.bz2 yuescript-42f973f85ba7e3934111aa53588b43049c123a56.zip |
fixing issue #148.
Diffstat (limited to '')
-rw-r--r-- | src/yue_wasm.cpp | 13 |
1 files changed, 7 insertions, 6 deletions
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) { | |||
140 | execStr(R"yuescript( | 140 | execStr(R"yuescript( |
141 | _G.__output = {} | 141 | _G.__output = {} |
142 | _G.print = (...)-> | 142 | _G.print = (...)-> |
143 | len = select "#", ... | 143 | _G.__output[] = table.concat [tostring select i, ... for i = 1, select "#", ...], " " |
144 | strs = {} | 144 | _G.__output[] = "\n" |
145 | for i = 1, len | 145 | _io_write = io.write |
146 | strs[#strs + 1] = tostring select i, ... | 146 | _G.io.write = (...)-> |
147 | _G.__output[#_G.__output + 1] = table.concat strs, "\n" | 147 | _G.__output[] = table.concat [tostring select i, ... for i = 1, select "#", ...] |
148 | _io_write ... | ||
148 | )yuescript"); | 149 | )yuescript"); |
149 | std::string res2 = execStr(codes); | 150 | std::string res2 = execStr(codes); |
150 | std::string res1 = execStr(R"yuescript( | 151 | std::string res1 = execStr(R"yuescript( |
151 | res = table.concat _G.__output, "\n" | 152 | res = table.concat _G.__output |
152 | return res if res ~= "" | 153 | return res if res ~= "" |
153 | )yuescript"); | 154 | )yuescript"); |
154 | if (res1.empty()) { | 155 | if (res1.empty()) { |