@@ -81,22 +81,21 @@ fn parse_input(sess: session, cfg: ast::crate_cfg, input: str) ->
81
81
if !input_is_stdin ( input) {
82
82
parser:: parse_crate_from_file ( input, cfg, sess. parse_sess )
83
83
} else {
84
- let srcbytes = get_input_stream ( sess, input) . read_whole_stream ( ) ;
85
- let srcstring = str:: unsafe_from_bytes ( srcbytes) ;
86
- parser:: parse_crate_from_source_str ( input, srcstring, cfg,
87
- sess. parse_sess )
84
+ let src = get_input_str ( sess, input) ;
85
+ parser:: parse_crate_from_source_str ( input, src, cfg, sess. parse_sess )
88
86
}
89
87
}
90
88
91
- fn get_input_stream ( sess : session , infile : str ) -> io :: reader {
92
- if !input_is_stdin ( infile) {
89
+ fn get_input_str ( sess : session , infile : str ) -> str {
90
+ let stream = if !input_is_stdin ( infile) {
93
91
alt io:: file_reader ( infile) {
94
92
result:: ok ( reader) { reader }
95
93
result:: err ( e) {
96
94
sess. fatal ( e)
97
95
}
98
96
}
99
- } else { io:: stdin ( ) }
97
+ } else { io:: stdin ( ) } ;
98
+ str:: unsafe_from_bytes ( stream. read_whole_stream ( ) )
100
99
}
101
100
102
101
fn time < T > ( do_it : bool , what : str , thunk : fn @( ) -> T ) -> T {
@@ -285,7 +284,7 @@ fn pretty_print_input(sess: session, cfg: ast::crate_cfg, input: str,
285
284
_ { cu_parse }
286
285
} ;
287
286
let { crate , tcx} = compile_upto ( sess, cfg, input, upto, none) ;
288
- let src = get_input_stream ( sess, input) ;
287
+ let src = get_input_str ( sess, input) ;
289
288
290
289
let ann: pprust:: pp_ann = pprust:: no_ann ( ) ;
291
290
alt ppm {
@@ -299,7 +298,7 @@ fn pretty_print_input(sess: session, cfg: ast::crate_cfg, input: str,
299
298
ppm_expanded. | ppm_normal . { }
300
299
}
301
300
pprust:: print_crate ( sess. codemap , sess. diagnostic , crate , input,
302
- src, io:: stdout ( ) , ann) ;
301
+ io :: string_reader ( src) , io:: stdout ( ) , ann) ;
303
302
}
304
303
305
304
fn get_os ( triple : str ) -> option < session:: os > {
0 commit comments