diff options
author | daurnimator <quae@daurnimator.com> | 2018-02-04 16:06:51 -0800 |
---|---|---|
committer | daurnimator <quae@daurnimator.com> | 2018-02-04 16:06:55 -0800 |
commit | 89d049c7a3a68bbeffa262bf3bf6fa3bcb83d176 (patch) | |
tree | 55f7fe1380fa7a9712873f8ab579727573236aea | |
parent | b42f1c3e18bab816203cc34a9af4d1c11e55199b (diff) | |
download | fengari-89d049c7a3a68bbeffa262bf3bf6fa3bcb83d176.tar.gz fengari-89d049c7a3a68bbeffa262bf3bf6fa3bcb83d176.tar.bz2 fengari-89d049c7a3a68bbeffa262bf3bf6fa3bcb83d176.zip |
src/lauxlib.js: Check default value when using luaL_optstring
-rw-r--r-- | src/lauxlib.js | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/lauxlib.js b/src/lauxlib.js index d5b943b..15d8dab 100644 --- a/src/lauxlib.js +++ b/src/lauxlib.js @@ -76,6 +76,7 @@ const { lua_version } = require('./lua.js'); const { + from_userstring, luastring_eq, to_luastring, to_uristring @@ -366,7 +367,7 @@ const luaL_checkudata = function(L, ud, tname) { }; const luaL_checkoption = function(L, arg, def, lst) { - let name = def ? luaL_optstring(L, arg, def) : luaL_checkstring(L, arg); + let name = def !== null ? luaL_optstring(L, arg, def) : luaL_checkstring(L, arg); for (let i = 0; lst[i]; i++) if (luastring_eq(lst[i], name)) return i; @@ -414,7 +415,7 @@ const luaL_checklstring = function(L, arg) { const luaL_optlstring = function(L, arg, def) { if (lua_type(L, arg) <= 0) { - return def; + return def === null ? null : from_userstring(def); } else return luaL_checklstring(L, arg); }; |