Skip to content

core: io: the read_until function checks bytes not chars, so type should reflect that. #5933

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

Merged
merged 1 commit into from
Apr 18, 2013
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/libcore/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ pub trait ReaderUtil {
fn read_bytes(&self, len: uint) -> ~[u8];

/**
* Reads up until a specific character or EOF.
* Reads up until a specific byte is seen or EOF.
*
* The `include` parameter specifies if the character should be included
* in the returned string.
Expand All @@ -185,7 +185,7 @@ pub trait ReaderUtil {
*
* None right now.
*/
fn read_until(&self, c: char, include: bool) -> ~str;
fn read_until(&self, c: u8, include: bool) -> ~str;

/**
* Reads up until the first '\n' or EOF.
Expand Down Expand Up @@ -577,7 +577,7 @@ impl<T:Reader> ReaderUtil for T {
bytes
}

fn read_until(&self, c: char, include: bool) -> ~str {
fn read_until(&self, c: u8, include: bool) -> ~str {
let mut bytes = ~[];
loop {
let ch = self.read_byte();
Expand All @@ -593,7 +593,7 @@ impl<T:Reader> ReaderUtil for T {
}

fn read_line(&self) -> ~str {
self.read_until('\n', false)
self.read_until('\n' as u8, false)
}

fn read_chars(&self, n: uint) -> ~[char] {
Expand Down Expand Up @@ -667,7 +667,7 @@ impl<T:Reader> ReaderUtil for T {
}

fn read_c_str(&self) -> ~str {
self.read_until(0 as char, false)
self.read_until(0u8, false)
}

fn read_whole_stream(&self) -> ~[u8] {
Expand All @@ -693,7 +693,7 @@ impl<T:Reader> ReaderUtil for T {
// include the \n, so that we can distinguish an entirely empty
// line read after "...\n", and the trailing empty line in
// "...\n\n".
let mut line = self.read_until('\n', true);
let mut line = self.read_until('\n' as u8, true);

// blank line at the end of the reader is ignored
if self.eof() && line.is_empty() { break; }
Expand Down