From 668a641ee18ec3715e0fb57bab1a954362019e54 Mon Sep 17 00:00:00 2001 From: daurnimator Date: Sun, 22 Apr 2018 21:29:21 +1000 Subject: 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 --- src/loslib.js | 4 +--- 1 file changed, 1 insertion(+), 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? */ -- cgit v1.2.3-54-g00ecf