From 59ae5323e8ebdb26c8f031283ba0eb96a9132ab7 Mon Sep 17 00:00:00 2001 From: nhz2 Date: Thu, 25 Apr 2024 21:25:20 -0400 Subject: [PATCH] fix typo and use isascii --- base/iostream.jl | 4 ++-- test/read.jl | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/base/iostream.jl b/base/iostream.jl index 0ee51b9b98efd..f39d9013a7fc9 100644 --- a/base/iostream.jl +++ b/base/iostream.jl @@ -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) diff --git a/test/read.jl b/test/read.jl index 283381668c28a..34224c146864e 100644 --- a/test/read.jl +++ b/test/read.jl @@ -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