From a303fca56bdf6928a0fd827ab4e9e2d5dba0abd2 Mon Sep 17 00:00:00 2001 From: Crum Date: Thu, 21 Jun 2018 16:27:38 -0500 Subject: [PATCH] test Import Profile --- .../Libraries/LibBase64-1.0/LibBase64-1.0.lua | 35 ++++++++----------- 1 file changed, 15 insertions(+), 20 deletions(-) diff --git a/ElvUI/Libraries/LibBase64-1.0/LibBase64-1.0.lua b/ElvUI/Libraries/LibBase64-1.0/LibBase64-1.0.lua index 6591aa1..9ede3c9 100644 --- a/ElvUI/Libraries/LibBase64-1.0/LibBase64-1.0.lua +++ b/ElvUI/Libraries/LibBase64-1.0/LibBase64-1.0.lua @@ -14,20 +14,15 @@ end 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 fmod = math.fmod +local byte, char, format, gsub, len, sub = string.byte, string.char, string.format, string.gsub, string.len, string.sub local _chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' local charTable = {} local byteToNum = {} local numToChar = {} -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(convert(_chars)) do +for i = 1, len(_chars) do numToChar[i - 1] = sub(_chars, i, i) byteToNum[byte(_chars, i)] = i - 1 end @@ -65,7 +60,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 mod(maxLineLength, 4) ~= 0 then + elseif fmod(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) @@ -92,16 +87,16 @@ function LibBase64:Encode(text, maxLineLength, lineEnding) end local num = a * 2^16 + b * 2^8 + c - local d = mod(num, 2^6) + local d = fmod(num, 2^6) num = (num - d) / 2^6 - local c = mod(num, 2^6) + local c = fmod(num, 2^6) num = (num - c) / 2^6 - local b = mod(num, 2^6) + local b = fmod(num, 2^6) num = (num - b) / 2^6 - local a = mod(num, 2^6) + local a = fmod(num, 2^6) t[getn(t)+1] = numToChar[a] @@ -112,7 +107,7 @@ function LibBase64:Encode(text, maxLineLength, lineEnding) t[getn(t)+1] = (nilNum >= 1) and "=" or numToChar[d] currentLength = currentLength + 4 - if maxLineLength and mod(currentLength, maxLineLength) == 0 then + if maxLineLength and fmod(currentLength, maxLineLength) == 0 then t[getn(t)+1] = lineEnding end end @@ -137,7 +132,7 @@ function LibBase64:Decode(text) error(format("Bad argument #1 to `Decode'. Expected %q, got %q", "string", type(text)), 2) end - for i = 1, getn(text) do + for i = 1, len(text) do local byte = byte(text, i) if whitespace[byte] or byte == equals_byte then -- do nothing @@ -169,13 +164,13 @@ function LibBase64:Decode(text) local num = a * 2^18 + b * 2^12 + c * 2^6 + d - local c = mod(num, 2^8) + local c = fmod(num, 2^8) num = (num - c) / 2^8 - local b = mod(num, 2^8) + local b = fmod(num, 2^8) num = (num - b) / 2^8 - local a = mod(num, 2^8) + local a = fmod(num, 2^8) t[getn(t)+1] = char(a) if nilNum < 2 then @@ -204,11 +199,11 @@ function LibBase64:IsBase64(text) error(format("Bad argument #1 to `IsBase64'. Expected %q, got %q", "string", type(text)), 2) end - if mod(getn(text), 4) ~= 0 then + if fmod(len(text), 4) ~= 0 then return false end - for i = 1, getn(text) do + for i = 1, len(text) do local byte = byte(text, i) if whitespace[byte] or byte == equals_byte then -- do nothing