aboutsummaryrefslogtreecommitdiffstats
path: root/util/human/units.lua
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2020-06-03 20:17:33 +0200
committerKim Alvefur <zash@zash.se>2020-06-03 20:17:33 +0200
commit715aaf3e80a330a4c74f495f5659faa4b7c5c540 (patch)
tree2d38a12ff54c1c61c2630b3e570f584d1f4d6cee /util/human/units.lua
parentbed3607b09feff29c48bc543a5ff5d93deffda5f (diff)
downloadprosody-715aaf3e80a330a4c74f495f5659faa4b7c5c540.tar.gz
prosody-715aaf3e80a330a4c74f495f5659faa4b7c5c540.zip
util.human.units: Handle lack of math.log(n, base) on Lua 5.1
Diffstat (limited to 'util/human/units.lua')
-rw-r--r--util/human/units.lua8
1 files changed, 8 insertions, 0 deletions
diff --git a/util/human/units.lua b/util/human/units.lua
index 471c82a0..5a083783 100644
--- a/util/human/units.lua
+++ b/util/human/units.lua
@@ -6,6 +6,14 @@ local math_max = math.max;
local math_min = math.min;
local unpack = table.unpack or unpack; --luacheck: ignore 113
+if math_log(10, 10) ~= 1 then
+ -- Lua 5.1 COMPAT
+ local log10 = math.log10;
+ function math_log(n, base)
+ return log10(n) / log10(base);
+ end
+end
+
local large = {
"k", 1000,
"M", 1000000,