aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordaurnimator <quae@daurnimator.com>2018-04-22 21:29:21 +1000
committerdaurnimator <quae@daurnimator.com>2018-04-22 21:31:01 +1000
commit668a641ee18ec3715e0fb57bab1a954362019e54 (patch)
treea5de4c90974528b37ee9b80833ae5172f05cf156
parentc0cb496af1f9901de323563e4efcc3a4f41c8f7a (diff)
downloadfengari-668a641ee18ec3715e0fb57bab1a954362019e54.tar.gz
fengari-668a641ee18ec3715e0fb57bab1a954362019e54.tar.bz2
fengari-668a641ee18ec3715e0fb57bab1a954362019e54.zip
src/loslib.js: Avoid luaL_opt when default case is complex expression
In C its a macro and won't evaluate the arg, but JavaScript will always evaluate
-rw-r--r--src/loslib.js4
1 files changed, 1 insertions, 3 deletions
diff --git a/src/loslib.js b/src/loslib.js
index 854719a..462fd49 100644
--- a/src/loslib.js
+++ b/src/loslib.js
@@ -35,7 +35,6 @@ const {
luaL_execresult,
luaL_fileresult,
luaL_newlib,
- luaL_opt,
luaL_optinteger,
luaL_optlstring,
luaL_optstring,
@@ -123,8 +122,7 @@ const checkoption = function(L, conv, i, buff) {
const os_date = function(L) {
let s = luaL_optlstring(L, 1, "%c");
- let t = luaL_opt(L, l_checktime, 2, new Date().getTime() / 1000) * 1000;
- let stm = new Date(t);
+ let stm = lua_isnoneornil(L, 2) ? new Date() : new Date(l_checktime(L, 2) * 1000);
let utc = false;
let i = 0;
if (s[i] === '!'.charCodeAt(0)) { /* UTC? */