#377 switched to using ... for vararg

This commit is contained in:
Mikayla Fischler 2023-11-27 19:32:52 -05:00
parent a048b0aa4a
commit 94a62f8c31
2 changed files with 5 additions and 14 deletions

View File

@ -2,9 +2,7 @@ return {
-- initialize booted environment -- initialize booted environment
init_env = function () init_env = function ()
local _require, _env = require("cc.require"), setmetatable({}, { __index = _ENV }) local _require, _env = require("cc.require"), setmetatable({}, { __index = _ENV })
-- overwrite require/package globals
require, package = _require.make(_env, "/") require, package = _require.make(_env, "/")
-- reset terminal
term.clear(); term.setCursorPos(1, 1) term.clear(); term.setCursorPos(1, 1)
end end
} }

View File

@ -16,13 +16,13 @@ local type = type
local t_concat = table.concat local t_concat = table.concat
local t_insert = table.insert local t_insert = table.insert
local t_unpack = table.unpack local t_pack = table.pack
---@class util ---@class util
local util = {} local util = {}
-- scada-common version -- scada-common version
util.version = "1.1.9" util.version = "1.1.10"
util.TICK_TIME_S = 0.05 util.TICK_TIME_S = 0.05
util.TICK_TIME_MS = 50 util.TICK_TIME_MS = 50
@ -104,17 +104,13 @@ end
---@return table lines ---@return table lines
function util.strwrap(str, limit) return cc_strings.wrap(str, limit) end function util.strwrap(str, limit) return cc_strings.wrap(str, limit) end
-- luacheck: no unused args
-- concatenation with built-in to string -- concatenation with built-in to string
---@nodiscard ---@nodiscard
---@vararg any ---@vararg any
---@return string ---@return string
---@diagnostic disable-next-line: unused-vararg
function util.concat(...) function util.concat(...)
local strings = {} local args, strings = t_pack(...), {}
---@diagnostic disable-next-line: undefined-field for i = 1, args.n do strings[i] = util.strval(args[i]) end
for i = 1, arg.n do strings[i] = util.strval(arg[i]) end
return t_concat(strings) return t_concat(strings)
end end
@ -125,10 +121,7 @@ util.c = util.concat
---@nodiscard ---@nodiscard
---@param format string ---@param format string
---@vararg any ---@vararg any
---@diagnostic disable-next-line: unused-vararg function util.sprintf(format, ...) return string.format(format, ...) end
function util.sprintf(format, ...) return string.format(format, t_unpack(arg)) end
-- luacheck: unused args
-- format a number string with commas as the thousands separator<br> -- format a number string with commas as the thousands separator<br>
-- subtracts from spaces at the start if present for each comma used -- subtracts from spaces at the start if present for each comma used