mirror of
https://github.com/1bardesign/batteries.git
synced 2024-11-24 22:54:35 +00:00
fixed iteration bug in stringx.split with long delimiters
This commit is contained in:
parent
e10a6bf498
commit
0b8eeb1948
@ -49,18 +49,20 @@ function stringx.split(self, delim, limit)
|
||||
for j = 2, delim_length do
|
||||
if self:byte(i + j - 1) ~= delim:byte(j) then
|
||||
has_whole_delim = false
|
||||
--step forward as far as we got
|
||||
i = i + j
|
||||
break
|
||||
end
|
||||
end
|
||||
if has_whole_delim then
|
||||
if #res < limit then
|
||||
table.insert(res, i)
|
||||
--iterate forward the whole delimiter
|
||||
i = i + delim_length
|
||||
else
|
||||
break
|
||||
end
|
||||
end
|
||||
--iterate forward
|
||||
i = i + delim_length
|
||||
else
|
||||
--iterate forward
|
||||
i = i + 1
|
||||
|
Loading…
Reference in New Issue
Block a user