summaryrefslogtreecommitdiff
path: root/src/lapi.js
diff options
context:
space:
mode:
authordenis <denisv@post.skynet.lt>2017-09-07 03:44:37 +0300
committerdenis <denisv@post.skynet.lt>2017-09-07 15:24:00 +0300
commitb482e19917395c842780bd2b8da7731158947c40 (patch)
treed8951ce0846874d36a22f9e0d7bfbc2b0b5993af /src/lapi.js
parentfc3d60b9a7cd7b8e46a9b342ec504d84c927aa08 (diff)
downloadfengari-b482e19917395c842780bd2b8da7731158947c40.tar.gz
fengari-b482e19917395c842780bd2b8da7731158947c40.tar.bz2
fengari-b482e19917395c842780bd2b8da7731158947c40.zip
src/lapi.js, src/lauxlib.js: lua_tointeger should return 0 when conversion fails for luaL_ref to work
Diffstat (limited to 'src/lapi.js')
-rw-r--r--src/lapi.js11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/lapi.js b/src/lapi.js
index b7fed83..1be0837 100644
--- a/src/lapi.js
+++ b/src/lapi.js
@@ -708,11 +708,16 @@ const lua_tocfunction = function(L, idx) {
};
const lua_tointeger = function(L, idx) {
+ let n = lua_tointegerx(L, idx);
+ return n === false ? 0 : n;
+};
+
+const lua_tointegerx = function(L, idx) {
return lvm.tointeger(index2addr(L, idx));
};
const lua_tonumber = function(L, idx) {
- let n = lvm.tonumber(index2addr(L, idx));
+ let n = lua_tonumberx(L, idx);
return n === false ? 0 : n;
};
@@ -814,10 +819,6 @@ const lua_stringtonumber = function(L, s) {
return 0;
};
-const lua_tointegerx = function(L, idx) {
- return lvm.tointeger(index2addr(L, idx));
-};
-
const f_call = function(L, ud) {
ldo.luaD_callnoyield(L, ud.funcOff, ud.nresults);
};