Use ioivec::read_whole_file_str in a few places

This commit is contained in:
Brian Anderson 2011-08-01 16:01:40 -07:00
parent a1a25969a0
commit 35e9e02066
4 changed files with 8 additions and 16 deletions

View File

@ -108,8 +108,7 @@ fn maybe_highlight_lines(sp: &option::t[span], cm: &codemap,
// FIXME: reading in the entire file is the worst possible way to
// get access to the necessary lines.
let rdr = ioivec::file_reader(lines.name);
let file = str::unsafe_from_bytes_ivec(rdr.read_whole_stream());
let file = ioivec::read_whole_file_str(lines.name);
let fm = get_filemap(cm, lines.name);
// arbitrarily only print up to six lines of the error

View File

@ -62,8 +62,7 @@ fn new_parser_from_file(sess: parse_sess, cfg:
ast::crate_cfg, path: str,
chpos: uint, byte_pos: uint,
ftype: file_type) -> parser {
let srdr = ioivec::file_reader(path);
let src = str::unsafe_from_bytes_ivec(srdr.read_whole_stream());
let src = ioivec::read_whole_file_str(path);
let filemap = codemap::new_filemap(path, chpos, byte_pos);
sess.cm.files += ~[filemap];
let itr = @interner::mk(str::hash, str::eq);

View File

@ -21,11 +21,6 @@ import rustc::syntax::codemap;
import rustc::syntax::parse::parser;
import rustc::syntax::print::pprust;
fn read_whole_file(filename: &str) -> str {
str::unsafe_from_bytes_ivec(ioivec::file_reader(filename).read_whole_stream())
}
fn write_file(filename: &str, content: &str) {
ioivec::file_writer(filename,
~[ioivec::create,
@ -35,7 +30,7 @@ fn write_file(filename: &str, content: &str) {
}
fn file_contains(filename: &str, needle: &str) -> bool {
let contents = read_whole_file(filename);
let contents = ioivec::read_whole_file_str(filename);
ret str::find(contents, needle) != -1;
}
@ -325,7 +320,7 @@ fn check_convergence(files: &str[]) {
log_err #fmt("pp convergence tests: %u files", ivec::len(files));
for file in files {
if !file_is_confusing(file) {
let s = read_whole_file(file);
let s = ioivec::read_whole_file_str(file);
if !content_is_confusing(s) {
log_err #fmt("pp converge: %s", file);
// Change from 7u to 2u when https://github.com/graydon/rust/issues/759 is fixed
@ -338,7 +333,7 @@ fn check_convergence(files: &str[]) {
fn check_variants(files: &str[]) {
for file in files {
if !file_is_confusing(file) {
let s = read_whole_file(file);
let s = ioivec::read_whole_file_str(file);
if content_is_dangerous_to_modify(s) || content_is_confusing(s) { cont; }
log_err "check_variants: " + file;
let codemap = codemap::new_codemap();

View File

@ -1,4 +1,5 @@
import std::io;
import std::ioivec;
import std::str;
import std::option;
import std::vec;
@ -86,8 +87,7 @@ fn run_pretty_test(cx: &cx, props: &test_props, testfile: &str) {
option::none. { 2 }
};
let srcs = ~[str::unsafe_from_bytes(
io::file_reader(testfile).read_whole_stream())];
let srcs = ~[ioivec::read_whole_file_str(testfile)];
let round = 0;
while round < rounds {
@ -106,8 +106,7 @@ fn run_pretty_test(cx: &cx, props: &test_props, testfile: &str) {
let expected = alt props.pp_exact {
option::some(file) {
let filepath = fs::connect(fs::dirname(testfile), file);
str::unsafe_from_bytes(
io::file_reader(filepath).read_whole_stream())
ioivec::read_whole_file_str(filepath)
}
option::none. {
srcs.(ivec::len(srcs) - 2u)