Skip to content

Commit

Permalink
Don't raise EndOfFile when stdin::read reaches EOF.
Browse files Browse the repository at this point in the history
Just return `None' as stipulated by the `Reader' trait. Fixes rust-lang#11104.
  • Loading branch information
spaolacci committed Dec 23, 2013
1 parent ba801d8 commit 1b3784c
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions src/libstd/io/stdio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ use option::{Option, Some, None};
use result::{Ok, Err};
use io::buffered::LineBufferedWriter;
use rt::rtio::{DontClose, IoFactory, LocalIo, RtioFileStream, RtioTTY};
use super::{Reader, Writer, io_error, IoError, OtherIoError,
standard_error, EndOfFile};
use super::{Reader, Writer, io_error, IoError, OtherIoError};

// And so begins the tale of acquiring a uv handle to a stdio stream on all
// platforms in all situations. Our story begins by splitting the world into two
Expand Down Expand Up @@ -202,10 +201,7 @@ impl Reader for StdReader {
// return an actual EOF error, but apparently for stdin it's a
// little different. Hence, here we convert a 0 length read to an
// end-of-file indicator so the caller knows to stop reading.
Ok(0) => {
io_error::cond.raise(standard_error(EndOfFile));
None
}
Ok(0) => None,
Ok(amt) => Some(amt as uint),
Err(e) => {
io_error::cond.raise(e);
Expand Down

1 comment on commit 1b3784c

@spaolacci
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Testing stdin without causing side effects is not easy (which is why, I guess, StdReader and StdWriter have almost no test), but the patch does fixe the reproducer provided with issue rust-lang#11104.

Please sign in to comment.