aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBenoit Giannangeli <giann008@gmail.com>2017-03-24 10:57:49 +0100
committerBenoit Giannangeli <giann008@gmail.com>2017-03-24 10:59:27 +0100
commita6fa99b44b6d536a1fb23f9ffd7a84786c63edab (patch)
tree6e44f116dc2e072a4a54cc5a8af9cc194d5e0d08 /src
parenteafdbc018fbeeec088b82172ff59a413558e92e7 (diff)
downloadfengari-a6fa99b44b6d536a1fb23f9ffd7a84786c63edab.tar.gz
fengari-a6fa99b44b6d536a1fb23f9ffd7a84786c63edab.tar.bz2
fengari-a6fa99b44b6d536a1fb23f9ffd7a84786c63edab.zip
string.char bypass to_luastring conversion
Diffstat (limited to 'src')
-rw-r--r--src/lstrlib.js7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/lstrlib.js b/src/lstrlib.js
index 1b62db1..4bd8664 100644
--- a/src/lstrlib.js
+++ b/src/lstrlib.js
@@ -53,13 +53,14 @@ const str_len = function(L) {
const str_char = function(L) {
let n = lapi.lua_gettop(L); /* number of arguments */
- let p = "";
+ let p = [];
for (let i = 1; i <= n; i++) {
let c = lauxlib.luaL_checkinteger(L, i);
lauxlib.luaL_argcheck(L, c >= 0 && c <= 255, "value out of range"); // Strings are 8-bit clean
- p += String.fromCharCode(c);
+ p.push(c);
}
- lapi.lua_pushstring(L, p);
+ lapi.lua_pushstring(L, "");
+ L.stack[L.top - 1].value = p; // Since value are already capped, avoid conversion
return 1;
};