Adjust pp interface to that printing a crate (an reproducing literals/comments) takes a reader, not just a filename. Fixes first big pp-fuzzer bug.
This commit is contained in:
parent
5749a2deac
commit
552bff8a21
4 changed files with 37 additions and 26 deletions
|
|
@ -217,8 +217,9 @@ fn pretty_print_input(session::session sess, ast::crate_cfg cfg,
|
|||
ann = pprust::no_ann();
|
||||
}
|
||||
}
|
||||
pprust::print_crate(sess.get_codemap(), crate, input, ioivec::stdout(),
|
||||
ann);
|
||||
pprust::print_crate(sess.get_codemap(), crate, input,
|
||||
ioivec::file_reader(input),
|
||||
ioivec::stdout(), ann);
|
||||
}
|
||||
|
||||
fn version(str argv0) {
|
||||
|
|
|
|||
|
|
@ -736,9 +736,9 @@ fn is_lit(&token::token t) -> bool {
|
|||
|
||||
type lit = rec(str lit, uint pos);
|
||||
|
||||
fn gather_comments_and_literals(&codemap::codemap cm, str path)
|
||||
fn gather_comments_and_literals(&codemap::codemap cm, str path,
|
||||
ioivec::reader srdr)
|
||||
-> rec(cmnt[] cmnts, lit[] lits) {
|
||||
auto srdr = ioivec::file_reader(path);
|
||||
auto src = str::unsafe_from_bytes_ivec(srdr.read_whole_stream());
|
||||
auto itr = @interner::mk[str](str::hash, str::eq);
|
||||
auto rdr = new_reader(cm, src, codemap::new_filemap(path, 0u, 0u), itr);
|
||||
|
|
|
|||
|
|
@ -73,10 +73,14 @@ const uint alt_indent_unit = 2u;
|
|||
|
||||
const uint default_columns = 78u;
|
||||
|
||||
fn print_crate(&codemap cm, @ast::crate crate, str filename,
|
||||
// Requires you to pass an input filename and reader so that
|
||||
// it can scan the input text for comments and literals to
|
||||
// copy forward.
|
||||
fn print_crate(&codemap cm, @ast::crate crate,
|
||||
str filename, ioivec::reader in,
|
||||
ioivec::writer out, &pp_ann ann) {
|
||||
let pp::breaks[] boxes = ~[];
|
||||
auto r = lexer::gather_comments_and_literals(cm, filename);
|
||||
auto r = lexer::gather_comments_and_literals(cm, filename, in);
|
||||
auto s =
|
||||
@rec(s=pp::mk_printer(out, default_columns),
|
||||
cm=some(cm),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue