summaryrefslogtreecommitdiff
path: root/src/lstrlib.js
diff options
context:
space:
mode:
authorBenoit Giannangeli <giann008@gmail.com>2017-03-24 09:34:56 +0100
committerBenoit Giannangeli <giann008@gmail.com>2017-03-24 09:34:56 +0100
commitf2250406ab210d71ca8ae71db93facc34f3c9992 (patch)
tree61afe1d325709f3391157f2d3bff2639d3ed2073 /src/lstrlib.js
parent6b0acbceafce33b6ef695f8632d1b12bfaa434de (diff)
downloadfengari-f2250406ab210d71ca8ae71db93facc34f3c9992.tar.gz
fengari-f2250406ab210d71ca8ae71db93facc34f3c9992.tar.bz2
fengari-f2250406ab210d71ca8ae71db93facc34f3c9992.zip
TValue.jsstring can take start and end indexes
Diffstat (limited to 'src/lstrlib.js')
-rw-r--r--src/lstrlib.js4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/lstrlib.js b/src/lstrlib.js
index c6c0dc3..1b62db1 100644
--- a/src/lstrlib.js
+++ b/src/lstrlib.js
@@ -33,13 +33,15 @@ const posrelat = function(pos, len) {
const str_sub = function(L) {
let s = lauxlib.luaL_checkstring(L, 1);
+ let ts = L.stack[lapi.index2addr_(L, 1)];
+ s = ts.value;
let l = s.length;
let start = posrelat(lauxlib.luaL_checkinteger(L, 2), l);
let end = posrelat(lauxlib.luaL_optinteger(L, 3, -1), l);
if (start < 1) start = 1;
if (end > l) end = l;
if (start <= end)
- lapi.lua_pushstring(L, s.slice(start - 1, (start - 1) + (end - start + 1)));
+ lapi.lua_pushstring(L, ts.jsstring(start - 1, (start - 1) + (end - start + 1)));
else lapi.lua_pushliteral(L, "");
return 1;
};