mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 11:37:44 +00:00
StrBuf was renamed to String
This commit is contained in:
parent
d3c27119e9
commit
1bf7569084
33 changed files with 77 additions and 77 deletions
|
@ -85,8 +85,8 @@ fn main() {
|
|||
println(name.as_slice());
|
||||
}
|
||||
|
||||
fn strip_dir(fullname: &str) -> StrBuf {
|
||||
let mut name = StrBuf::new();
|
||||
fn strip_dir(fullname: &str) -> String {
|
||||
let mut name = String::new();
|
||||
|
||||
for c in fullname.chars().rev() {
|
||||
if c == '/' || c == '\\' {
|
||||
|
@ -98,7 +98,7 @@ fn strip_dir(fullname: &str) -> StrBuf {
|
|||
return name.as_slice().chars().rev().collect();
|
||||
}
|
||||
|
||||
fn strip_suffix(name: &str, suffix: &str) -> StrBuf {
|
||||
fn strip_suffix(name: &str, suffix: &str) -> String {
|
||||
if name == suffix {
|
||||
return name.into_strbuf();
|
||||
}
|
||||
|
|
|
@ -96,7 +96,7 @@ fn is_newline_char(byte: u8) -> bool {
|
|||
byte == LF
|
||||
}
|
||||
|
||||
pub fn exec(files: Vec<StrBuf>, number: NumberingMode, show_nonprint: bool, show_ends: bool, show_tabs: bool, squeeze_blank: bool) {
|
||||
pub fn exec(files: Vec<String>, number: NumberingMode, show_nonprint: bool, show_ends: bool, show_tabs: bool, squeeze_blank: bool) {
|
||||
|
||||
if NumberNone != number || show_nonprint || show_ends || show_tabs || squeeze_blank {
|
||||
let mut counter: uint = 1;
|
||||
|
|
|
@ -21,8 +21,8 @@ use std::path::Path;
|
|||
static NAME : &'static str = "comm";
|
||||
static VERSION : &'static str = "1.0.0";
|
||||
|
||||
fn mkdelim(col: uint, opts: &getopts::Matches) -> StrBuf {
|
||||
let mut s = StrBuf::new();
|
||||
fn mkdelim(col: uint, opts: &getopts::Matches) -> String {
|
||||
let mut s = String::new();
|
||||
let delim = match opts.opt_str("output-delimiter") {
|
||||
Some(d) => d.clone(),
|
||||
None => "\t".to_strbuf(),
|
||||
|
|
|
@ -73,7 +73,7 @@ extern {
|
|||
pub fn getgrgid(gid: uid_t) -> *c_group;
|
||||
}
|
||||
|
||||
pub fn get_pw_from_args(free: &Vec<StrBuf>) -> Option<c_passwd> {
|
||||
pub fn get_pw_from_args(free: &Vec<String>) -> Option<c_passwd> {
|
||||
if free.len() == 1 {
|
||||
let username = free.get(0).as_slice();
|
||||
|
||||
|
|
4
du/du.rs
4
du/du.rs
|
@ -32,7 +32,7 @@ static VERSION: &'static str = "1.0.0";
|
|||
|
||||
struct Options {
|
||||
all: bool,
|
||||
program_name: StrBuf,
|
||||
program_name: String,
|
||||
max_depth: Option<uint>,
|
||||
total: bool,
|
||||
separate_dirs: bool,
|
||||
|
@ -268,7 +268,7 @@ ers of 1000).",
|
|||
None => 1024
|
||||
};
|
||||
|
||||
let convert_size = |size: u64| -> StrBuf {
|
||||
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))
|
||||
|
|
6
env/env.rs
vendored
6
env/env.rs
vendored
|
@ -16,9 +16,9 @@
|
|||
struct options {
|
||||
ignore_env: bool,
|
||||
null: bool,
|
||||
unsets: Vec<StrBuf>,
|
||||
sets: Vec<(StrBuf, StrBuf)>,
|
||||
program: Vec<StrBuf>
|
||||
unsets: Vec<String>,
|
||||
sets: Vec<(String, String)>,
|
||||
program: Vec<String>
|
||||
}
|
||||
|
||||
fn usage(prog: &str) {
|
||||
|
|
|
@ -82,8 +82,8 @@ fn main() {
|
|||
}
|
||||
}
|
||||
|
||||
fn handle_obsolete(args: &[StrBuf]) -> (Vec<StrBuf>, Option<StrBuf>) {
|
||||
let mut args = Vec::<StrBuf>::from_slice(args);
|
||||
fn handle_obsolete(args: &[String]) -> (Vec<String>, Option<String>) {
|
||||
let mut args = Vec::<String>::from_slice(args);
|
||||
let mut i = 0;
|
||||
while i < args.len() {
|
||||
if args.get(i).as_slice().char_at(0) == '-' && args.get(i).len() > 1 && args.get(i).as_slice().char_at(1).is_digit() {
|
||||
|
@ -95,7 +95,7 @@ fn handle_obsolete(args: &[StrBuf]) -> (Vec<StrBuf>, Option<StrBuf>) {
|
|||
(args, None)
|
||||
}
|
||||
|
||||
fn fold(filenames: Vec<StrBuf>, bytes: bool, spaces: bool, width: uint) {
|
||||
fn fold(filenames: Vec<String>, bytes: bool, spaces: bool, width: uint) {
|
||||
for filename in filenames.iter() {
|
||||
let filename: &str = filename.as_slice();
|
||||
let buffer = BufferedReader::new(
|
||||
|
@ -137,7 +137,7 @@ fn fold_file<T: io::Reader>(file: BufferedReader<T>, bytes: bool, spaces: bool,
|
|||
i += slice.len();
|
||||
}
|
||||
} else {
|
||||
let mut output = StrBuf::new();
|
||||
let mut output = String::new();
|
||||
let mut count = 0;
|
||||
for (i, ch) in line.chars().enumerate() {
|
||||
match ch {
|
||||
|
|
|
@ -96,8 +96,8 @@ fn main () {
|
|||
//
|
||||
// In case is found, the options vector will get rid of that object so that
|
||||
// getopts works correctly.
|
||||
fn obsolete (options: &[StrBuf]) -> (Vec<StrBuf>, Option<uint>) {
|
||||
let mut options: Vec<StrBuf> = Vec::from_slice(options);
|
||||
fn obsolete (options: &[String]) -> (Vec<String>, Option<uint>) {
|
||||
let mut options: Vec<String> = Vec::from_slice(options);
|
||||
let mut a = 0;
|
||||
let b = options.len();
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ extern {
|
|||
}
|
||||
|
||||
fn main() {
|
||||
let args: Vec<StrBuf> = os::args().iter().map(|x| x.to_strbuf()).collect();
|
||||
let args: Vec<String> = os::args().iter().map(|x| x.to_strbuf()).collect();
|
||||
|
||||
let opts = [
|
||||
optflag("", "help", "display this help and exit"),
|
||||
|
@ -87,7 +87,7 @@ fn version() {
|
|||
println!("{} {}", NAME, VERSION);
|
||||
}
|
||||
|
||||
fn get_help_text(progname: &str, usage: &str) -> StrBuf {
|
||||
fn get_help_text(progname: &str, usage: &str) -> String {
|
||||
format!("Usage: \n {0} {1}", progname, usage)
|
||||
}
|
||||
|
||||
|
|
|
@ -77,7 +77,7 @@ fn help_menu(program: &str, options: &[getopts::OptGroup]) {
|
|||
print!("{:s}", usage("Print or set the system's host name.", options));
|
||||
}
|
||||
|
||||
fn xgethostname() -> StrBuf {
|
||||
fn xgethostname() -> String {
|
||||
let namelen = 256u;
|
||||
let mut name = Vec::from_elem(namelen, 0u8);
|
||||
|
||||
|
|
|
@ -149,14 +149,14 @@ fn print_signals() {
|
|||
}
|
||||
}
|
||||
|
||||
fn list(arg: Option<StrBuf>) {
|
||||
fn list(arg: Option<String>) {
|
||||
match arg {
|
||||
Some(x) => print_signal(x.as_slice()),
|
||||
None => print_signals(),
|
||||
};
|
||||
}
|
||||
|
||||
fn get_help_text(progname: &str, usage: &str) -> StrBuf {
|
||||
fn get_help_text(progname: &str, usage: &str) -> String {
|
||||
format!("Usage: \n {0} {1}", progname, usage)
|
||||
}
|
||||
|
||||
|
@ -177,7 +177,7 @@ fn signal_by_name_or_value(signal_name_or_value: &str) -> Option<uint> {
|
|||
return None;
|
||||
}
|
||||
|
||||
fn kill(signalname: &str, pids: std::vec::Vec<StrBuf>) {
|
||||
fn kill(signalname: &str, pids: std::vec::Vec<String>) {
|
||||
let optional_signal_value = signal_by_name_or_value(signalname);
|
||||
let signal_value = match optional_signal_value {
|
||||
Some(x) => x,
|
||||
|
|
|
@ -30,7 +30,7 @@ extern {
|
|||
pub fn getlogin() -> *libc::c_char;
|
||||
}
|
||||
|
||||
unsafe fn get_userlogin() -> StrBuf {
|
||||
unsafe fn get_userlogin() -> String {
|
||||
let login: *libc::c_char = getlogin();
|
||||
|
||||
str::raw::from_c_str(login)
|
||||
|
|
|
@ -28,7 +28,7 @@ static NAME: &'static str = "md5sum";
|
|||
static VERSION: &'static str = "1.0.0";
|
||||
|
||||
fn main() {
|
||||
let args: Vec<StrBuf> = os::args().iter().map(|x| x.to_strbuf()).collect();
|
||||
let args: Vec<String> = os::args().iter().map(|x| x.to_strbuf()).collect();
|
||||
|
||||
let program = args.get(0).clone();
|
||||
|
||||
|
@ -76,7 +76,7 @@ fn main() {
|
|||
}
|
||||
}
|
||||
|
||||
fn md5sum(files: Vec<StrBuf>, binary: bool, check: bool, tag: bool, status: bool, quiet: bool, strict: bool, warn: bool) {
|
||||
fn md5sum(files: Vec<String>, binary: bool, check: bool, tag: bool, status: bool, quiet: bool, strict: bool, warn: bool) {
|
||||
let mut md5 = crypto::md5::Md5::new();
|
||||
let bytes = md5.output_bits() / 4;
|
||||
let mut bad_format = 0;
|
||||
|
@ -145,7 +145,7 @@ fn md5sum(files: Vec<StrBuf>, binary: bool, check: bool, tag: bool, status: bool
|
|||
}
|
||||
}
|
||||
|
||||
fn calc_sum(md5: &mut crypto::md5::Md5, file: &mut Reader, binary: bool) -> StrBuf {
|
||||
fn calc_sum(md5: &mut crypto::md5::Md5, file: &mut Reader, binary: bool) -> String {
|
||||
let data =
|
||||
if binary {
|
||||
(safe_unwrap!(file.read_to_end()))
|
||||
|
|
|
@ -29,7 +29,7 @@ static VERSION: &'static str = "1.0.0";
|
|||
* Handles option parsing
|
||||
*/
|
||||
fn main() {
|
||||
let args: Vec<StrBuf> = os::args().iter().map(|x| x.to_strbuf()).collect();
|
||||
let args: Vec<String> = os::args().iter().map(|x| x.to_strbuf()).collect();
|
||||
|
||||
let opts = ~[
|
||||
// Linux-specific options, not implemented
|
||||
|
@ -95,7 +95,7 @@ fn print_help(opts: &[getopts::OptGroup]) {
|
|||
/**
|
||||
* Create the list of new directories
|
||||
*/
|
||||
fn exec(dirs: Vec<StrBuf>, mk_parents: bool, mode: FilePermission, verbose: bool) {
|
||||
fn exec(dirs: Vec<String>, mk_parents: bool, mode: FilePermission, verbose: bool) {
|
||||
let mut parent_dirs = Vec::new();
|
||||
if mk_parents {
|
||||
for dir in dirs.iter() {
|
||||
|
|
|
@ -24,7 +24,7 @@ static NAME: &'static str = "paste";
|
|||
static VERSION: &'static str = "1.0.0";
|
||||
|
||||
fn main() {
|
||||
let args: Vec<StrBuf> = os::args().iter().map(|x| x.to_strbuf()).collect();
|
||||
let args: Vec<String> = os::args().iter().map(|x| x.to_strbuf()).collect();
|
||||
let program = args.get(0).clone();
|
||||
|
||||
let opts = ~[
|
||||
|
@ -56,7 +56,7 @@ fn main() {
|
|||
}
|
||||
}
|
||||
|
||||
fn paste(filenames: Vec<StrBuf>, serial: bool, delimiters: &str) {
|
||||
fn paste(filenames: Vec<String>, serial: bool, delimiters: &str) {
|
||||
let mut files: Vec<io::BufferedReader<Box<Reader>>> = filenames.move_iter().map(|name|
|
||||
io::BufferedReader::new(
|
||||
if name.as_slice() == "-" {
|
||||
|
@ -66,11 +66,11 @@ fn paste(filenames: Vec<StrBuf>, serial: bool, delimiters: &str) {
|
|||
}
|
||||
)
|
||||
).collect();
|
||||
let delimiters: Vec<StrBuf> = delimiters.chars().map(|x| x.to_str()).collect();
|
||||
let delimiters: Vec<String> = delimiters.chars().map(|x| x.to_str()).collect();
|
||||
let mut delim_count = 0;
|
||||
if serial {
|
||||
for file in files.mut_iter() {
|
||||
let mut output = StrBuf::new();
|
||||
let mut output = String::new();
|
||||
loop {
|
||||
match file.read_line() {
|
||||
Ok(line) => {
|
||||
|
|
|
@ -25,7 +25,7 @@ mod util;
|
|||
static NAME: &'static str = "printenv";
|
||||
|
||||
fn main() {
|
||||
let args: Vec<StrBuf> = os::args().iter().map(|x| x.to_strbuf()).collect();
|
||||
let args: Vec<String> = os::args().iter().map(|x| x.to_strbuf()).collect();
|
||||
let program = args.get(0).clone();
|
||||
let opts = ~[
|
||||
getopts::optflag("0", "null", "end each output line with 0 byte rather than newline"),
|
||||
|
@ -59,7 +59,7 @@ fn main() {
|
|||
exec(matches.free, separator);
|
||||
}
|
||||
|
||||
pub fn exec(args: Vec<StrBuf>, separator: &str) {
|
||||
pub fn exec(args: Vec<String>, separator: &str) {
|
||||
if args.is_empty() {
|
||||
let vars = os::env();
|
||||
for (env_var, value) in vars.move_iter() {
|
||||
|
|
|
@ -24,7 +24,7 @@ static NAME: &'static str = "pwd";
|
|||
static VERSION: &'static str = "1.0.0";
|
||||
|
||||
fn main() {
|
||||
let args: Vec<StrBuf> = os::args().iter().map(|x| x.to_strbuf()).collect();
|
||||
let args: Vec<String> = os::args().iter().map(|x| x.to_strbuf()).collect();
|
||||
let program = args.get(0).clone();
|
||||
let opts = ~[
|
||||
getopts::optflag("", "help", "display this help and exit"),
|
||||
|
|
4
rm/rm.rs
4
rm/rm.rs
|
@ -30,7 +30,7 @@ enum InteractiveMode {
|
|||
static NAME: &'static str = "rm";
|
||||
|
||||
fn main() {
|
||||
let args: Vec<StrBuf> = os::args().iter().map(|x| x.to_strbuf()).collect();
|
||||
let args: Vec<String> = os::args().iter().map(|x| x.to_strbuf()).collect();
|
||||
let program = args.get(0).clone();
|
||||
|
||||
// TODO: make getopts support -R in addition to -r
|
||||
|
@ -120,7 +120,7 @@ fn main() {
|
|||
}
|
||||
|
||||
// TODO: implement one-file-system
|
||||
fn remove(files: Vec<StrBuf>, force: bool, interactive: InteractiveMode, one_fs: bool, preserve_root: bool, recursive: bool, dir: bool, verbose: bool) {
|
||||
fn remove(files: Vec<String>, force: bool, interactive: InteractiveMode, one_fs: bool, preserve_root: bool, recursive: bool, dir: bool, verbose: bool) {
|
||||
for filename in files.iter() {
|
||||
let filename = filename.as_slice();
|
||||
let file = Path::new(filename);
|
||||
|
|
|
@ -23,7 +23,7 @@ mod util;
|
|||
static NAME: &'static str = "rmdir";
|
||||
|
||||
fn main() {
|
||||
let args: Vec<StrBuf> = os::args().iter().map(|x| x.to_strbuf()).collect();
|
||||
let args: Vec<String> = os::args().iter().map(|x| x.to_strbuf()).collect();
|
||||
let program = args.get(0).clone();
|
||||
|
||||
let opts = ~[
|
||||
|
@ -61,7 +61,7 @@ fn main() {
|
|||
}
|
||||
}
|
||||
|
||||
fn remove(dirs: Vec<StrBuf>, ignore: bool, parents: bool, verbose: bool) {
|
||||
fn remove(dirs: Vec<String>, ignore: bool, parents: bool, verbose: bool) {
|
||||
for dir in dirs.iter() {
|
||||
let path = Path::new(dir.as_slice());
|
||||
if path.exists() {
|
||||
|
|
|
@ -21,20 +21,20 @@ fn print_usage(opts: ~[getopts::OptGroup]) {
|
|||
println!("{:s}", getopts::usage("Print sequences of numbers", opts));
|
||||
}
|
||||
|
||||
fn parse_float(s: &str) -> Result<f32, StrBuf>{
|
||||
fn parse_float(s: &str) -> Result<f32, String>{
|
||||
match from_str(s) {
|
||||
Some(n) => Ok(n),
|
||||
None => Err(format!("seq: invalid floating point argument: {:s}", s))
|
||||
}
|
||||
}
|
||||
|
||||
fn escape_sequences(s: &str) -> StrBuf {
|
||||
fn escape_sequences(s: &str) -> String {
|
||||
s.replace("\\n", "\n").
|
||||
replace("\\t", "\t")
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let args: Vec<StrBuf> = os::args().iter().map(|x| x.to_strbuf()).collect();
|
||||
let args: Vec<String> = os::args().iter().map(|x| x.to_strbuf()).collect();
|
||||
let opts = ~[
|
||||
getopts::optopt("s", "separator", "Separator character (defaults to \\n)", ""),
|
||||
getopts::optopt("t", "terminator", "Terminator character (defaults to separator)", ""),
|
||||
|
@ -96,7 +96,7 @@ fn done_printing(next: f32, step: f32, last: f32) -> bool {
|
|||
}
|
||||
}
|
||||
|
||||
fn print_seq(first: f32, step: f32, last: f32, separator: StrBuf, terminator: StrBuf, pad: bool) {
|
||||
fn print_seq(first: f32, step: f32, last: f32, separator: String, terminator: String, pad: bool) {
|
||||
let mut i = first;
|
||||
let maxlen = first.max(last).to_str().len();
|
||||
while !done_printing(i, step, last) {
|
||||
|
|
|
@ -24,7 +24,7 @@ mod util;
|
|||
static NAME: &'static str = "sleep";
|
||||
|
||||
fn main() {
|
||||
let args: Vec<StrBuf> = os::args().iter().map(|x| x.to_strbuf()).collect();
|
||||
let args: Vec<String> = os::args().iter().map(|x| x.to_strbuf()).collect();
|
||||
let program = args.get(0).clone();
|
||||
|
||||
let opts = ~[
|
||||
|
@ -62,7 +62,7 @@ specified by the sum of their values.", opts).as_slice());
|
|||
}
|
||||
}
|
||||
|
||||
fn sleep(args: Vec<StrBuf>) {
|
||||
fn sleep(args: Vec<String>) {
|
||||
let sleep_time = args.iter().fold(0.0, |result, arg| {
|
||||
let (arg, suffix_time) = match match_suffix(arg.as_slice()) {
|
||||
Ok(m) => m,
|
||||
|
@ -86,7 +86,7 @@ fn sleep(args: Vec<StrBuf>) {
|
|||
timer::sleep((sleep_time * 1000.0) as u64);
|
||||
}
|
||||
|
||||
fn match_suffix(arg: &str) -> Result<(StrBuf, int), StrBuf> {
|
||||
fn match_suffix(arg: &str) -> Result<(String, int), String> {
|
||||
let result = match (arg).char_at_reverse(0) {
|
||||
's' | 'S' => 1,
|
||||
'm' | 'M' => 60,
|
||||
|
|
|
@ -24,7 +24,7 @@ static NAME: &'static str = "tac";
|
|||
static VERSION: &'static str = "1.0.0";
|
||||
|
||||
fn main() {
|
||||
let args: Vec<StrBuf> = os::args().iter().map(|x| x.to_strbuf()).collect();
|
||||
let args: Vec<String> = os::args().iter().map(|x| x.to_strbuf()).collect();
|
||||
let program = args.get(0).clone();
|
||||
|
||||
let opts = ~[
|
||||
|
@ -69,7 +69,7 @@ fn main() {
|
|||
}
|
||||
}
|
||||
|
||||
fn tac(filenames: Vec<StrBuf>, before: bool, _: bool, separator: &str) {
|
||||
fn tac(filenames: Vec<String>, before: bool, _: bool, separator: &str) {
|
||||
for filename in filenames.move_iter() {
|
||||
let mut file = io::BufferedReader::new(
|
||||
if filename.as_slice() == "-" {
|
||||
|
@ -87,7 +87,7 @@ fn tac(filenames: Vec<StrBuf>, before: bool, _: bool, separator: &str) {
|
|||
data = buf.into_owned();
|
||||
}
|
||||
let split_vec: Vec<&str> = data.as_slice().split_str(separator).collect();
|
||||
let rev: StrBuf = split_vec.iter().rev().fold(StrBuf::new(), |mut a, &b| {
|
||||
let rev: String = split_vec.iter().rev().fold(String::new(), |mut a, &b| {
|
||||
if before {
|
||||
a.push_str(separator);
|
||||
a.push_str(b);
|
||||
|
|
10
tee/tee.rs
10
tee/tee.rs
|
@ -32,14 +32,14 @@ fn main() {
|
|||
}
|
||||
|
||||
struct Options {
|
||||
program: StrBuf,
|
||||
program: String,
|
||||
append: bool,
|
||||
ignore_interrupts: bool,
|
||||
print_and_exit: Option<StrBuf>,
|
||||
print_and_exit: Option<String>,
|
||||
files: Box<Vec<Path>>
|
||||
}
|
||||
|
||||
fn options(args: &[StrBuf]) -> Result<Options, ()> {
|
||||
fn options(args: &[String]) -> Result<Options, ()> {
|
||||
let opts = ~[
|
||||
optflag("a", "append", "append to the given FILEs, do not overwrite"),
|
||||
optflag("i", "ignore-interrupts", "ignore interrupt signals"),
|
||||
|
@ -47,7 +47,7 @@ fn options(args: &[StrBuf]) -> Result<Options, ()> {
|
|||
optflag("V", "version", "output version information and exit"),
|
||||
];
|
||||
|
||||
let args: Vec<StrBuf> = args.iter().map(|x| x.to_strbuf()).collect();
|
||||
let args: Vec<String> = args.iter().map(|x| x.to_strbuf()).collect();
|
||||
|
||||
getopts(args.tail(), opts).map_err(|e| e.to_err_msg()).and_then(|m| {
|
||||
let version = format!("{} {}", NAME, VERSION);
|
||||
|
@ -58,7 +58,7 @@ fn options(args: &[StrBuf]) -> Result<Options, ()> {
|
|||
let help = format!("{}\n\nUsage:\n {} {}\n\n{}\n{}",
|
||||
version, program, arguments, usage(brief, opts),
|
||||
comment);
|
||||
let names = m.free.clone().move_iter().collect::<Vec<StrBuf>>().append_one("-".to_strbuf());
|
||||
let names = m.free.clone().move_iter().collect::<Vec<String>>().append_one("-".to_strbuf());
|
||||
let to_print = if m.opt_present("help") { Some(help) }
|
||||
else if m.opt_present("version") { Some(version) }
|
||||
else { None };
|
||||
|
|
2
tr/tr.rs
2
tr/tr.rs
|
@ -147,7 +147,7 @@ fn usage(opts: &[OptGroup]) {
|
|||
}
|
||||
|
||||
pub fn main() {
|
||||
let args: Vec<StrBuf> = os::args().iter().map(|x| x.to_strbuf()).collect();
|
||||
let args: Vec<String> = os::args().iter().map(|x| x.to_strbuf()).collect();
|
||||
let opts = [
|
||||
getopts::optflag("c", "complement", "use the complement of SET1"),
|
||||
getopts::optflag("C", "", "same as -c"),
|
||||
|
|
|
@ -47,7 +47,7 @@ enum TruncateMode {
|
|||
static NAME: &'static str = "truncate";
|
||||
|
||||
fn main() {
|
||||
let args: Vec<StrBuf> = os::args().iter().map(|x| x.to_strbuf()).collect();
|
||||
let args: Vec<String> = os::args().iter().map(|x| x.to_strbuf()).collect();
|
||||
let program = args.get(0).clone();
|
||||
|
||||
let opts = ~[
|
||||
|
@ -108,7 +108,7 @@ file based on its current size:
|
|||
}
|
||||
}
|
||||
|
||||
fn truncate(no_create: bool, _: bool, reference: Option<StrBuf>, size: Option<StrBuf>, filenames: Vec<StrBuf>) {
|
||||
fn truncate(no_create: bool, _: bool, reference: Option<String>, size: Option<String>, filenames: Vec<String>) {
|
||||
let (refsize, mode) = match reference {
|
||||
Some(rfilename) => {
|
||||
let rfile = match File::open(&Path::new(rfilename.clone())) {
|
||||
|
|
|
@ -35,7 +35,7 @@ extern {
|
|||
static NAME: &'static str = "tty";
|
||||
|
||||
fn main () {
|
||||
let args: Vec<StrBuf> = os::args().iter().map(|x| x.to_strbuf()).collect();
|
||||
let args: Vec<String> = os::args().iter().map(|x| x.to_strbuf()).collect();
|
||||
|
||||
let options = [
|
||||
optflag("s", "silent", "print nothing, only return an exit status")
|
||||
|
|
|
@ -27,11 +27,11 @@ use c_types::utsname;
|
|||
#[path = "../common/c_types.rs"] mod c_types;
|
||||
|
||||
struct utsrust {
|
||||
sysname: StrBuf,
|
||||
nodename: StrBuf,
|
||||
release: StrBuf,
|
||||
version: StrBuf,
|
||||
machine: StrBuf
|
||||
sysname: String,
|
||||
nodename: String,
|
||||
release: String,
|
||||
version: String,
|
||||
machine: String
|
||||
}
|
||||
|
||||
extern {
|
||||
|
@ -52,7 +52,7 @@ unsafe fn getuname() -> utsrust {
|
|||
static NAME: &'static str = "uname";
|
||||
|
||||
fn main() {
|
||||
let args: Vec<StrBuf> = os::args().iter().map(|x| x.to_strbuf()).collect();
|
||||
let args: Vec<String> = os::args().iter().map(|x| x.to_strbuf()).collect();
|
||||
let program = args.get(0).as_slice();
|
||||
let opts = ~[
|
||||
getopts::optflag("h", "help", "display this help and exit"),
|
||||
|
@ -78,7 +78,7 @@ fn main() {
|
|||
return;
|
||||
}
|
||||
let uname = unsafe { getuname() };
|
||||
let mut output = StrBuf::new();
|
||||
let mut output = String::new();
|
||||
if matches.opt_present("sysname") || matches.opt_present("all")
|
||||
|| !matches.opts_present(["nodename".to_strbuf(), "release".to_strbuf(), "version".to_strbuf(), "machine".to_strbuf()]) {
|
||||
output.push_str(uname.sysname.as_slice());
|
||||
|
|
|
@ -27,7 +27,7 @@ mod util;
|
|||
static NAME: &'static str = "unlink";
|
||||
|
||||
fn main() {
|
||||
let args: Vec<StrBuf> = os::args().iter().map(|x| x.to_strbuf()).collect();
|
||||
let args: Vec<String> = os::args().iter().map(|x| x.to_strbuf()).collect();
|
||||
let program = args.get(0).clone();
|
||||
let opts = ~[
|
||||
getopts::optflag("h", "help", "display this help and exit"),
|
||||
|
|
|
@ -48,7 +48,7 @@ extern {
|
|||
}
|
||||
|
||||
fn main() {
|
||||
let args: Vec<StrBuf> = os::args().iter().map(|x| x.to_strbuf()).collect();
|
||||
let args: Vec<String> = os::args().iter().map(|x| x.to_strbuf()).collect();
|
||||
let program = args.get(0).clone();
|
||||
let opts = ~[
|
||||
getopts::optflag("v", "version", "output version information and exit"),
|
||||
|
|
|
@ -48,7 +48,7 @@ extern {
|
|||
static NAME: &'static str = "users";
|
||||
|
||||
fn main() {
|
||||
let args: Vec<StrBuf> = os::args().iter().map(|x| x.to_strbuf()).collect();
|
||||
let args: Vec<String> = os::args().iter().map(|x| x.to_strbuf()).collect();
|
||||
let program = args.get(0).as_slice();
|
||||
let opts = ~[
|
||||
getopts::optflag("h", "help", "display this help and exit"),
|
||||
|
|
8
wc/wc.rs
8
wc/wc.rs
|
@ -23,7 +23,7 @@ use getopts::Matches;
|
|||
mod util;
|
||||
|
||||
struct Result {
|
||||
filename: StrBuf,
|
||||
filename: String,
|
||||
bytes: uint,
|
||||
chars: uint,
|
||||
lines: uint,
|
||||
|
@ -34,7 +34,7 @@ struct Result {
|
|||
static NAME: &'static str = "wc";
|
||||
|
||||
fn main() {
|
||||
let args: Vec<StrBuf> = os::args().iter().map(|x| x.to_strbuf()).collect();
|
||||
let args: Vec<String> = os::args().iter().map(|x| x.to_strbuf()).collect();
|
||||
let program = args.get(0).clone();
|
||||
let opts = ~[
|
||||
getopts::optflag("c", "bytes", "print the byte counts"),
|
||||
|
@ -87,7 +87,7 @@ fn is_word_seperator(byte: u8) -> bool {
|
|||
byte == SPACE || byte == TAB || byte == CR || byte == SYN || byte == FF
|
||||
}
|
||||
|
||||
pub fn wc(files: Vec<StrBuf>, matches: &Matches) {
|
||||
pub fn wc(files: Vec<String>, matches: &Matches) {
|
||||
let mut total_line_count: uint = 0;
|
||||
let mut total_word_count: uint = 0;
|
||||
let mut total_char_count: uint = 0;
|
||||
|
@ -222,7 +222,7 @@ fn print_stats(filename: &str, line_count: uint, word_count: uint, char_count: u
|
|||
}
|
||||
}
|
||||
|
||||
fn open(path: StrBuf) -> Option<BufferedReader<Box<Reader>>> {
|
||||
fn open(path: String) -> Option<BufferedReader<Box<Reader>>> {
|
||||
if "-" == path.as_slice() {
|
||||
let reader = box stdin() as Box<Reader>;
|
||||
return Some(BufferedReader::new(reader));
|
||||
|
|
|
@ -30,7 +30,7 @@ extern {
|
|||
pub fn geteuid() -> libc::c_int;
|
||||
}
|
||||
|
||||
unsafe fn getusername() -> StrBuf {
|
||||
unsafe fn getusername() -> String {
|
||||
let passwd: *c_passwd = getpwuid(geteuid());
|
||||
|
||||
let pw_name: *libc::c_char = (*passwd).pw_name;
|
||||
|
@ -42,7 +42,7 @@ unsafe fn getusername() -> StrBuf {
|
|||
static NAME: &'static str = "whoami";
|
||||
|
||||
fn main() {
|
||||
let args: Vec<StrBuf> = os::args().iter().map(|x| x.to_strbuf()).collect();
|
||||
let args: Vec<String> = os::args().iter().map(|x| x.to_strbuf()).collect();
|
||||
let program = args.get(0).as_slice();
|
||||
let opts = ~[
|
||||
getopts::optflag("h", "help", "display this help and exit"),
|
||||
|
|
|
@ -25,7 +25,7 @@ mod util;
|
|||
static NAME: &'static str = "yes";
|
||||
|
||||
fn main() {
|
||||
let args: Vec<StrBuf> = os::args().iter().map(|x| x.to_strbuf()).collect();
|
||||
let args: Vec<String> = os::args().iter().map(|x| x.to_strbuf()).collect();
|
||||
let program = args.get(0).clone();
|
||||
let opts = ~[
|
||||
getopts::optflag("h", "help", "display this help and exit"),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue