diff options
Diffstat (limited to 'util')
-rw-r--r-- | util/format.lua | 4 | ||||
-rw-r--r-- | util/jsonpointer.lua | 4 | ||||
-rw-r--r-- | util/serialization.lua | 4 | ||||
-rw-r--r-- | util/startup.lua | 14 |
4 files changed, 17 insertions, 9 deletions
diff --git a/util/format.lua b/util/format.lua index 203bdeab..0631f423 100644 --- a/util/format.lua +++ b/util/format.lua @@ -11,9 +11,7 @@ local pack = table.pack; local valid_utf8 = require "util.encodings".utf8.valid; local type = type; local dump = require "util.serialization".new("debug"); -local num_type = math.type or function (n) - return n % 1 == 0 and n <= 9007199254740992 and n >= -9007199254740992 and "integer" or "float"; -end +local num_type = math.type; -- In Lua 5.3+ these formats throw an error if given a float local expects_integer = { c = true, d = true, i = true, o = true, u = true, X = true, x = true, }; diff --git a/util/jsonpointer.lua b/util/jsonpointer.lua index 9b871ae7..f1c354a4 100644 --- a/util/jsonpointer.lua +++ b/util/jsonpointer.lua @@ -1,6 +1,4 @@ -local m_type = math.type or function (n) - return n % 1 == 0 and n <= 9007199254740992 and n >= -9007199254740992 and "integer" or "float"; -end; +local m_type = math.type; local function unescape_token(escaped_token) local unescaped = escaped_token:gsub("~1", "/"):gsub("~0", "~") diff --git a/util/serialization.lua b/util/serialization.lua index d310a3e8..6552d53b 100644 --- a/util/serialization.lua +++ b/util/serialization.lua @@ -22,9 +22,7 @@ local pcall = pcall; local envload = require"util.envload".envload; local pos_inf, neg_inf = math.huge, -math.huge; -local m_type = math.type or function (n) - return n % 1 == 0 and n <= 9007199254740992 and n >= -9007199254740992 and "integer" or "float"; -end; +local m_type = math.type; local function rawpairs(t) return next, t, nil; diff --git a/util/startup.lua b/util/startup.lua index 10ff1875..9e512cb3 100644 --- a/util/startup.lua +++ b/util/startup.lua @@ -277,6 +277,20 @@ function startup.init_global_state() startup.detect_platform(); startup.detect_installed(); _G.prosody = prosody; + + -- COMPAT Lua < 5.3 + if not math.type then + -- luacheck: ignore 122/math + function math.type(n) + if type(n) == "number" then + if n % 1 == 0 and (n + 1 ~= n and n - 1 ~= n) then + return "integer" + else + return "float" + end + end + end + end end function startup.setup_datadir() |