1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-08-01 05:27:45 +00:00

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

View file

@ -38,8 +38,8 @@ pub fn uumain(args: Vec<String>) -> int {
}; };
if matches.opt_present("help") { if matches.opt_present("help") {
println!("Usage: {0:s} NAME [SUFFIX]", program); println!("Usage: {0} NAME [SUFFIX]", program);
println!(" or: {0:s} OPTION", program); println!(" or: {0} OPTION", program);
println!("Print NAME with any leading directory components removed."); println!("Print NAME with any leading directory components removed.");
println!("If specified, also remove a trailing SUFFIX."); 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!("cat 1.0.0");
println!(""); println!("");
println!("Usage:"); println!("Usage:");
println!(" {0:s} [OPTION]... [FILE]...", program); println!(" {0} [OPTION]... [FILE]...", program);
println!(""); println!("");
print(getopts::usage("Concatenate FILE(s), or standard input, to \ print(getopts::usage("Concatenate FILE(s), or standard input, to \
standard output.", &opts).as_slice()); 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 in_buf[pos] == '\n' as u8 {
if !at_line_start || !squeeze_blank { if !at_line_start || !squeeze_blank {
if at_line_start && number == NumberingMode::NumberAll { 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; line_counter += 1;
} }
if show_ends { if show_ends {
@ -134,7 +134,7 @@ fn write_lines(files: Vec<String>, number: NumberingMode, squeeze_blank: bool,
continue; continue;
} }
if at_line_start && number != NumberingMode::NumberNone { 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; line_counter += 1;
} }
match in_buf.slice_from(pos).iter().position(|c| *c == '\n' as u8) { 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 byte == '\n' as u8 {
if !at_line_start || !squeeze_blank { if !at_line_start || !squeeze_blank {
if at_line_start && number == NumberingMode::NumberAll { 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; line_counter += 1;
} }
if show_ends { if show_ends {
@ -207,7 +207,7 @@ fn write_bytes(files: Vec<String>, number: NumberingMode, squeeze_blank: bool,
continue; continue;
} }
if at_line_start && number != NumberingMode::NumberNone { 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; line_counter += 1;
at_line_start = false; at_line_start = false;
} }
@ -284,7 +284,7 @@ fn open(path: &str) -> Option<(Box<Reader>, bool)> {
match File::open(&std::path::Path::new(path)) { match File::open(&std::path::Path::new(path)) {
Ok(f) => Some((box f as Box<Reader>, false)), Ok(f) => Some((box f as Box<Reader>, false)),
Err(e) => { 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 None
}, },
} }

View file

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

View file

@ -65,7 +65,7 @@ pub fn uumain(args: Vec<String>) -> int {
if opts.free.len() == 0 { if opts.free.len() == 0 {
println!("Missing operand: NEWROOT"); 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 return 1
} }
@ -108,7 +108,7 @@ fn set_context(root: &Path, options: &getopts::Matches) {
Some(ref u) => { Some(ref u) => {
let s: Vec<&str> = u.as_slice().split(':').collect(); let s: Vec<&str> = u.as_slice().split(':').collect();
if s.len() != 2 { if s.len() != 2 {
crash!(1, "invalid userspec: `{:s}`", u.as_slice()) crash!(1, "invalid userspec: `{}`", u.as_slice())
}; };
s s
} }
@ -131,7 +131,7 @@ fn enter_chroot(root: &Path) {
chroot(".".to_c_str().unwrap() as *const libc::c_char) chroot(".".to_c_str().unwrap() as *const libc::c_char)
}; };
if err != 0 { 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) }; let err = unsafe { setgid(group_id) };
if err != 0 { 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); let err = set_groups(groups_vec);
if err != 0 { 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 user_id = get_pw_from_args(&vec!(String::from_str(user))).unwrap().pw_uid;
let err = unsafe { setuid(user_id as libc::uid_t) }; let err = unsafe { setuid(user_id as libc::uid_t) };
if err != 0 { 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]) { fn help_menu(program: &str, options: &[getopts::OptGroup]) {
version(); version();
println!("Usage:"); println!("Usage:");
println!(" {:s} [OPTION]… NEWROOT [COMMAND [ARG]…]", program); println!(" {} [OPTION]… NEWROOT [COMMAND [ARG]…]", program);
println!(""); println!("");
print!("{:s}", usage( print!("{}", usage(
"Run COMMAND with root directory set to NEWROOT.\n\ "Run COMMAND with root directory set to NEWROOT.\n\
If COMMAND is not specified, it defaults to '${SHELL} -i'. \ If COMMAND is not specified, it defaults to '${SHELL} -i'. \
If ${SHELL} is not set, /bin/sh is used.", options)) 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() { if pw_pointer.is_not_null() {
Some(unsafe { read(pw_pointer) }) Some(unsafe { read(pw_pointer) })
} else { } else {
crash!(1, "{:s}: no such user", username); crash!(1, "{}: no such user", username);
} }
// Passed the username as a string // 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() { if pw_pointer.is_not_null() {
Some(unsafe { read(pw_pointer) }) Some(unsafe { read(pw_pointer) })
} else { } else {
crash!(1, "{:s}: no such user", username); crash!(1, "{}: no such user", username);
} }
} }
} else { } else {
@ -210,7 +210,7 @@ pub fn group(possible_pw: Option<c_passwd>, nflag: bool) {
match groups { match groups {
Err(errno) => Err(errno) =>
crash!(1, "failed to get group list (errno={:u})", errno), crash!(1, "failed to get group list (errno={})", errno),
Ok(groups) => { Ok(groups) => {
for &g in groups.iter() { for &g in groups.iter() {
if nflag { if nflag {
@ -219,10 +219,10 @@ pub fn group(possible_pw: Option<c_passwd>, nflag: bool) {
let name = unsafe { let name = unsafe {
from_buf(read(group).gr_name as *const u8) from_buf(read(group).gr_name as *const u8)
}; };
print!("{:s} ", name); print!("{} ", name);
} }
} else { } else {
print!("{:u} ", g); print!("{} ", g);
} }
} }
println!(""); println!("");

View file

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

View file

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

View file

@ -29,10 +29,10 @@ pub fn uumain(args: Vec<String>) -> int {
}; };
if matches.opt_present("help") { 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!("");
println!("Usage:"); println!("Usage:");
println!(" {0:s} [OPTION] NAME...", program); println!(" {0} [OPTION] NAME...", program);
println!(""); println!("");
print(getopts::usage("Output each NAME with its last non-slash component and trailing slashes 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 removed; if NAME contains no /'s, output '.' (meaning the current
@ -41,7 +41,7 @@ directory).", &opts).as_slice());
} }
if matches.opt_present("version") { if matches.opt_present("version") {
println!("dirname version: {:s}", VERSION); println!("dirname version: {}", VERSION);
return 0; return 0;
} }
@ -60,8 +60,8 @@ directory).", &opts).as_slice());
print(separator); print(separator);
} }
} else { } else {
println!("{0:s}: missing operand", program); println!("{0}: missing operand", program);
println!("Try '{0:s} --help' for more information.", program); println!("Try '{0} --help' for more information.", program);
return 1; 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())); let max_depth = max_depth_str.as_ref().and_then(|s| from_str::<uint>(s.as_slice()));
match (max_depth_str, max_depth) { match (max_depth_str, max_depth) {
(Some(ref s), _) if summarize => { (Some(ref s), _) if summarize => {
show_error!("summarizing conflicts with --max-depth={:s}", *s); show_error!("summarizing conflicts with --max-depth={}", *s);
return 1; return 1;
} }
(Some(ref s), None) => { (Some(ref s), None) => {
show_error!("invalid maximum depth '{:s}'", *s); show_error!("invalid maximum depth '{}'", *s);
return 1; return 1;
} }
(Some(_), Some(_)) | (None, _) => { /* valid */ } (Some(_), Some(_)) | (None, _) => { /* valid */ }
@ -271,9 +271,9 @@ ers of 1000).",
let convert_size = |size: u64| -> String { let convert_size = |size: u64| -> String {
if matches.opt_present("human-readable") || matches.opt_present("si") { if matches.opt_present("human-readable") || matches.opt_present("si") {
if size >= MB { 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 { } else if size >= KB {
format!("{:.1f}K", (size as f64) / (KB as f64)) format!("{:.1}K", (size as f64) / (KB as f64))
} else { } else {
format!("{}B", size) 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("h", "help", "display this help and exit"),
getopts::optflag("V", "version", "output version information 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!("");
println!("Usage:"); println!("Usage:");
println!(" {0:s} [SHORT-OPTION]... [STRING]...", *program); println!(" {0} [SHORT-OPTION]... [STRING]...", *program);
println!(" {0:s} LONG-OPTION", *program); println!(" {0} LONG-OPTION", *program);
println!(""); println!("");
println(getopts::usage("Echo the STRING(s) to standard output.", &opts).as_slice()); println(getopts::usage("Echo the STRING(s) to standard output.", &opts).as_slice());
println("If -e is in effect, the following sequences are recognized: println("If -e is in effect, the following sequences are recognized:
@ -160,7 +160,7 @@ fn print_help(program: &String) {
} }
fn print_version() { fn print_version() {
println!("echo version: {:s}", VERSION); println!("echo version: {}", VERSION);
} }
pub fn uumain(args: Vec<String>) -> int { 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) { 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!("Set each NAME to VALUE in the environment and run COMMAND\n");
println!("Possible options are:"); println!("Possible options are:");
println!(" -i --ignore-environment\t start with an empty environment"); println!(" -i --ignore-environment\t start with an empty environment");
@ -43,7 +43,7 @@ fn print_env(null: bool) {
let env = std::os::env(); let env = std::os::env();
for &(ref n, ref v) in env.iter() { for &(ref n, ref v) in env.iter() {
print!("{:s}={:s}{:c}", print!("{}={}{}",
n.as_slice(), n.as_slice(),
v.as_slice(), v.as_slice(),
if null { '\0' } else { '\n' } if null { '\0' } else { '\n' }
@ -101,14 +101,14 @@ pub fn uumain(args: Vec<String>) -> int {
let var = iter.next(); let var = iter.next();
match var { 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()) Some(s) => opts.unsets.push(s.to_string())
} }
} }
_ => { _ => {
println!("{:s}: invalid option \"{:s}\"", prog, *opt); println!("{}: invalid option \"{}\"", prog, *opt);
println!("Type \"{:s} --help\" for detailed informations", prog); println!("Type \"{} --help\" for detailed informations", prog);
return 1; return 1;
} }
} }
@ -134,13 +134,13 @@ pub fn uumain(args: Vec<String>) -> int {
let var = iter.next(); let var = iter.next();
match var { 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()) Some(s) => opts.unsets.push(s.to_string())
} }
} }
_ => { _ => {
println!("{:s}: illegal option -- {:c}", prog, c); println!("{}: illegal option -- {}", prog, c);
println!("Type \"{:s} --help\" for detailed informations", prog); println!("Type \"{} --help\" for detailed informations", prog);
return 1; return 1;
} }
} }
@ -181,8 +181,8 @@ pub fn uumain(args: Vec<String>) -> int {
} }
} }
for ref name in opts.unsets.iter() { for name in opts.unsets.iter() {
std::os::unsetenv(name.as_slice()) std::os::unsetenv((name).as_slice())
} }
for &(ref name, ref val) in opts.sets.iter() { 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") { if matches.opt_present("help") {
println!("Usage: {:s} [OPTION]... [FILE]...", NAME); println!("Usage: {} [OPTION]... [FILE]...", NAME);
io::print(getopts::usage( io::print(getopts::usage(
"Convert tabs in each FILE to spaces, writing to standard output.\n\ "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()); 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 => { Ok('\t') if init || !options.iflag => {
let nb_spaces = to_next_stop(options.tabstops.as_slice(), col); let nb_spaces = to_next_stop(options.tabstops.as_slice(), col);
col += nb_spaces; col += nb_spaces;
safe_write!(output, "{:1$s}", "", nb_spaces); safe_write!(&mut output, "{:1$}", "", nb_spaces);
} }
Ok('\x08') => { Ok('\x08') => {
if col > 0 { if col > 0 {
col -= 1; col -= 1;
} }
init = false; init = false;
safe_write!(output, "{:c}", '\x08'); safe_write!(&mut output, "{}", '\x08');
} }
Ok('\n') => { Ok('\n') => {
col = 0; col = 0;
init = true; init = true;
safe_write!(output, "{:c}", '\n'); safe_write!(&mut output, "{}", '\n');
} }
Ok(c) => { Ok(c) => {
col += 1; col += 1;
if c != ' ' { if c != ' ' {
init = false; init = false;
} }
safe_write!(output, "{:c}", c); safe_write!(&mut output, "{}", c);
} }
Err(_) => break 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) { let given_options = match getopts(args.as_slice(), &possible_options) {
Ok (m) => { m } Ok (m) => { m }
Err(_) => { Err(_) => {
println!("{:s}", usage(NAME, &possible_options)); println!("{}", usage(NAME, &possible_options));
return 1; return 1;
} }
}; };
if given_options.opt_present("h") { if given_options.opt_present("h") {
println!("{:s}", usage(NAME, &possible_options)); println!("{}", usage(NAME, &possible_options));
return 0; return 0;
} }
if given_options.opt_present("V") { version(); 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() { for file in files.iter() {
if multiple { if multiple {
if !firstime { pipe_println!(""); } if !firstime { pipe_println!(""); }
pipe_println!("==> {:s} <==", file.as_slice()); pipe_println!("==> {} <==", file.as_slice());
} }
firstime = false; firstime = false;

View file

@ -95,7 +95,7 @@ pub fn uumain(args: Vec<String>) -> int {
if matches.opt_present("s") { if matches.opt_present("s") {
let pos = hostname.as_slice().find_str("."); let pos = hostname.as_slice().find_str(".");
if pos.is_some() { if pos.is_some() {
println!("{:s}", hostname.as_slice().slice_to(pos.unwrap())); println!("{}", hostname.as_slice().slice_to(pos.unwrap()));
return 0; return 0;
} }
} else if matches.opt_present("d") { } 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()), 1 => xsethostname(matches.free.last().unwrap().as_slice()),
@ -124,9 +124,9 @@ fn help_menu(program: &str, options: &[getopts::OptGroup]) {
version(); version();
println!(""); println!("");
println!("Usage:"); println!("Usage:");
println!(" {:s} [OPTION]... [HOSTNAME]", program); println!(" {} [OPTION]... [HOSTNAME]", program);
println!(""); 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 { fn xgethostname() -> String {
@ -156,7 +156,7 @@ fn xsethostname(name: &str) {
}; };
if err != 0 { 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 { 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) { let matches = match getopts(args_t, &options) {
Ok(m) => { m }, Ok(m) => { m },
Err(_) => { Err(_) => {
println!("{:s}", usage(NAME, &options)); println!("{}", usage(NAME, &options));
return 1; return 1;
} }
}; };
if matches.opt_present("h") { if matches.opt_present("h") {
println!("{:s}", usage(NAME, &options)); println!("{}", usage(NAME, &options));
return 0; return 0;
} }
@ -140,9 +140,9 @@ pub fn uumain(args: Vec<String>) -> int {
if nflag && gr.is_not_null() { if nflag && gr.is_not_null() {
let gr_name = unsafe { from_buf(read(gr).gr_name as *const u8) }; let gr_name = unsafe { from_buf(read(gr).gr_name as *const u8) };
println!("{:s}", gr_name); println!("{}", gr_name);
} else { } else {
println!("{:u}", id); println!("{}", id);
} }
return 0; return 0;
} }
@ -161,9 +161,9 @@ pub fn uumain(args: Vec<String>) -> int {
let pw_name = unsafe { let pw_name = unsafe {
from_buf(read(pw).pw_name as *const u8) from_buf(read(pw).pw_name as *const u8)
}; };
println!("{:s}", pw_name); println!("{}", pw_name);
} else { } else {
println!("{:u}", id); println!("{}", id);
} }
return 0; return 0;
@ -198,7 +198,7 @@ fn pretty(possible_pw: Option<c_passwd>) {
let pw = possible_pw.unwrap(); let pw = possible_pw.unwrap();
let pw_name = unsafe { from_buf(pw.pw_name as *const u8) }; 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); group(possible_pw, true);
} else { } else {
let login = unsafe { from_buf(getlogin() as *const u8) }; 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 { if pw.is_null() || is_same_user {
println!("login\t{:s}", login); println!("login\t{}", login);
} }
if pw.is_not_null() { if pw.is_not_null() {
println!( println!(
"uid\t{:s}", "uid\t{}",
unsafe { from_buf(read(pw).pw_name as *const u8) }) unsafe { from_buf(read(pw).pw_name as *const u8) })
} else { } else {
println!("uid\t{:u}\n", rid); println!("uid\t{}\n", rid);
} }
let eid = unsafe { getegid() }; let eid = unsafe { getegid() };
@ -226,10 +226,10 @@ fn pretty(possible_pw: Option<c_passwd>) {
let pw = unsafe { getpwuid(eid) }; let pw = unsafe { getpwuid(eid) };
if pw.is_not_null() { if pw.is_not_null() {
println!( println!(
"euid\t{:s}", "euid\t{}",
unsafe { from_buf(read(pw).pw_name as *const u8) }); unsafe { from_buf(read(pw).pw_name as *const u8) });
} else { } 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) }; let gr = unsafe { getgrgid(rid) };
if gr.is_not_null() { if gr.is_not_null() {
println!( println!(
"rgid\t{:s}", "rgid\t{}",
unsafe { from_buf(read(gr).gr_name as *const u8) }); unsafe { from_buf(read(gr).gr_name as *const u8) });
} else { } 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) }; let pw_shell = unsafe { from_buf(pw.pw_shell as *const u8) };
println!( println!(
"{:s}:{:s}:{:u}:{:u}:{:s}:{:d}:{:d}:{:s}:{:s}:{:s}", "{}:{}:{}:{}:{}:{}:{}:{}:{}:{}",
pw_name, pw_name,
pw_passwd, pw_passwd,
pw.pw_uid, 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)}; let pw_shell = unsafe { from_buf(pw.pw_shell as *const u8)};
println!( println!(
"{:s}:{:s}:{:u}:{:u}:{:s}:{:s}:{:s}", "{}:{}:{}:{}:{}:{}:{}",
pw_name, pw_name,
pw_passwd, pw_passwd,
pw.pw_uid, pw.pw_uid,
@ -317,11 +317,11 @@ fn auditid() {
return; return;
} }
println!("auid={:u}", auditinfo.ai_auid); println!("auid={}", auditinfo.ai_auid);
println!("mask.success=0x{:x}", auditinfo.ai_mask.am_success); println!("mask.success=0x{:x}", auditinfo.ai_mask.am_success);
println!("mask.failure=0x{:x}", auditinfo.ai_mask.am_failure); println!("mask.failure=0x{:x}", auditinfo.ai_mask.am_failure);
println!("termid.port=0x{:x}", auditinfo.ai_termid.port); 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>, 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| { 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() { if possible_pw.is_some() {
print!( print!(
"uid={:u}({:s})", "uid={}({})",
uid, uid,
unsafe { from_buf(possible_pw.unwrap().pw_name as *const u8) }); unsafe { from_buf(possible_pw.unwrap().pw_name as *const u8) });
} else { } else {
print!("uid={:u}", unsafe { getuid() }); print!("uid={}", unsafe { getuid() });
} }
print!(" gid={:u}", gid); print!(" gid={}", gid);
let gr = unsafe { getgrgid(gid) }; let gr = unsafe { getgrgid(gid) };
if gr.is_not_null() { if gr.is_not_null() {
print!( print!(
"({:s})", "({})",
unsafe { from_buf(read(gr).gr_name as *const u8) }); unsafe { from_buf(read(gr).gr_name as *const u8) });
} }
let euid = unsafe { geteuid() }; let euid = unsafe { geteuid() };
if p_euid && (euid != uid) { if p_euid && (euid != uid) {
print!(" euid={:u}", euid); print!(" euid={}", euid);
let pw = unsafe { getpwuid(euid) }; let pw = unsafe { getpwuid(euid) };
if pw.is_not_null() { if pw.is_not_null() {
print!( print!(
"({:s})", "({})",
unsafe { from_buf(read(pw).pw_name as *const u8) }); unsafe { from_buf(read(pw).pw_name as *const u8) });
} }
} }
let egid = unsafe { getegid() }; let egid = unsafe { getegid() };
if p_egid && (egid != gid) { if p_egid && (egid != gid) {
print!(" egid={:u}", egid); print!(" egid={}", egid);
unsafe { unsafe {
let grp = getgrgid(egid); let grp = getgrgid(egid);
if grp.is_not_null() { 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; let mut first = true;
for &gr in groups.iter() { for &gr in groups.iter() {
if !first { print!(",") } if !first { print!(",") }
print!("{:u}", gr); print!("{}", gr);
let group = unsafe { getgrgid(gr) }; let group = unsafe { getgrgid(gr) };
if group.is_not_null() { if group.is_not_null() {
let name = unsafe { let name = unsafe {
from_buf(read(group).gr_name as *const u8) from_buf(read(group).gr_name as *const u8)
}; };
print!("({:s})", name); print!("({})", name);
} }
first = false first = false
} }

View file

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

View file

@ -12,7 +12,6 @@
#![feature(macro_rules)] #![feature(macro_rules)]
extern crate getopts; extern crate getopts;
extern crate libc; extern crate libc;
extern crate native;
use getopts::{optflag, getopts, usage}; use getopts::{optflag, getopts, usage};
use std::io::stdio::{stdin_raw, stdout_raw, stderr_raw}; 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 { if opts.free.len() == 0 {
show_error!("Missing operand: COMMAND"); 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 return 1
} }
replace_fds(); replace_fds();
@ -179,10 +178,10 @@ fn version() {
fn show_usage(program: &str, options: &[getopts::OptGroup]) { fn show_usage(program: &str, options: &[getopts::OptGroup]) {
version(); version();
println!("Usage:"); println!("Usage:");
println!(" {:s} COMMAND [ARG]…", program); println!(" {} COMMAND [ARG]…", program);
println!(" {:s} OPTION", program); println!(" {} OPTION", program);
println!(""); println!("");
print!("{:s}", usage( print!("{}", usage(
"Run COMMAND ignoring hangup signals.\n\ "Run COMMAND ignoring hangup signals.\n\
If standard input is terminal, it'll be replaced with /dev/null.\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, \ 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!("{} {}", NAME, VERSION);
println!(""); println!("");
println!("Usage:"); println!("Usage:");
println!(" {0:s} [OPTION]... [FILE]...", program); println!(" {0} [OPTION]... [FILE]...", program);
println!(""); println!("");
print!("{}", getopts::usage("Write lines consisting of the sequentially corresponding lines from each FILE, separated by TABs, to standard output.", &opts)); 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") { } 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!("printenv 1.0.0");
println!(""); println!("");
println!("Usage:"); println!("Usage:");
println!(" {0:s} [VARIABLE]... [OPTION]...", program); println!(" {0} [VARIABLE]... [OPTION]...", program);
println!(""); println!("");
print(getopts::usage("Prints the given environment VARIABLE(s), otherwise prints them all.", &opts).as_slice()); print(getopts::usage("Prints the given environment VARIABLE(s), otherwise prints them all.", &opts).as_slice());
return 0; return 0;
@ -64,7 +64,7 @@ pub fn exec(args: Vec<String>, separator: &str) {
if args.is_empty() { if args.is_empty() {
let vars = os::env(); let vars = os::env();
for (env_var, value) in vars.into_iter() { for (env_var, value) in vars.into_iter() {
print!("{0:s}={1:s}", env_var, value); print!("{0}={1}", env_var, value);
print(separator); print(separator);
} }
return; return;

View file

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

View file

@ -44,7 +44,7 @@ pub fn uumain(args: Vec<String>) -> int {
if opts.free.len() == 0 { if opts.free.len() == 0 {
show_error!("Missing operand: FILENAME, at least one is required"); 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 return 1
} }
@ -125,11 +125,11 @@ fn version() {
fn show_usage(program: &str, options: &[getopts::OptGroup]) { fn show_usage(program: &str, options: &[getopts::OptGroup]) {
version(); version();
println!("Usage:"); println!("Usage:");
println!(" {:s} [-s|--strip] [-z|--zero] FILENAME…", program); println!(" {} [-s|--strip] [-z|--zero] FILENAME…", program);
println!(" {:s} -V|--version", program); println!(" {} -V|--version", program);
println!(" {:s} -h|--help", program); println!(" {} -h|--help", program);
println!(""); println!("");
print!("{:s}", usage( print!("{}", usage(
"Convert each FILENAME to the absolute path.\n\ "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\ 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\ 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 { if opts.free.len() == 0 {
show_error!("Missing operand: TO"); 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 return 1
} }
@ -89,11 +89,11 @@ fn version() {
fn show_usage(program: &str, options: &[getopts::OptGroup]) { fn show_usage(program: &str, options: &[getopts::OptGroup]) {
version(); version();
println!("Usage:"); println!("Usage:");
println!(" {:s} [-d DIR] TO [FROM]", program); println!(" {} [-d DIR] TO [FROM]", program);
println!(" {:s} -V|--version", program); println!(" {} -V|--version", program);
println!(" {:s} -h|--help", program); println!(" {} -h|--help", program);
println!(""); println!("");
print!("{:s}", usage( print!("{}", usage(
"Convert TO destination to the relative path from the FROM dir.\n\ "Convert TO destination to the relative path from the FROM dir.\n\
If FROM path is omitted, current working dir will be used.", options) 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!("rm 1.0.0");
println!(""); println!("");
println!("Usage:"); println!("Usage:");
println!(" {0:s} [OPTION]... [FILE]...", program); println!(" {0} [OPTION]... [FILE]...", program);
println!(""); println!("");
print(getopts::usage("Remove (unlink) the FILE(s).", &opts).as_slice()); print(getopts::usage("Remove (unlink) the FILE(s).", &opts).as_slice());
println!(""); println!("");
@ -77,7 +77,7 @@ pub fn uumain(args: Vec<String>) -> int {
println!("rm 1.0.0"); println!("rm 1.0.0");
} else if matches.free.is_empty() { } else if matches.free.is_empty() {
show_error!("missing an argument"); show_error!("missing an argument");
show_error!("for help, try '{0:s} --help'", program); show_error!("for help, try '{0} --help'", program);
return 1; return 1;
} else { } else {
let force = matches.opt_present("force"); 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!("rmdir 1.0.0");
println!(""); println!("");
println!("Usage:"); println!("Usage:");
println!(" {0:s} [OPTION]... DIRECTORY...", program); println!(" {0} [OPTION]... DIRECTORY...", program);
println!(""); println!("");
print(getopts::usage("Remove the DIRECTORY(ies), if they are empty.", &opts).as_slice()); print(getopts::usage("Remove the DIRECTORY(ies), if they are empty.", &opts).as_slice());
} else if matches.opt_present("version") { } else if matches.opt_present("version") {
println!("rmdir 1.0.0"); println!("rmdir 1.0.0");
} else if matches.free.is_empty() { } else if matches.free.is_empty() {
show_error!("missing an argument"); show_error!("missing an argument");
show_error!("for help, try '{0:s} --help'", program); show_error!("for help, try '{0} --help'", program);
return 1; return 1;
} else { } else {
let ignore = matches.opt_present("ignore-fail-on-non-empty"); 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>{ fn parse_float(s: &str) -> Result<f64, String>{
match from_str(s) { match from_str(s) {
Some(n) => Ok(n), 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!("seq 1.0.0\n");
println!("Usage:\n {} [-w] [-s string] [-t string] [first [step]] last\n", *program); 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() { fn print_version() {
@ -168,7 +168,7 @@ pub fn uumain(args: Vec<String>) -> int {
padding = dec; padding = dec;
match parse_float(slice) { match parse_float(slice) {
Ok(n) => n, Ok(n) => n,
Err(s) => { show_error!("{:s}", s); return 1; } Err(s) => { show_error!("{}", s); return 1; }
} }
} else { } else {
1.0 1.0
@ -181,7 +181,7 @@ pub fn uumain(args: Vec<String>) -> int {
padding = cmp::max(padding, dec); padding = cmp::max(padding, dec);
match parse_float(free[1].as_slice()) { match parse_float(free[1].as_slice()) {
Ok(n) => n, Ok(n) => n,
Err(s) => { show_error!("{:s}", s); return 1; } Err(s) => { show_error!("{}", s); return 1; }
} }
} else { } else {
1.0 1.0
@ -191,7 +191,7 @@ pub fn uumain(args: Vec<String>) -> int {
padding = cmp::max(padding, slice.find('.').unwrap_or(slice.len())); padding = cmp::max(padding, slice.find('.').unwrap_or(slice.len()));
match parse_float(slice) { match parse_float(slice) {
Ok(n) => n, 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()); 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; i += 1;
value = first + i as f64 * step; value = first + i as f64 * step;
if !done_printing(value, step, last) { if !done_printing(value, step, last) {
if !pipe_print!("{:s}", separator) { if !pipe_print!("{}", separator) {
return; return;
} }
} }
} }
if (first >= last && step < 0f64) || (first <= last && step > 0f64) { 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!("sleep 1.0.0");
println!(""); println!("");
println!("Usage:"); println!("Usage:");
println!(" {0:s} NUMBER[SUFFIX]", program); println!(" {0} NUMBER[SUFFIX]", program);
println!("or"); println!("or");
println!(" {0:s} OPTION", program); println!(" {0} OPTION", program);
println!(""); println!("");
print(getopts::usage("Pause for NUMBER seconds. SUFFIX may be 's' for seconds (the default), 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 '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"); println!("sleep 1.0.0");
} else if matches.free.is_empty() { } else if matches.free.is_empty() {
show_error!("missing an argument"); show_error!("missing an argument");
show_error!("for help, try '{0:s} --help'", program); show_error!("for help, try '{0} --help'", program);
return 1; return 1;
} else { } else {
sleep(matches.free); sleep(matches.free);

View file

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

View file

@ -45,7 +45,7 @@ pub fn uumain(args: Vec<String>) -> int {
println!("{} v{}", NAME, VERSION); println!("{} v{}", NAME, VERSION);
println!(""); println!("");
println!("Usage:"); println!("Usage:");
println!(" {0:s} [OPTION]... [INPUT [PREFIX]]", NAME); println!(" {0} [OPTION]... [INPUT [PREFIX]]", NAME);
println!(""); 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()); 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; return 0;

View file

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

View file

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

View file

@ -40,7 +40,7 @@ pub fn uumain(args: Vec<String>) -> int {
println!("tac {}", VERSION); println!("tac {}", VERSION);
println!(""); println!("");
println!("Usage:"); println!("Usage:");
println!(" {0:s} [OPTION]... [FILE]...", program); println!(" {0} [OPTION]... [FILE]...", program);
println!(""); println!("");
print!("{}", getopts::usage("Write each file to standard output, last line first.", &opts)); print!("{}", getopts::usage("Write each file to standard output, last line first.", &opts));
} else if matches.opt_present("version") { } 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) { let given_options = match getopts(args.as_slice(), &possible_options) {
Ok (m) => { m } Ok (m) => { m }
Err(_) => { Err(_) => {
println!("{:s}", usage(NAME, &possible_options)); println!("{}", usage(NAME, &possible_options));
return 1; return 1;
} }
}; };
if given_options.opt_present("h") { if given_options.opt_present("h") {
println!("{:s}", usage(NAME, &possible_options)); println!("{}", usage(NAME, &possible_options));
return 0; return 0;
} }
if given_options.opt_present("V") { version(); 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() { for file in files.iter() {
if multiple { if multiple {
if !firstime { println!(""); } if !firstime { println!(""); }
println!("==> {:s} <==", file.as_slice()); println!("==> {} <==", file.as_slice());
} }
firstime = false; firstime = false;

View file

@ -63,7 +63,7 @@ Usage:
println!("{} v{}", NAME, VERSION); println!("{} v{}", NAME, VERSION);
} else if matches.free.len() < 2 { } else if matches.free.len() < 2 {
show_error!("missing an argument"); 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; return ERR_EXIT_STATUS;
} else { } else {
let status = matches.opt_present("preserve-status"); 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") { if matches.opt_present("version") {
println!("{:s} {:s}", NAME, VERSION); println!("{} {}", NAME, VERSION);
return 0; return 0;
} }
if matches.opt_present("help") || matches.free.is_empty() { if matches.opt_present("help") || matches.free.is_empty() {
println!("{:s} {:s}", NAME, VERSION); println!("{} {}", NAME, VERSION);
println!(""); println!("");
println!("Usage: {:s} [OPTION]... FILE...", NAME); println!("Usage: {} [OPTION]... FILE...", NAME);
println!(""); 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)); each FILE to the current time.", &opts));
if matches.free.is_empty() { if matches.free.is_empty() {
return 1; return 1;

View file

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

View file

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

View file

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

View file

@ -147,7 +147,7 @@ pub fn uumain(args: Vec<String>) -> int {
println!("{} {}", NAME, VERSION); println!("{} {}", NAME, VERSION);
println!(""); println!("");
println!("Usage:"); println!("Usage:");
println!(" {0:s} [OPTION]... [FILE]...", program); println!(" {0} [OPTION]... [FILE]...", program);
println!(""); println!("");
print!("{}", getopts::usage("Filter adjacent matching lines from INPUT (or standard input),\n\ print!("{}", getopts::usage("Filter adjacent matching lines from INPUT (or standard input),\n\
writing to OUTPUT (or standard output).", &opts)); 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!("unlink 1.0.0");
println!(""); println!("");
println!("Usage:"); println!("Usage:");
println!(" {0:s} [FILE]... [OPTION]...", program); println!(" {0} [FILE]... [OPTION]...", program);
println!(""); println!("");
print(getopts::usage("Unlink the file at [FILE].", &opts).as_slice()); print(getopts::usage("Unlink the file at [FILE].", &opts).as_slice());
return 0; return 0;
@ -55,9 +55,9 @@ pub fn uumain(args: Vec<String>) -> int {
} }
if matches.free.len() == 0 { 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 { } 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()); 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 { if matches.opt_present("help") || matches.free.len() > 0 {
println!("Usage:"); println!("Usage:");
println!(" {0:s} [OPTION]", program); println!(" {0} [OPTION]", program);
println!(""); println!("");
print(getopts::usage("Print the current time, the length of time the system has been up,\n\ 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\ the number of users on the system, and the average number of jobs\n\
@ -96,7 +96,7 @@ fn print_loadavg() {
else { else {
print!("load average: ") print!("load average: ")
for n in range(0, loads) { 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 { ", " } ); else { ", " } );
} }
} }
@ -153,7 +153,7 @@ fn print_time() {
if local_time.tm_hour >= 0 && local_time.tm_min >= 0 && if local_time.tm_hour >= 0 && local_time.tm_min >= 0 &&
local_time.tm_sec >= 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); local_time.tm_min, local_time.tm_sec);
} }
} }
@ -187,12 +187,12 @@ fn print_uptime(upsecs: i64) {
let uphours = (upsecs - (updays * 86400)) / 3600; let uphours = (upsecs - (updays * 86400)) / 3600;
let upmins = (upsecs - (updays * 86400) - (uphours * 3600)) / 60; let upmins = (upsecs - (updays * 86400) - (uphours * 3600)) / 60;
if updays == 1 { 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 { else if updays > 1 {
print!("up {:1d} days, {:2d}:{:02d}, ", updays, uphours, upmins); print!("up {:1} days, {:2}:{:02}, ", updays, uphours, upmins);
} }
else { 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!("users 1.0.0");
println!(""); println!("");
println!("Usage:"); println!("Usage:");
println!(" {:s} [OPTION]... [FILE]", program); println!(" {} [OPTION]... [FILE]", program);
println!(""); println!("");
print(getopts::usage("Output who is currently logged in according to FILE.", &opts).as_slice()); print(getopts::usage("Output who is currently logged in according to FILE.", &opts).as_slice());
return 0; return 0;

View file

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

View file

@ -80,7 +80,7 @@ pub fn uumain(args: Vec<String>) -> int {
println!("whoami 1.0.0"); println!("whoami 1.0.0");
println!(""); println!("");
println!("Usage:"); println!("Usage:");
println!(" {:s}", program); println!(" {}", program);
println!(""); println!("");
print(getopts::usage("print effective userid", &opts).as_slice()); print(getopts::usage("print effective userid", &opts).as_slice());
return 0; return 0;
@ -98,6 +98,6 @@ pub fn uumain(args: Vec<String>) -> int {
pub fn exec() { pub fn exec() {
unsafe { unsafe {
let username = platform::getusername(); 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!("yes 1.0.0");
println!(""); println!("");
println!("Usage:"); println!("Usage:");
println!(" {0:s} [STRING]... [OPTION]...", program); println!(" {0} [STRING]... [OPTION]...", program);
println!(""); println!("");
print(getopts::usage("Repeatedly output a line with all specified STRING(s), or 'y'.", &opts).as_slice()); print(getopts::usage("Repeatedly output a line with all specified STRING(s), or 'y'.", &opts).as_slice());
return 0; return 0;

View file

@ -5,28 +5,28 @@ static PROGNAME: &'static str = "./seq";
#[test] #[test]
fn test_count_up() { 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(); let out = str::from_utf8(p.output.as_slice()).unwrap();
assert_eq!(out, "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n"); assert_eq!(out, "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n");
} }
#[test] #[test]
fn test_count_down() { 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(); let out = str::from_utf8(p.output.as_slice()).unwrap();
assert_eq!(out, "5\n4\n3\n2\n1\n"); assert_eq!(out, "5\n4\n3\n2\n1\n");
} }
#[test] #[test]
fn test_separator_and_terminator() { 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(); let out = str::from_utf8(p.output.as_slice()).unwrap();
assert_eq!(out, "2,3,4,5,6!"); assert_eq!(out, "2,3,4,5,6!");
} }
#[test] #[test]
fn test_equalize_widths() { 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(); let out = str::from_utf8(p.output.as_slice()).unwrap();
assert_eq!(out, "05\n06\n07\n08\n09\n10\n"); 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] #[test]
fn test_toupper() { 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!"); assert_eq!(out.as_slice(), b"!ABCD!");
} }
#[test] #[test]
fn test_small_set2() { 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"); assert_eq!(out.as_slice(), b"@XXXXXXXXXX");
} }
#[test] #[test]
fn test_unicode() { fn test_unicode() {
let out = run("(,°□°), ┬─┬", [", ┬─┬", "╯︵┻━┻"]); let out = run("(,°□°), ┬─┬", &[", ┬─┬", "╯︵┻━┻"]);
assert_eq!(out.as_slice(), "(╯°□°)╯︵┻━┻".as_bytes()); assert_eq!(out.as_slice(), "(╯°□°)╯︵┻━┻".as_bytes());
} }
#[test] #[test]
fn test_delete() { fn test_delete() {
let out = run("aBcD", ["-d", "a-z"]); let out = run("aBcD", &["-d", "a-z"]);
assert_eq!(out.as_slice(), b"BD"); assert_eq!(out.as_slice(), b"BD");
} }
#[test] #[test]
fn test_delete_complement() { 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"); assert_eq!(out.as_slice(), b"ac");
} }

View file

@ -15,7 +15,7 @@ fn make_file(name: &str) -> io::File {
#[test] #[test]
fn test_increase_file_size() { fn test_increase_file_size() {
let mut file = make_file(TFILE1); 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!(); panic!();
} }
file.seek(0, io::SeekEnd).unwrap(); file.seek(0, io::SeekEnd).unwrap();
@ -29,7 +29,7 @@ fn test_increase_file_size() {
fn test_decrease_file_size() { fn test_decrease_file_size() {
let mut file = make_file(TFILE2); let mut file = make_file(TFILE2);
file.write(b"1234567890").unwrap(); 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!(); panic!();
} }
file.seek(0, io::SeekEnd).unwrap(); file.seek(0, io::SeekEnd).unwrap();

View file

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