Skip to content

Commit 359d2ed

Browse files
committed
---
yaml --- r: 139190 b: refs/heads/try2 c: 1a0d212 h: refs/heads/master v: v3
1 parent 56957e4 commit 359d2ed

File tree

6 files changed

+88
-183
lines changed

6 files changed

+88
-183
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 1616ffd0c2627502b1015b6388480ed7429ef042
8+
refs/heads/try2: 1a0d212dd94c5d6c62d1cc2939da8ae2c895b65f
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/compiletest/runtest.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ fn run_debuginfo_test(config: config, props: TestProps, testfile: &Path) {
267267
// check if each line in props.check_lines appears in the
268268
// output (in order)
269269
let mut i = 0u;
270-
for str::lines_each(ProcRes.stdout) |line| {
270+
for str::lines(ProcRes.stdout).each |line| {
271271
if props.check_lines[i].trim() == line.trim() {
272272
i += 1u;
273273
}
@@ -297,8 +297,8 @@ fn check_error_patterns(props: TestProps,
297297
let mut next_err_idx = 0u;
298298
let mut next_err_pat = props.error_patterns[next_err_idx];
299299
let mut done = false;
300-
for str::lines_each(ProcRes.stderr) |line| {
301-
if str::contains(line, next_err_pat) {
300+
for str::split_char(ProcRes.stderr, '\n').each |line| {
301+
if str::contains(*line, next_err_pat) {
302302
debug!("found error pattern %s", next_err_pat);
303303
next_err_idx += 1u;
304304
if next_err_idx == vec::len(props.error_patterns) {
@@ -347,15 +347,15 @@ fn check_expected_errors(expected_errors: ~[errors::ExpectedError],
347347
// filename:line1:col1: line2:col2: *warning:* msg
348348
// where line1:col1: is the starting point, line2:col2:
349349
// is the ending point, and * represents ANSI color codes.
350-
for str::lines_each(ProcRes.stderr) |line| {
350+
for str::split_char(ProcRes.stderr, '\n').each |line| {
351351
let mut was_expected = false;
352352
for vec::eachi(expected_errors) |i, ee| {
353353
if !found_flags[i] {
354354
debug!("prefix=%s ee.kind=%s ee.msg=%s line=%s",
355-
prefixes[i], ee.kind, ee.msg, line);
356-
if (str::starts_with(line, prefixes[i]) &&
357-
str::contains(line, ee.kind) &&
358-
str::contains(line, ee.msg)) {
355+
prefixes[i], ee.kind, ee.msg, *line);
356+
if (str::starts_with(*line, prefixes[i]) &&
357+
str::contains(*line, ee.kind) &&
358+
str::contains(*line, ee.msg)) {
359359
found_flags[i] = true;
360360
was_expected = true;
361361
break;
@@ -364,13 +364,13 @@ fn check_expected_errors(expected_errors: ~[errors::ExpectedError],
364364
}
365365

366366
// ignore this msg which gets printed at the end
367-
if str::contains(line, ~"aborting due to") {
367+
if str::contains(*line, ~"aborting due to") {
368368
was_expected = true;
369369
}
370370

371-
if !was_expected && is_compiler_error_or_warning(str::from_slice(line)) {
371+
if !was_expected && is_compiler_error_or_warning(*line) {
372372
fatal_ProcRes(fmt!("unexpected compiler error or warning: '%s'",
373-
line),
373+
*line),
374374
ProcRes);
375375
}
376376
}

branches/try2/src/libcore/io.rs

Lines changed: 6 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,8 @@ pub trait ReaderUtil {
9999
/// Read len bytes into a new vec.
100100
fn read_bytes(&self, len: uint) -> ~[u8];
101101

102-
/// Read up until a specified character (which is optionally included) or EOF.
103-
fn read_until(&self, c: char, include: bool) -> ~str;
102+
/// Read up until a specified character (which is not returned) or EOF.
103+
fn read_until(&self, c: char) -> ~str;
104104

105105
/// Read up until the first '\n' char (which is not returned), or EOF.
106106
fn read_line(&self) -> ~str;
@@ -126,9 +126,6 @@ pub trait ReaderUtil {
126126
/// Iterate over every line until the iterator breaks or EOF.
127127
fn each_line(&self, it: &fn(&str) -> bool);
128128

129-
/// Read all the lines of the file into a vector.
130-
fn read_lines(&self) -> ~[~str];
131-
132129
/// Read n (between 1 and 8) little-endian unsigned integer bytes.
133130
fn read_le_uint_n(&self, nbytes: uint) -> u64;
134131

@@ -222,14 +219,11 @@ impl<T:Reader> ReaderUtil for T {
222219
bytes
223220
}
224221

225-
fn read_until(&self, c: char, include: bool) -> ~str {
222+
fn read_until(&self, c: char) -> ~str {
226223
let mut bytes = ~[];
227224
loop {
228225
let ch = self.read_byte();
229226
if ch == -1 || ch == c as int {
230-
if include && ch == c as int {
231-
bytes.push(ch as u8);
232-
}
233227
break;
234228
}
235229
bytes.push(ch as u8);
@@ -238,7 +232,7 @@ impl<T:Reader> ReaderUtil for T {
238232
}
239233

240234
fn read_line(&self) -> ~str {
241-
self.read_until('\n', false)
235+
self.read_until('\n')
242236
}
243237

244238
fn read_chars(&self, n: uint) -> ~[char] {
@@ -312,7 +306,7 @@ impl<T:Reader> ReaderUtil for T {
312306
}
313307

314308
fn read_c_str(&self) -> ~str {
315-
self.read_until(0 as char, false)
309+
self.read_until(0 as char)
316310
}
317311

318312
fn read_whole_stream(&self) -> ~[u8] {
@@ -335,29 +329,7 @@ impl<T:Reader> ReaderUtil for T {
335329

336330
fn each_line(&self, it: &fn(s: &str) -> bool) {
337331
while !self.eof() {
338-
// include the \n, so that we can distinguish an entirely empty
339-
// line read after "...\n", and the trailing empty line in
340-
// "...\n\n".
341-
let mut line = self.read_until('\n', true);
342-
343-
// blank line at the end of the reader is ignored
344-
if self.eof() && line.is_empty() { break; }
345-
346-
// trim the \n, so that each_line is consistent with read_line
347-
let n = str::len(line);
348-
if line[n-1] == '\n' as u8 {
349-
unsafe { str::raw::set_len(&mut line, n-1); }
350-
}
351-
352-
if !it(line) { break; }
353-
}
354-
}
355-
356-
fn read_lines(&self) -> ~[~str] {
357-
do vec::build |push| {
358-
for self.each_line |line| {
359-
push(str::from_slice(line));
360-
}
332+
if !it(self.read_line()) { break; }
361333
}
362334
}
363335

@@ -1363,21 +1335,6 @@ mod tests {
13631335
}
13641336
}
13651337
1366-
#[test]
1367-
fn test_read_lines() {
1368-
do io::with_str_reader(~"a\nb\nc\n") |inp| {
1369-
fail_unless!(inp.read_lines() == ~[~"a", ~"b", ~"c"]);
1370-
}
1371-
1372-
do io::with_str_reader(~"a\nb\nc") |inp| {
1373-
fail_unless!(inp.read_lines() == ~[~"a", ~"b", ~"c"]);
1374-
}
1375-
1376-
do io::with_str_reader(~"") |inp| {
1377-
fail_unless!(inp.read_lines().is_empty());
1378-
}
1379-
}
1380-
13811338
#[test]
13821339
fn test_readchars_wide() {
13831340
let wide_test = ~"生锈的汤匙切肉汤hello生锈的汤匙切肉汤";

0 commit comments

Comments
 (0)