@@ -27,7 +27,7 @@ reset once it has been finished, so attempting to iterate on `[None,
27
27
None]` will only take input once unless `io::stdin().seek(0, SeekSet)`
28
28
is called between.
29
29
30
- The `make_path_option_vec ` function handles converting a list of file paths as
30
+ The `pathify ` function handles converting a list of file paths as
31
31
strings to the appropriate format, including the (optional) conversion
32
32
of `"-"` to `stdin`.
33
33
@@ -42,7 +42,7 @@ to handle any `FileInput` structs. E.g. a simple `cat` program
42
42
43
43
or a program that numbers lines after concatenating two files
44
44
45
- for input_vec_state(make_path_option_vec ([~"a.txt", ~"b.txt"])) |line, state| {
45
+ for input_vec_state(pathify ([~"a.txt", ~"b.txt"])) |line, state| {
46
46
io::println(fmt!("%u: %s", state.line_num,
47
47
line));
48
48
}
@@ -145,14 +145,8 @@ struct FileInput_ {
145
145
previous_was_newline : bool
146
146
}
147
147
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
148
+ // XXX: remove this when Reader has &mut self. Should be removable via
149
+ // "self.fi." -> "self." and renaming FileInput_. Documentation above
156
150
// will likely have to be updated to use `let mut in = ...`.
157
151
pub struct FileInput {
158
152
fi : @mut FileInput_
@@ -200,7 +194,7 @@ impl FileInput {
200
194
*/
201
195
pub fn from_args ( ) -> FileInput {
202
196
let args = os:: args ( ) ;
203
- let pathed = make_path_option_vec ( args. tail ( ) , true ) ;
197
+ let pathed = pathify ( args. tail ( ) , true ) ;
204
198
FileInput :: from_vec ( pathed)
205
199
}
206
200
@@ -357,7 +351,8 @@ Convert a list of strings to an appropriate form for a `FileInput`
357
351
instance. `stdin_hyphen` controls whether `-` represents `stdin` or
358
352
a literal `-`.
359
353
*/
360
- pub fn make_path_option_vec ( vec : & [ ~str ] , stdin_hyphen : bool ) -> ~[ Option < Path > ] {
354
+ // XXX: stupid, unclear name
355
+ pub fn pathify ( vec : & [ ~str ] , stdin_hyphen : bool ) -> ~[ Option < Path > ] {
361
356
vec. iter ( ) . map ( |str| {
362
357
if stdin_hyphen && "-" == * str {
363
358
None
@@ -415,7 +410,7 @@ pub fn input_vec_state(files: ~[Option<Path>],
415
410
#[ cfg( test) ]
416
411
mod test {
417
412
418
- use super :: { FileInput , make_path_option_vec , input_vec, input_vec_state} ;
413
+ use super :: { FileInput , pathify , input_vec, input_vec_state} ;
419
414
420
415
use std:: io;
421
416
use std:: uint;
@@ -431,22 +426,22 @@ mod test {
431
426
}
432
427
433
428
#[ test]
434
- fn test_make_path_option_vec ( ) {
429
+ fn test_pathify ( ) {
435
430
let strs = [ ~"some/path",
436
431
~"some/other/path"] ;
437
432
let paths = ~[ Some ( Path ( "some/path" ) ) ,
438
433
Some ( Path ( "some/other/path" ) ) ] ;
439
434
440
- assert_eq ! ( make_path_option_vec ( strs, true ) , paths. clone( ) ) ;
441
- assert_eq ! ( make_path_option_vec ( strs, false ) , paths) ;
435
+ assert_eq ! ( pathify ( strs, true ) , paths. clone( ) ) ;
436
+ assert_eq ! ( pathify ( strs, false ) , paths) ;
442
437
443
- assert_eq!( make_path_option_vec ( [ ~"-"], true), ~[None]);
444
- assert_eq!(make_path_option_vec ([~" -"], false), ~[Some(Path(" -"))]);
438
+ assert_eq!( pathify ( [ ~"-"], true), ~[None]);
439
+ assert_eq!(pathify ([~" -"], false), ~[Some(Path(" -"))]);
445
440
}
446
441
447
442
#[test]
448
443
fn test_fileinput_read_byte() {
449
- let filenames = make_path_option_vec (vec::from_fn(
444
+ let filenames = pathify (vec::from_fn(
450
445
3,
451
446
|i| fmt!(" tmp/lib-fileinput-test-fileinput-read-byte-%u. tmp", i)), true);
452
447
@@ -476,7 +471,7 @@ mod test {
476
471
477
472
#[test]
478
473
fn test_fileinput_read() {
479
- let filenames = make_path_option_vec (vec::from_fn(
474
+ let filenames = pathify (vec::from_fn(
480
475
3,
481
476
|i| fmt!(" tmp/lib-fileinput-test-fileinput-read-%u. tmp", i)), true);
482
477
@@ -497,7 +492,7 @@ mod test {
497
492
#[ test]
498
493
fn test_input_vec( ) {
499
494
let mut all_lines = ~[ ] ;
500
- let filenames = make_path_option_vec ( vec:: from_fn(
495
+ let filenames = pathify ( vec:: from_fn(
501
496
3 ,
502
497
|i| fmt!( "tmp/lib-fileinput-test-input-vec-%u.tmp" , i) ) , true ) ;
503
498
@@ -519,7 +514,7 @@ mod test {
519
514
520
515
#[ test]
521
516
fn test_input_vec_state( ) {
522
- let filenames = make_path_option_vec ( vec:: from_fn(
517
+ let filenames = pathify ( vec:: from_fn(
523
518
3 ,
524
519
|i| fmt!( "tmp/lib-fileinput-test-input-vec-state-%u.tmp" , i) ) , true ) ;
525
520
@@ -541,7 +536,7 @@ mod test {
541
536
542
537
#[ test]
543
538
fn test_empty_files( ) {
544
- let filenames = make_path_option_vec ( vec:: from_fn(
539
+ let filenames = pathify ( vec:: from_fn(
545
540
3 ,
546
541
|i| fmt!( "tmp/lib-fileinput-test-empty-files-%u.tmp" , i) ) , true ) ;
547
542
@@ -588,7 +583,7 @@ mod test {
588
583
589
584
#[test]
590
585
fn test_next_file() {
591
- let filenames = make_path_option_vec (vec::from_fn(
586
+ let filenames = pathify (vec::from_fn(
592
587
3,
593
588
|i| fmt!(" tmp/lib-fileinput-test-next-file-%u. tmp", i)),true);
594
589
@@ -619,7 +614,7 @@ mod test {
619
614
#[test]
620
615
#[should_fail]
621
616
fn test_input_vec_missing_file() {
622
- do input_vec(make_path_option_vec ([~" this/file/doesnt/exist" ] , true ) ) |line| {
617
+ do input_vec(pathify ([~" this/file/doesnt/exist" ] , true ) ) |line| {
623
618
println( line) ;
624
619
true
625
620
} ;
0 commit comments