mirror of
https://github.com/minetest-mods/MoreMesecons.git
synced 2025-01-06 04:37:33 +01:00
do not normalize luajit functions
This commit is contained in:
parent
686c18c49e
commit
9fcb45d9f2
22
md5.lua
22
md5.lua
@ -35,9 +35,12 @@ local char, byte, format, rep, sub =
|
|||||||
local bit_or, bit_and, bit_not, bit_xor, bit_rshift, bit_lshift
|
local bit_or, bit_and, bit_not, bit_xor, bit_rshift, bit_lshift
|
||||||
|
|
||||||
local ok, bit = pcall(require, 'bit')
|
local ok, bit = pcall(require, 'bit')
|
||||||
if not ok then ok, bit = pcall(require, 'bit32') end
|
|
||||||
|
|
||||||
if ok then
|
if ok then
|
||||||
|
bit_or, bit_and, bit_not, bit_xor, bit_rshift, bit_lshift = bit.bor, bit.band, bit.bnot, bit.xor, bit.rshift, bit.lshift
|
||||||
|
else
|
||||||
|
ok, bit = pcall(require, 'bit32')
|
||||||
|
|
||||||
|
if ok then
|
||||||
|
|
||||||
bit_not = bit.bnot
|
bit_not = bit.bnot
|
||||||
|
|
||||||
@ -52,7 +55,7 @@ if ok then
|
|||||||
bit_or, bit_and, bit_xor = normalize(bit.bor), normalize(bit.band), normalize(bit.bxor)
|
bit_or, bit_and, bit_xor = normalize(bit.bor), normalize(bit.band), normalize(bit.bxor)
|
||||||
bit_rshift, bit_lshift = normalize(bit.rshift), normalize(bit.lshift)
|
bit_rshift, bit_lshift = normalize(bit.rshift), normalize(bit.lshift)
|
||||||
|
|
||||||
else
|
else
|
||||||
|
|
||||||
local function tbl2number(tbl)
|
local function tbl2number(tbl)
|
||||||
local result = 0
|
local result = 0
|
||||||
@ -189,21 +192,22 @@ else
|
|||||||
end
|
end
|
||||||
return bit_and(n, 0xFFFFFFFF)
|
return bit_and(n, 0xFFFFFFFF)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- convert little-endian 32-bit int to a 4-char string
|
-- convert little-endian 32-bit int to a 4-char string
|
||||||
local function lei2str(i)
|
local function lei2str(i)
|
||||||
local f=function (s) return char( bit_and( bit_rshift(i, s), 255)) end
|
local f=function (s) return char( bit_and( bit_rshift(i, s), 255)) end
|
||||||
return f(0)..f(8)..f(16)..f(24)
|
return f(0)..f(8)..f(16)..f(24)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- convert raw string to big-endian int
|
-- convert raw string to big-endian int
|
||||||
local function str2bei(s)
|
local function str2bei(s)
|
||||||
local v=0
|
local v=0
|
||||||
for i=1, #s do
|
for i=1, #s do
|
||||||
v = v * 256 + byte(s, i)
|
v = v * 256 + byte(s, i)
|
||||||
end
|
end
|
||||||
return v
|
return v
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- convert raw string to little-endian int
|
-- convert raw string to little-endian int
|
||||||
|
Loading…
Reference in New Issue
Block a user