@@ -524,6 +524,7 @@ julia> rm("my_file.txt")
524
524
readuntil (filename:: AbstractString , delim; kw... ) = open (io-> readuntil (io, delim; kw... ), convert (String, filename):: String )
525
525
readuntil (stream:: IO , delim:: UInt8 ; kw... ) = _unsafe_take! (copyuntil (IOBuffer (sizehint= 70 ), stream, delim; kw... ))
526
526
readuntil (stream:: IO , delim:: Union{AbstractChar, AbstractString} ; kw... ) = String (_unsafe_take! (copyuntil (IOBuffer (sizehint= 70 ), stream, delim; kw... )))
527
+ readuntil (stream:: IO , delim:: T ; keep:: Bool = false ) where T = _copyuntil (Vector {T} (), stream, delim, keep)
527
528
528
529
529
530
"""
@@ -914,6 +915,10 @@ function copyuntil(out::IO, s::IO, delim::AbstractChar; keep::Bool=false)
914
915
end
915
916
916
917
# note: optimized methods of copyuntil for IOStreams and delim::UInt8 in iostream.jl
918
+ # and for IOBuffer with delim::UInt8 in iobuffer.jl
919
+ copyuntil (out:: IO , s:: IO , delim; keep:: Bool = false ) = _copyuntil (out, s, delim, keep)
920
+
921
+ # supports out::Union{IO, AbstractVector} for use with both copyuntil & readuntil
917
922
function _copyuntil (out, s:: IO , delim:: T , keep:: Bool ) where T
918
923
output! = isa (out, IO) ? write : push!
919
924
for c in readeach (s, T)
@@ -925,12 +930,6 @@ function _copyuntil(out, s::IO, delim::T, keep::Bool) where T
925
930
end
926
931
return out
927
932
end
928
- readuntil (s:: IO , delim:: T ; keep:: Bool = false ) where T =
929
- _copyuntil (Vector {T} (), s, delim, keep)
930
- readuntil (s:: IO , delim:: UInt8 ; keep:: Bool = false ) =
931
- _copyuntil (resize! (StringVector (70 ), 0 ), s, delim, keep)
932
- copyuntil (out:: IO , s:: IO , delim:: T ; keep:: Bool = false ) where T =
933
- _copyuntil (out, s, delim, keep)
934
933
935
934
# requires that indices for target are the integer unit range from firstindex to lastindex
936
935
# returns whether the delimiter was matched
0 commit comments