From f040e09ab79e821314f737bbc652c63cac278a7a Mon Sep 17 00:00:00 2001 From: daurnimator Date: Mon, 22 May 2017 01:39:33 +1000 Subject: lua_stringtonumber is meant to return length + 1 --- src/lapi.js | 2 +- src/lbaselib.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src') 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 { -- cgit v1.2.3-70-g09d2