Convert std::io to istrs. Issue #855
This commit is contained in:
parent
20178b9312
commit
fcc031c5b4
@ -100,7 +100,7 @@ fn parse_input_src(sess: session::session, cfg: &ast::crate_cfg, infile: str)
|
||||
-> {crate: @ast::crate, src: str} {
|
||||
let srcbytes =
|
||||
if infile != "-" {
|
||||
io::file_reader(infile)
|
||||
io::file_reader(istr::from_estr(infile))
|
||||
} else { io::stdin() }.read_whole_stream();
|
||||
let src = str::unsafe_from_bytes(srcbytes);
|
||||
let crate =
|
||||
@ -238,18 +238,21 @@ fn pretty_print_input(sess: session::session, cfg: ast::crate_cfg, input: str,
|
||||
ppm_normal. { ann = pprust::no_ann(); }
|
||||
}
|
||||
pprust::print_crate(sess.get_codemap(), crate, input,
|
||||
io::string_reader(src), io::stdout(), ann);
|
||||
io::string_reader(istr::from_estr(src)),
|
||||
io::stdout(), ann);
|
||||
}
|
||||
|
||||
fn version(argv0: str) {
|
||||
let vers = "unknown version";
|
||||
let env_vers = #env["CFG_VERSION"];
|
||||
if str::byte_len(env_vers) != 0u { vers = env_vers; }
|
||||
io::stdout().write_str(#fmt["%s %s\n", argv0, vers]);
|
||||
io::stdout().write_str(
|
||||
istr::from_estr(#fmt["%s %s\n", argv0, vers]));
|
||||
}
|
||||
|
||||
fn usage(argv0: str) {
|
||||
io::stdout().write_str(#fmt["usage: %s [options] <input>\n", argv0] +
|
||||
io::stdout().write_str(istr::from_estr(
|
||||
#fmt["usage: %s [options] <input>\n", argv0] +
|
||||
"
|
||||
options:
|
||||
|
||||
@ -283,7 +286,7 @@ options:
|
||||
--test build test harness
|
||||
--gc garbage collect shared data (experimental/temporary)
|
||||
|
||||
");
|
||||
"));
|
||||
}
|
||||
|
||||
fn get_os(triple: str) -> session::os {
|
||||
|
@ -86,7 +86,8 @@ fn list_file_metadata(path: str, out: io::writer) {
|
||||
alt get_metadata_section(path) {
|
||||
option::some(bytes) { decoder::list_crate_metadata(bytes, out); }
|
||||
option::none. {
|
||||
out.write_str("Could not find metadata in " + path + ".\n");
|
||||
out.write_str(
|
||||
istr::from_estr("Could not find metadata in " + path + ".\n"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import std::ebml;
|
||||
import std::vec;
|
||||
import std::option;
|
||||
import std::str;
|
||||
import std::istr;
|
||||
import std::io;
|
||||
import std::map::hashmap;
|
||||
import syntax::ast;
|
||||
@ -346,18 +347,20 @@ fn get_attributes(md: &ebml::doc) -> [ast::attribute] {
|
||||
|
||||
fn list_meta_items(meta_items: &ebml::doc, out: io::writer) {
|
||||
for mi: @ast::meta_item in get_meta_items(meta_items) {
|
||||
out.write_str(#fmt["%s\n", pprust::meta_item_to_str(*mi)]);
|
||||
out.write_str(
|
||||
istr::from_estr(#fmt["%s\n", pprust::meta_item_to_str(*mi)]));
|
||||
}
|
||||
}
|
||||
|
||||
fn list_crate_attributes(md: &ebml::doc, out: io::writer) {
|
||||
out.write_str("=Crate Attributes=\n");
|
||||
out.write_str(~"=Crate Attributes=\n");
|
||||
|
||||
for attr: ast::attribute in get_attributes(md) {
|
||||
out.write_str(#fmt["%s\n", pprust::attribute_to_str(attr)]);
|
||||
out.write_str(
|
||||
istr::from_estr(#fmt["%s\n", pprust::attribute_to_str(attr)]));
|
||||
}
|
||||
|
||||
out.write_str("\n\n");
|
||||
out.write_str(~"\n\n");
|
||||
}
|
||||
|
||||
fn get_crate_attributes(data: @[u8]) -> [ast::attribute] {
|
||||
@ -380,17 +383,18 @@ fn get_crate_deps(data: @[u8]) -> [crate_dep] {
|
||||
}
|
||||
|
||||
fn list_crate_deps(data: @[u8], out: io::writer) {
|
||||
out.write_str("=External Dependencies=\n");
|
||||
out.write_str(~"=External Dependencies=\n");
|
||||
|
||||
for dep: crate_dep in get_crate_deps(data) {
|
||||
out.write_str(#fmt["%d %s\n", dep.cnum, dep.ident]);
|
||||
out.write_str(
|
||||
istr::from_estr(#fmt["%d %s\n", dep.cnum, dep.ident]));
|
||||
}
|
||||
|
||||
out.write_str("\n");
|
||||
out.write_str(~"\n");
|
||||
}
|
||||
|
||||
fn list_crate_items(bytes: &@[u8], md: &ebml::doc, out: io::writer) {
|
||||
out.write_str("=Items=\n");
|
||||
out.write_str(~"=Items=\n");
|
||||
let paths = ebml::get_doc(md, tag_paths);
|
||||
let items = ebml::get_doc(md, tag_items);
|
||||
let index = ebml::get_doc(paths, tag_index);
|
||||
@ -403,11 +407,12 @@ fn list_crate_items(bytes: &@[u8], md: &ebml::doc, out: io::writer) {
|
||||
let def = ebml::doc_at(bytes, data.pos);
|
||||
let did_doc = ebml::get_doc(def, tag_def_id);
|
||||
let did = parse_def_id(ebml::doc_data(did_doc));
|
||||
out.write_str(#fmt["%s (%s)\n", data.path,
|
||||
describe_def(items, did)]);
|
||||
out.write_str(
|
||||
istr::from_estr(#fmt["%s (%s)\n", data.path,
|
||||
describe_def(items, did)]));
|
||||
}
|
||||
}
|
||||
out.write_str("\n");
|
||||
out.write_str(~"\n");
|
||||
}
|
||||
|
||||
fn list_crate_metadata(bytes: &@[u8], out: io::writer) {
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
import std::vec;
|
||||
import std::str;
|
||||
import std::istr;
|
||||
import std::uint;
|
||||
import std::io;
|
||||
import std::option;
|
||||
@ -435,7 +436,9 @@ fn encode_index<T>(ebml_w: &ebml::writer, buckets: &[@[entry<T>]],
|
||||
ebml::end_tag(ebml_w);
|
||||
}
|
||||
|
||||
fn write_str(writer: &io::writer, s: &str) { writer.write_str(s); }
|
||||
fn write_str(writer: &io::writer, s: &str) {
|
||||
writer.write_str(istr::from_estr(s));
|
||||
}
|
||||
|
||||
fn write_int(writer: &io::writer, n: &int) {
|
||||
writer.write_be_uint(n as uint, 4u);
|
||||
@ -616,7 +619,7 @@ fn encode_metadata(cx: &@crate_ctxt, crate: &@crate) -> str {
|
||||
// remaining % 4 bytes.
|
||||
|
||||
buf_w.write([0u8, 0u8, 0u8, 0u8]);
|
||||
ret string_w.get_str();
|
||||
ret istr::to_estr(string_w.get_str());
|
||||
}
|
||||
|
||||
// Get the encoded string for a type
|
||||
@ -624,7 +627,7 @@ fn encoded_ty(tcx: &ty::ctxt, t: ty::t) -> str {
|
||||
let cx = @{ds: def_to_str, tcx: tcx, abbrevs: tyencode::ac_no_abbrevs};
|
||||
let sw = io::string_writer();
|
||||
tyencode::enc_ty(sw.get_writer(), cx, t);
|
||||
ret sw.get_str();
|
||||
ret istr::to_estr(sw.get_str());
|
||||
}
|
||||
|
||||
|
||||
|
@ -46,15 +46,15 @@ fn enc_ty(w: &io::writer, cx: &@ctxt, t: ty::t) {
|
||||
none. {
|
||||
let sw = io::string_writer();
|
||||
enc_sty(sw.get_writer(), cx, ty::struct(cx.tcx, t));
|
||||
result_str = sw.get_str();
|
||||
result_str = istr::to_estr(sw.get_str());
|
||||
cx.tcx.short_names_cache.insert(t, result_str);
|
||||
}
|
||||
}
|
||||
w.write_str(result_str);
|
||||
w.write_str(istr::from_estr(result_str));
|
||||
}
|
||||
ac_use_abbrevs(abbrevs) {
|
||||
alt abbrevs.find(t) {
|
||||
some(a) { w.write_str(a.s); ret; }
|
||||
some(a) { w.write_str(istr::from_estr(a.s)); ret; }
|
||||
none. {
|
||||
let pos = w.get_buf_writer().tell();
|
||||
enc_sty(w, cx, ty::struct(cx.tcx, t));
|
||||
@ -100,30 +100,30 @@ fn enc_sty(w: &io::writer, cx: &@ctxt, st: &ty::sty) {
|
||||
ty::ty_float. { w.write_char('l'); }
|
||||
ty::ty_machine(mach) {
|
||||
alt mach {
|
||||
ty_u8. { w.write_str("Mb"); }
|
||||
ty_u16. { w.write_str("Mw"); }
|
||||
ty_u32. { w.write_str("Ml"); }
|
||||
ty_u64. { w.write_str("Md"); }
|
||||
ty_i8. { w.write_str("MB"); }
|
||||
ty_i16. { w.write_str("MW"); }
|
||||
ty_i32. { w.write_str("ML"); }
|
||||
ty_i64. { w.write_str("MD"); }
|
||||
ty_f32. { w.write_str("Mf"); }
|
||||
ty_f64. { w.write_str("MF"); }
|
||||
ty_u8. { w.write_str(~"Mb"); }
|
||||
ty_u16. { w.write_str(~"Mw"); }
|
||||
ty_u32. { w.write_str(~"Ml"); }
|
||||
ty_u64. { w.write_str(~"Md"); }
|
||||
ty_i8. { w.write_str(~"MB"); }
|
||||
ty_i16. { w.write_str(~"MW"); }
|
||||
ty_i32. { w.write_str(~"ML"); }
|
||||
ty_i64. { w.write_str(~"MD"); }
|
||||
ty_f32. { w.write_str(~"Mf"); }
|
||||
ty_f64. { w.write_str(~"MF"); }
|
||||
}
|
||||
}
|
||||
ty::ty_char. { w.write_char('c'); }
|
||||
ty::ty_str. { w.write_char('s'); }
|
||||
ty::ty_istr. { w.write_char('S'); }
|
||||
ty::ty_tag(def, tys) {
|
||||
w.write_str("t[");
|
||||
w.write_str(cx.ds(def));
|
||||
w.write_str(~"t[");
|
||||
w.write_str(istr::from_estr(cx.ds(def)));
|
||||
w.write_char('|');
|
||||
for t: ty::t in tys { enc_ty(w, cx, t); }
|
||||
w.write_char(']');
|
||||
}
|
||||
ty::ty_tup(ts) {
|
||||
w.write_str("T[");
|
||||
w.write_str(~"T[");
|
||||
for t in ts { enc_ty(w, cx, t); }
|
||||
w.write_char(']');
|
||||
}
|
||||
@ -132,9 +132,9 @@ fn enc_sty(w: &io::writer, cx: &@ctxt, st: &ty::sty) {
|
||||
ty::ty_ptr(mt) { w.write_char('*'); enc_mt(w, cx, mt); }
|
||||
ty::ty_vec(mt) { w.write_char('I'); enc_mt(w, cx, mt); }
|
||||
ty::ty_rec(fields) {
|
||||
w.write_str("R[");
|
||||
w.write_str(~"R[");
|
||||
for field: ty::field in fields {
|
||||
w.write_str(field.ident);
|
||||
w.write_str(istr::from_estr(field.ident));
|
||||
w.write_char('=');
|
||||
enc_mt(w, cx, field.mt);
|
||||
}
|
||||
@ -156,17 +156,17 @@ fn enc_sty(w: &io::writer, cx: &@ctxt, st: &ty::sty) {
|
||||
enc_ty_fn(w, cx, args, out, return, []);
|
||||
}
|
||||
ty::ty_obj(methods) {
|
||||
w.write_str("O[");
|
||||
w.write_str(~"O[");
|
||||
for m: ty::method in methods {
|
||||
enc_proto(w, m.proto);
|
||||
w.write_str(m.ident);
|
||||
w.write_str(istr::from_estr(m.ident));
|
||||
enc_ty_fn(w, cx, m.inputs, m.output, m.cf, m.constrs);
|
||||
}
|
||||
w.write_char(']');
|
||||
}
|
||||
ty::ty_res(def, ty, tps) {
|
||||
w.write_str("r[");
|
||||
w.write_str(cx.ds(def));
|
||||
w.write_str(~"r[");
|
||||
w.write_str(istr::from_estr(cx.ds(def)));
|
||||
w.write_char('|');
|
||||
enc_ty(w, cx, ty);
|
||||
for t: ty::t in tps { enc_ty(w, cx, t); }
|
||||
@ -174,24 +174,24 @@ fn enc_sty(w: &io::writer, cx: &@ctxt, st: &ty::sty) {
|
||||
}
|
||||
ty::ty_var(id) {
|
||||
w.write_char('X');
|
||||
w.write_str(istr::to_estr(int::str(id)));
|
||||
w.write_str(int::str(id));
|
||||
}
|
||||
ty::ty_native(def) {
|
||||
w.write_char('E');
|
||||
w.write_str(cx.ds(def));
|
||||
w.write_str(istr::from_estr(cx.ds(def)));
|
||||
w.write_char('|');
|
||||
}
|
||||
ty::ty_param(id, k) {
|
||||
alt k {
|
||||
kind_unique. { w.write_str("pu"); }
|
||||
kind_shared. { w.write_str("ps"); }
|
||||
kind_pinned. { w.write_str("pp"); }
|
||||
kind_unique. { w.write_str(~"pu"); }
|
||||
kind_shared. { w.write_str(~"ps"); }
|
||||
kind_pinned. { w.write_str(~"pp"); }
|
||||
}
|
||||
w.write_str(istr::to_estr(uint::str(id)));
|
||||
w.write_str(uint::str(id));
|
||||
}
|
||||
ty::ty_type. { w.write_char('Y'); }
|
||||
ty::ty_constr(ty, cs) {
|
||||
w.write_str("A[");
|
||||
w.write_str(~"A[");
|
||||
enc_ty(w, cx, ty);
|
||||
for tc: @ty::type_constr in cs { enc_ty_constr(w, cx, tc); }
|
||||
w.write_char(']');
|
||||
@ -235,9 +235,9 @@ fn enc_ty_fn(w: &io::writer, cx: &@ctxt, args: &[ty::arg], out: ty::t,
|
||||
|
||||
// FIXME less copy-and-paste
|
||||
fn enc_constr(w: &io::writer, cx: &@ctxt, c: &@ty::constr) {
|
||||
w.write_str(path_to_str(c.node.path));
|
||||
w.write_str(istr::from_estr(path_to_str(c.node.path)));
|
||||
w.write_char('(');
|
||||
w.write_str(cx.ds(c.node.id));
|
||||
w.write_str(istr::from_estr(cx.ds(c.node.id)));
|
||||
w.write_char('|');
|
||||
let semi = false;
|
||||
for a: @constr_arg in c.node.args {
|
||||
@ -245,24 +245,28 @@ fn enc_constr(w: &io::writer, cx: &@ctxt, c: &@ty::constr) {
|
||||
alt a.node {
|
||||
carg_base. { w.write_char('*'); }
|
||||
carg_ident(i) { w.write_uint(i); }
|
||||
carg_lit(l) { w.write_str(lit_to_str(l)); }
|
||||
carg_lit(l) {
|
||||
w.write_str(istr::from_estr(lit_to_str(l)));
|
||||
}
|
||||
}
|
||||
}
|
||||
w.write_char(')');
|
||||
}
|
||||
|
||||
fn enc_ty_constr(w: &io::writer, cx: &@ctxt, c: &@ty::type_constr) {
|
||||
w.write_str(path_to_str(c.node.path));
|
||||
w.write_str(istr::from_estr(path_to_str(c.node.path)));
|
||||
w.write_char('(');
|
||||
w.write_str(cx.ds(c.node.id));
|
||||
w.write_str(istr::from_estr(cx.ds(c.node.id)));
|
||||
w.write_char('|');
|
||||
let semi = false;
|
||||
for a: @ty::ty_constr_arg in c.node.args {
|
||||
if semi { w.write_char(';'); } else { semi = true; }
|
||||
alt a.node {
|
||||
carg_base. { w.write_char('*'); }
|
||||
carg_ident(p) { w.write_str(path_to_str(p)); }
|
||||
carg_lit(l) { w.write_str(lit_to_str(l)); }
|
||||
carg_ident(p) {
|
||||
w.write_str(istr::from_estr(path_to_str(p))); }
|
||||
carg_lit(l) {
|
||||
w.write_str(istr::from_estr(lit_to_str(l))); }
|
||||
}
|
||||
}
|
||||
w.write_char(')');
|
||||
|
@ -1,6 +1,7 @@
|
||||
import std::vec;
|
||||
import std::uint;
|
||||
import std::str;
|
||||
import std::istr;
|
||||
import std::term;
|
||||
import std::io;
|
||||
import std::option;
|
||||
@ -108,13 +109,13 @@ fn emit_diagnostic(sp: &option::t<span>, msg: &str, kind: &str, color: u8,
|
||||
}
|
||||
none. { }
|
||||
}
|
||||
io::stdout().write_str(ss);
|
||||
io::stdout().write_str(istr::from_estr(ss));
|
||||
if term::color_supported() {
|
||||
term::fg(io::stdout().get_buf_writer(), color);
|
||||
}
|
||||
io::stdout().write_str(#fmt["%s:", kind]);
|
||||
io::stdout().write_str(istr::from_estr(#fmt["%s:", kind]));
|
||||
if term::color_supported() { term::reset(io::stdout().get_buf_writer()); }
|
||||
io::stdout().write_str(#fmt[" %s\n", msg]);
|
||||
io::stdout().write_str(istr::from_estr(#fmt[" %s\n", msg]));
|
||||
|
||||
maybe_highlight_lines(sp, cm, maybe_lines);
|
||||
}
|
||||
@ -130,7 +131,8 @@ 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 file = io::read_whole_file_str(lines.name);
|
||||
let file = istr::to_estr(
|
||||
io::read_whole_file_str(istr::from_estr(lines.name)));
|
||||
let fm = get_filemap(cm, lines.name);
|
||||
|
||||
// arbitrarily only print up to six lines of the error
|
||||
@ -143,18 +145,19 @@ fn maybe_highlight_lines(sp: &option::t<span>, cm: &codemap,
|
||||
}
|
||||
// Print the offending lines
|
||||
for line: uint in display_lines {
|
||||
io::stdout().write_str(#fmt["%s:%u ", fm.name, line + 1u]);
|
||||
io::stdout().write_str(
|
||||
istr::from_estr(#fmt["%s:%u ", fm.name, line + 1u]));
|
||||
let s = get_line(fm, line as int, file);
|
||||
if !str::ends_with(s, "\n") { s += "\n"; }
|
||||
io::stdout().write_str(s);
|
||||
io::stdout().write_str(istr::from_estr(s));
|
||||
}
|
||||
if elided {
|
||||
let last_line = display_lines[vec::len(display_lines) - 1u];
|
||||
let s = #fmt["%s:%u ", fm.name, last_line + 1u];
|
||||
let indent = str::char_len(s);
|
||||
let out = "";
|
||||
while indent > 0u { out += " "; indent -= 1u; }
|
||||
out += "...\n";
|
||||
let out = ~"";
|
||||
while indent > 0u { out += ~" "; indent -= 1u; }
|
||||
out += ~"...\n";
|
||||
io::stdout().write_str(out);
|
||||
}
|
||||
|
||||
@ -180,7 +183,7 @@ fn maybe_highlight_lines(sp: &option::t<span>, cm: &codemap,
|
||||
let width = hi.col - lo.col - 1u;
|
||||
while width > 0u { str::push_char(s, '~'); width -= 1u; }
|
||||
}
|
||||
io::stdout().write_str(s + "\n");
|
||||
io::stdout().write_str(istr::from_estr(s + "\n"));
|
||||
}
|
||||
}
|
||||
_ { }
|
||||
|
@ -1,12 +1,14 @@
|
||||
import std::option;
|
||||
import base::*;
|
||||
import syntax::ast;
|
||||
import std::istr;
|
||||
|
||||
fn expand_syntax_ext(cx: &ext_ctxt, sp: codemap::span, arg: @ast::expr,
|
||||
_body: option::t<str>) -> @ast::expr {
|
||||
|
||||
cx.print_backtrace();
|
||||
std::io::stdout().write_line(print::pprust::expr_to_str(arg));
|
||||
std::io::stdout().write_line(
|
||||
istr::from_estr(print::pprust::expr_to_str(arg)));
|
||||
|
||||
//trivial expression
|
||||
ret @{id: cx.next_id(), node: ast::expr_rec([], option::none), span: sp};
|
||||
|
@ -63,7 +63,7 @@ type parser =
|
||||
fn new_parser_from_file(sess: parse_sess, cfg: ast::crate_cfg, path: str,
|
||||
chpos: uint, byte_pos: uint, ftype: file_type) ->
|
||||
parser {
|
||||
let src = io::read_whole_file_str(path);
|
||||
let src = istr::to_estr(io::read_whole_file_str(istr::from_estr(path)));
|
||||
let filemap = codemap::new_filemap(path, chpos, byte_pos);
|
||||
sess.cm.files += [filemap];
|
||||
let itr = @interner::mk(str::hash, str::eq);
|
||||
|
@ -2,7 +2,7 @@
|
||||
import std::io;
|
||||
import std::vec;
|
||||
import std::str;
|
||||
|
||||
import std::istr;
|
||||
|
||||
/*
|
||||
* This pretty-printer is a direct reimplementation of Philip Karlton's
|
||||
@ -391,7 +391,7 @@ obj printer(out: io::writer,
|
||||
}
|
||||
fn print_newline(amount: int) {
|
||||
log #fmt["NEWLINE %d", amount];
|
||||
out.write_str("\n");
|
||||
out.write_str(~"\n");
|
||||
pending_indentation = 0;
|
||||
self.indent(amount);
|
||||
}
|
||||
@ -407,10 +407,10 @@ obj printer(out: io::writer,
|
||||
}
|
||||
fn write_str(s: str) {
|
||||
while pending_indentation > 0 {
|
||||
out.write_str(" ");
|
||||
out.write_str(~" ");
|
||||
pending_indentation -= 1;
|
||||
}
|
||||
out.write_str(s);
|
||||
out.write_str(istr::from_estr(s));
|
||||
}
|
||||
fn print(x: token, L: int) {
|
||||
log #fmt["print %s %d (remaining line space=%d)", tok_str(x), L,
|
||||
|
@ -112,7 +112,7 @@ fn fun_to_str(f: &ast::_fn, name: str, params: &[ast::ty_param]) -> str {
|
||||
let s = rust_printer(writer.get_writer());
|
||||
print_fn(s, f.decl, f.proto, name, params, f.decl.constraints);
|
||||
eof(s.s);
|
||||
ret writer.get_str();
|
||||
ret istr::to_estr(writer.get_str());
|
||||
}
|
||||
|
||||
fn block_to_str(blk: &ast::blk) -> str {
|
||||
@ -126,7 +126,7 @@ fn block_to_str(blk: &ast::blk) -> str {
|
||||
ibox(s, 0u);
|
||||
print_block(s, blk);
|
||||
eof(s.s);
|
||||
ret writer.get_str();
|
||||
ret istr::to_estr(writer.get_str());
|
||||
}
|
||||
|
||||
fn meta_item_to_str(mi: &ast::meta_item) -> str {
|
||||
@ -1621,7 +1621,7 @@ fn to_str<T>(t: &T, f: fn(&ps, &T)) -> str {
|
||||
let s = rust_printer(writer.get_writer());
|
||||
f(s, t);
|
||||
eof(s.s);
|
||||
ret writer.get_str();
|
||||
ret istr::to_estr(writer.get_str());
|
||||
}
|
||||
|
||||
fn next_comment(s: &ps) -> option::t<lexer::cmnt> {
|
||||
|
@ -58,7 +58,7 @@ i = 0
|
||||
for t in stage2_tests:
|
||||
p = os.path.join("test", "run-pass", t)
|
||||
p = p.replace("\\", "\\\\")
|
||||
d.write(" out.write_str(\"run-pass [stage2]: %s\\n\");\n" % p)
|
||||
d.write(" out.write_str(~\"run-pass [stage2]: %s\\n\");\n" % p)
|
||||
if t in take_args:
|
||||
d.write(" t_%d::main([\"arg0\"]);\n" % i)
|
||||
else:
|
||||
|
@ -22,13 +22,13 @@ import rustc::syntax::parse::parser;
|
||||
import rustc::syntax::print::pprust;
|
||||
|
||||
fn write_file(filename: &str, content: &str) {
|
||||
io::file_writer(filename, [io::create, io::truncate]).write_str(content);
|
||||
io::file_writer(istr::from_estr(filename), [io::create, io::truncate]).write_str(istr::from_estr(content));
|
||||
// Work around https://github.com/graydon/rust/issues/726
|
||||
std::run::run_program(~"chmod", [~"644", istr::from_estr(filename)]);
|
||||
}
|
||||
|
||||
fn file_contains(filename: &str, needle: &str) -> bool {
|
||||
let contents = io::read_whole_file_str(filename);
|
||||
let contents = istr::to_estr(io::read_whole_file_str(istr::from_estr(filename)));
|
||||
ret str::find(contents, needle) != -1;
|
||||
}
|
||||
|
||||
@ -154,7 +154,7 @@ fn devnull() -> io::writer { std::io::string_writer().get_writer() }
|
||||
fn as_str(f: fn(io::writer)) -> str {
|
||||
let w = std::io::string_writer();
|
||||
f(w.get_writer());
|
||||
ret w.get_str();
|
||||
ret istr::to_estr(w.get_str());
|
||||
}
|
||||
|
||||
fn check_variants_of_ast(crate: &ast::crate, codemap: &codemap::codemap,
|
||||
@ -171,7 +171,7 @@ fn check_variants_of_ast(crate: &ast::crate, codemap: &codemap::codemap,
|
||||
// string for stability is easier and ok for now.
|
||||
let str3 =
|
||||
as_str(bind pprust::print_crate(codemap, crate2, filename,
|
||||
io::string_reader(""), _,
|
||||
io::string_reader(~""), _,
|
||||
pprust::no_ann()));
|
||||
// 1u would be sane here, but the pretty-printer currently has lots of whitespace and paren issues,
|
||||
// and https://github.com/graydon/rust/issues/766 is hilarious.
|
||||
@ -254,7 +254,7 @@ fn parse_and_print(code: &str) -> str {
|
||||
//write_file(filename, code);
|
||||
let crate = parser::parse_crate_from_source_str(filename, code, [], sess);
|
||||
ret as_str(bind pprust::print_crate(sess.cm, crate, filename,
|
||||
io::string_reader(code), _,
|
||||
io::string_reader(istr::from_estr(code)), _,
|
||||
pprust::no_ann()));
|
||||
}
|
||||
|
||||
@ -340,7 +340,7 @@ fn check_convergence(files: &[str]) {
|
||||
log_err #fmt["pp convergence tests: %u files", vec::len(files)];
|
||||
for file in files {
|
||||
if !file_is_confusing(file) {
|
||||
let s = io::read_whole_file_str(file);
|
||||
let s = istr::to_estr(io::read_whole_file_str(istr::from_estr(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
|
||||
@ -353,7 +353,7 @@ fn check_convergence(files: &[str]) {
|
||||
fn check_variants(files: &[str]) {
|
||||
for file in files {
|
||||
if !file_is_confusing(file) {
|
||||
let s = io::read_whole_file_str(file);
|
||||
let s = istr::to_estr(io::read_whole_file_str(istr::from_estr(file)));
|
||||
if content_is_dangerous_to_modify(s) || content_is_confusing(s) {
|
||||
cont;
|
||||
}
|
||||
@ -362,7 +362,7 @@ fn check_variants(files: &[str]) {
|
||||
let crate =
|
||||
parser::parse_crate_from_source_str(file, s, [], sess);
|
||||
log_err as_str(bind pprust::print_crate(sess.cm, crate, file,
|
||||
io::string_reader(s), _,
|
||||
io::string_reader(istr::from_estr(s)), _,
|
||||
pprust::no_ann()));
|
||||
check_variants_of_ast(*crate, sess.cm, file);
|
||||
}
|
||||
|
@ -39,8 +39,8 @@ type reader =
|
||||
fn read_bytes(uint) -> [u8];
|
||||
fn read_char() -> char;
|
||||
fn eof() -> bool;
|
||||
fn read_line() -> str;
|
||||
fn read_c_str() -> str;
|
||||
fn read_line() -> istr;
|
||||
fn read_c_str() -> istr;
|
||||
fn read_le_uint(uint) -> uint;
|
||||
fn read_le_int(uint) -> int;
|
||||
fn read_be_uint(uint) -> uint;
|
||||
@ -104,7 +104,7 @@ obj new_reader(rdr: buf_reader) {
|
||||
ret val as char;
|
||||
}
|
||||
fn eof() -> bool { ret rdr.eof(); }
|
||||
fn read_line() -> str {
|
||||
fn read_line() -> istr {
|
||||
let buf: [u8] = [];
|
||||
// No break yet in rustc
|
||||
|
||||
@ -115,16 +115,16 @@ obj new_reader(rdr: buf_reader) {
|
||||
go_on = false;
|
||||
} else { buf += [ch as u8]; }
|
||||
}
|
||||
ret str::unsafe_from_bytes(buf);
|
||||
ret istr::unsafe_from_bytes(buf);
|
||||
}
|
||||
fn read_c_str() -> str {
|
||||
fn read_c_str() -> istr {
|
||||
let buf: [u8] = [];
|
||||
let go_on = true;
|
||||
while go_on {
|
||||
let ch = rdr.read_byte();
|
||||
if ch < 1 { go_on = false; } else { buf += [ch as u8]; }
|
||||
}
|
||||
ret str::unsafe_from_bytes(buf);
|
||||
ret istr::unsafe_from_bytes(buf);
|
||||
}
|
||||
|
||||
// FIXME deal with eof?
|
||||
@ -172,8 +172,10 @@ fn stdin() -> reader {
|
||||
ret new_reader(FILE_buf_reader(rustrt::rust_get_stdin(), option::none));
|
||||
}
|
||||
|
||||
fn file_reader(path: str) -> reader {
|
||||
let f = os::libc::fopen(str::buf(path), str::buf("r"));
|
||||
fn file_reader(path: &istr) -> reader {
|
||||
let path = istr::to_estr(path);
|
||||
let mode = "r";
|
||||
let f = os::libc::fopen(str::buf(path), str::buf(mode));
|
||||
if f as uint == 0u { log_err "error opening " + path; fail; }
|
||||
ret new_reader(FILE_buf_reader(f, option::some(@FILE_res(f))));
|
||||
}
|
||||
@ -213,8 +215,8 @@ fn new_byte_buf_reader(buf: &[u8]) -> buf_reader {
|
||||
ret byte_buf_reader(@{buf: buf, mutable pos: 0u});
|
||||
}
|
||||
|
||||
fn string_reader(s: &str) -> reader {
|
||||
ret new_reader(new_byte_buf_reader(str::bytes(s)));
|
||||
fn string_reader(s: &istr) -> reader {
|
||||
ret new_reader(new_byte_buf_reader(istr::bytes(s)));
|
||||
}
|
||||
|
||||
|
||||
@ -273,7 +275,8 @@ obj fd_buf_writer(fd: int, res: option::t<@fd_res>) {
|
||||
}
|
||||
}
|
||||
|
||||
fn file_buf_writer(path: str, flags: &[fileflag]) -> buf_writer {
|
||||
fn file_buf_writer(path: &istr, flags: &[fileflag]) -> buf_writer {
|
||||
let path = istr::to_estr(path);
|
||||
let fflags: int =
|
||||
os::libc_constants::O_WRONLY() | os::libc_constants::O_BINARY();
|
||||
for f: fileflag in flags {
|
||||
@ -301,8 +304,8 @@ type writer =
|
||||
// function will be provided for general encoded string output
|
||||
obj {
|
||||
fn get_buf_writer() -> buf_writer;
|
||||
fn write_str(str);
|
||||
fn write_line(str);
|
||||
fn write_str(&istr);
|
||||
fn write_line(&istr);
|
||||
fn write_char(char);
|
||||
fn write_int(int);
|
||||
fn write_uint(uint);
|
||||
@ -327,20 +330,20 @@ fn uint_to_be_bytes(n: uint, size: uint) -> [u8] {
|
||||
|
||||
obj new_writer(out: buf_writer) {
|
||||
fn get_buf_writer() -> buf_writer { ret out; }
|
||||
fn write_str(s: str) { out.write(str::bytes(s)); }
|
||||
fn write_line(s: str) {
|
||||
out.write(str::bytes(s));
|
||||
out.write(str::bytes("\n"));
|
||||
fn write_str(s: &istr) { out.write(istr::bytes(s)); }
|
||||
fn write_line(s: &istr) {
|
||||
out.write(istr::bytes(s));
|
||||
out.write(istr::bytes(~"\n"));
|
||||
}
|
||||
fn write_char(ch: char) {
|
||||
// FIXME needlessly consy
|
||||
|
||||
out.write(str::bytes(str::from_char(ch)));
|
||||
out.write(istr::bytes(istr::from_char(ch)));
|
||||
}
|
||||
fn write_int(n: int) { out.write(str::bytes(
|
||||
istr::to_estr(int::to_str(n, 10u)))); }
|
||||
fn write_uint(n: uint) { out.write(str::bytes(
|
||||
istr::to_estr(uint::to_str(n, 10u)))); }
|
||||
fn write_int(n: int) { out.write(istr::bytes(
|
||||
int::to_str(n, 10u))); }
|
||||
fn write_uint(n: uint) { out.write(istr::bytes(
|
||||
uint::to_str(n, 10u))); }
|
||||
fn write_bytes(bytes: &[u8]) { out.write(bytes); }
|
||||
fn write_le_uint(n: uint, size: uint) {
|
||||
out.write(uint_to_le_bytes(n, size));
|
||||
@ -353,14 +356,16 @@ obj new_writer(out: buf_writer) {
|
||||
}
|
||||
}
|
||||
|
||||
fn file_writer(path: str, flags: &[fileflag]) -> writer {
|
||||
fn file_writer(path: &istr, flags: &[fileflag]) -> writer {
|
||||
ret new_writer(file_buf_writer(path, flags));
|
||||
}
|
||||
|
||||
|
||||
// FIXME: fileflags
|
||||
fn buffered_file_buf_writer(path: str) -> buf_writer {
|
||||
let f = os::libc::fopen(str::buf(path), str::buf("w"));
|
||||
fn buffered_file_buf_writer(path: &istr) -> buf_writer {
|
||||
let path = istr::to_estr(path);
|
||||
let mode = "w";
|
||||
let f = os::libc::fopen(str::buf(path), str::buf(mode));
|
||||
if f as uint == 0u { log_err "error opening " + path; fail; }
|
||||
ret FILE_writer(f, option::some(@FILE_res(f)));
|
||||
}
|
||||
@ -372,7 +377,7 @@ fn stdout() -> writer { ret new_writer(fd_buf_writer(1, option::none)); }
|
||||
type str_writer =
|
||||
obj {
|
||||
fn get_writer() -> writer;
|
||||
fn get_str() -> str;
|
||||
fn get_str() -> istr;
|
||||
};
|
||||
|
||||
type mutable_byte_buf = @{mutable buf: [mutable u8], mutable pos: uint};
|
||||
@ -415,7 +420,7 @@ fn string_writer() -> str_writer {
|
||||
let buf: mutable_byte_buf = @{mutable buf: b, mutable pos: 0u};
|
||||
obj str_writer_wrap(wr: writer, buf: mutable_byte_buf) {
|
||||
fn get_writer() -> writer { ret wr; }
|
||||
fn get_str() -> str { ret str::unsafe_from_bytes(buf.buf); }
|
||||
fn get_str() -> istr { ret istr::unsafe_from_bytes(buf.buf); }
|
||||
}
|
||||
ret str_writer_wrap(new_writer(byte_buf_writer(buf)), buf);
|
||||
}
|
||||
@ -435,11 +440,11 @@ fn seek_in_buf(offset: int, pos: uint, len: uint, whence: seek_style) ->
|
||||
ret bpos as uint;
|
||||
}
|
||||
|
||||
fn read_whole_file_str(file: &str) -> str {
|
||||
str::unsafe_from_bytes(read_whole_file(file))
|
||||
fn read_whole_file_str(file: &istr) -> istr {
|
||||
istr::unsafe_from_bytes(read_whole_file(file))
|
||||
}
|
||||
|
||||
fn read_whole_file(file: &str) -> [u8] {
|
||||
fn read_whole_file(file: &istr) -> [u8] {
|
||||
|
||||
// FIXME: There's a lot of copying here
|
||||
file_reader(file).read_whole_stream()
|
||||
|
@ -119,26 +119,30 @@ fn run_tests_console_(opts: &test_opts, tests: &[test_desc],
|
||||
alt event {
|
||||
te_filtered(filtered_tests) {
|
||||
st.total = vec::len(filtered_tests);
|
||||
st.out.write_line(#fmt["\nrunning %u tests", st.total]);
|
||||
st.out.write_line(
|
||||
istr::from_estr(#fmt["\nrunning %u tests", st.total]));
|
||||
}
|
||||
te_wait(test) {
|
||||
st.out.write_str(
|
||||
istr::from_estr(#fmt["test %s ... ", test.name]));
|
||||
}
|
||||
te_wait(test) { st.out.write_str(#fmt["test %s ... ", test.name]); }
|
||||
te_result(test, result) {
|
||||
alt result {
|
||||
tr_ok. {
|
||||
st.passed += 1u;
|
||||
write_ok(st.out, st.use_color);
|
||||
st.out.write_line("");
|
||||
st.out.write_line(~"");
|
||||
}
|
||||
tr_failed. {
|
||||
st.failed += 1u;
|
||||
write_failed(st.out, st.use_color);
|
||||
st.out.write_line("");
|
||||
st.out.write_line(~"");
|
||||
st.failures += [test];
|
||||
}
|
||||
tr_ignored. {
|
||||
st.ignored += 1u;
|
||||
write_ignored(st.out, st.use_color);
|
||||
st.out.write_line("");
|
||||
st.out.write_line(~"");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -160,20 +164,22 @@ fn run_tests_console_(opts: &test_opts, tests: &[test_desc],
|
||||
let success = st.failed == 0u;
|
||||
|
||||
if !success {
|
||||
st.out.write_line("\nfailures:");
|
||||
st.out.write_line(~"\nfailures:");
|
||||
for test: test_desc in st.failures {
|
||||
let testname = test.name; // Satisfy alias analysis
|
||||
st.out.write_line(#fmt[" %s", testname]);
|
||||
st.out.write_line(istr::from_estr(#fmt[" %s", testname]));
|
||||
}
|
||||
}
|
||||
|
||||
st.out.write_str(#fmt["\nresult: "]);
|
||||
st.out.write_str(istr::from_estr(#fmt["\nresult: "]));
|
||||
if success {
|
||||
// There's no parallelism at this point so it's safe to use color
|
||||
write_ok(st.out, true);
|
||||
} else { write_failed(st.out, true); }
|
||||
st.out.write_str(#fmt[". %u passed; %u failed; %u ignored\n\n", st.passed,
|
||||
st.failed, st.ignored]);
|
||||
st.out.write_str(
|
||||
istr::from_estr(
|
||||
#fmt[". %u passed; %u failed; %u ignored\n\n", st.passed,
|
||||
st.failed, st.ignored]));
|
||||
|
||||
ret success;
|
||||
|
||||
@ -194,7 +200,7 @@ fn run_tests_console_(opts: &test_opts, tests: &[test_desc],
|
||||
if use_color && term::color_supported() {
|
||||
term::fg(out.get_buf_writer(), color);
|
||||
}
|
||||
out.write_str(word);
|
||||
out.write_str(istr::from_estr(word));
|
||||
if use_color && term::color_supported() {
|
||||
term::reset(out.get_buf_writer());
|
||||
}
|
||||
|
@ -107,8 +107,10 @@ fn main(argv: [str]) {
|
||||
|
||||
let elapsed = stop - start;
|
||||
|
||||
out.write_line(#fmt["%d\t%d\t%s", n, fibn,
|
||||
istr::to_estr(u64::str(elapsed))]);
|
||||
out.write_line(
|
||||
istr::from_estr(
|
||||
#fmt["%d\t%d\t%s", n, fibn,
|
||||
istr::to_estr(u64::str(elapsed))]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ import std::comm::recv;
|
||||
import std::comm::send;
|
||||
|
||||
fn map(filename: &[u8], emit: &map_reduce::putter<[u8], int>) {
|
||||
let f = io::file_reader(str::unsafe_from_bytes(filename));
|
||||
let f = io::file_reader(istr::unsafe_from_bytes(filename));
|
||||
|
||||
while true {
|
||||
alt read_word(f) {
|
||||
@ -202,7 +202,8 @@ fn main(argv: [str]) {
|
||||
if vec::len(argv) < 2u {
|
||||
let out = io::stdout();
|
||||
|
||||
out.write_line(#fmt["Usage: %s <filename> ...", argv[0]]);
|
||||
out.write_line(
|
||||
istr::from_estr(#fmt["Usage: %s <filename> ...", argv[0]]));
|
||||
|
||||
// TODO: run something just to make sure the code hasn't
|
||||
// broken yet. This is the unit test mode of this program.
|
||||
|
@ -14,6 +14,7 @@ import option = std::option::t;
|
||||
import std::option::some;
|
||||
import std::option::none;
|
||||
import std::str;
|
||||
import std::istr;
|
||||
import std::map;
|
||||
import std::vec;
|
||||
import std::io;
|
||||
@ -30,7 +31,7 @@ import std::comm::recv;
|
||||
import std::comm::send;
|
||||
|
||||
fn map(filename: str, emit: map_reduce::putter) {
|
||||
let f = io::file_reader(filename);
|
||||
let f = io::file_reader(istr::from_estr(filename));
|
||||
|
||||
|
||||
while true {
|
||||
@ -196,7 +197,8 @@ fn main(argv: [str]) {
|
||||
if vec::len(argv) < 2u {
|
||||
let out = io::stdout();
|
||||
|
||||
out.write_line(#fmt["Usage: %s <filename> ...", argv[0]]);
|
||||
out.write_line(istr::from_estr(
|
||||
#fmt["Usage: %s <filename> ...", argv[0]]));
|
||||
|
||||
// TODO: run something just to make sure the code hasn't
|
||||
// broken yet. This is the unit test mode of this program.
|
||||
|
@ -71,9 +71,9 @@ fn is_test_ignored(config: &config, testfile: &str) -> bool {
|
||||
}
|
||||
|
||||
iter iter_header(testfile: &str) -> str {
|
||||
let rdr = io::file_reader(testfile);
|
||||
let rdr = io::file_reader(istr::from_estr(testfile));
|
||||
while !rdr.eof() {
|
||||
let ln = rdr.read_line();
|
||||
let ln = istr::to_estr(rdr.read_line());
|
||||
|
||||
// Assume that any directives will be found before the first
|
||||
// module or function. This doesn't seem to be an optimization
|
||||
|
@ -73,7 +73,7 @@ fn run(handle: &handle, lib_path: &str, prog: &str, args: &[str],
|
||||
fn writeclose(fd: int, s: &option::t<str>) {
|
||||
if option::is_some(s) {
|
||||
let writer = io::new_writer(io::fd_buf_writer(fd, option::none));
|
||||
writer.write_str(option::get(s));
|
||||
writer.write_str(istr::from_estr(option::get(s)));
|
||||
}
|
||||
|
||||
os::libc::close(fd);
|
||||
|
@ -23,7 +23,7 @@ fn run(cx: &cx, _testfile: -[u8]) {
|
||||
let testfile = str::unsafe_from_bytes(_testfile);
|
||||
if cx.config.verbose {
|
||||
// We're going to be dumping a lot of info. Start on a new line.
|
||||
io::stdout().write_str("\n\n");
|
||||
io::stdout().write_str(~"\n\n");
|
||||
}
|
||||
log #fmt["running %s", testfile];
|
||||
let props = load_props(testfile);
|
||||
@ -87,7 +87,8 @@ fn run_pretty_test(cx: &cx, props: &test_props, testfile: &str) {
|
||||
let rounds =
|
||||
alt props.pp_exact { option::some(_) { 1 } option::none. { 2 } };
|
||||
|
||||
let srcs = [io::read_whole_file_str(testfile)];
|
||||
let srcs = [istr::to_estr(io::read_whole_file_str(
|
||||
istr::from_estr(testfile)))];
|
||||
|
||||
let round = 0;
|
||||
while round < rounds {
|
||||
@ -108,7 +109,7 @@ fn run_pretty_test(cx: &cx, props: &test_props, testfile: &str) {
|
||||
option::some(file) {
|
||||
let filepath = fs::connect(fs::dirname(
|
||||
istr::from_estr(testfile)), istr::from_estr(file));
|
||||
io::read_whole_file_str(istr::to_estr(filepath))
|
||||
istr::to_estr(io::read_whole_file_str(filepath))
|
||||
}
|
||||
option::none. { srcs[vec::len(srcs) - 2u] }
|
||||
};
|
||||
@ -159,7 +160,7 @@ actual:\n\
|
||||
------------------------------------------\n\
|
||||
\n",
|
||||
expected, actual];
|
||||
io::stdout().write_str(msg);
|
||||
io::stdout().write_str(istr::from_estr(msg));
|
||||
fail;
|
||||
}
|
||||
}
|
||||
@ -329,8 +330,9 @@ fn dump_output(config: &config, testfile: &str, out: &str, err: &str) {
|
||||
fn dump_output_file(config: &config, testfile: &str, out: &str,
|
||||
extension: &str) {
|
||||
let outfile = make_out_name(config, testfile, extension);
|
||||
let writer = io::file_writer(outfile, [io::create, io::truncate]);
|
||||
writer.write_str(out);
|
||||
let writer = io::file_writer(istr::from_estr(outfile),
|
||||
[io::create, io::truncate]);
|
||||
writer.write_str(istr::from_estr(out));
|
||||
}
|
||||
|
||||
// FIXME (726): Can't use file_writer on mac
|
||||
@ -361,21 +363,23 @@ fn maybe_dump_to_stdout(config: &config, out: &str, err: &str) {
|
||||
let sep1 = #fmt["------%s------------------------------", "stdout"];
|
||||
let sep2 = #fmt["------%s------------------------------", "stderr"];
|
||||
let sep3 = "------------------------------------------";
|
||||
io::stdout().write_line(sep1);
|
||||
io::stdout().write_line(out);
|
||||
io::stdout().write_line(sep2);
|
||||
io::stdout().write_line(err);
|
||||
io::stdout().write_line(sep3);
|
||||
io::stdout().write_line(istr::from_estr(sep1));
|
||||
io::stdout().write_line(istr::from_estr(out));
|
||||
io::stdout().write_line(istr::from_estr(sep2));
|
||||
io::stdout().write_line(istr::from_estr(err));
|
||||
io::stdout().write_line(istr::from_estr(sep3));
|
||||
}
|
||||
}
|
||||
|
||||
fn error(err: &str) { io::stdout().write_line(#fmt["\nerror: %s", err]); }
|
||||
fn error(err: &str) {
|
||||
io::stdout().write_line(istr::from_estr(#fmt["\nerror: %s", err]));
|
||||
}
|
||||
|
||||
fn fatal(err: &str) -> ! { error(err); fail; }
|
||||
|
||||
fn fatal_procres(err: &str, procres: procres) -> ! {
|
||||
let msg =
|
||||
#fmt["\n\
|
||||
istr::from_estr(#fmt["\n\
|
||||
error: %s\n\
|
||||
command: %s\n\
|
||||
stdout:\n\
|
||||
@ -387,7 +391,7 @@ stderr:\n\
|
||||
%s\n\
|
||||
------------------------------------------\n\
|
||||
\n",
|
||||
err, procres.cmdline, procres.stdout, procres.stderr];
|
||||
err, procres.cmdline, procres.stdout, procres.stderr]);
|
||||
io::stdout().write_str(msg);
|
||||
fail;
|
||||
}
|
||||
|
@ -25,5 +25,7 @@ fn lib_path_env_var() -> str { "PATH" }
|
||||
|
||||
fn logv(config: &config, s: &str) {
|
||||
log s;
|
||||
if config.verbose { io::stdout().write_line(s); }
|
||||
if config.verbose {
|
||||
io::stdout().write_line(std::istr::from_estr(s));
|
||||
}
|
||||
}
|
||||
|
@ -1,15 +1,15 @@
|
||||
// -*- rust -*-
|
||||
use std;
|
||||
import std::io;
|
||||
import std::str;
|
||||
import std::istr;
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
#[cfg(target_os = "win32")]
|
||||
#[test]
|
||||
fn test_simple() {
|
||||
let tmpfile: str = "test/run-pass/lib-io-test-simple.tmp";
|
||||
let tmpfile: istr = ~"test/run-pass/lib-io-test-simple.tmp";
|
||||
log tmpfile;
|
||||
let frood: str = "A hoopy frood who really knows where his towel is.";
|
||||
let frood: istr = ~"A hoopy frood who really knows where his towel is.";
|
||||
log frood;
|
||||
{
|
||||
let out: io::writer =
|
||||
@ -17,9 +17,9 @@ fn test_simple() {
|
||||
out.write_str(frood);
|
||||
}
|
||||
let inp: io::reader = io::file_reader(tmpfile);
|
||||
let frood2: str = inp.read_c_str();
|
||||
let frood2: istr = inp.read_c_str();
|
||||
log frood2;
|
||||
assert (str::eq(frood, frood2));
|
||||
assert (istr::eq(frood, frood2));
|
||||
}
|
||||
|
||||
// FIXME (726)
|
||||
|
@ -3,7 +3,7 @@ import std::run;
|
||||
import std::os;
|
||||
import std::io;
|
||||
import std::option;
|
||||
import std::str;
|
||||
import std::istr;
|
||||
import std::vec;
|
||||
|
||||
// Regression test for memory leaks
|
||||
@ -36,7 +36,7 @@ fn test_pipes() {
|
||||
os::libc::close(pipe_err.out);
|
||||
|
||||
if pid == -1 { fail; }
|
||||
let expected = "test";
|
||||
let expected = ~"test";
|
||||
writeclose(pipe_in.out, expected);
|
||||
let actual = readclose(pipe_out.in);
|
||||
readclose(pipe_err.in);
|
||||
@ -46,21 +46,21 @@ fn test_pipes() {
|
||||
log actual;
|
||||
assert (expected == actual);
|
||||
|
||||
fn writeclose(fd: int, s: &str) {
|
||||
fn writeclose(fd: int, s: &istr) {
|
||||
let writer = io::new_writer(io::fd_buf_writer(fd, option::none));
|
||||
writer.write_str(s);
|
||||
|
||||
os::libc::close(fd);
|
||||
}
|
||||
|
||||
fn readclose(fd: int) -> str {
|
||||
fn readclose(fd: int) -> istr {
|
||||
// Copied from run::program_output
|
||||
let file = os::fd_FILE(fd);
|
||||
let reader = io::new_reader(io::FILE_buf_reader(file, option::none));
|
||||
let buf = "";
|
||||
let buf = ~"";
|
||||
while !reader.eof() {
|
||||
let bytes = reader.read_bytes(4096u);
|
||||
buf += str::unsafe_from_bytes(bytes);
|
||||
buf += istr::unsafe_from_bytes(bytes);
|
||||
}
|
||||
os::libc::fclose(file);
|
||||
ret buf;
|
||||
|
Loading…
x
Reference in New Issue
Block a user