fixed iteration bug in stringx.split with long delimiters

This commit is contained in:
Max Cahill 2024-09-18 14:59:01 +10:00
parent e10a6bf498
commit 0b8eeb1948

View File

@ -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