summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordaurnimator <quae@daurnimator.com>2017-05-22 01:39:33 +1000
committerdaurnimator <quae@daurnimator.com>2017-05-22 01:39:33 +1000
commitf040e09ab79e821314f737bbc652c63cac278a7a (patch)
tree169760e35c7e5d38d49a0a197c3fb6bff625cf26 /src
parent9a3c95285ffa95eacf586b19b955f9014f4975f0 (diff)
downloadfengari-f040e09ab79e821314f737bbc652c63cac278a7a.tar.gz
fengari-f040e09ab79e821314f737bbc652c63cac278a7a.tar.bz2
fengari-f040e09ab79e821314f737bbc652c63cac278a7a.zip
lua_stringtonumber is meant to return length + 1
Diffstat (limited to 'src')
-rw-r--r--src/lapi.js2
-rw-r--r--src/lbaselib.js2
2 files changed, 2 insertions, 2 deletions
diff --git a/src/lapi.js b/src/lapi.js
index 1fb8baa..d2f5c95 100644
--- a/src/lapi.js
+++ b/src/lapi.js
@@ -800,7 +800,7 @@ const lua_stringtonumber = function(L, s) {
if (tv) {
L.stack[L.top++] = tv;
assert(L.top <= L.ci.top, "stack overflow");
- return s.length;
+ return s.length+1;
}
return 0;
};
diff --git a/src/lbaselib.js b/src/lbaselib.js
index bffe5a6..613adc0 100644
--- a/src/lbaselib.js
+++ b/src/lbaselib.js
@@ -162,7 +162,7 @@ const luaB_tonumber = function(L) {
return 1;
} else {
let s = lua.lua_tostring(L, 1);
- if (s !== null && lua.lua_stringtonumber(L, s) === s.length)
+ if (s !== null && lua.lua_stringtonumber(L, s) === s.length+1)
return 1; /* successful conversion to number */
}
} else {