Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error in skipchars(BufferedInputStream) #57

Closed
denius opened this issue Mar 7, 2019 · 2 comments · Fixed by #77
Closed

error in skipchars(BufferedInputStream) #57

denius opened this issue Mar 7, 2019 · 2 comments · Fixed by #77

Comments

@denius
Copy link

denius commented Mar 7, 2019

Hello!
I'm trying to parse a buffered file, but

skipchars(isspace, BufferedInputStream(IOBuffer(" test")))

yields ERROR: ArgumentError: n must be non-negative in skip(::BufferedInputStream, n) due to
https://github.com/BioJulia/BufferedStreams.jl/blob/b85ff82efcd95d3a4d72a4021f0833b579554bec/src/bufferedinputstream.jl#L126 which is different from Julia/base/iobuffer.jl

@JeffBezanson
Copy link

It would be very useful to implement negative skip amounts, since that allows using a buffered stream as a drop-in replacement in more cases. For example in JuliaLang/julia#34195 this would be needed for BufferedStreams to work with SeisIO.

@stevengj
Copy link
Member

stevengj commented Jul 12, 2023

It's not clear to me how to implement negative skip amounts if the underlying stream is not seekable? Actually we already seem to support seek to arbitrary positions if the underlying stream is seekable, so we should be able to do the same thing with skip I guess.

In the meantime you can use mark and reset for a lot of cases where you might otherwise use negative skips.

In the meantime we should simply implement skipchars, since this can be done more efficiently for buffered streams than for generic streams.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants