mirror of
https://github.com/Bluewhale1337/ElvUIModernized.git
synced 2026-07-27 08:24:44 +00:00
Global convert indentation to tabs
This commit is contained in:
@@ -16,7 +16,7 @@ local byte = string.byte
|
||||
local LibBase64 = LibStub:NewLibrary("LibBase64-1.0", 1)
|
||||
|
||||
if not LibBase64 then
|
||||
return
|
||||
return
|
||||
end
|
||||
|
||||
local _chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
|
||||
@@ -25,12 +25,12 @@ local byteToNum = {}
|
||||
local numToChar = {}
|
||||
|
||||
for i = 1, strlen(_chars) do
|
||||
charTable[i] = sub(_chars, i, i)
|
||||
charTable[i] = sub(_chars, i, i)
|
||||
end
|
||||
|
||||
for i = 1, getn(charTable) do
|
||||
numToChar[i - 1] = sub(_chars, i, i)
|
||||
byteToNum[byte(_chars, i)] = i - 1
|
||||
numToChar[i - 1] = sub(_chars, i, i)
|
||||
byteToNum[byte(_chars, i)] = i - 1
|
||||
end
|
||||
|
||||
_chars = nil
|
||||
@@ -45,10 +45,10 @@ local plus_byte = byte("+")
|
||||
local slash_byte = byte("/")
|
||||
local equals_byte = byte("=")
|
||||
local whitespace = {
|
||||
[byte(" ")] = true,
|
||||
[byte("\t")] = true,
|
||||
[byte("\n")] = true,
|
||||
[byte("\r")] = true,
|
||||
[byte(" ")] = true,
|
||||
[byte("\t")] = true,
|
||||
[byte("\n")] = true,
|
||||
[byte("\r")] = true,
|
||||
}
|
||||
|
||||
local t = {}
|
||||
@@ -60,27 +60,27 @@ local t = {}
|
||||
-- @usage LibBase64.Encode("Hello, how are you doing today?") == "SGVsbG8sIGhvdyBhcmUgeW91IGRvaW5nIHRvZGF5Pw=="
|
||||
-- @return a Base64-encoded string
|
||||
function LibBase64:Encode(text, maxLineLength, lineEnding)
|
||||
if type(text) ~= "string" then
|
||||
error(format("Bad argument #1 to `Encode'. Expected %q, got %q", "string", type(text)), 2)
|
||||
end
|
||||
if type(text) ~= "string" then
|
||||
error(format("Bad argument #1 to `Encode'. Expected %q, got %q", "string", type(text)), 2)
|
||||
end
|
||||
|
||||
if maxLineLength == nil then
|
||||
-- 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
|
||||
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)
|
||||
end
|
||||
if maxLineLength == nil then
|
||||
-- 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
|
||||
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)
|
||||
end
|
||||
|
||||
if lineEnding == nil then
|
||||
lineEnding = "\r\n"
|
||||
elseif type(lineEnding) ~= "string" then
|
||||
error(format("Bad argument #3 to `Encode'. Expected %q, got %q", "string", type(lineEnding)), 2)
|
||||
end
|
||||
if lineEnding == nil then
|
||||
lineEnding = "\r\n"
|
||||
elseif type(lineEnding) ~= "string" then
|
||||
error(format("Bad argument #3 to `Encode'. Expected %q, got %q", "string", type(lineEnding)), 2)
|
||||
end
|
||||
|
||||
local currentLength = 0
|
||||
local currentLength = 0
|
||||
|
||||
for i = 1, getn(text), 3 do
|
||||
local a, b, c = byte(text, i, i+2)
|
||||
@@ -116,7 +116,7 @@ function LibBase64:Encode(text, maxLineLength, lineEnding)
|
||||
|
||||
currentLength = currentLength + 4
|
||||
if maxLineLength and modf(currentLength, maxLineLength) == 0 then
|
||||
t[getn(t)+1] = lineEnding
|
||||
t[getn(t)+1] = lineEnding
|
||||
end
|
||||
end
|
||||
|
||||
@@ -136,29 +136,29 @@ local t2 = {}
|
||||
-- @usage LibBase64.Encode("SGVsbG8sIGhvdyBhcmUgeW91IGRvaW5nIHRvZGF5Pw==") == "Hello, how are you doing today?"
|
||||
-- @return a bytestring
|
||||
function LibBase64:Decode(text)
|
||||
if type(text) ~= "string" then
|
||||
error(format("Bad argument #1 to `Decode'. Expected %q, got %q", "string", type(text)), 2)
|
||||
end
|
||||
if type(text) ~= "string" then
|
||||
error(format("Bad argument #1 to `Decode'. Expected %q, got %q", "string", type(text)), 2)
|
||||
end
|
||||
|
||||
for i = 1, getn(text) do
|
||||
local byte = byte(text, i)
|
||||
if whitespace[byte] or byte == equals_byte then
|
||||
-- do nothing
|
||||
else
|
||||
local num = byteToNum[byte]
|
||||
if not num then
|
||||
for i = 1, getn(t2) do
|
||||
t2[k] = nil
|
||||
end
|
||||
for i = 1, getn(text) do
|
||||
local byte = byte(text, i)
|
||||
if whitespace[byte] or byte == equals_byte then
|
||||
-- do nothing
|
||||
else
|
||||
local num = byteToNum[byte]
|
||||
if not num then
|
||||
for i = 1, getn(t2) do
|
||||
t2[k] = nil
|
||||
end
|
||||
|
||||
error(format("Bad argument #1 to `Decode'. Received an invalid char: %q", sub(text, i, i)), 2)
|
||||
end
|
||||
t2[getn(t2)+1] = num
|
||||
end
|
||||
end
|
||||
error(format("Bad argument #1 to `Decode'. Received an invalid char: %q", sub(text, i, i)), 2)
|
||||
end
|
||||
t2[getn(t2)+1] = num
|
||||
end
|
||||
end
|
||||
|
||||
for i = 1, getn(t2), 4 do
|
||||
local a, b, c, d = t2[i], t2[i+1], t2[i+2], t2[i+3]
|
||||
for i = 1, getn(t2), 4 do
|
||||
local a, b, c, d = t2[i], t2[i+1], t2[i+2], t2[i+3]
|
||||
|
||||
local nilNum = 0
|
||||
if not c then
|
||||
|
||||
Reference in New Issue
Block a user