Skip to content

Commit 8e776c7

Browse files
committed
auto merge of #8570 : catamorphism/rust/2013-08-16-rollup, r=catamorphism
Nothing arguable here, as far as I can tell.
2 parents 3ddfb72 + a9aa4ad commit 8e776c7

25 files changed

+395
-148
lines changed

src/libextra/fileinput.rs

+25-20
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ reset once it has been finished, so attempting to iterate on `[None,
2727
None]` will only take input once unless `io::stdin().seek(0, SeekSet)`
2828
is called between.
2929
30-
The `pathify` function handles converting a list of file paths as
30+
The `make_path_option_vec` function handles converting a list of file paths as
3131
strings to the appropriate format, including the (optional) conversion
3232
of `"-"` to `stdin`.
3333
@@ -42,7 +42,7 @@ to handle any `FileInput` structs. E.g. a simple `cat` program
4242
4343
or a program that numbers lines after concatenating two files
4444
45-
for input_vec_state(pathify([~"a.txt", ~"b.txt"])) |line, state| {
45+
for input_vec_state(make_path_option_vec([~"a.txt", ~"b.txt"])) |line, state| {
4646
io::println(fmt!("%u: %s", state.line_num,
4747
line));
4848
}
@@ -145,8 +145,14 @@ struct FileInput_ {
145145
previous_was_newline: bool
146146
}
147147

148-
// XXX: remove this when Reader has &mut self. Should be removable via
149-
// "self.fi." -> "self." and renaming FileInput_. Documentation above
148+
149+
// FIXME #5723: remove this when Reader has &mut self.
150+
// Removing it would mean giving read_byte in the Reader impl for
151+
// FileInput &mut self, which in turn means giving most of the
152+
// io::Reader trait methods &mut self. That can't be done right now
153+
// because of io::with_bytes_reader and #5723.
154+
// Should be removable via
155+
// "self.fi" -> "self." and renaming FileInput_. Documentation above
150156
// will likely have to be updated to use `let mut in = ...`.
151157
pub struct FileInput {
152158
fi: @mut FileInput_
@@ -194,7 +200,7 @@ impl FileInput {
194200
*/
195201
pub fn from_args() -> FileInput {
196202
let args = os::args();
197-
let pathed = pathify(args.tail(), true);
203+
let pathed = make_path_option_vec(args.tail(), true);
198204
FileInput::from_vec(pathed)
199205
}
200206

@@ -351,8 +357,7 @@ Convert a list of strings to an appropriate form for a `FileInput`
351357
instance. `stdin_hyphen` controls whether `-` represents `stdin` or
352358
a literal `-`.
353359
*/
354-
// XXX: stupid, unclear name
355-
pub fn pathify(vec: &[~str], stdin_hyphen : bool) -> ~[Option<Path>] {
360+
pub fn make_path_option_vec(vec: &[~str], stdin_hyphen : bool) -> ~[Option<Path>] {
356361
vec.iter().map(|str| {
357362
if stdin_hyphen && "-" == *str {
358363
None
@@ -410,7 +415,7 @@ pub fn input_vec_state(files: ~[Option<Path>],
410415
#[cfg(test)]
411416
mod test {
412417

413-
use super::{FileInput, pathify, input_vec, input_vec_state};
418+
use super::{FileInput, make_path_option_vec, input_vec, input_vec_state};
414419

415420
use std::io;
416421
use std::uint;
@@ -426,22 +431,22 @@ mod test {
426431
}
427432

428433
#[test]
429-
fn test_pathify() {
434+
fn test_make_path_option_vec() {
430435
let strs = [~"some/path",
431436
~"some/other/path"];
432437
let paths = ~[Some(Path("some/path")),
433438
Some(Path("some/other/path"))];
434439

435-
assert_eq!(pathify(strs, true), paths.clone());
436-
assert_eq!(pathify(strs, false), paths);
440+
assert_eq!(make_path_option_vec(strs, true), paths.clone());
441+
assert_eq!(make_path_option_vec(strs, false), paths);
437442

438-
assert_eq!(pathify([~"-"], true), ~[None]);
439-
assert_eq!(pathify([~"-"], false), ~[Some(Path("-"))]);
443+
assert_eq!(make_path_option_vec([~"-"], true), ~[None]);
444+
assert_eq!(make_path_option_vec([~"-"], false), ~[Some(Path("-"))]);
440445
}
441446
442447
#[test]
443448
fn test_fileinput_read_byte() {
444-
let filenames = pathify(vec::from_fn(
449+
let filenames = make_path_option_vec(vec::from_fn(
445450
3,
446451
|i| fmt!("tmp/lib-fileinput-test-fileinput-read-byte-%u.tmp", i)), true);
447452
@@ -471,7 +476,7 @@ mod test {
471476
472477
#[test]
473478
fn test_fileinput_read() {
474-
let filenames = pathify(vec::from_fn(
479+
let filenames = make_path_option_vec(vec::from_fn(
475480
3,
476481
|i| fmt!("tmp/lib-fileinput-test-fileinput-read-%u.tmp", i)), true);
477482
@@ -492,7 +497,7 @@ mod test {
492497
#[test]
493498
fn test_input_vec() {
494499
let mut all_lines = ~[];
495-
let filenames = pathify(vec::from_fn(
500+
let filenames = make_path_option_vec(vec::from_fn(
496501
3,
497502
|i| fmt!("tmp/lib-fileinput-test-input-vec-%u.tmp", i)), true);
498503

@@ -514,7 +519,7 @@ mod test {
514519

515520
#[test]
516521
fn test_input_vec_state() {
517-
let filenames = pathify(vec::from_fn(
522+
let filenames = make_path_option_vec(vec::from_fn(
518523
3,
519524
|i| fmt!("tmp/lib-fileinput-test-input-vec-state-%u.tmp", i)),true);
520525

@@ -536,7 +541,7 @@ mod test {
536541

537542
#[test]
538543
fn test_empty_files() {
539-
let filenames = pathify(vec::from_fn(
544+
let filenames = make_path_option_vec(vec::from_fn(
540545
3,
541546
|i| fmt!("tmp/lib-fileinput-test-empty-files-%u.tmp", i)),true);
542547

@@ -583,7 +588,7 @@ mod test {
583588
584589
#[test]
585590
fn test_next_file() {
586-
let filenames = pathify(vec::from_fn(
591+
let filenames = make_path_option_vec(vec::from_fn(
587592
3,
588593
|i| fmt!("tmp/lib-fileinput-test-next-file-%u.tmp", i)),true);
589594
@@ -614,7 +619,7 @@ mod test {
614619
#[test]
615620
#[should_fail]
616621
fn test_input_vec_missing_file() {
617-
do input_vec(pathify([~"this/file/doesnt/exist"], true)) |line| {
622+
do input_vec(make_path_option_vec([~"this/file/doesnt/exist"], true)) |line| {
618623
println(line);
619624
true
620625
};

src/libextra/flatpipes.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -564,8 +564,10 @@ pub mod bytepipes {
564564
}
565565
}
566566

567-
// XXX: Remove `@mut` when this module is ported to the new I/O traits,
568-
// which use `&mut self` properly.
567+
// FIXME #6850: Remove `@mut` when this module is ported to the new I/O traits,
568+
// which use `&mut self` properly. (For example, util::comm::GenericPort's try_recv
569+
// method doesn't use `&mut self`, so the `try_recv` method in the impl of `BytePort`
570+
// for `PipeBytePort` can't have `&mut self` either.)
569571
pub struct PipeBytePort {
570572
port: comm::Port<~[u8]>,
571573
buf: @mut ~[u8]

src/libextra/io_util.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ impl BufReader {
3030
}
3131

3232
fn as_bytes_reader<A>(&self, f: &fn(&BytesReader) -> A) -> A {
33-
// XXX FIXME(#5723)
33+
// FIXME(#5723)
3434
let bytes = ::std::util::id::<&[u8]>(self.buf);
3535
let bytes: &'static [u8] = unsafe { cast::transmute(bytes) };
3636
// Recreating the BytesReader state every call since

0 commit comments

Comments
 (0)