summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2020-01-18 23:33:03 +0800
committerruki <[email protected]>2020-01-18 23:33:03 +0800
commit747b281a52494170e0521151570df11f4c241cb4 (patch)
tree87d514748087fb23d47beb66b9a9f7c975b32f5e
parent8a7a668045c3be0458388a77164467972b29a660 (diff)
fix table.move for termux/arm64
-rw-r--r--xmake/core/base/table.lua22
1 files changed, 22 insertions, 0 deletions
diff --git a/xmake/core/base/table.lua b/xmake/core/base/table.lua
index 509082f5c..328bd9f6c 100644
--- a/xmake/core/base/table.lua
+++ b/xmake/core/base/table.lua
@@ -335,6 +335,7 @@ function table.imap(arr, mapper)
return newarr
end
+-- reverse table values
function table.reverse(arr)
assert(arr)
@@ -347,5 +348,26 @@ function table.reverse(arr)
return revarr
end
+-- move values of table(a1) to table(a2)
+--
+-- disable the builtin implementation for android termux/arm64, it will crash when calling `table.move({1, 1}, 1, 2, 1, {})`
+--
+-- @see https://github.com/xmake-io/xmake/pull/667#issuecomment-575859604
+--
+if xmake._ARCH:startswith("arm") then
+ function table.move(a1, f, e, t, a2)
+ if a2 == nil then a2 = a1 end
+ if e >= f then
+ local d = t - f
+ if t > e or t <= f or a2 ~= a1 then
+ for i = f, e do a2[i + d] = a1[i] end
+ else
+ for i = e, f, -1 do a2[i + d] = a1[i] end
+ end
+ end
+ return a2
+ end
+end
+
-- return module: table
return table