Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions base/iostream.jl
Original file line number Diff line number Diff line change
Expand Up @@ -449,8 +449,8 @@ function readuntil_string(s::IOStream, delim::UInt8, keep::Bool)
@_lock_ios s ccall(:jl_readuntil, Ref{String}, (Ptr{Cvoid}, UInt8, UInt8, UInt8), s.ios, delim, 1, !keep)
end
readuntil(s::IOStream, delim::AbstractChar; keep::Bool=false) =
delim ≤ '\x7f' ? readuntil_string(s, delim % UInt8, keep) :
String(unsafe_take!(copyuntil(IOBuffer(sizehint=70), s, delim; keep)))
isascii(delim) ? readuntil_string(s, delim % UInt8, keep) :
String(_unsafe_take!(copyuntil(IOBuffer(sizehint=70), s, delim; keep)))

function readline(s::IOStream; keep::Bool=false)
@_lock_ios s ccall(:jl_readuntil, Ref{String}, (Ptr{Cvoid}, UInt8, UInt8, UInt8), s.ios, '\n', 1, keep ? 0 : 2)
Expand Down
4 changes: 4 additions & 0 deletions test/read.jl
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,10 @@ for (name, f) in l
local t, s, m, kept
@test readuntil(io(t), s) == m
@test readuntil(io(t), s, keep=true) == kept
if isone(length(s))
@test readuntil(io(t), first(s)) == m
@test readuntil(io(t), first(s), keep=true) == kept
end
@test readuntil(io(t), SubString(s, firstindex(s))) == m
@test readuntil(io(t), SubString(s, firstindex(s)), keep=true) == kept
@test readuntil(io(t), GenericString(s)) == m
Expand Down