Skip to content
Snippets Groups Projects
Commit 334a31cd authored by Dmitry E. Oboukhov's avatar Dmitry E. Oboukhov
Browse files

socket:read returns shortest pattern. #474

parent 5ba01e3a
No related branches found
No related tags found
No related merge requests found
......@@ -556,18 +556,24 @@ local function readline_check(self, eols, limit)
if string.len(rbuf) == 0 then
return nil
end
local shortest
for i, eol in pairs(eols) do
if string.len(rbuf) >= string.len(eol) then
local data = string.match(rbuf, "^(.-" .. eol .. ")")
if data ~= nil then
if string.len(data) > limit then
return string.sub(data, 1, limit)
data = string.sub(data, 1, limit)
end
if shortest == nil then
shortest = data
elseif #shortest > #data then
shortest = data
end
return data
end
end
end
return nil
return shortest
end
local function readline(self, limit, eol, timeout)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment