summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordaurnimator <quae@daurnimator.com>2017-05-29 16:51:35 +1000
committerdaurnimator <quae@daurnimator.com>2017-05-29 16:51:35 +1000
commitb84b8362abf0ae9359339b549563e556ff857458 (patch)
treee1790094d1f6267bff6167cb65332ac084184891
parent5ad20228dd320f9fd3c250fbd246f531a7f4b5cf (diff)
downloadfengari-b84b8362abf0ae9359339b549563e556ff857458.tar.gz
fengari-b84b8362abf0ae9359339b549563e556ff857458.tar.bz2
fengari-b84b8362abf0ae9359339b549563e556ff857458.zip
src/lstrlib.js: Fix position capture returning wrong value
-rw-r--r--src/lstrlib.js2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/lstrlib.js b/src/lstrlib.js
index c0dc2d2..eec086f 100644
--- a/src/lstrlib.js
+++ b/src/lstrlib.js
@@ -1110,7 +1110,7 @@ const push_onecapture = function(ms, i, s, e) {
let l = ms.capture[i].len;
if (l === CAP_UNFINISHED) lauxlib.luaL_error(ms.L, lua.to_luastring("unfinished capture", true));
if (l === CAP_POSITION)
- lua.lua_pushinteger(ms.L, ms.src_init + 1);
+ lua.lua_pushinteger(ms.L, ms.capture[i].init - ms.src_init + 1);
else
lua.lua_pushlstring(ms.L, ms.src.slice(ms.capture[i].init), l);
}