Fix. Add `split` function (required by lazy_settings).
This commit is contained in:
parent
2a3b762aa2
commit
6d1e73ca13
|
|
@ -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
|
||||||
|
|
||||||
Loading…
Reference in New Issue