summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOpportunity <[email protected]>2020-01-18 19:52:01 +0800
committerOpportunity <[email protected]>2020-01-19 13:01:08 +0800
commitfaca684d1ec62de7bc3e56224c986ab24533f4fa (patch)
tree93703488961974b15a8e61e6c19a3c2423010ee3
parent1ba3e7c62e0f64b95923c2a41249ec956c436871 (diff)
use table.new
-rw-r--r--xmake/core/base/bytes.lua1
-rw-r--r--xmake/core/base/option.lua5
-rw-r--r--xmake/core/base/text.lua2
-rw-r--r--xmake/core/main.lua3
4 files changed, 7 insertions, 4 deletions
diff --git a/xmake/core/base/bytes.lua b/xmake/core/base/bytes.lua
index 54343a962..3776695a1 100644
--- a/xmake/core/base/bytes.lua
+++ b/xmake/core/base/bytes.lua
@@ -65,6 +65,7 @@ function _instance.new(...)
else
-- bytes(size): allocates a buffer of given size
ptr = ffi.C.malloc(size)
+ ffi.fill(ptr, size, 0)
instance._CDATA = ffi.gc(ffi.cast("unsigned char*", ptr), ffi.C.free)
instance._MANAGED = true
end
diff --git a/xmake/core/base/option.lua b/xmake/core/base/option.lua
index 9d6853baa..e03c4dc1d 100644
--- a/xmake/core/base/option.lua
+++ b/xmake/core/base/option.lua
@@ -760,13 +760,14 @@ function option.show_options(options, taskname)
end
-- get description
- local description = table.move(opt, 5, table.maxn(opt), 1, {})
+ local optdespn = table.maxn(opt)
+ local description = table.move(opt, 5, optdespn, 1, table.new(optdespn - 5 + 1, 0))
if #description == 0 then
description[1] = ""
end
-- transform description
- local desp_strs = {}
+ local desp_strs = table.new(#description, 0)
for _, v in ipairs(description) do
if type(v) == "function" then
v = v()
diff --git a/xmake/core/base/text.lua b/xmake/core/base/text.lua
index 75ed3bf98..38f6912d9 100644
--- a/xmake/core/base/text.lua
+++ b/xmake/core/base/text.lua
@@ -25,7 +25,7 @@ local text = text or {}
local string = require("base/string")
local colors = require("base/colors")
local math = require("base/math")
-local dump = require("base/dump")
+local table = require("base/table")
-- @see https://unicode.org/reports/tr14/
function text._lastwbr(str, width, wordbreak)
diff --git a/xmake/core/main.lua b/xmake/core/main.lua
index 1078175d6..bc8bc04b5 100644
--- a/xmake/core/main.lua
+++ b/xmake/core/main.lua
@@ -27,6 +27,7 @@ local log = require("base/log")
local path = require("base/path")
local utils = require("base/utils")
local option = require("base/option")
+local table = require("base/table")
local global = require("base/global")
local deprecated = require("base/deprecated")
local privilege = require("base/privilege")
@@ -123,7 +124,7 @@ function main._basicparse()
if xmake._ARGV[1] and not xmake._ARGV[1]:startswith('-') then
-- regard it as command name
xmake._COMMAND = xmake._ARGV[1]
- xmake._COMMAND_ARGV = table.move(xmake._ARGV, 2, #xmake._ARGV, 1, {})
+ xmake._COMMAND_ARGV = table.move(xmake._ARGV, 2, #xmake._ARGV, 1, table.new(#xmake._ARGV - 1, 0))
else
xmake._COMMAND_ARGV = xmake._ARGV
end