Skip to content

Commit

Permalink
Merge pull request #379 from MikaylaFischler/377-compatibility-fixes-…
Browse files Browse the repository at this point in the history
…for-lua-5.2

#377 switched to using ... for vararg
  • Loading branch information
MikaylaFischler authored Nov 28, 2023
2 parents e6f49f2 + 94a62f8 commit b1f1753
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 14 deletions.
2 changes: 0 additions & 2 deletions initenv.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ return {
-- initialize booted environment
init_env = function ()
local _require, _env = require("cc.require"), setmetatable({}, { __index = _ENV })
-- overwrite require/package globals
require, package = _require.make(_env, "/")
-- reset terminal
term.clear(); term.setCursorPos(1, 1)
end
}
17 changes: 5 additions & 12 deletions scada-common/util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ local type = type

local t_concat = table.concat
local t_insert = table.insert
local t_unpack = table.unpack
local t_pack = table.pack

---@class util
local util = {}

-- scada-common version
util.version = "1.1.9"
util.version = "1.1.10"

util.TICK_TIME_S = 0.05
util.TICK_TIME_MS = 50
Expand Down Expand Up @@ -104,17 +104,13 @@ end
---@return table lines
function util.strwrap(str, limit) return cc_strings.wrap(str, limit) end

-- luacheck: no unused args

-- concatenation with built-in to string
---@nodiscard
---@vararg any
---@return string
---@diagnostic disable-next-line: unused-vararg
function util.concat(...)
local strings = {}
---@diagnostic disable-next-line: undefined-field
for i = 1, arg.n do strings[i] = util.strval(arg[i]) end
local args, strings = t_pack(...), {}
for i = 1, args.n do strings[i] = util.strval(args[i]) end
return t_concat(strings)
end

Expand All @@ -125,10 +121,7 @@ util.c = util.concat
---@nodiscard
---@param format string
---@vararg any
---@diagnostic disable-next-line: unused-vararg
function util.sprintf(format, ...) return string.format(format, t_unpack(arg)) end

-- luacheck: unused args
function util.sprintf(format, ...) return string.format(format, ...) end

-- format a number string with commas as the thousands separator<br>
-- subtracts from spaces at the start if present for each comma used
Expand Down

0 comments on commit b1f1753

Please sign in to comment.