Merge pull request #453 from ebfe/fix-build-master

Fix build with rust master
This commit is contained in:
Heather 2014-11-22 12:24:34 +04:00
commit be37a74af3
52 changed files with 203 additions and 205 deletions

2
deps/rust-crypto vendored

@ -1 +1 @@
Subproject commit 2fcd4c81de3f04c95d69af03d731dae3de7ae301
Subproject commit bd7b061e7e22864352e29d6fe453842727916ce8

View file

@ -68,7 +68,7 @@ pub fn uumain(args: Vec<String>) -> int {
Some(s) => match from_str(s.as_slice()) {
Some(s) => s,
None => {
error!("error: {:s}", "Argument to option 'wrap' improperly formatted.");
error!("error: {}", "Argument to option 'wrap' improperly formatted.");
panic!()
}
},
@ -165,7 +165,7 @@ fn encode(input: &mut Reader, line_wrap: uint) {
}
fn help(progname: &str, usage: &str) {
println!("Usage: {:s} [OPTION]... [FILE]", progname);
println!("Usage: {} [OPTION]... [FILE]", progname);
println!("");
println(usage);

View file

@ -38,8 +38,8 @@ pub fn uumain(args: Vec<String>) -> int {
};
if matches.opt_present("help") {
println!("Usage: {0:s} NAME [SUFFIX]", program);
println!(" or: {0:s} OPTION", program);
println!("Usage: {0} NAME [SUFFIX]", program);
println!(" or: {0} OPTION", program);
println!("Print NAME with any leading directory components removed.");
println!("If specified, also remove a trailing SUFFIX.");

View file

@ -44,7 +44,7 @@ pub fn uumain(args: Vec<String>) -> int {
println!("cat 1.0.0");
println!("");
println!("Usage:");
println!(" {0:s} [OPTION]... [FILE]...", program);
println!(" {0} [OPTION]... [FILE]...", program);
println!("");
print(getopts::usage("Concatenate FILE(s), or standard input, to \
standard output.", &opts).as_slice());
@ -119,7 +119,7 @@ fn write_lines(files: Vec<String>, number: NumberingMode, squeeze_blank: bool,
if in_buf[pos] == '\n' as u8 {
if !at_line_start || !squeeze_blank {
if at_line_start && number == NumberingMode::NumberAll {
(write!(&mut writer, "{0:6u}\t", line_counter)).unwrap();
(write!(&mut writer, "{0:6}\t", line_counter)).unwrap();
line_counter += 1;
}
if show_ends {
@ -134,7 +134,7 @@ fn write_lines(files: Vec<String>, number: NumberingMode, squeeze_blank: bool,
continue;
}
if at_line_start && number != NumberingMode::NumberNone {
(write!(&mut writer, "{0:6u}\t", line_counter)).unwrap();
(write!(&mut writer, "{0:6}\t", line_counter)).unwrap();
line_counter += 1;
}
match in_buf.slice_from(pos).iter().position(|c| *c == '\n' as u8) {
@ -192,7 +192,7 @@ fn write_bytes(files: Vec<String>, number: NumberingMode, squeeze_blank: bool,
if byte == '\n' as u8 {
if !at_line_start || !squeeze_blank {
if at_line_start && number == NumberingMode::NumberAll {
(write!(&mut writer, "{0:6u}\t", line_counter)).unwrap();
(write!(&mut writer, "{0:6}\t", line_counter)).unwrap();
line_counter += 1;
}
if show_ends {
@ -207,7 +207,7 @@ fn write_bytes(files: Vec<String>, number: NumberingMode, squeeze_blank: bool,
continue;
}
if at_line_start && number != NumberingMode::NumberNone {
(write!(&mut writer, "{0:6u}\t", line_counter)).unwrap();
(write!(&mut writer, "{0:6}\t", line_counter)).unwrap();
line_counter += 1;
at_line_start = false;
}
@ -284,7 +284,7 @@ fn open(path: &str) -> Option<(Box<Reader>, bool)> {
match File::open(&std::path::Path::new(path)) {
Ok(f) => Some((box f as Box<Reader>, false)),
Err(e) => {
(writeln!(stderr(), "cat: {0:s}: {1:s}", path, e.to_string())).unwrap();
(writeln!(&mut stderr(), "cat: {0}: {1}", path, e.to_string())).unwrap();
None
},
}

View file

@ -15,7 +15,6 @@
extern crate getopts;
extern crate libc;
extern crate native;
extern crate regex;
#[phase(plugin)] extern crate regex_macros;
@ -145,7 +144,7 @@ fn verify_mode(mode: &str) -> Result<(), String> {
Ok(())
}
fn chmod(files: Vec<String>, changes: bool, quiet: bool, verbose: bool, preserve_root: bool, recursive: bool, fmode: Option<u32>, cmode: Option<&String>) -> Result<(), int> {
fn chmod(files: Vec<String>, changes: bool, quiet: bool, verbose: bool, preserve_root: bool, recursive: bool, fmode: Option<libc::mode_t>, cmode: Option<&String>) -> Result<(), int> {
let mut r = Ok(());
for filename in files.iter() {
@ -181,7 +180,7 @@ fn chmod(files: Vec<String>, changes: bool, quiet: bool, verbose: bool, preserve
r
}
fn chmod_file(file: &Path, name: &str, changes: bool, quiet: bool, verbose: bool, fmode: Option<u32>, cmode: Option<&String>) -> Result<(), int> {
fn chmod_file(file: &Path, name: &str, changes: bool, quiet: bool, verbose: bool, fmode: Option<libc::mode_t>, cmode: Option<&String>) -> Result<(), int> {
let path = name.to_c_str();
match fmode {
Some(mode) => {
@ -279,7 +278,7 @@ fn chmod_file(file: &Path, name: &str, changes: bool, quiet: bool, verbose: bool
'+' | '-' | '=' => (ch, change.slice_from(1)),
_ => ('=', change)
};
let mode = from_str_radix::<u32>(slice, 8).unwrap(); // already verified
let mode = from_str_radix::<u32>(slice, 8).unwrap() as libc::mode_t; // already verified
match action {
'+' => fperm |= mode,
'-' => fperm &= !mode,

View file

@ -65,7 +65,7 @@ pub fn uumain(args: Vec<String>) -> int {
if opts.free.len() == 0 {
println!("Missing operand: NEWROOT");
println!("Try `{:s} --help` for more information.", program.as_slice());
println!("Try `{} --help` for more information.", program.as_slice());
return 1
}
@ -108,7 +108,7 @@ fn set_context(root: &Path, options: &getopts::Matches) {
Some(ref u) => {
let s: Vec<&str> = u.as_slice().split(':').collect();
if s.len() != 2 {
crash!(1, "invalid userspec: `{:s}`", u.as_slice())
crash!(1, "invalid userspec: `{}`", u.as_slice())
};
s
}
@ -131,7 +131,7 @@ fn enter_chroot(root: &Path) {
chroot(".".to_c_str().unwrap() as *const libc::c_char)
};
if err != 0 {
crash!(1, "cannot chroot to {}: {:s}", root_str, strerror(err).as_slice())
crash!(1, "cannot chroot to {}: {}", root_str, strerror(err).as_slice())
};
}
@ -143,7 +143,7 @@ fn set_main_group(group: &str) {
};
let err = unsafe { setgid(group_id) };
if err != 0 {
crash!(1, "cannot set gid to {:u}: {:s}", group_id, strerror(err).as_slice())
crash!(1, "cannot set gid to {}: {}", group_id, strerror(err).as_slice())
}
}
}
@ -175,7 +175,7 @@ fn set_groups_from_str(groups: &str) {
);
let err = set_groups(groups_vec);
if err != 0 {
crash!(1, "cannot set groups: {:s}", strerror(err).as_slice())
crash!(1, "cannot set groups: {}", strerror(err).as_slice())
}
}
}
@ -185,7 +185,7 @@ fn set_user(user: &str) {
let user_id = get_pw_from_args(&vec!(String::from_str(user))).unwrap().pw_uid;
let err = unsafe { setuid(user_id as libc::uid_t) };
if err != 0 {
crash!(1, "cannot set user to {:s}: {:s}", user, strerror(err).as_slice())
crash!(1, "cannot set user to {}: {}", user, strerror(err).as_slice())
}
}
}
@ -204,9 +204,9 @@ fn version() {
fn help_menu(program: &str, options: &[getopts::OptGroup]) {
version();
println!("Usage:");
println!(" {:s} [OPTION]… NEWROOT [COMMAND [ARG]…]", program);
println!(" {} [OPTION]… NEWROOT [COMMAND [ARG]…]", program);
println!("");
print!("{:s}", usage(
print!("{}", usage(
"Run COMMAND with root directory set to NEWROOT.\n\
If COMMAND is not specified, it defaults to '${SHELL} -i'. \
If ${SHELL} is not set, /bin/sh is used.", options))

View file

@ -118,7 +118,7 @@ pub fn get_pw_from_args(free: &Vec<String>) -> Option<c_passwd> {
if pw_pointer.is_not_null() {
Some(unsafe { read(pw_pointer) })
} else {
crash!(1, "{:s}: no such user", username);
crash!(1, "{}: no such user", username);
}
// Passed the username as a string
@ -129,7 +129,7 @@ pub fn get_pw_from_args(free: &Vec<String>) -> Option<c_passwd> {
if pw_pointer.is_not_null() {
Some(unsafe { read(pw_pointer) })
} else {
crash!(1, "{:s}: no such user", username);
crash!(1, "{}: no such user", username);
}
}
} else {
@ -210,7 +210,7 @@ pub fn group(possible_pw: Option<c_passwd>, nflag: bool) {
match groups {
Err(errno) =>
crash!(1, "failed to get group list (errno={:u})", errno),
crash!(1, "failed to get group list (errno={})", errno),
Ok(groups) => {
for &g in groups.iter() {
if nflag {
@ -219,10 +219,10 @@ pub fn group(possible_pw: Option<c_passwd>, nflag: bool) {
let name = unsafe {
from_buf(read(group).gr_name as *const u8)
};
print!("{:s} ", name);
print!("{} ", name);
}
} else {
print!("{:u} ", g);
print!("{} ", g);
}
}
println!("");

View file

@ -88,7 +88,7 @@ macro_rules! return_if_err(
#[macro_export]
macro_rules! pipe_print(
($($args:expr),+) => (
match write!(&mut ::std::io::stdout() as &mut Writer, $($args),+) {
match write!(&mut ::std::io::stdout(), $($args),+) {
Ok(_) => true,
Err(f) => {
if f.kind == ::std::io::BrokenPipe {
@ -104,7 +104,7 @@ macro_rules! pipe_print(
#[macro_export]
macro_rules! pipe_println(
($($args:expr),+) => (
match writeln!(&mut ::std::io::stdout() as &mut Writer, $($args),+) {
match writeln!(&mut ::std::io::stdout(), $($args),+) {
Ok(_) => true,
Err(f) => {
if f.kind == ::std::io::BrokenPipe {

View file

@ -102,13 +102,13 @@ fn copy(matches: getopts::Matches) {
Err(e) => if e.kind == io::FileNotFound {
false
} else {
error!("error: {:s}", e.to_string());
error!("error: {}", e.to_string());
panic!()
}
};
if same_file {
error!("error: \"{:s}\" and \"{:s}\" are the same file",
error!("error: \"{}\" and \"{}\" are the same file",
source.display().to_string(),
dest.display().to_string());
panic!();
@ -118,7 +118,7 @@ fn copy(matches: getopts::Matches) {
if io_result.is_err() {
let err = io_result.unwrap_err();
error!("error: {:s}", err.to_string());
error!("error: {}", err.to_string());
panic!();
}
} else {
@ -129,7 +129,7 @@ fn copy(matches: getopts::Matches) {
for source in sources.iter() {
if fs::stat(source).unwrap().kind != io::TypeFile {
error!("error: \"{:s}\" is not a file", source.display().to_string());
error!("error: \"{}\" is not a file", source.display().to_string());
continue;
}
@ -137,13 +137,13 @@ fn copy(matches: getopts::Matches) {
full_dest.push(source.filename_str().unwrap());
println!("{:s}", full_dest.display().to_string());
println!("{}", full_dest.display().to_string());
let io_result = fs::copy(source, &full_dest);
if io_result.is_err() {
let err = io_result.unwrap_err();
error!("error: {:s}", err.to_string());
error!("error: {}", err.to_string());
panic!()
}
}

View file

@ -29,10 +29,10 @@ pub fn uumain(args: Vec<String>) -> int {
};
if matches.opt_present("help") {
println!("dirname {:s} - strip last component from file name", VERSION);
println!("dirname {} - strip last component from file name", VERSION);
println!("");
println!("Usage:");
println!(" {0:s} [OPTION] NAME...", program);
println!(" {0} [OPTION] NAME...", program);
println!("");
print(getopts::usage("Output each NAME with its last non-slash component and trailing slashes
removed; if NAME contains no /'s, output '.' (meaning the current
@ -41,7 +41,7 @@ directory).", &opts).as_slice());
}
if matches.opt_present("version") {
println!("dirname version: {:s}", VERSION);
println!("dirname version: {}", VERSION);
return 0;
}
@ -60,8 +60,8 @@ directory).", &opts).as_slice());
print(separator);
}
} else {
println!("{0:s}: missing operand", program);
println!("Try '{0:s} --help' for more information.", program);
println!("{0}: missing operand", program);
println!("Try '{0} --help' for more information.", program);
return 1;
}

View file

@ -197,11 +197,11 @@ ers of 1000).",
let max_depth = max_depth_str.as_ref().and_then(|s| from_str::<uint>(s.as_slice()));
match (max_depth_str, max_depth) {
(Some(ref s), _) if summarize => {
show_error!("summarizing conflicts with --max-depth={:s}", *s);
show_error!("summarizing conflicts with --max-depth={}", *s);
return 1;
}
(Some(ref s), None) => {
show_error!("invalid maximum depth '{:s}'", *s);
show_error!("invalid maximum depth '{}'", *s);
return 1;
}
(Some(_), Some(_)) | (None, _) => { /* valid */ }
@ -271,9 +271,9 @@ ers of 1000).",
let convert_size = |size: u64| -> String {
if matches.opt_present("human-readable") || matches.opt_present("si") {
if size >= MB {
format!("{:.1f}M", (size as f64) / (MB as f64))
format!("{:.1}M", (size as f64) / (MB as f64))
} else if size >= KB {
format!("{:.1f}K", (size as f64) / (KB as f64))
format!("{:.1}K", (size as f64) / (KB as f64))
} else {
format!("{}B", size)
}

View file

@ -136,11 +136,11 @@ fn print_help(program: &String) {
getopts::optflag("h", "help", "display this help and exit"),
getopts::optflag("V", "version", "output version information and exit"),
];
println!("echo {:s} - display a line of text", VERSION);
println!("echo {} - display a line of text", VERSION);
println!("");
println!("Usage:");
println!(" {0:s} [SHORT-OPTION]... [STRING]...", *program);
println!(" {0:s} LONG-OPTION", *program);
println!(" {0} [SHORT-OPTION]... [STRING]...", *program);
println!(" {0} LONG-OPTION", *program);
println!("");
println(getopts::usage("Echo the STRING(s) to standard output.", &opts).as_slice());
println("If -e is in effect, the following sequences are recognized:
@ -160,7 +160,7 @@ fn print_help(program: &String) {
}
fn print_version() {
println!("echo version: {:s}", VERSION);
println!("echo version: {}", VERSION);
}
pub fn uumain(args: Vec<String>) -> int {

20
src/env/env.rs vendored
View file

@ -22,7 +22,7 @@ struct options {
}
fn usage(prog: &str) {
println!("Usage: {:s} [OPTION]... [-] [NAME=VALUE]... [COMMAND [ARG]...]", prog);
println!("Usage: {} [OPTION]... [-] [NAME=VALUE]... [COMMAND [ARG]...]", prog);
println!("Set each NAME to VALUE in the environment and run COMMAND\n");
println!("Possible options are:");
println!(" -i --ignore-environment\t start with an empty environment");
@ -43,7 +43,7 @@ fn print_env(null: bool) {
let env = std::os::env();
for &(ref n, ref v) in env.iter() {
print!("{:s}={:s}{:c}",
print!("{}={}{}",
n.as_slice(),
v.as_slice(),
if null { '\0' } else { '\n' }
@ -101,14 +101,14 @@ pub fn uumain(args: Vec<String>) -> int {
let var = iter.next();
match var {
None => println!("{:s}: this option requires an argument: {:s}", prog, opt.as_slice()),
None => println!("{}: this option requires an argument: {}", prog, opt.as_slice()),
Some(s) => opts.unsets.push(s.to_string())
}
}
_ => {
println!("{:s}: invalid option \"{:s}\"", prog, *opt);
println!("Type \"{:s} --help\" for detailed informations", prog);
println!("{}: invalid option \"{}\"", prog, *opt);
println!("Type \"{} --help\" for detailed informations", prog);
return 1;
}
}
@ -134,13 +134,13 @@ pub fn uumain(args: Vec<String>) -> int {
let var = iter.next();
match var {
None => println!("{:s}: this option requires an argument: {:s}", prog, opt.as_slice()),
None => println!("{}: this option requires an argument: {}", prog, opt.as_slice()),
Some(s) => opts.unsets.push(s.to_string())
}
}
_ => {
println!("{:s}: illegal option -- {:c}", prog, c);
println!("Type \"{:s} --help\" for detailed informations", prog);
println!("{}: illegal option -- {}", prog, c);
println!("Type \"{} --help\" for detailed informations", prog);
return 1;
}
}
@ -181,8 +181,8 @@ pub fn uumain(args: Vec<String>) -> int {
}
}
for ref name in opts.unsets.iter() {
std::os::unsetenv(name.as_slice())
for name in opts.unsets.iter() {
std::os::unsetenv((name).as_slice())
}
for &(ref name, ref val) in opts.sets.iter() {

View file

@ -88,7 +88,7 @@ pub fn uumain(args: Vec<String>) -> int {
};
if matches.opt_present("help") {
println!("Usage: {:s} [OPTION]... [FILE]...", NAME);
println!("Usage: {} [OPTION]... [FILE]...", NAME);
io::print(getopts::usage(
"Convert tabs in each FILE to spaces, writing to standard output.\n\
With no FILE, or when FILE is -, read standard input.", &opts).as_slice());
@ -139,26 +139,26 @@ fn expand(options: Options) {
Ok('\t') if init || !options.iflag => {
let nb_spaces = to_next_stop(options.tabstops.as_slice(), col);
col += nb_spaces;
safe_write!(output, "{:1$s}", "", nb_spaces);
safe_write!(&mut output, "{:1$}", "", nb_spaces);
}
Ok('\x08') => {
if col > 0 {
col -= 1;
}
init = false;
safe_write!(output, "{:c}", '\x08');
safe_write!(&mut output, "{}", '\x08');
}
Ok('\n') => {
col = 0;
init = true;
safe_write!(output, "{:c}", '\n');
safe_write!(&mut output, "{}", '\n');
}
Ok(c) => {
col += 1;
if c != ' ' {
init = false;
}
safe_write!(output, "{:c}", c);
safe_write!(&mut output, "{}", c);
}
Err(_) => break
}

View file

@ -49,13 +49,13 @@ pub fn uumain(args: Vec<String>) -> int {
let given_options = match getopts(args.as_slice(), &possible_options) {
Ok (m) => { m }
Err(_) => {
println!("{:s}", usage(NAME, &possible_options));
println!("{}", usage(NAME, &possible_options));
return 1;
}
};
if given_options.opt_present("h") {
println!("{:s}", usage(NAME, &possible_options));
println!("{}", usage(NAME, &possible_options));
return 0;
}
if given_options.opt_present("V") { version(); return 0 }
@ -112,7 +112,7 @@ pub fn uumain(args: Vec<String>) -> int {
for file in files.iter() {
if multiple {
if !firstime { pipe_println!(""); }
pipe_println!("==> {:s} <==", file.as_slice());
pipe_println!("==> {} <==", file.as_slice());
}
firstime = false;

View file

@ -95,7 +95,7 @@ pub fn uumain(args: Vec<String>) -> int {
if matches.opt_present("s") {
let pos = hostname.as_slice().find_str(".");
if pos.is_some() {
println!("{:s}", hostname.as_slice().slice_to(pos.unwrap()));
println!("{}", hostname.as_slice().slice_to(pos.unwrap()));
return 0;
}
} else if matches.opt_present("d") {
@ -106,7 +106,7 @@ pub fn uumain(args: Vec<String>) -> int {
}
}
println!("{:s}", hostname);
println!("{}", hostname);
}
}
1 => xsethostname(matches.free.last().unwrap().as_slice()),
@ -124,9 +124,9 @@ fn help_menu(program: &str, options: &[getopts::OptGroup]) {
version();
println!("");
println!("Usage:");
println!(" {:s} [OPTION]... [HOSTNAME]", program);
println!(" {} [OPTION]... [HOSTNAME]", program);
println!("");
print!("{:s}", usage("Print or set the system's host name.", options));
print!("{}", usage("Print or set the system's host name.", options));
}
fn xgethostname() -> String {
@ -156,7 +156,7 @@ fn xsethostname(name: &str) {
};
if err != 0 {
println!("Cannot set hostname to {:s}", name);
println!("Cannot set hostname to {}", name);
}
}
@ -169,6 +169,6 @@ fn xsethostname(name: &str) {
};
if err != 0 {
println!("Cannot set hostname to {:s}", name);
println!("Cannot set hostname to {}", name);
}
}

View file

@ -103,13 +103,13 @@ pub fn uumain(args: Vec<String>) -> int {
let matches = match getopts(args_t, &options) {
Ok(m) => { m },
Err(_) => {
println!("{:s}", usage(NAME, &options));
println!("{}", usage(NAME, &options));
return 1;
}
};
if matches.opt_present("h") {
println!("{:s}", usage(NAME, &options));
println!("{}", usage(NAME, &options));
return 0;
}
@ -140,9 +140,9 @@ pub fn uumain(args: Vec<String>) -> int {
if nflag && gr.is_not_null() {
let gr_name = unsafe { from_buf(read(gr).gr_name as *const u8) };
println!("{:s}", gr_name);
println!("{}", gr_name);
} else {
println!("{:u}", id);
println!("{}", id);
}
return 0;
}
@ -161,9 +161,9 @@ pub fn uumain(args: Vec<String>) -> int {
let pw_name = unsafe {
from_buf(read(pw).pw_name as *const u8)
};
println!("{:s}", pw_name);
println!("{}", pw_name);
} else {
println!("{:u}", id);
println!("{}", id);
}
return 0;
@ -198,7 +198,7 @@ fn pretty(possible_pw: Option<c_passwd>) {
let pw = possible_pw.unwrap();
let pw_name = unsafe { from_buf(pw.pw_name as *const u8) };
print!("uid\t{:s}\ngroups\t", pw_name);
print!("uid\t{}\ngroups\t", pw_name);
group(possible_pw, true);
} else {
let login = unsafe { from_buf(getlogin() as *const u8) };
@ -210,15 +210,15 @@ fn pretty(possible_pw: Option<c_passwd>) {
};
if pw.is_null() || is_same_user {
println!("login\t{:s}", login);
println!("login\t{}", login);
}
if pw.is_not_null() {
println!(
"uid\t{:s}",
"uid\t{}",
unsafe { from_buf(read(pw).pw_name as *const u8) })
} else {
println!("uid\t{:u}\n", rid);
println!("uid\t{}\n", rid);
}
let eid = unsafe { getegid() };
@ -226,10 +226,10 @@ fn pretty(possible_pw: Option<c_passwd>) {
let pw = unsafe { getpwuid(eid) };
if pw.is_not_null() {
println!(
"euid\t{:s}",
"euid\t{}",
unsafe { from_buf(read(pw).pw_name as *const u8) });
} else {
println!("euid\t{:u}", eid);
println!("euid\t{}", eid);
}
}
@ -239,10 +239,10 @@ fn pretty(possible_pw: Option<c_passwd>) {
let gr = unsafe { getgrgid(rid) };
if gr.is_not_null() {
println!(
"rgid\t{:s}",
"rgid\t{}",
unsafe { from_buf(read(gr).gr_name as *const u8) });
} else {
println!("rgid\t{:u}", rid);
println!("rgid\t{}", rid);
}
}
@ -267,7 +267,7 @@ fn pline(possible_pw: Option<c_passwd>) {
let pw_shell = unsafe { from_buf(pw.pw_shell as *const u8) };
println!(
"{:s}:{:s}:{:u}:{:u}:{:s}:{:d}:{:d}:{:s}:{:s}:{:s}",
"{}:{}:{}:{}:{}:{}:{}:{}:{}:{}",
pw_name,
pw_passwd,
pw.pw_uid,
@ -295,7 +295,7 @@ fn pline(possible_pw: Option<c_passwd>) {
let pw_shell = unsafe { from_buf(pw.pw_shell as *const u8)};
println!(
"{:s}:{:s}:{:u}:{:u}:{:s}:{:s}:{:s}",
"{}:{}:{}:{}:{}:{}:{}",
pw_name,
pw_passwd,
pw.pw_uid,
@ -317,11 +317,11 @@ fn auditid() {
return;
}
println!("auid={:u}", auditinfo.ai_auid);
println!("auid={}", auditinfo.ai_auid);
println!("mask.success=0x{:x}", auditinfo.ai_mask.am_success);
println!("mask.failure=0x{:x}", auditinfo.ai_mask.am_failure);
println!("termid.port=0x{:x}", auditinfo.ai_termid.port);
println!("asid={:d}", auditinfo.ai_asid);
println!("asid={}", auditinfo.ai_asid);
}
fn id_print(possible_pw: Option<c_passwd>,
@ -345,44 +345,44 @@ fn id_print(possible_pw: Option<c_passwd>,
};
let groups = groups.unwrap_or_else(|errno| {
crash!(1, "failed to get group list (errno={:u})", errno);
crash!(1, "failed to get group list (errno={})", errno);
});
if possible_pw.is_some() {
print!(
"uid={:u}({:s})",
"uid={}({})",
uid,
unsafe { from_buf(possible_pw.unwrap().pw_name as *const u8) });
} else {
print!("uid={:u}", unsafe { getuid() });
print!("uid={}", unsafe { getuid() });
}
print!(" gid={:u}", gid);
print!(" gid={}", gid);
let gr = unsafe { getgrgid(gid) };
if gr.is_not_null() {
print!(
"({:s})",
"({})",
unsafe { from_buf(read(gr).gr_name as *const u8) });
}
let euid = unsafe { geteuid() };
if p_euid && (euid != uid) {
print!(" euid={:u}", euid);
print!(" euid={}", euid);
let pw = unsafe { getpwuid(euid) };
if pw.is_not_null() {
print!(
"({:s})",
"({})",
unsafe { from_buf(read(pw).pw_name as *const u8) });
}
}
let egid = unsafe { getegid() };
if p_egid && (egid != gid) {
print!(" egid={:u}", egid);
print!(" egid={}", egid);
unsafe {
let grp = getgrgid(egid);
if grp.is_not_null() {
print!("({:s})", from_buf(read(grp).gr_name as *const u8));
print!("({})", from_buf(read(grp).gr_name as *const u8));
}
}
}
@ -393,13 +393,13 @@ fn id_print(possible_pw: Option<c_passwd>,
let mut first = true;
for &gr in groups.iter() {
if !first { print!(",") }
print!("{:u}", gr);
print!("{}", gr);
let group = unsafe { getgrgid(gr) };
if group.is_not_null() {
let name = unsafe {
from_buf(read(group).gr_name as *const u8)
};
print!("({:s})", name);
print!("({})", name);
}
first = false
}

View file

@ -62,7 +62,7 @@ pub fn uumain(args: Vec<String>) -> int {
version();
println!("");
println!("Usage:");
println!(" {:s}", program);
println!(" {}", program);
println!("");
print(getopts::usage("print user's login name", &opts).as_slice());
return 0;
@ -80,6 +80,6 @@ pub fn uumain(args: Vec<String>) -> int {
fn exec() {
unsafe {
let userlogin = get_userlogin();
println!("{:s}", userlogin);
println!("{}", userlogin);
}
}

View file

@ -322,7 +322,7 @@ fn pass_all(_: &str, _: &regex::Regex) -> bool {
}
fn print_usage(opts: &[OptGroup]) {
println!("{:s}", usage(USAGE, opts));
println!("{}", usage(USAGE, opts));
}
fn version () {

View file

@ -12,7 +12,6 @@
#![feature(macro_rules)]
extern crate getopts;
extern crate libc;
extern crate native;
use getopts::{optflag, getopts, usage};
use std::io::stdio::{stdin_raw, stdout_raw, stderr_raw};
@ -93,7 +92,7 @@ pub fn uumain(args: Vec<String>) -> int {
if opts.free.len() == 0 {
show_error!("Missing operand: COMMAND");
println!("Try `{:s} --help` for more information.", program.as_slice());
println!("Try `{} --help` for more information.", program.as_slice());
return 1
}
replace_fds();
@ -179,10 +178,10 @@ fn version() {
fn show_usage(program: &str, options: &[getopts::OptGroup]) {
version();
println!("Usage:");
println!(" {:s} COMMAND [ARG]…", program);
println!(" {:s} OPTION", program);
println!(" {} COMMAND [ARG]…", program);
println!(" {} OPTION", program);
println!("");
print!("{:s}", usage(
print!("{}", usage(
"Run COMMAND ignoring hangup signals.\n\
If standard input is terminal, it'll be replaced with /dev/null.\n\
If standard output is terminal, it'll be appended to nohup.out instead, \

View file

@ -39,7 +39,7 @@ pub fn uumain(args: Vec<String>) -> int {
println!("{} {}", NAME, VERSION);
println!("");
println!("Usage:");
println!(" {0:s} [OPTION]... [FILE]...", program);
println!(" {0} [OPTION]... [FILE]...", program);
println!("");
print!("{}", getopts::usage("Write lines consisting of the sequentially corresponding lines from each FILE, separated by TABs, to standard output.", &opts));
} else if matches.opt_present("version") {

View file

@ -41,7 +41,7 @@ pub fn uumain(args: Vec<String>) -> int {
println!("printenv 1.0.0");
println!("");
println!("Usage:");
println!(" {0:s} [VARIABLE]... [OPTION]...", program);
println!(" {0} [VARIABLE]... [OPTION]...", program);
println!("");
print(getopts::usage("Prints the given environment VARIABLE(s), otherwise prints them all.", &opts).as_slice());
return 0;
@ -64,7 +64,7 @@ pub fn exec(args: Vec<String>, separator: &str) {
if args.is_empty() {
let vars = os::env();
for (env_var, value) in vars.into_iter() {
print!("{0:s}={1:s}", env_var, value);
print!("{0}={1}", env_var, value);
print(separator);
}
return;

View file

@ -40,7 +40,7 @@ pub fn uumain(args: Vec<String>) -> int {
println!("pwd {}", VERSION);
println!("");
println!("Usage:");
println!(" {0:s} [OPTION] NAME...", program);
println!(" {0} [OPTION] NAME...", program);
println!("");
print(getopts::usage("Print the full filename of the current working directory.", &opts).as_slice());
} else if matches.opt_present("version") {

View file

@ -44,7 +44,7 @@ pub fn uumain(args: Vec<String>) -> int {
if opts.free.len() == 0 {
show_error!("Missing operand: FILENAME, at least one is required");
println!("Try `{:s} --help` for more information.", program.as_slice());
println!("Try `{} --help` for more information.", program.as_slice());
return 1
}
@ -125,11 +125,11 @@ fn version() {
fn show_usage(program: &str, options: &[getopts::OptGroup]) {
version();
println!("Usage:");
println!(" {:s} [-s|--strip] [-z|--zero] FILENAME…", program);
println!(" {:s} -V|--version", program);
println!(" {:s} -h|--help", program);
println!(" {} [-s|--strip] [-z|--zero] FILENAME…", program);
println!(" {} -V|--version", program);
println!(" {} -h|--help", program);
println!("");
print!("{:s}", usage(
print!("{}", usage(
"Convert each FILENAME to the absolute path.\n\
All the symbolic links will be resolved, resulting path will contain no special components like '.' or '..'.\n\
Each path component must exist or resolution will fail and non-zero exit status returned.\n\

View file

@ -42,7 +42,7 @@ pub fn uumain(args: Vec<String>) -> int {
if opts.free.len() == 0 {
show_error!("Missing operand: TO");
println!("Try `{:s} --help` for more information.", program.as_slice());
println!("Try `{} --help` for more information.", program.as_slice());
return 1
}
@ -89,11 +89,11 @@ fn version() {
fn show_usage(program: &str, options: &[getopts::OptGroup]) {
version();
println!("Usage:");
println!(" {:s} [-d DIR] TO [FROM]", program);
println!(" {:s} -V|--version", program);
println!(" {:s} -h|--help", program);
println!(" {} [-d DIR] TO [FROM]", program);
println!(" {} -V|--version", program);
println!(" {} -h|--help", program);
println!("");
print!("{:s}", usage(
print!("{}", usage(
"Convert TO destination to the relative path from the FROM dir.\n\
If FROM path is omitted, current working dir will be used.", options)
);

View file

@ -57,7 +57,7 @@ pub fn uumain(args: Vec<String>) -> int {
println!("rm 1.0.0");
println!("");
println!("Usage:");
println!(" {0:s} [OPTION]... [FILE]...", program);
println!(" {0} [OPTION]... [FILE]...", program);
println!("");
print(getopts::usage("Remove (unlink) the FILE(s).", &opts).as_slice());
println!("");
@ -77,7 +77,7 @@ pub fn uumain(args: Vec<String>) -> int {
println!("rm 1.0.0");
} else if matches.free.is_empty() {
show_error!("missing an argument");
show_error!("for help, try '{0:s} --help'", program);
show_error!("for help, try '{0} --help'", program);
return 1;
} else {
let force = matches.opt_present("force");

View file

@ -44,14 +44,14 @@ pub fn uumain(args: Vec<String>) -> int {
println!("rmdir 1.0.0");
println!("");
println!("Usage:");
println!(" {0:s} [OPTION]... DIRECTORY...", program);
println!(" {0} [OPTION]... DIRECTORY...", program);
println!("");
print(getopts::usage("Remove the DIRECTORY(ies), if they are empty.", &opts).as_slice());
} else if matches.opt_present("version") {
println!("rmdir 1.0.0");
} else if matches.free.is_empty() {
show_error!("missing an argument");
show_error!("for help, try '{0:s} --help'", program);
show_error!("for help, try '{0} --help'", program);
return 1;
} else {
let ignore = matches.opt_present("ignore-fail-on-non-empty");

View file

@ -25,7 +25,7 @@ struct SeqOptions {
fn parse_float(s: &str) -> Result<f64, String>{
match from_str(s) {
Some(n) => Ok(n),
None => Err(format!("seq: invalid floating point argument: {:s}", s))
None => Err(format!("seq: invalid floating point argument: {}", s))
}
}
@ -136,7 +136,7 @@ fn print_help(program: &String) {
];
println!("seq 1.0.0\n");
println!("Usage:\n {} [-w] [-s string] [-t string] [first [step]] last\n", *program);
println!("{:s}", getopts::usage("Print sequences of numbers", &opts));
println!("{}", getopts::usage("Print sequences of numbers", &opts));
}
fn print_version() {
@ -168,7 +168,7 @@ pub fn uumain(args: Vec<String>) -> int {
padding = dec;
match parse_float(slice) {
Ok(n) => n,
Err(s) => { show_error!("{:s}", s); return 1; }
Err(s) => { show_error!("{}", s); return 1; }
}
} else {
1.0
@ -181,7 +181,7 @@ pub fn uumain(args: Vec<String>) -> int {
padding = cmp::max(padding, dec);
match parse_float(free[1].as_slice()) {
Ok(n) => n,
Err(s) => { show_error!("{:s}", s); return 1; }
Err(s) => { show_error!("{}", s); return 1; }
}
} else {
1.0
@ -191,7 +191,7 @@ pub fn uumain(args: Vec<String>) -> int {
padding = cmp::max(padding, slice.find('.').unwrap_or(slice.len()));
match parse_float(slice) {
Ok(n) => n,
Err(s) => { show_error!("{:s}", s); return 1; }
Err(s) => { show_error!("{}", s); return 1; }
}
};
let separator = escape_sequences(options.separator.as_slice());
@ -245,12 +245,12 @@ fn print_seq(first: f64, step: f64, last: f64, largest_dec: uint, separator: Str
i += 1;
value = first + i as f64 * step;
if !done_printing(value, step, last) {
if !pipe_print!("{:s}", separator) {
if !pipe_print!("{}", separator) {
return;
}
}
}
if (first >= last && step < 0f64) || (first <= last && step > 0f64) {
pipe_print!("{:s}", terminator);
pipe_print!("{}", terminator);
}
}

View file

@ -45,9 +45,9 @@ pub fn uumain(args: Vec<String>) -> int {
println!("sleep 1.0.0");
println!("");
println!("Usage:");
println!(" {0:s} NUMBER[SUFFIX]", program);
println!(" {0} NUMBER[SUFFIX]", program);
println!("or");
println!(" {0:s} OPTION", program);
println!(" {0} OPTION", program);
println!("");
print(getopts::usage("Pause for NUMBER seconds. SUFFIX may be 's' for seconds (the default),
'm' for minutes, 'h' for hours or 'd' for days. Unlike most implementations
@ -58,7 +58,7 @@ specified by the sum of their values.", &opts).as_slice());
println!("sleep 1.0.0");
} else if matches.free.is_empty() {
show_error!("missing an argument");
show_error!("for help, try '{0:s} --help'", program);
show_error!("for help, try '{0} --help'", program);
return 1;
} else {
sleep(matches.free);

View file

@ -40,7 +40,7 @@ pub fn uumain(args: Vec<String>) -> int {
Err(f) => crash!(1, "Invalid options\n{}", f)
};
if matches.opt_present("help") {
println!("Usage: {0:s} [OPTION]... [FILE]...", program);
println!("Usage: {0} [OPTION]... [FILE]...", program);
println!("Write the sorted concatenation of all FILE(s) to standard output.");
println!("");
print(getopts::usage("Mandatory arguments for long options are mandatory for short options too.", &opts).as_slice());
@ -152,7 +152,7 @@ fn open<'a>(path: &str) -> Option<(Box<Reader + 'a>, bool)> {
match File::open(&std::path::Path::new(path)) {
Ok(f) => Some((box f as Box<Reader>, false)),
Err(e) => {
show_error!("sort: {0:s}: {1:s}", path, e.to_string());
show_error!("sort: {0}: {1}", path, e.to_string());
None
},
}

View file

@ -45,7 +45,7 @@ pub fn uumain(args: Vec<String>) -> int {
println!("{} v{}", NAME, VERSION);
println!("");
println!("Usage:");
println!(" {0:s} [OPTION]... [INPUT [PREFIX]]", NAME);
println!(" {0} [OPTION]... [INPUT [PREFIX]]", NAME);
println!("");
io::print(getopts::usage("Output fixed-size pieces of INPUT to PREFIXaa, PREFIX ab, ...; default size is 1000, and default PREFIX is 'x'. With no INPUT, or when INPUT is -, read standard input." , &opts).as_slice());
return 0;

View file

@ -93,7 +93,7 @@ pub fn uumain(args: Vec<String>) -> int {
println!("{} {}", program, VERSION);
println!("");
println!("Usage:");
println!(" {0:s} [OPTION]... [FILE]...", program);
println!(" {0} [OPTION]... [FILE]...", program);
println!("");
print(getopts::usage("checksum and count the blocks in a file", &opts).as_slice());
println!("");

View file

@ -175,8 +175,8 @@ fn version() {
}
fn help(program: &str, options: &[getopts::OptGroup]) {
println!("Usage: {:s} [OPTION]", program);
print!("{:s}", usage("Force changed blocks to disk, update the super block.", options));
println!("Usage: {} [OPTION]", program);
print!("{}", usage("Force changed blocks to disk, update the super block.", options));
}
fn uusync() -> int {

View file

@ -40,7 +40,7 @@ pub fn uumain(args: Vec<String>) -> int {
println!("tac {}", VERSION);
println!("");
println!("Usage:");
println!(" {0:s} [OPTION]... [FILE]...", program);
println!(" {0} [OPTION]... [FILE]...", program);
println!("");
print!("{}", getopts::usage("Write each file to standard output, last line first.", &opts));
} else if matches.opt_present("version") {

View file

@ -57,13 +57,13 @@ pub fn uumain(args: Vec<String>) -> int {
let given_options = match getopts(args.as_slice(), &possible_options) {
Ok (m) => { m }
Err(_) => {
println!("{:s}", usage(NAME, &possible_options));
println!("{}", usage(NAME, &possible_options));
return 1;
}
};
if given_options.opt_present("h") {
println!("{:s}", usage(NAME, &possible_options));
println!("{}", usage(NAME, &possible_options));
return 0;
}
if given_options.opt_present("V") { version(); return 0 }
@ -134,7 +134,7 @@ pub fn uumain(args: Vec<String>) -> int {
for file in files.iter() {
if multiple {
if !firstime { println!(""); }
println!("==> {:s} <==", file.as_slice());
println!("==> {} <==", file.as_slice());
}
firstime = false;

View file

@ -63,7 +63,7 @@ Usage:
println!("{} v{}", NAME, VERSION);
} else if matches.free.len() < 2 {
show_error!("missing an argument");
show_error!("for help, try '{0:s} --help'", program);
show_error!("for help, try '{0} --help'", program);
return ERR_EXIT_STATUS;
} else {
let status = matches.opt_present("preserve-status");

View file

@ -45,16 +45,16 @@ pub fn uumain(args: Vec<String>) -> int {
};
if matches.opt_present("version") {
println!("{:s} {:s}", NAME, VERSION);
println!("{} {}", NAME, VERSION);
return 0;
}
if matches.opt_present("help") || matches.free.is_empty() {
println!("{:s} {:s}", NAME, VERSION);
println!("{} {}", NAME, VERSION);
println!("");
println!("Usage: {:s} [OPTION]... FILE...", NAME);
println!("Usage: {} [OPTION]... FILE...", NAME);
println!("");
println!("{:s}", getopts::usage("Update the access and modification times of \
println!("{}", getopts::usage("Update the access and modification times of \
each FILE to the current time.", &opts));
if matches.free.is_empty() {
return 1;

View file

@ -55,7 +55,7 @@ pub fn uumain(args: Vec<String>) -> int {
println!("truncate 1.0.0");
println!("");
println!("Usage:");
println!(" {0:s} [OPTION]... FILE...", program);
println!(" {0} [OPTION]... FILE...", program);
println!("");
print!("{}", getopts::usage("Shrink or extend the size of each file to the specified size.", &opts));
print!("

View file

@ -72,5 +72,5 @@ pub fn uumain(args: Vec<String>) -> int {
}
fn usage () {
safe_writeln!(&mut stderr() as &mut Writer, "usage: tty [-s]");
safe_writeln!(&mut stderr(), "usage: tty [-s]");
}

View file

@ -72,7 +72,7 @@ pub fn uumain(args: Vec<String>) -> int {
println!("uname 1.0.0");
println!("");
println!("Usage:");
println!(" {:s}", program);
println!(" {}", program);
println!("");
print(getopts::usage("The uname utility writes symbols representing one or more system characteristics to the standard output.", &opts).as_slice());
return 0;

View file

@ -90,7 +90,7 @@ pub fn uumain(args: Vec<String>) -> int {
};
if matches.opt_present("help") {
println!("Usage: {:s} [OPTION]... [FILE]...", NAME);
println!("Usage: {} [OPTION]... [FILE]...", NAME);
io::print(getopts::usage(
"Convert blanks in each FILE to tabs, writing to standard output.\n\
With no FILE, or when FILE is -, read standard input.", &opts).as_slice());
@ -135,21 +135,21 @@ fn to_next_stop(tabstops: &[uint], col: uint) -> Option<uint> {
}
}
fn unexpandspan(output: &mut io::LineBufferedWriter<io::stdio::StdWriter>,
fn unexpandspan(mut output: &mut io::LineBufferedWriter<io::stdio::StdWriter>,
tabstops: &[uint], nspaces: uint, col: uint, init: bool) {
let mut cur = col - nspaces;
if nspaces > 1 || init {
loop {
match to_next_stop(tabstops, cur) {
Some(to_next) if cur + to_next <= col => {
safe_write!(output, "{:c}", '\t');
safe_write!(&mut output, "{}", '\t');
cur += to_next;
}
_ => break
}
}
}
safe_write!(output, "{:1$s}", "", col - cur);
safe_write!(&mut output, "{:1$}", "", col - cur);
}
fn unexpand(options: Options) {
@ -167,7 +167,7 @@ fn unexpand(options: Options) {
nspaces += 1;
} else {
nspaces = 0;
safe_write!(output, "{:c}", ' ');
safe_write!(&mut output, "{}", ' ');
}
col += 1;
}
@ -175,7 +175,7 @@ fn unexpand(options: Options) {
if is_tabstop(ts, col) {
nspaces = 0;
col += 1;
safe_write!(output, "{:c}", '\t');
safe_write!(&mut output, "{}", '\t');
}
match to_next_stop(ts, col) {
Some(to_next) => {
@ -186,7 +186,7 @@ fn unexpand(options: Options) {
col += 1;
unexpandspan(&mut output, ts, nspaces, col, init);
nspaces = 0;
safe_write!(output, "{:c}", '\t');
safe_write!(&mut output, "{}", '\t');
}
}
}
@ -197,7 +197,7 @@ fn unexpand(options: Options) {
nspaces = 0;
if col > 0 { col -= 1; }
init = false;
safe_write!(output, "{:c}", '\x08');
safe_write!(&mut output, "{}", '\x08');
}
Ok('\n') => {
if init || options.aflag {
@ -206,7 +206,7 @@ fn unexpand(options: Options) {
nspaces = 0;
col = 0;
init = true;
safe_write!(output, "{:c}", '\n');
safe_write!(&mut output, "{}", '\n');
}
Ok(c) => {
if init || options.aflag {
@ -215,7 +215,7 @@ fn unexpand(options: Options) {
nspaces = 0;
col += 1;
init = false;
safe_write!(output, "{:c}", c);
safe_write!(&mut output, "{}", c);
}
Err(_) => break
}

View file

@ -147,7 +147,7 @@ pub fn uumain(args: Vec<String>) -> int {
println!("{} {}", NAME, VERSION);
println!("");
println!("Usage:");
println!(" {0:s} [OPTION]... [FILE]...", program);
println!(" {0} [OPTION]... [FILE]...", program);
println!("");
print!("{}", getopts::usage("Filter adjacent matching lines from INPUT (or standard input),\n\
writing to OUTPUT (or standard output).", &opts));

View file

@ -43,7 +43,7 @@ pub fn uumain(args: Vec<String>) -> int {
println!("unlink 1.0.0");
println!("");
println!("Usage:");
println!(" {0:s} [FILE]... [OPTION]...", program);
println!(" {0} [FILE]... [OPTION]...", program);
println!("");
print(getopts::usage("Unlink the file at [FILE].", &opts).as_slice());
return 0;
@ -55,9 +55,9 @@ pub fn uumain(args: Vec<String>) -> int {
}
if matches.free.len() == 0 {
crash!(1, "missing operand\nTry '{0:s} --help' for more information.", program);
crash!(1, "missing operand\nTry '{0} --help' for more information.", program);
} else if matches.free.len() > 1 {
crash!(1, "extra operand: '{1}'\nTry '{0:s} --help' for more information.", program, matches.free[1]);
crash!(1, "extra operand: '{1}'\nTry '{0} --help' for more information.", program, matches.free[1]);
}
let path = Path::new(matches.free[0].clone());

View file

@ -68,7 +68,7 @@ pub fn uumain(args: Vec<String>) -> int {
}
if matches.opt_present("help") || matches.free.len() > 0 {
println!("Usage:");
println!(" {0:s} [OPTION]", program);
println!(" {0} [OPTION]", program);
println!("");
print(getopts::usage("Print the current time, the length of time the system has been up,\n\
the number of users on the system, and the average number of jobs\n\
@ -96,7 +96,7 @@ fn print_loadavg() {
else {
print!("load average: ")
for n in range(0, loads) {
print!("{:.2f}{}", avg[n as uint], if n == loads - 1 { "\n" }
print!("{:.2}{}", avg[n as uint], if n == loads - 1 { "\n" }
else { ", " } );
}
}
@ -153,7 +153,7 @@ fn print_time() {
if local_time.tm_hour >= 0 && local_time.tm_min >= 0 &&
local_time.tm_sec >= 0 {
print!(" {:02d}:{:02d}:{:02d} ", local_time.tm_hour,
print!(" {:02}:{:02}:{:02} ", local_time.tm_hour,
local_time.tm_min, local_time.tm_sec);
}
}
@ -187,12 +187,12 @@ fn print_uptime(upsecs: i64) {
let uphours = (upsecs - (updays * 86400)) / 3600;
let upmins = (upsecs - (updays * 86400) - (uphours * 3600)) / 60;
if updays == 1 {
print!("up {:1d} day, {:2d}:{:02d}, ", updays, uphours, upmins);
print!("up {:1} day, {:2}:{:02}, ", updays, uphours, upmins);
}
else if updays > 1 {
print!("up {:1d} days, {:2d}:{:02d}, ", updays, uphours, upmins);
print!("up {:1} days, {:2}:{:02}, ", updays, uphours, upmins);
}
else {
print!("up {:2d}:{:02d}, ", uphours, upmins);
print!("up {:2}:{:02}, ", uphours, upmins);
}
}

View file

@ -68,7 +68,7 @@ pub fn uumain(args: Vec<String>) -> int {
println!("users 1.0.0");
println!("");
println!("Usage:");
println!(" {:s} [OPTION]... [FILE]", program);
println!(" {} [OPTION]... [FILE]", program);
println!("");
print(getopts::usage("Output who is currently logged in according to FILE.", &opts).as_slice());
return 0;

View file

@ -56,7 +56,7 @@ pub fn uumain(args: Vec<String>) -> int {
if matches.opt_present("help") {
println!("Usage:");
println!(" {0:s} [OPTION]... [FILE]...", program);
println!(" {0} [OPTION]... [FILE]...", program);
println!("");
print(getopts::usage("Print newline, word and byte counts for each FILE", &opts).as_slice());
println!("");

View file

@ -80,7 +80,7 @@ pub fn uumain(args: Vec<String>) -> int {
println!("whoami 1.0.0");
println!("");
println!("Usage:");
println!(" {:s}", program);
println!(" {}", program);
println!("");
print(getopts::usage("print effective userid", &opts).as_slice());
return 0;
@ -98,6 +98,6 @@ pub fn uumain(args: Vec<String>) -> int {
pub fn exec() {
unsafe {
let username = platform::getusername();
println!("{:s}", username);
println!("{}", username);
}
}

View file

@ -39,7 +39,7 @@ pub fn uumain(args: Vec<String>) -> int {
println!("yes 1.0.0");
println!("");
println!("Usage:");
println!(" {0:s} [STRING]... [OPTION]...", program);
println!(" {0} [STRING]... [OPTION]...", program);
println!("");
print(getopts::usage("Repeatedly output a line with all specified STRING(s), or 'y'.", &opts).as_slice());
return 0;

View file

@ -5,28 +5,28 @@ static PROGNAME: &'static str = "./seq";
#[test]
fn test_count_up() {
let p = Command::new(PROGNAME).args(["10"]).output().unwrap();
let p = Command::new(PROGNAME).args(&["10"]).output().unwrap();
let out = str::from_utf8(p.output.as_slice()).unwrap();
assert_eq!(out, "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n");
}
#[test]
fn test_count_down() {
let p = Command::new(PROGNAME).args(["--", "5", "-1", "1"]).output().unwrap();
let p = Command::new(PROGNAME).args(&["--", "5", "-1", "1"]).output().unwrap();
let out = str::from_utf8(p.output.as_slice()).unwrap();
assert_eq!(out, "5\n4\n3\n2\n1\n");
}
#[test]
fn test_separator_and_terminator() {
let p = Command::new(PROGNAME).args(["-s", ",", "-t", "!", "2", "6"]).output().unwrap();
let p = Command::new(PROGNAME).args(&["-s", ",", "-t", "!", "2", "6"]).output().unwrap();
let out = str::from_utf8(p.output.as_slice()).unwrap();
assert_eq!(out, "2,3,4,5,6!");
}
#[test]
fn test_equalize_widths() {
let p = Command::new(PROGNAME).args(["-w", "5", "10"]).output().unwrap();
let p = Command::new(PROGNAME).args(&["-w", "5", "10"]).output().unwrap();
let out = str::from_utf8(p.output.as_slice()).unwrap();
assert_eq!(out, "05\n06\n07\n08\n09\n10\n");
}

View file

@ -16,31 +16,31 @@ fn run(input: &str, args: &[&'static str]) -> Vec<u8> {
#[test]
fn test_toupper() {
let out = run("!abcd!", ["a-z", "A-Z"]);
let out = run("!abcd!", &["a-z", "A-Z"]);
assert_eq!(out.as_slice(), b"!ABCD!");
}
#[test]
fn test_small_set2() {
let out = run("@0123456789", ["0-9", "X"]);
let out = run("@0123456789", &["0-9", "X"]);
assert_eq!(out.as_slice(), b"@XXXXXXXXXX");
}
#[test]
fn test_unicode() {
let out = run("(,°□°), ┬─┬", [", ┬─┬", "╯︵┻━┻"]);
let out = run("(,°□°), ┬─┬", &[", ┬─┬", "╯︵┻━┻"]);
assert_eq!(out.as_slice(), "(╯°□°)╯︵┻━┻".as_bytes());
}
#[test]
fn test_delete() {
let out = run("aBcD", ["-d", "a-z"]);
let out = run("aBcD", &["-d", "a-z"]);
assert_eq!(out.as_slice(), b"BD");
}
#[test]
fn test_delete_complement() {
let out = run("aBcD", ["-d", "-c", "a-z"]);
let out = run("aBcD", &["-d", "-c", "a-z"]);
assert_eq!(out.as_slice(), b"ac");
}

View file

@ -15,7 +15,7 @@ fn make_file(name: &str) -> io::File {
#[test]
fn test_increase_file_size() {
let mut file = make_file(TFILE1);
if !Command::new(PROGNAME).args(["-s", "+5K", TFILE1]).status().unwrap().success() {
if !Command::new(PROGNAME).args(&["-s", "+5K", TFILE1]).status().unwrap().success() {
panic!();
}
file.seek(0, io::SeekEnd).unwrap();
@ -29,7 +29,7 @@ fn test_increase_file_size() {
fn test_decrease_file_size() {
let mut file = make_file(TFILE2);
file.write(b"1234567890").unwrap();
if !Command::new(PROGNAME).args(["--size=-4", TFILE2]).status().unwrap().success() {
if !Command::new(PROGNAME).args(&["--size=-4", TFILE2]).status().unwrap().success() {
panic!();
}
file.seek(0, io::SeekEnd).unwrap();

View file

@ -16,56 +16,56 @@ fn run(input: &str, args: &[&'static str]) -> Vec<u8> {
#[test]
fn unexpand_init_0() {
let out = run(" 1\n 2\n 3\n 4\n", ["-t4"]);
let out = run(" 1\n 2\n 3\n 4\n", &["-t4"]);
assert_eq!(out.as_slice(), b" 1\n 2\n 3\n\t4\n");
}
#[test]
fn unexpand_init_1() {
let out = run(" 5\n 6\n 7\n 8\n", ["-t4"]);
let out = run(" 5\n 6\n 7\n 8\n", &["-t4"]);
assert_eq!(out.as_slice(), b"\t 5\n\t 6\n\t 7\n\t\t8\n");
}
#[test]
fn unexpand_init_list_0() {
let out = run(" 1\n 2\n 3\n 4\n", ["-t2,4"]);
let out = run(" 1\n 2\n 3\n 4\n", &["-t2,4"]);
assert_eq!(out.as_slice(), b" 1\n\t2\n\t 3\n\t\t4\n");
}
#[test]
fn unexpand_init_list_1() {
// Once the list is exhausted, spaces are not converted anymore
let out = run(" 5\n 6\n 7\n 8\n", ["-t2,4"]);
let out = run(" 5\n 6\n 7\n 8\n", &["-t2,4"]);
assert_eq!(out.as_slice(), b"\t\t 5\n\t\t 6\n\t\t 7\n\t\t 8\n");
}
#[test]
fn unexpand_aflag_0() {
let out = run("e E\nf F\ng G\nh H\n", []);
let out = run("e E\nf F\ng G\nh H\n", &[]);
assert_eq!(out.as_slice(), b"e E\nf F\ng G\nh H\n");
}
#[test]
fn unexpand_aflag_1() {
let out = run("e E\nf F\ng G\nh H\n", ["-a"]);
let out = run("e E\nf F\ng G\nh H\n", &["-a"]);
assert_eq!(out.as_slice(), b"e E\nf F\ng\tG\nh\t H\n");
}
#[test]
fn unexpand_aflag_2() {
let out = run("e E\nf F\ng G\nh H\n", ["-t8"]);
let out = run("e E\nf F\ng G\nh H\n", &["-t8"]);
assert_eq!(out.as_slice(), b"e E\nf F\ng\tG\nh\t H\n");
}
#[test]
fn unexpand_first_only_0() {
let out = run(" A B", ["-t3"]);
let out = run(" A B", &["-t3"]);
assert_eq!(out.as_slice(), b"\t\t A\t B");
}
#[test]
fn unexpand_first_only_1() {
let out = run(" A B", ["-t3", "--first-only"]);
let out = run(" A B", &["-t3", "--first-only"]);
assert_eq!(out.as_slice(), b"\t\t A B");
}
@ -73,20 +73,20 @@ fn unexpand_first_only_1() {
fn unexpand_trailing_space_0() { // evil
// Individual spaces before fields starting with non blanks should not be
// converted, unless they are at the beginning of the line.
let out = run("123 \t1\n123 1\n123 \n123 ", ["-t4"]);
let out = run("123 \t1\n123 1\n123 \n123 ", &["-t4"]);
assert_eq!(out.as_slice(), b"123\t\t1\n123 1\n123 \n123 ");
}
#[test]
fn unexpand_trailing_space_1() { // super evil
let out = run(" abc d e f g ", ["-t1"]);
let out = run(" abc d e f g ", &["-t1"]);
assert_eq!(out.as_slice(), b"\tabc d e\t\tf\t\tg ");
}
#[test]
fn unexpand_spaces_follow_tabs_0() {
// The two first spaces can be included into the first tab.
let out = run(" \t\t A", []);
let out = run(" \t\t A", &[]);
assert_eq!(out.as_slice(), b"\t\t A");
}
@ -97,7 +97,7 @@ fn unexpand_spaces_follow_tabs_1() { // evil
// ' \t' -> '\t' // second tabstop (4)
// ' ' -> '\t' // third tabstop (5)
// ' B \t' -> ' B \t' // after the list is exhausted, nothing must change
let out = run("a \t B \t", ["-t1,4,5"]);
let out = run("a \t B \t", &["-t1,4,5"]);
assert_eq!(out.as_slice(), b"a\t\t B \t");
}