From b84b8362abf0ae9359339b549563e556ff857458 Mon Sep 17 00:00:00 2001
From: daurnimator <quae@daurnimator.com>
Date: Mon, 29 May 2017 16:51:35 +1000
Subject: src/lstrlib.js: Fix position capture returning wrong value

---
 src/lstrlib.js | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'src')

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);
     }
-- 
cgit v1.2.3-70-g09d2