diff --git a/ElvUI/Libraries/AceSerializer-3.0/AceSerializer-3.0.lua b/ElvUI/Libraries/AceSerializer-3.0/AceSerializer-3.0.lua index 75430bb..f6e1b0c 100644 --- a/ElvUI/Libraries/AceSerializer-3.0/AceSerializer-3.0.lua +++ b/ElvUI/Libraries/AceSerializer-3.0/AceSerializer-3.0.lua @@ -10,25 +10,23 @@ -- make into AceSerializer. -- @class file -- @name AceSerializer-3.0 --- @release $Id: AceSerializer-3.0.lua 1135 2015-09-19 20:39:16Z nevcairiel $ -local MAJOR,MINOR = "AceSerializer-3.0", 5 +-- @release $Id: AceSerializer-3.0.lua 910 2010-02-11 21:54:24Z mikk $ +local MAJOR,MINOR = "AceSerializer-3.0", 3 local AceSerializer, oldminor = LibStub:NewLibrary(MAJOR, MINOR) if not AceSerializer then return end -- Lua APIs -local strbyte, strchar, gsub, gfind, format = string.byte, string.char, string.gsub, string.gfind, string.format +local strbyte, strchar, gsub, gmatch, format = string.byte, string.char, string.gsub, string.gmatch, string.format local assert, error, pcall = assert, error, pcall local type, tostring, tonumber = type, tostring, tonumber local pairs, select, frexp = pairs, select, math.frexp -local tconcat, tgetn = table.concat, table.getn +local tconcat = table.concat -- quick copies of string representations of wonky numbers -local inf = 1/0 - -local serNaN -- can't do this in 4.3, see ace3 ticket 268 -local serInf, serInfMac = "1.#INF", "inf" -local serNegInf, serNegInfMac = "-1.#INF", "-inf" +local serNaN = tostring(0/0) +local serInf = tostring(1/0) +local serNegInf = tostring(-1/0) -- Serialization functions @@ -62,15 +60,11 @@ local function SerializeValue(v, res, nres) elseif t=="number" then -- ^N = number (just tostring()ed) or ^F (float components) local str = tostring(v) - if tonumber(str)==v --[[not in 4.3 or str==serNaN]] then + if tonumber(str)==v or str==serNaN or str==serInf or str==serNegInf then -- translates just fine, transmit as-is res[nres+1] = "^N" res[nres+2] = str nres=nres+2 - elseif v == inf or v == -inf then - res[nres+1] = "^N" - res[nres+2] = v == inf and serInf or serNegInf - nres=nres+2 else local m,e = frexp(v) res[nres+1] = "^F" @@ -121,8 +115,9 @@ local serializeTbl = { "^1" } -- "^1" = Hi, I'm data serialized by AceSerializer -- @return The data in its serialized form (string) function AceSerializer:Serialize(...) local nres = 1 - for i = 1,tgetn(arg) do - local v = arg[i] + + for i = 1, arg.n do + local v = select(i, unpack(arg)) nres = SerializeValue(v, serializeTbl, nres) end @@ -148,12 +143,12 @@ local function DeserializeStringHelper(escape) end local function DeserializeNumberHelper(number) - --[[ not in 4.3 if number == serNaN then + if number == serNaN then return 0/0 - else]]if number == serNegInf or number == serNegInfMac then - return -inf - elseif number == serInf or number == serInfMac then - return inf + elseif number == serNegInf then + return -1/0 + elseif number == serInf then + return 1/0 else return tonumber(number) end @@ -245,7 +240,7 @@ end function AceSerializer:Deserialize(str) str = gsub(str, "[%c ]", "") -- ignore all control characters; nice for embedding in email and stuff - local iter = gfind(str, "(^.)([^^]*)") -- Any ^x followed by string of non-^ + local iter = gmatch(str, "(^.)([^^]*)") -- Any ^x followed by string of non-^ local ctl,data = iter() if not ctl or ctl~="^1" then -- we purposefully ignore the data portion of the start code, it can be used as an extension mechanism diff --git a/ElvUI/Libraries/LibBase64-1.0/LibBase64-1.0.lua b/ElvUI/Libraries/LibBase64-1.0/LibBase64-1.0.lua index daf2ce8..6591aa1 100644 --- a/ElvUI/Libraries/LibBase64-1.0/LibBase64-1.0.lua +++ b/ElvUI/Libraries/LibBase64-1.0/LibBase64-1.0.lua @@ -6,35 +6,32 @@ Description: A library to encode and decode Base64 strings License: MIT ]] -local modf = math.modf -local sub = string.sub -local format = string.format -local getn = table.getn -local strlen = string.len -local byte = string.byte - local LibBase64 = LibStub:NewLibrary("LibBase64-1.0", 1) if not LibBase64 then return end -local _chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" +local error, tonumber, type = error, tonumber, type +local concat, insert = table.concat, table.insert +local byte, char, format, gsub, mod, sub = string.byte, string.char, string.format, string.gsub, string.fmod, string.sub + +local _chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' local charTable = {} local byteToNum = {} local numToChar = {} -for i = 1, strlen(_chars) do - charTable[i] = sub(_chars, i, i) +local function convert(string) + local t = {} + gsub(string, "%-?%d+", function(n) t[getn(t)+1] = tonumber(n) end) + return t end -for i = 1, getn(charTable) do +for i = 1, getn(convert(_chars)) do numToChar[i - 1] = sub(_chars, i, i) byteToNum[byte(_chars, i)] = i - 1 end - _chars = nil - local A_byte = byte("A") local Z_byte = byte("Z") local a_byte = byte("a") @@ -68,7 +65,7 @@ function LibBase64:Encode(text, maxLineLength, lineEnding) -- do nothing elseif type(maxLineLength) ~= "number" then error(format("Bad argument #2 to `Encode'. Expected %q or %q, got %q", "number", "nil", type(maxLineLength)), 2) - elseif modf(maxLineLength, 4) ~= 0 then + elseif mod(maxLineLength, 4) ~= 0 then error(format("Bad argument #2 to `Encode'. Expected a multiple of 4, got %s", maxLineLength), 2) elseif maxLineLength <= 0 then error(format("Bad argument #2 to `Encode'. Expected a number > 0, got %s", maxLineLength), 2) @@ -95,16 +92,16 @@ function LibBase64:Encode(text, maxLineLength, lineEnding) end local num = a * 2^16 + b * 2^8 + c - local d = modf(num, 2^6) + local d = mod(num, 2^6) num = (num - d) / 2^6 - local c = modf(num, 2^6) + local c = mod(num, 2^6) num = (num - c) / 2^6 - local b = modf(num, 2^6) + local b = mod(num, 2^6) num = (num - b) / 2^6 - local a = modf(num, 2^6) + local a = mod(num, 2^6) t[getn(t)+1] = numToChar[a] @@ -115,12 +112,12 @@ function LibBase64:Encode(text, maxLineLength, lineEnding) t[getn(t)+1] = (nilNum >= 1) and "=" or numToChar[d] currentLength = currentLength + 4 - if maxLineLength and modf(currentLength, maxLineLength) == 0 then + if maxLineLength and mod(currentLength, maxLineLength) == 0 then t[getn(t)+1] = lineEnding end end - local s = table.concat(t) + local s = concat(t) for i = 1, getn(t) do t[i] = nil end @@ -172,20 +169,20 @@ function LibBase64:Decode(text) local num = a * 2^18 + b * 2^12 + c * 2^6 + d - local c = modf(num, 2^8) + local c = mod(num, 2^8) num = (num - c) / 2^8 - local b = modf(num, 2^8) + local b = mod(num, 2^8) num = (num - b) / 2^8 - local a = modf(num, 2^8) + local a = mod(num, 2^8) - t[getn(t)+1] = string.char(a) + t[getn(t)+1] = char(a) if nilNum < 2 then - t[getn(t)+1] = string.char(b) + t[getn(t)+1] = char(b) end if nilNum < 1 then - t[getn(t)+1] = string.char(c) + t[getn(t)+1] = char(c) end end @@ -193,7 +190,7 @@ function LibBase64:Decode(text) t2[i] = nil end - local s = table.concat(t) + local s = concat(t) for i = 1, getn(t) do t[i] = nil @@ -207,7 +204,7 @@ function LibBase64:IsBase64(text) error(format("Bad argument #1 to `IsBase64'. Expected %q, got %q", "string", type(text)), 2) end - if modf(strlen(text), 4) ~= 0 then + if mod(getn(text), 4) ~= 0 then return false end @@ -224,4 +221,4 @@ function LibBase64:IsBase64(text) end return true -end +end \ No newline at end of file