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

io::Reader for TcpSocketBuf is inconsistent in its implementation of read_byte() and eof() #3891

Closed
am0d opened this issue Oct 31, 2012 · 1 comment
Milestone

Comments

@am0d
Copy link
Contributor

am0d commented Oct 31, 2012

Firstly, this eof() always returns false. While it is understandable due to the way it has been implemented, this is incorrect behaviour. read(...) for the same implementation is able to determine when the end-of-file has been reached, and therefore eof() should be able to as well.

Second, read_byte() of this implementation will fail if no data is read from the buffer. While somewhat understandable behaviour, this breaks the use of ReaderUtil::read_line(), which calls read_byte() repeatedly until it finds an end-of-line or end-of-file. Looking through other implementations of read_byte() in io.rs, it appears that the standard behaviour is to return -1 when end-of-file has been reached. I suggest that we should do the same here, and assume that we have reached the end of the file when no more bytes are read.

@am0d
Copy link
Contributor Author

am0d commented Nov 2, 2012

I have a fix for this, I'll send a pull request as soon as I figure out how to cleanup my commit history and send a clean pull request ...

am0d added a commit to am0d/rust that referenced this issue Nov 8, 2012
@brson brson closed this as completed in 59a592f Nov 8, 2012
brson added a commit that referenced this issue Nov 8, 2012
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

No branches or pull requests

2 participants