mirror of
https://github.com/kepler155c/opus
synced 2025-02-11 14:30:01 +00:00
lua 5.2 compatibility (#14)
compatibility update - making a few changes in next commit...
This commit is contained in:
parent
9ce61b5d98
commit
09be81be27
@ -139,7 +139,7 @@ end
|
|||||||
term.clear()
|
term.clear()
|
||||||
term.setCursorPos(1, 1)
|
term.setCursorPos(1, 1)
|
||||||
if bootOptions[bootOption].args then
|
if bootOptions[bootOption].args then
|
||||||
os.run(_G.getfenv(1), table.unpack(bootOptions[bootOption].args))
|
os.run({}, table.unpack(bootOptions[bootOption].args))
|
||||||
else
|
else
|
||||||
print(bootOptions[bootOption].prompt)
|
print(bootOptions[bootOption].prompt)
|
||||||
end
|
end
|
||||||
|
@ -3,4 +3,4 @@ local args = { ... }
|
|||||||
local target = table.remove(args, 1)
|
local target = table.remove(args, 1)
|
||||||
target = shell.resolve(target)
|
target = shell.resolve(target)
|
||||||
|
|
||||||
fs.mount(target, unpack(args))
|
fs.mount(target, table.unpack(args))
|
||||||
|
@ -48,7 +48,7 @@ local function sambaConnection(socket)
|
|||||||
end
|
end
|
||||||
local ret
|
local ret
|
||||||
local s, m = pcall(function()
|
local s, m = pcall(function()
|
||||||
ret = fn(unpack(msg.args))
|
ret = fn(table.unpack(msg.args))
|
||||||
end)
|
end)
|
||||||
if not s and m then
|
if not s and m then
|
||||||
_G.printError('samba: ' .. m)
|
_G.printError('samba: ' .. m)
|
||||||
|
@ -70,7 +70,7 @@ local function connect()
|
|||||||
break
|
break
|
||||||
end
|
end
|
||||||
for _,v in ipairs(data) do
|
for _,v in ipairs(data) do
|
||||||
ct[v.f](unpack(v.args))
|
ct[v.f](table.unpack(v.args))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
@ -241,7 +241,7 @@ local function _place(action, indexOrId)
|
|||||||
if not state.digPolicy(action) then
|
if not state.digPolicy(action) then
|
||||||
state.attackPolicy(action)
|
state.attackPolicy(action)
|
||||||
end
|
end
|
||||||
return unpack(result)
|
return table.unpack(result)
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -1024,7 +1024,7 @@ function turtle.run(fn, ...)
|
|||||||
|
|
||||||
synchronized(turtle, function()
|
synchronized(turtle, function()
|
||||||
turtle.resetState()
|
turtle.resetState()
|
||||||
s, m = pcall(function() fn(unpack(args)) end)
|
s, m = pcall(function() fn(table.unpack(args)) end)
|
||||||
turtle.resetState()
|
turtle.resetState()
|
||||||
if not s and m then
|
if not s and m then
|
||||||
_G.printError(m)
|
_G.printError(m)
|
||||||
|
@ -34,7 +34,7 @@ local function quarterRound(s, a, b, c, d)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function hashBlock(state, rnd)
|
local function hashBlock(state, rnd)
|
||||||
local s = {unpack(state)}
|
local s = {table.unpack(state)}
|
||||||
for i = 1, rnd do
|
for i = 1, rnd do
|
||||||
local r = i%2==1
|
local r = i%2==1
|
||||||
s = r and quarterRound(s, 1, 5, 9, 13) or quarterRound(s, 1, 6, 11, 16)
|
s = r and quarterRound(s, 1, 5, 9, 13) or quarterRound(s, 1, 6, 11, 16)
|
||||||
@ -92,9 +92,9 @@ local function serialize(state)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local mt = {
|
local mt = {
|
||||||
__tostring = function(a) return string.char(unpack(a)) end,
|
__tostring = function(a) return string.char(table.unpack(a)) end,
|
||||||
__index = {
|
__index = {
|
||||||
toHex = function(self) return ("%02x"):rep(#self):format(unpack(self)) end,
|
toHex = function(self) return ("%02x"):rep(#self):format(table.unpack(self)) end,
|
||||||
isEqual = function(self, t)
|
isEqual = function(self, t)
|
||||||
if type(t) ~= "table" then return false end
|
if type(t) ~= "table" then return false end
|
||||||
if #self ~= #t then return false end
|
if #self ~= #t then return false end
|
||||||
@ -113,7 +113,7 @@ local function crypt(data, key, nonce, cntr, round)
|
|||||||
assert(#key == 16 or #key == 32, "ChaCha20: Invalid key length ("..#key.."), must be 16 or 32")
|
assert(#key == 16 or #key == 32, "ChaCha20: Invalid key length ("..#key.."), must be 16 or 32")
|
||||||
assert(#nonce == 12, "ChaCha20: Invalid nonce length ("..#nonce.."), must be 12")
|
assert(#nonce == 12, "ChaCha20: Invalid nonce length ("..#nonce.."), must be 12")
|
||||||
|
|
||||||
data = type(data) == "table" and {unpack(data)} or {tostring(data):byte(1,-1)}
|
data = type(data) == "table" and {table.unpack(data)} or {tostring(data):byte(1,-1)}
|
||||||
cntr = tonumber(cntr) or 1
|
cntr = tonumber(cntr) or 1
|
||||||
round = tonumber(round) or 20
|
round = tonumber(round) or 20
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ local band = bit32 and bit32.band or bit.band
|
|||||||
local bnot = bit32 and bit32.bnot or bit.bnot
|
local bnot = bit32 and bit32.bnot or bit.bnot
|
||||||
local bxor = bit32 and bit32.bxor or bit.bxor
|
local bxor = bit32 and bit32.bxor or bit.bxor
|
||||||
local blshift = bit32 and bit32.lshift or bit.blshift
|
local blshift = bit32 and bit32.lshift or bit.blshift
|
||||||
local upack = unpack
|
local upack = unpack or table.unpack
|
||||||
|
|
||||||
local function rrotate(n, b)
|
local function rrotate(n, b)
|
||||||
local s = n/(2^b)
|
local s = n/(2^b)
|
||||||
@ -95,9 +95,9 @@ local function digestblock(w, C)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local mt = {
|
local mt = {
|
||||||
__tostring = function(a) return string.char(unpack(a)) end,
|
__tostring = function(a) return string.char(upack(a)) end,
|
||||||
__index = {
|
__index = {
|
||||||
toHex = function(self) return ("%02x"):rep(#self):format(unpack(self)) end,
|
toHex = function(self) return ("%02x"):rep(#self):format(upack(self)) end,
|
||||||
isEqual = function(self, t)
|
isEqual = function(self, t)
|
||||||
if type(t) ~= "table" then return false end
|
if type(t) ~= "table" then return false end
|
||||||
if #self ~= #t then return false end
|
if #self ~= #t then return false end
|
||||||
|
@ -21,7 +21,7 @@ end
|
|||||||
|
|
||||||
function Util.byteArrayToHex(tbl)
|
function Util.byteArrayToHex(tbl)
|
||||||
if not tbl then error('byteArrayToHex: invalid table', 2) end
|
if not tbl then error('byteArrayToHex: invalid table', 2) end
|
||||||
return ("%02x"):rep(#tbl):format(unpack(tbl))
|
return ("%02x"):rep(#tbl):format(table.unpack(tbl))
|
||||||
end
|
end
|
||||||
|
|
||||||
function Util.tryTimed(timeout, f, ...)
|
function Util.tryTimed(timeout, f, ...)
|
||||||
@ -39,10 +39,10 @@ function Util.tryTimes(attempts, f, ...)
|
|||||||
for _ = 1, attempts do
|
for _ = 1, attempts do
|
||||||
result = { f(...) }
|
result = { f(...) }
|
||||||
if result[1] then
|
if result[1] then
|
||||||
return unpack(result)
|
return table.unpack(result)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return unpack(result)
|
return table.unpack(result)
|
||||||
end
|
end
|
||||||
|
|
||||||
function Util.timer()
|
function Util.timer()
|
||||||
@ -490,7 +490,7 @@ function Util.loadTable(fname)
|
|||||||
if not fc then
|
if not fc then
|
||||||
return false, 'Unable to read file'
|
return false, 'Unable to read file'
|
||||||
end
|
end
|
||||||
local s, m = loadstring('return ' .. fc, fname)
|
local s, m = load('return ' .. fc, fname)
|
||||||
if s then
|
if s then
|
||||||
s, m = pcall(s)
|
s, m = pcall(s)
|
||||||
if s then
|
if s then
|
||||||
@ -551,8 +551,9 @@ function Util.run(env, path, ...)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function Util.runFunction(env, fn, ...)
|
function Util.runFunction(env, fn, ...)
|
||||||
setfenv(fn, env)
|
--setfenv(fn, env)
|
||||||
setmetatable(env, { __index = _G })
|
setmetatable(env, { __index = _G })
|
||||||
|
fn = load(fn,"util.runfunction",nil,env)
|
||||||
return pcall(fn, ...)
|
return pcall(fn, ...)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user