Skip to content

Commit b189372

Browse files
eholkbrson
authored andcommitted
---
yaml --- r: 24171 b: refs/heads/master c: 135ebca h: refs/heads/master i: 24169: 508a22a 24167: 869e860 v: v3
1 parent 1190fd3 commit b189372

File tree

6 files changed

+18
-7
lines changed

6 files changed

+18
-7
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: f41cf208b7809bcb5cd12e81970802a52b2c265e
2+
refs/heads/master: 135ebca8aa1bb546984c1915eac4e5c9bfdcf4d6
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: cd6f24f9d14ac90d167386a56e7a6ac1f0318195
55
refs/heads/try: ffbe0e0e00374358b789b0037bcb3a577cd218be

trunk/src/libcore/io.rs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,17 @@ trait Reader {
4848
trait ReaderUtil {
4949
fn read_bytes(len: uint) -> ~[u8];
5050
fn read_line() -> ~str;
51+
52+
fn read_chars(n: uint) -> ~[char];
53+
fn read_char() -> char;
54+
fn read_c_str() -> ~str;
55+
fn read_le_uint(size: uint) -> uint;
56+
fn read_le_int(size: uint) -> int;
57+
fn read_be_uint(size: uint) -> uint;
58+
fn read_whole_stream() -> ~[u8];
59+
fn each_byte(it: fn(int) -> bool);
60+
fn each_char(it: fn(char) -> bool);
61+
fn each_line(it: fn((&str)) -> bool);
5162
}
5263

5364
impl<T: Reader> T : ReaderUtil {
@@ -69,12 +80,10 @@ impl<T: Reader> T : ReaderUtil {
6980
}
7081
str::from_bytes(buf)
7182
}
72-
}
7383

74-
impl Reader {
7584
fn read_chars(n: uint) -> ~[char] {
7685
// returns the (consumed offset, n_req), appends characters to &chars
77-
fn chars_from_bytes(buf: &~[u8], chars: &mut ~[char])
86+
fn chars_from_bytes<T: Reader>(buf: &~[u8], chars: &mut ~[char])
7887
-> (uint, uint) {
7988
let mut i = 0;
8089
let buf_len = buf.len();
@@ -120,7 +129,7 @@ impl Reader {
120129
break;
121130
}
122131
vec::push_all(buf, data);
123-
let (offset, nbreq) = chars_from_bytes(&buf, &mut chars);
132+
let (offset, nbreq) = chars_from_bytes::<T>(&buf, &mut chars);
124133
let ncreq = n - chars.len();
125134
// again we either know we need a certain number of bytes
126135
// to complete a character, or we make sure we don't

trunk/src/libstd/json.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
99
use core::cmp::{Eq, Ord};
1010
use result::{Result, Ok, Err};
11-
use io::WriterUtil;
11+
use io::{WriterUtil, ReaderUtil};
1212
use map::HashMap;
1313
use map::Map;
1414
use sort::Sort;

trunk/src/libstd/time.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
use core::cmp::Eq;
55
use libc::{c_char, c_int, c_long, size_t, time_t};
6-
use io::Reader;
6+
use io::{Reader, ReaderUtil};
77
use result::{Result, Ok, Err};
88

99
export

trunk/src/libsyntax/parse/comments.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use io::println;//XXXXXXXXxxx
2+
use io::ReaderUtil;
23
use util::interner;
34
use lexer::{string_reader, bump, is_eof, nextch,
45
is_whitespace, get_str_from, reader};

trunk/src/rustc/driver/rustc.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ use core::*;
1212

1313
// -*- rust -*-
1414
use result::{Ok, Err};
15+
use io::ReaderUtil;
1516
use std::getopts;
1617
use std::map::HashMap;
1718
use getopts::{opt_present};

0 commit comments

Comments
 (0)