clarify EOF error across stream types and predicates (#1867, #1870)

This commit is contained in:
Mark
2023-07-08 13:38:32 -06:00
parent 2e26f37f5e
commit 067b5998ee
11 changed files with 84 additions and 71 deletions

View File

@@ -150,7 +150,7 @@ impl ReadlineStream {
Ok(self.pending_input.get_ref().get_ref().len())
}
Err(ReadlineError::Eof) => Ok(0),
Err(ReadlineError::Eof) => Err(Error::from(ErrorKind::UnexpectedEof)),
Err(e) => Err(Error::new(ErrorKind::InvalidInput, e)),
}
}
@@ -178,9 +178,6 @@ impl ReadlineStream {
loop {
match byte {
Some(0) => {
return Ok(0);
}
Some(b) => {
return Ok(b);
}
@@ -188,10 +185,6 @@ impl ReadlineStream {
Err(e) => {
return Err(e);
}
Ok(0) => {
self.pending_input.get_mut().get_mut().push('\u{0}');
return Ok(0);
}
_ => {
set_prompt(false);
}
@@ -218,9 +211,6 @@ impl CharRead for ReadlineStream {
fn peek_char(&mut self) -> Option<std::io::Result<char>> {
loop {
match self.pending_input.peek_char() {
Some(Ok('\u{0}')) => {
return Some(Ok('\u{0}'));
}
Some(Ok(c)) => {
return Some(Ok(c));
}
@@ -229,10 +219,6 @@ impl CharRead for ReadlineStream {
Err(e) => {
return Some(Err(e));
}
Ok(0) => {
self.pending_input.get_mut().get_mut().push('\u{0}');
return Some(Ok('\u{0}'));
}
_ => {
set_prompt(false);
}