JuliaIO / TranscodingStreams.jl

Simple, consistent interfaces for any codec.
https://juliaio.github.io/TranscodingStreams.jl/
Other
86 stars 28 forks source link

Fix interaction between unread and mark #208

Closed nhz2 closed 6 months ago

nhz2 commented 6 months ago

On master

julia> using TranscodingStreams

julia> stream = NoopStream(IOBuffer("foobar"));

julia> mark(stream)
0

julia> read(stream, String)
"foobar"

julia> TranscodingStreams.unread(stream, b"bar")

julia> reset(stream)
-3

julia> read(stream, String)
"foobarbar"

With this PR:

julia> using TranscodingStreams

julia> stream = NoopStream(IOBuffer("foobar"));

julia> mark(stream)
0

julia> read(stream, String)
"foobar"

julia> TranscodingStreams.unread(stream, b"bar")

julia> reset(stream)
0

julia> read(stream, String)
"foobar"