Fix. Add `split` function (required by lazy_settings).

This commit is contained in:
Alexey Melnichuk 2015-11-24 14:26:21 +03:00
parent 2a3b762aa2
commit 6d1e73ca13
1 changed files with 27 additions and 0 deletions

View File

@ -0,0 +1,27 @@
function split(str, sep, plain)
local b, res = 1, {}
while b <= #str do
local e, e2 = string.find(str, sep, b, plain)
if e then
res[#res + 1] = string.sub(str, b, e-1)
b = e2 + 1
else
res[#res + 1] = string.sub(str, b)
break
end
end
return res
end
function split_first(str, sep, plain)
local e, e2 = string.find(str, sep, nil, plain)
if e then
return string.sub(str, 1, e - 1), string.sub(str, e2 + 1)
end
return str
end
local unpack = unpack or table.unpack
function usplit(...) return unpack(split(...)) end