Skip to content

Commit

Permalink
Change 'print(fmt!(...))' to printf!/printfln! in src/lib*
Browse files Browse the repository at this point in the history
  • Loading branch information
poiru authored and thestinger committed Jul 24, 2013
1 parent af5a17b commit d047cf1
Show file tree
Hide file tree
Showing 27 changed files with 103 additions and 112 deletions.
14 changes: 7 additions & 7 deletions src/libextra/base64.rs
Expand Up @@ -75,7 +75,7 @@ impl<'self> ToBase64 for &'self [u8] {
*
* fn main () {
* let str = [52,32].to_base64(standard);
* println(fmt!("%s", str));
* printfln!("%s", str);
* }
* ~~~
*/
Expand Down Expand Up @@ -164,7 +164,7 @@ impl<'self> ToBase64 for &'self str {
*
* fn main () {
* let str = "Hello, World".to_base64(standard);
* println(fmt!("%s",str));
* printfln!("%s", str);
* }
* ~~~
*
Expand Down Expand Up @@ -194,9 +194,9 @@ impl<'self> FromBase64 for &'self [u8] {
*
* fn main () {
* let str = [52,32].to_base64(standard);
* println(fmt!("%s", str));
* printfln!("%s", str);
* let bytes = str.from_base64();
* println(fmt!("%?",bytes));
* printfln!("%?", bytes);
* }
* ~~~
*/
Expand Down Expand Up @@ -271,11 +271,11 @@ impl<'self> FromBase64 for &'self str {
*
* fn main () {
* let hello_str = "Hello, World".to_base64(standard);
* println(fmt!("%s",hello_str));
* printfln!("%s", hello_str);
* let bytes = hello_str.from_base64();
* println(fmt!("%?",bytes));
* printfln!("%?", bytes);
* let result_str = str::from_bytes(bytes);
* println(fmt!("%s",result_str));
* printfln!("%s", result_str);
* }
* ~~~
*/
Expand Down
2 changes: 1 addition & 1 deletion src/libextra/future.rs
Expand Up @@ -19,7 +19,7 @@
* # fn make_a_sandwich() {};
* let mut delayed_fib = extra::future::spawn (|| fib(5000) );
* make_a_sandwich();
* println(fmt!("fib(5000) = %?", delayed_fib.get()))
* printfln!("fib(5000) = %?", delayed_fib.get())
* ~~~
*/

Expand Down
2 changes: 1 addition & 1 deletion src/libextra/getopts.rs
Expand Up @@ -44,7 +44,7 @@
* }
*
* fn print_usage(program: &str, _opts: &[Opt]) {
* println(fmt!("Usage: %s [options]", program));
* printfln!("Usage: %s [options]", program);
* println("-o\t\tOutput");
* println("-h --help\tUsage");
* }
Expand Down
2 changes: 1 addition & 1 deletion src/libextra/task_pool.rs
Expand Up @@ -103,6 +103,6 @@ fn test_task_pool() {
};
let mut pool = TaskPool::new(4, Some(SingleThreaded), f);
for 8.times {
pool.execute(|i| println(fmt!("Hello from thread %u!", *i)));
pool.execute(|i| printfln!("Hello from thread %u!", *i));
}
}
2 changes: 1 addition & 1 deletion src/libextra/treemap.rs
Expand Up @@ -1263,7 +1263,7 @@ mod test_set {

let mut n = 0;
for m.iter().advance |x| {
println(fmt!("%?", x));
printfln!(x);
assert_eq!(*x, n);
n += 1
}
Expand Down
9 changes: 4 additions & 5 deletions src/librust/rust.rs
Expand Up @@ -132,13 +132,13 @@ fn cmd_help(args: &[~str]) -> ValidUsage {
match find_cmd(command_string) {
Some(command) => {
match command.action {
CallMain(prog, _) => io::println(fmt!(
CallMain(prog, _) => printfln!(
"The %s command is an alias for the %s program.",
command.cmd, prog)),
command.cmd, prog),
_ => ()
}
match command.usage_full {
UsgStr(msg) => io::println(fmt!("%s\n", msg)),
UsgStr(msg) => printfln!("%s\n", msg),
UsgCall(f) => f(),
}
Valid(0)
Expand Down Expand Up @@ -211,8 +211,7 @@ fn usage() {

for COMMANDS.iter().advance |command| {
let padding = " ".repeat(INDENT - command.cmd.len());
io::println(fmt!(" %s%s%s",
command.cmd, padding, command.usage_line));
printfln!(" %s%s%s", command.cmd, padding, command.usage_line);
}

io::print(
Expand Down
8 changes: 4 additions & 4 deletions src/librustc/back/passes.rs
Expand Up @@ -191,15 +191,15 @@ pub fn list_passes() {

io::println("\nAnalysis Passes:");
for analysis_passes.iter().advance |&(name, desc)| {
io::println(fmt!(" %-30s -- %s", name, desc));
printfln!(" %-30s -- %s", name, desc);
}
io::println("\nTransformation Passes:");
for transform_passes.iter().advance |&(name, desc)| {
io::println(fmt!(" %-30s -- %s", name, desc));
printfln!(" %-30s -- %s", name, desc);
}
io::println("\nUtility Passes:");
for utility_passes.iter().advance |&(name, desc)| {
io::println(fmt!(" %-30s -- %s", name, desc));
printfln!(" %-30s -- %s", name, desc);
}
}

Expand Down Expand Up @@ -344,7 +344,7 @@ fn passes_exist() {
if failed.len() > 0 {
io::println("Some passes don't exist:");
for failed.iter().advance |&n| {
io::println(fmt!(" %s", n));
printfln!(" %s", n);
}
fail!();
}
Expand Down
20 changes: 10 additions & 10 deletions src/librustc/metadata/encoder.rs
Expand Up @@ -1624,16 +1624,16 @@ pub fn encode_metadata(parms: EncodeParams, crate: &Crate) -> ~[u8] {
}

io::println("metadata stats:");
io::println(fmt!(" inline bytes: %u", ecx.stats.inline_bytes));
io::println(fmt!(" attribute bytes: %u", ecx.stats.attr_bytes));
io::println(fmt!(" dep bytes: %u", ecx.stats.dep_bytes));
io::println(fmt!(" lang item bytes: %u", ecx.stats.lang_item_bytes));
io::println(fmt!(" link args bytes: %u", ecx.stats.link_args_bytes));
io::println(fmt!(" misc bytes: %u", ecx.stats.misc_bytes));
io::println(fmt!(" item bytes: %u", ecx.stats.item_bytes));
io::println(fmt!(" index bytes: %u", ecx.stats.index_bytes));
io::println(fmt!(" zero bytes: %u", ecx.stats.zero_bytes));
io::println(fmt!(" total bytes: %u", ecx.stats.total_bytes));
printfln!(" inline bytes: %u", ecx.stats.inline_bytes);
printfln!(" attribute bytes: %u", ecx.stats.attr_bytes);
printfln!(" dep bytes: %u", ecx.stats.dep_bytes);
printfln!(" lang item bytes: %u", ecx.stats.lang_item_bytes);
printfln!(" link args bytes: %u", ecx.stats.link_args_bytes);
printfln!(" misc bytes: %u", ecx.stats.misc_bytes);
printfln!(" item bytes: %u", ecx.stats.item_bytes);
printfln!(" index bytes: %u", ecx.stats.index_bytes);
printfln!(" zero bytes: %u", ecx.stats.zero_bytes);
printfln!(" total bytes: %u", ecx.stats.total_bytes);
}

// Pad this, since something (LLVM, presumably) is cutting off the
Expand Down
20 changes: 10 additions & 10 deletions src/librustc/middle/borrowck/mod.rs
Expand Up @@ -93,16 +93,16 @@ pub fn check_crate(

if tcx.sess.borrowck_stats() {
io::println("--- borrowck stats ---");
io::println(fmt!("paths requiring guarantees: %u",
bccx.stats.guaranteed_paths));
io::println(fmt!("paths requiring loans : %s",
make_stat(bccx, bccx.stats.loaned_paths_same)));
io::println(fmt!("paths requiring imm loans : %s",
make_stat(bccx, bccx.stats.loaned_paths_imm)));
io::println(fmt!("stable paths : %s",
make_stat(bccx, bccx.stats.stable_paths)));
io::println(fmt!("paths requiring purity : %s",
make_stat(bccx, bccx.stats.req_pure_paths)));
printfln!("paths requiring guarantees: %u",
bccx.stats.guaranteed_paths);
printfln!("paths requiring loans : %s",
make_stat(bccx, bccx.stats.loaned_paths_same));
printfln!("paths requiring imm loans : %s",
make_stat(bccx, bccx.stats.loaned_paths_imm));
printfln!("stable paths : %s",
make_stat(bccx, bccx.stats.stable_paths));
printfln!("paths requiring purity : %s",
make_stat(bccx, bccx.stats.req_pure_paths));
}

return (bccx.root_map, bccx.write_guard_map);
Expand Down
24 changes: 11 additions & 13 deletions src/librustc/middle/trans/base.rs
Expand Up @@ -3011,32 +3011,30 @@ pub fn trans_crate(sess: session::Session,
write_metadata(ccx, crate);
if ccx.sess.trans_stats() {
io::println("--- trans stats ---");
io::println(fmt!("n_static_tydescs: %u",
ccx.stats.n_static_tydescs));
io::println(fmt!("n_glues_created: %u",
ccx.stats.n_glues_created));
io::println(fmt!("n_null_glues: %u", ccx.stats.n_null_glues));
io::println(fmt!("n_real_glues: %u", ccx.stats.n_real_glues));

io::println(fmt!("n_fns: %u", ccx.stats.n_fns));
io::println(fmt!("n_monos: %u", ccx.stats.n_monos));
io::println(fmt!("n_inlines: %u", ccx.stats.n_inlines));
io::println(fmt!("n_closures: %u", ccx.stats.n_closures));
printfln!("n_static_tydescs: %u", ccx.stats.n_static_tydescs);
printfln!("n_glues_created: %u", ccx.stats.n_glues_created);
printfln!("n_null_glues: %u", ccx.stats.n_null_glues);
printfln!("n_real_glues: %u", ccx.stats.n_real_glues);

printfln!("n_fns: %u", ccx.stats.n_fns);
printfln!("n_monos: %u", ccx.stats.n_monos);
printfln!("n_inlines: %u", ccx.stats.n_inlines);
printfln!("n_closures: %u", ccx.stats.n_closures);
io::println("fn stats:");
do sort::quick_sort(ccx.stats.fn_stats) |&(_, _, insns_a), &(_, _, insns_b)| {
insns_a > insns_b
}
for ccx.stats.fn_stats.iter().advance |tuple| {
match *tuple {
(ref name, ms, insns) => {
io::println(fmt!("%u insns, %u ms, %s", insns, ms, *name));
printfln!("%u insns, %u ms, %s", insns, ms, *name);
}
}
}
}
if ccx.sess.count_llvm_insns() {
for ccx.stats.llvm_insns.iter().advance |(k, v)| {
io::println(fmt!("%-7u %s", *v, *k));
printfln!("%-7u %s", *v, *k);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/librustc/middle/trans/callee.rs
Expand Up @@ -654,9 +654,9 @@ pub fn trans_call_inner(in_cx: @mut Block,

// Uncomment this to debug calls.
/*
io::println(fmt!("calling: %s", bcx.val_to_str(llfn)));
printfln!("calling: %s", bcx.val_to_str(llfn));
for llargs.iter().advance |llarg| {
io::println(fmt!("arg: %s", bcx.val_to_str(*llarg)));
printfln!("arg: %s", bcx.val_to_str(*llarg));
}
io::println("---");
*/
Expand Down
5 changes: 2 additions & 3 deletions src/librustc/middle/trans/glue.rs
Expand Up @@ -37,7 +37,6 @@ use util::ppaux::ty_to_short_str;

use middle::trans::type_::Type;

use std::io;
use std::libc::c_uint;
use std::str;
use syntax::ast;
Expand Down Expand Up @@ -649,8 +648,8 @@ pub fn declare_tydesc(ccx: &mut CrateContext, t: ty::t) -> @mut tydesc_info {
let llty = type_of(ccx, t);

if ccx.sess.count_type_sizes() {
io::println(fmt!("%u\t%s", llsize_of_real(ccx, llty),
ppaux::ty_to_str(ccx.tcx, t)));
printfln!("%u\t%s", llsize_of_real(ccx, llty),
ppaux::ty_to_str(ccx.tcx, t));
}

let llsize = llsize_of(ccx, llty);
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/ty.rs
Expand Up @@ -2712,7 +2712,7 @@ pub fn node_id_to_trait_ref(cx: ctxt, id: ast::node_id) -> @ty::TraitRef {
}

pub fn node_id_to_type(cx: ctxt, id: ast::node_id) -> t {
//io::println(fmt!("%?/%?", id, cx.node_types.len()));
//printfln!("%?/%?", id, cx.node_types.len());
match cx.node_types.find(&(id as uint)) {
Some(&t) => t,
None => cx.sess.bug(
Expand Down
34 changes: 17 additions & 17 deletions src/librustc/rustc.rs
Expand Up @@ -128,28 +128,28 @@ pub fn version(argv0: &str) {
let mut vers = ~"unknown version";
let env_vers = env!("CFG_VERSION");
if env_vers.len() != 0 { vers = env_vers.to_owned(); }
io::println(fmt!("%s %s", argv0, vers));
io::println(fmt!("host: %s", host_triple()));
printfln!("%s %s", argv0, vers);
printfln!("host: %s", host_triple());
}

pub fn usage(argv0: &str) {
let message = fmt!("Usage: %s [OPTIONS] INPUT", argv0);
io::println(fmt!("%s\
printfln!("%s\
Additional help:
-W help Print 'lint' options and default settings
-Z help Print internal options for debugging rustc\n",
groups::usage(message, optgroups())));
groups::usage(message, optgroups()));
}

pub fn describe_warnings() {
use extra::sort::Sort;
io::println(fmt!("
printfln!("
Available lint options:
-W <foo> Warn about <foo>
-A <foo> Allow <foo>
-D <foo> Deny <foo>
-F <foo> Forbid <foo> (deny, and deny all overrides)
"));
");

let lint_dict = lint::get_lint_dict();
let mut lint_dict = lint_dict.consume()
Expand All @@ -164,28 +164,28 @@ Available lint options:
fn padded(max: uint, s: &str) -> ~str {
str::from_bytes(vec::from_elem(max - s.len(), ' ' as u8)) + s
}
io::println(fmt!("\nAvailable lint checks:\n"));
io::println(fmt!(" %s %7.7s %s",
padded(max_key, "name"), "default", "meaning"));
io::println(fmt!(" %s %7.7s %s\n",
padded(max_key, "----"), "-------", "-------"));
printfln!("\nAvailable lint checks:\n");
printfln!(" %s %7.7s %s",
padded(max_key, "name"), "default", "meaning");
printfln!(" %s %7.7s %s\n",
padded(max_key, "----"), "-------", "-------");
for lint_dict.consume_iter().advance |(spec, name)| {
let name = name.replace("_", "-");
io::println(fmt!(" %s %7.7s %s",
padded(max_key, name),
lint::level_to_str(spec.default),
spec.desc));
printfln!(" %s %7.7s %s",
padded(max_key, name),
lint::level_to_str(spec.default),
spec.desc);
}
io::println("");
}

pub fn describe_debug_flags() {
io::println(fmt!("\nAvailable debug options:\n"));
printfln!("\nAvailable debug options:\n");
let r = session::debugging_opts_map();
for r.iter().advance |tuple| {
match *tuple {
(ref name, ref desc, _) => {
io::println(fmt!(" -Z %-20s -- %s", *name, *desc));
printfln!(" -Z %-20s -- %s", *name, *desc);
}
}
}
Expand Down
3 changes: 1 addition & 2 deletions src/librustc/util/common.rs
Expand Up @@ -14,15 +14,14 @@ use syntax::codemap::{span};
use syntax::visit;

use std::hashmap::HashSet;
use std::io;
use extra;

pub fn time<T>(do_it: bool, what: ~str, thunk: &fn() -> T) -> T {
if !do_it { return thunk(); }
let start = extra::time::precise_time_s();
let rv = thunk();
let end = extra::time::precise_time_s();
io::println(fmt!("time: %3.3f s\t%s", end - start, what));
printfln!("time: %3.3f s\t%s", end - start, what);
rv
}

Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/config.rs
Expand Up @@ -74,7 +74,7 @@ pub fn usage() {
println("Options:\n");
let r = opts();
for r.iter().advance |opt| {
println(fmt!(" %s", opt.second()));
printfln!(" %s", opt.second());
}
println("");
}
Expand Down
3 changes: 1 addition & 2 deletions src/librustdoc/rustdoc.rs
Expand Up @@ -23,7 +23,6 @@ extern mod extra;
extern mod rustc;
extern mod syntax;

use std::io;
use std::os;

use config::Config;
Expand Down Expand Up @@ -69,7 +68,7 @@ pub fn main() {
let config = match config::parse_config(args) {
Ok(config) => config,
Err(err) => {
io::println(fmt!("error: %s", err));
printfln!("error: %s", err);
return;
}
};
Expand Down

0 comments on commit d047cf1

Please sign in to comment.