diff options
author | Kim Alvefur <zash@zash.se> | 2019-05-30 13:54:11 +0200 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2019-05-30 13:54:11 +0200 |
commit | 9991f8892518b2d48cf27b3667a2fe33d25dcd67 (patch) | |
tree | 21e8655ccdf297cc318dd8288ef97debf7100fc1 /util | |
parent | be249b1a12e22c3276598555bedf7beb8386f550 (diff) | |
download | prosody-9991f8892518b2d48cf27b3667a2fe33d25dcd67.tar.gz prosody-9991f8892518b2d48cf27b3667a2fe33d25dcd67.zip |
util.format: Handle integer formats the same way on Lua versions without integer support
Diffstat (limited to 'util')
-rw-r--r-- | util/format.lua | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/util/format.lua b/util/format.lua index 857bb694..1ce670f3 100644 --- a/util/format.lua +++ b/util/format.lua @@ -7,9 +7,12 @@ local unpack = table.unpack or unpack; -- luacheck: ignore 113/unpack local pack = require "util.table".pack; -- TODO table.pack in 5.2+ local type = type; local dump = require "util.serialization".new("debug"); -local num_type = math.type; +local num_type = math.type or function (n) + return n % 1 == 0 and n <= 9007199254740992 and n >= -9007199254740992 and "integer" or "float"; +end -local expects_integer = num_type and { c = true, d = true, i = true, o = true, u = true, X = true, x = true, } or {}; +-- 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, }; local function format(formatstring, ...) local args = pack(...); |