Skip to content

lost data from mark/reset? #78

@stevengj

Description

@stevengj

I noticed this when rewriting peek in #77. Running peek (which calls mark and reset) sometimes seems to screw up the buffer so that the subsequent read fails:

julia> io = BufferedInputStream(IOBuffer("α∆"), 1)
BufferedInputStream{IOBuffer}(<1 B buffer, 0% filled>)

julia> read(io, Char)
'α': Unicode U+03B1 (category Ll: Letter, lowercase)

julia> peek(io, Char)
'': Unicode U+2206 (category Sm: Symbol, math)

julia> read(io, Char)
ERROR: EOFError: read end of file
Stacktrace:
 [1] read
   @ ~/.julia/packages/BufferedStreams/0mu59/src/bufferedinputstream.jl:186 [inlined]
 [2] read(io::BufferedInputStream{IOBuffer}, #unused#::Type{Char})
   @ Base ./io.jl:789
 [3] top-level scope
   @ REPL[72]:1

PR #77 avoids this problem specifically for peek(io, Char) since it adds an optimized implementation of that function, but it would be good to identify and solve the underlying problem.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions