summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2021-10-10 09:17:11 +0800
committerruki <[email protected]>2021-10-10 09:17:11 +0800
commitf706a145a7d3da0ca1d8267a1016b15dcf1e5a58 (patch)
treeb6f279f2665132134d1b5628855dac491f297b63
parentfc545b0e7bfd7441ea03f30c52fa373124186f4b (diff)
fix table.maxn for lua54
-rw-r--r--xmake/core/base/table.lua10
1 files changed, 8 insertions, 2 deletions
diff --git a/xmake/core/base/table.lua b/xmake/core/base/table.lua
index f571a4553..5f2c4585a 100644
--- a/xmake/core/base/table.lua
+++ b/xmake/core/base/table.lua
@@ -53,10 +53,16 @@ if not table.getn then
end
end
--- get array max length for lua5.4
+-- get array max integer key for lua5.4
if not table.maxn then
function table.maxn(t)
- return #t
+ local max = 0
+ for k, _ in pairs(t) do
+ if type(k) == "number" and k > max then
+ max = k
+ end
+ end
+ return max
end
end