1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 11:37:44 +00:00

Merge pull request #63 from Heather/master

update code for Rust print syntax changes
This commit is contained in:
Jordi Boggiano 2014-01-13 02:03:38 -08:00
commit 4f855fd96a
15 changed files with 93 additions and 91 deletions

View file

@ -12,7 +12,7 @@
extern mod extra; extern mod extra;
use std::char; use std::char;
use std::io::{File, stdin, stdout}; use std::io::{println, File, stdin, stdout};
use std::os; use std::os;
use std::str; use std::str;
@ -135,7 +135,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: {:s} [OPTION]... [FILE]", progname);
println(""); println!("");
println(usage); println(usage);
let msg = ~"With no FILE, or when FILE is -, read standard input.\n\n\ let msg = ~"With no FILE, or when FILE is -, read standard input.\n\n\
@ -149,7 +149,7 @@ fn help(progname: &str, usage: &str) {
} }
fn version() { fn version() {
println("base64 1.0.0"); println!("base64 1.0.0");
} }
enum Mode { enum Mode {

View file

@ -11,7 +11,7 @@
extern mod extra; extern mod extra;
use std::io::stderr; use std::io::{print, println, stderr};
use std::os; use std::os;
use std::str; use std::str;
use std::str::StrSlice; use std::str::StrSlice;
@ -46,8 +46,8 @@ fn main() {
if matches.opt_present("help") { if matches.opt_present("help") {
println!("Usage: {0:s} NAME [SUFFIX]", program); println!("Usage: {0:s} NAME [SUFFIX]", program);
println!(" or: {0:s} OPTION", program); println!(" or: {0:s} 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.");
print(groups::usage("", opts)); print(groups::usage("", opts));

View file

@ -15,7 +15,7 @@
extern mod extra; extern mod extra;
use std::os; use std::os;
use std::io::{stdin, stderr, stdout, File, result}; use std::io::{print, stdin, stderr, stdout, File, result};
use extra::getopts::groups; use extra::getopts::groups;
fn main() { fn main() {
@ -44,18 +44,18 @@ fn main() {
} }
}; };
if matches.opt_present("help") { if matches.opt_present("help") {
println("cat 1.0.0"); println!("cat 1.0.0");
println(""); println!("");
println("Usage:"); println!("Usage:");
println!(" {0:s} [OPTION]... [FILE]...", program); println!(" {0:s} [OPTION]... [FILE]...", program);
println(""); println!("");
print(groups::usage("Concatenate FILE(s), or standard input, to standard output.", opts)); print(groups::usage("Concatenate FILE(s), or standard input, to standard output.", opts));
println(""); println!("");
println("With no FILE, or when FILE is -, read standard input."); println!("With no FILE, or when FILE is -, read standard input.");
return; return;
} }
if matches.opt_present("version") { if matches.opt_present("version") {
println("cat 1.0.0"); println!("cat 1.0.0");
return; return;
} }

View file

@ -12,7 +12,7 @@
extern mod extra; extern mod extra;
use std::os; use std::os;
use std::io::stderr; use std::io::{print, stderr};
use extra::getopts::groups; use extra::getopts::groups;
static VERSION: &'static str = "1.0.0"; static VERSION: &'static str = "1.0.0";
@ -37,11 +37,11 @@ fn main() {
}; };
if matches.opt_present("help") { if matches.opt_present("help") {
println("dirname " + VERSION + " - strip last component from file name"); println!("dirname {:s} - strip last component from file name", VERSION);
println(""); println!("");
println("Usage:"); println!("Usage:");
println!(" {0:s} [OPTION] NAME...", program); println!(" {0:s} [OPTION] NAME...", program);
println(""); println!("");
print(groups::usage("Output each NAME with its last non-slash component and trailing slashes print(groups::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
directory).", opts)); directory).", opts));
@ -49,7 +49,7 @@ directory).", opts));
} }
if matches.opt_present("version") { if matches.opt_present("version") {
return println("dirname version: " + VERSION); return println!("dirname version: {:s}", VERSION);
} }
let separator = match matches.opt_present("zero") { let separator = match matches.opt_present("zero") {

View file

@ -12,7 +12,7 @@
extern mod extra; extern mod extra;
use std::os; use std::os;
use std::io::stderr; use std::io::{print, println, stderr};
use std::uint; use std::uint;
use extra::getopts::groups; use extra::getopts::groups;
@ -86,12 +86,12 @@ fn main() {
}; };
if matches.opt_present("help") { if matches.opt_present("help") {
println("echo " + VERSION + " - display a line of text"); println!("echo {:s} - display a line of text", VERSION);
println(""); println!("");
println("Usage:"); println!("Usage:");
println!(" {0:s} [SHORT-OPTION]... [STRING]...", program); println!(" {0:s} [SHORT-OPTION]... [STRING]...", program);
println!(" {0:s} LONG-OPTION", program); println!(" {0:s} LONG-OPTION", program);
println(""); println!("");
println(groups::usage("Echo the STRING(s) to standard output.", opts)); println(groups::usage("Echo the STRING(s) to standard output.", opts));
println("If -e is in effect, the following sequences are recognized: println("If -e is in effect, the following sequences are recognized:
@ -111,7 +111,7 @@ fn main() {
} }
if matches.opt_present("version") { if matches.opt_present("version") {
return println("echo version: " + VERSION); return println!("echo version: {:s}", VERSION);
} }
if !matches.free.is_empty() { if !matches.free.is_empty() {
@ -181,6 +181,6 @@ fn main() {
} }
if !matches.opt_present("n") { if !matches.opt_present("n") {
println("") println!("")
} }
} }

View file

@ -14,7 +14,7 @@
extern mod extra; extern mod extra;
use std::os; use std::os;
use std::io::stderr; use std::io::{print, stderr};
use extra::getopts::groups; use extra::getopts::groups;
fn main() { fn main() {
@ -35,16 +35,16 @@ fn main() {
} }
}; };
if matches.opt_present("help") { if matches.opt_present("help") {
println("printenv 1.0.0"); println!("printenv 1.0.0");
println(""); println!("");
println("Usage:"); println!("Usage:");
println!(" {0:s} [VARIABLE]... [OPTION]...", program); println!(" {0:s} [VARIABLE]... [OPTION]...", program);
println(""); println!("");
print(groups::usage("Prints the given environment VARIABLE(s), otherwise prints them all.", opts)); print(groups::usage("Prints the given environment VARIABLE(s), otherwise prints them all.", opts));
return; return;
} }
if matches.opt_present("version") { if matches.opt_present("version") {
println("printenv 1.0.0"); println!("printenv 1.0.0");
return; return;
} }
let mut separator = "\n"; let mut separator = "\n";

View file

@ -12,7 +12,7 @@
extern mod extra; extern mod extra;
use std::os; use std::os;
use std::io::stderr; use std::io::{print, stderr};
use extra::getopts::groups; use extra::getopts::groups;
static VERSION: &'static str = "1.0.0"; static VERSION: &'static str = "1.0.0";
@ -37,13 +37,13 @@ fn main() {
if matches.opt_present("help") { if matches.opt_present("help") {
println!("pwd {}", VERSION); println!("pwd {}", VERSION);
println(""); println!("");
println("Usage:"); println!("Usage:");
println!(" {0:s} [OPTION] NAME...", program); println!(" {0:s} [OPTION] NAME...", program);
println(""); println!("");
print(groups::usage("Print the full filename of the current working directory.", opts)); print(groups::usage("Print the full filename of the current working directory.", opts));
} else if matches.opt_present("version") { } else if matches.opt_present("version") {
return println("pwd version: " + VERSION); return println!("pwd version: {}", VERSION);
} else { } else {
let cwd = std::os::getcwd(); let cwd = std::os::getcwd();
println!("{}", cwd.display()); println!("{}", cwd.display());

View file

@ -12,7 +12,7 @@
extern mod extra; extern mod extra;
use std::os; use std::os;
use std::io::{stdin,stderr,stdio,fs,buffered,io_error}; use std::io::{print,stdin,stderr,stdio,fs,buffered,io_error};
use extra::getopts::groups; use extra::getopts::groups;
enum InteractiveMode { enum InteractiveMode {
@ -65,27 +65,27 @@ fn main() {
} }
}; };
if matches.opt_present("help") { if matches.opt_present("help") {
println("rm 1.0.0"); println!("rm 1.0.0");
println(""); println!("");
println("Usage:"); println!("Usage:");
println!(" {0:s} [OPTION]... [FILE]...", program); println!(" {0:s} [OPTION]... [FILE]...", program);
println(""); println!("");
print(groups::usage("Remove (unlink) the FILE(s).", opts)); print(groups::usage("Remove (unlink) the FILE(s).", opts));
println(""); println!("");
println("By default, rm does not remove directories. Use the --recursive (-r)"); println!("By default, rm does not remove directories. Use the --recursive (-r)");
println("option to remove each listed directory, too, along with all of its contents"); println!("option to remove each listed directory, too, along with all of its contents");
println(""); println!("");
println("To remove a file whose name starts with a '-', for example '-foo',"); println!("To remove a file whose name starts with a '-', for example '-foo',");
println("use one of these commands:"); println!("use one of these commands:");
println("rm -- -foo"); println!("rm -- -foo");
println(""); println!("");
println("rm ./-foo"); println!("rm ./-foo");
println(""); println!("");
println("Note that if you use rm to remove a file, it might be possible to recover"); println!("Note that if you use rm to remove a file, it might be possible to recover");
println("some of its contents, given sufficient expertise and/or time. For greater"); println!("some of its contents, given sufficient expertise and/or time. For greater");
println("assurance that the contents are truly unrecoverable, consider using shred."); println!("assurance that the contents are truly unrecoverable, consider using shred.");
} else if matches.opt_present("version") { } else if matches.opt_present("version") {
println("rm 1.0.0"); println!("rm 1.0.0");
} else if matches.free.is_empty() { } else if matches.free.is_empty() {
writeln!(&mut stderr() as &mut Writer, "Missing an argument"); writeln!(&mut stderr() as &mut Writer, "Missing an argument");
writeln!(&mut stderr() as &mut Writer, writeln!(&mut stderr() as &mut Writer,
@ -231,7 +231,7 @@ fn read_prompt() -> bool {
'y' | 'Y' => true, 'y' | 'Y' => true,
'n' | 'N' => false, 'n' | 'N' => false,
_ => { _ => {
print("Please enter either Y or N: "); print!("Please enter either Y or N: ");
read_prompt() read_prompt()
} }
} }

View file

@ -12,7 +12,7 @@
extern mod extra; extern mod extra;
use std::os; use std::os;
use std::io::{stderr, io_error, fs}; use std::io::{print, stderr, io_error, fs};
use extra::getopts::groups; use extra::getopts::groups;
fn main() { fn main() {
@ -36,14 +36,14 @@ fn main() {
}; };
if matches.opt_present("help") { if matches.opt_present("help") {
println("rmdir 1.0.0"); println!("rmdir 1.0.0");
println(""); println!("");
println("Usage:"); println!("Usage:");
println!(" {0:s} [OPTION]... DIRECTORY...", program); println!(" {0:s} [OPTION]... DIRECTORY...", program);
println(""); println!("");
print(groups::usage("Remove the DIRECTORY(ies), if they are empty.", opts)); print(groups::usage("Remove the DIRECTORY(ies), if they are empty.", opts));
} 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() {
writeln!(&mut stderr() as &mut Writer, "Missing an argument"); writeln!(&mut stderr() as &mut Writer, "Missing an argument");
writeln!(&mut stderr() as &mut Writer, writeln!(&mut stderr() as &mut Writer,

View file

@ -14,7 +14,7 @@ extern mod extra;
use std::num; use std::num;
use std::cast; use std::cast;
use std::os; use std::os;
use std::io::{stderr, timer}; use std::io::{print, stderr, timer};
use extra::getopts::groups; use extra::getopts::groups;
fn main() { fn main() {
@ -35,20 +35,20 @@ fn main() {
}; };
if matches.opt_present("help") { if matches.opt_present("help") {
println("sleep 1.0.0"); println!("sleep 1.0.0");
println(""); println!("");
println("Usage:"); println!("Usage:");
println!(" {0:s} NUMBER[SUFFIX]", program); println!(" {0:s} NUMBER[SUFFIX]", program);
println("or"); println!("or");
println!(" {0:s} OPTION", program); println!(" {0:s} OPTION", program);
println(""); println!("");
print(groups::usage("Pause for NUMBER seconds. SUFFIX may be 's' for seconds (the default), print(groups::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
that require NUMBER be an integer, here NUMBER may be an arbitrary floating that require NUMBER be an integer, here NUMBER may be an arbitrary floating
point number. Given two or more arguments, pause for the amount of time point number. Given two or more arguments, pause for the amount of time
specified by the sum of their values.", opts)); specified by the sum of their values.", opts));
} else if matches.opt_present("version") { } else if matches.opt_present("version") {
println("sleep 1.0.0"); println!("sleep 1.0.0");
} else if matches.free.is_empty() { } else if matches.free.is_empty() {
writeln!(&mut stderr() as &mut Writer, "Missing an argument"); writeln!(&mut stderr() as &mut Writer, "Missing an argument");
writeln!(&mut stderr() as &mut Writer, writeln!(&mut stderr() as &mut Writer,

View file

@ -12,7 +12,7 @@
extern mod extra; extern mod extra;
use std::io::{stdin, stdout, Append, File, Truncate, Write}; use std::io::{println, stdin, stdout, Append, File, Truncate, Write};
use std::io::{io_error, EndOfFile}; use std::io::{io_error, EndOfFile};
use std::io::signal::{Interrupt, Listener}; use std::io::signal::{Interrupt, Listener};
use std::io::util::{copy, NullWriter, MultiWriter}; use std::io::util::{copy, NullWriter, MultiWriter};

View file

@ -15,6 +15,7 @@
extern mod extra; extern mod extra;
use std::{libc,str,os}; use std::{libc,str,os};
use std::io::println;
use std::io::stdio::stderr; use std::io::stdio::stderr;
use extra::getopts::{optflag,getopts}; use extra::getopts::{optflag,getopts};
@ -47,7 +48,7 @@ fn main () {
if !tty.is_whitespace() { if !tty.is_whitespace() {
println(tty); println(tty);
} else { } else {
println("not a tty"); println!("not a tty");
} }
} }

View file

@ -12,7 +12,7 @@
extern mod extra; extern mod extra;
use std::os; use std::os;
use std::io::{stdin, stderr, File, result}; use std::io::{print, stdin, stderr, File, result};
use std::io::buffered::BufferedReader; use std::io::buffered::BufferedReader;
use std::str::from_utf8_opt; use std::str::from_utf8_opt;
use extra::getopts::{groups, Matches}; use extra::getopts::{groups, Matches};
@ -50,17 +50,17 @@ fn main() {
}; };
if matches.opt_present("help") { if matches.opt_present("help") {
println("Usage:"); println!("Usage:");
println!(" {0:s} [OPTION]... [FILE]...", program); println!(" {0:s} [OPTION]... [FILE]...", program);
println(""); println!("");
print(groups::usage("Print newline, word and byte counts for each FILE", opts)); print(groups::usage("Print newline, word and byte counts for each FILE", opts));
println(""); println!("");
println("With no FILE, or when FILE is -, read standard input."); println!("With no FILE, or when FILE is -, read standard input.");
return; return;
} }
if (matches.opt_present("version")) { if (matches.opt_present("version")) {
println("wc 1.0.0"); println!("wc 1.0.0");
return; return;
} }
@ -211,7 +211,7 @@ fn print_stats(filename: &~str, line_count: uint, word_count: uint, char_count:
println!(" {}", *filename); println!(" {}", *filename);
} }
else { else {
println(""); println!("");
} }
} }

View file

@ -13,6 +13,7 @@
extern mod extra; extern mod extra;
use std::io::print;
use std::os; use std::os;
use std::str; use std::str;
use std::libc; use std::libc;
@ -49,16 +50,16 @@ fn main() {
Err(f) => fail!(f.to_err_msg()), Err(f) => fail!(f.to_err_msg()),
}; };
if matches.opt_present("help") { if matches.opt_present("help") {
println("whoami 1.0.0"); println!("whoami 1.0.0");
println(""); println!("");
println("Usage:"); println!("Usage:");
println!(" {:s}", program); println!(" {:s}", program);
println(""); println!("");
print(groups::usage("print effective userid", opts)); print(groups::usage("print effective userid", opts));
return; return;
} }
if matches.opt_present("version") { if matches.opt_present("version") {
println("whoami 1.0.0"); println!("whoami 1.0.0");
return; return;
} }

View file

@ -14,7 +14,7 @@
extern mod extra; extern mod extra;
use std::os; use std::os;
use std::io::stderr; use std::io::{print, println, stderr};
use extra::getopts::groups; use extra::getopts::groups;
fn main() { fn main() {
@ -34,16 +34,16 @@ fn main() {
} }
}; };
if matches.opt_present("help") { if matches.opt_present("help") {
println("yes 1.0.0"); println!("yes 1.0.0");
println(""); println!("");
println("Usage:"); println!("Usage:");
println!(" {0:s} [STRING]... [OPTION]...", program); println!(" {0:s} [STRING]... [OPTION]...", program);
println(""); println!("");
print(groups::usage("Repeatedly output a line with all specified STRING(s), or 'y'.", opts)); print(groups::usage("Repeatedly output a line with all specified STRING(s), or 'y'.", opts));
return; return;
} }
if matches.opt_present("version") { if matches.opt_present("version") {
println("yes 1.0.0"); println!("yes 1.0.0");
return; return;
} }
let mut string = ~"y"; let mut string = ~"y";