Skip to content

Commit

Permalink
make readuntil accept the keep argument (#63)
Browse files Browse the repository at this point in the history
  • Loading branch information
bicycle1885 committed Aug 13, 2018
1 parent b87d348 commit 3cdc5a2
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/stream.jl
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ function Base.read(stream::TranscodingStream, ::Type{UInt8})
return readbyte!(stream.state.buffer1)
end

function Base.readuntil(stream::TranscodingStream, delim::UInt8)
function Base.readuntil(stream::TranscodingStream, delim::UInt8; keep::Bool=false)
ready_to_read!(stream)
buffer1 = stream.state.buffer1
ret = Vector{UInt8}(undef, 0)
Expand All @@ -292,6 +292,9 @@ function Base.readuntil(stream::TranscodingStream, delim::UInt8)
if p < marginptr(buffer1)
found = true
sz = Int(p + 1 - bufferptr(buffer1))
if !keep
sz -= 1
end
resize!(ret, filled + sz)
else
sz = buffersize(buffer1)
Expand Down

0 comments on commit 3cdc5a2

Please sign in to comment.