1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-29 12:07:46 +00:00

StrBuf was renamed to String

This commit is contained in:
Michael Gehring 2014-05-25 11:20:52 +02:00
parent d3c27119e9
commit 1bf7569084
33 changed files with 77 additions and 77 deletions

View file

@ -85,8 +85,8 @@ fn main() {
println(name.as_slice()); println(name.as_slice());
} }
fn strip_dir(fullname: &str) -> StrBuf { fn strip_dir(fullname: &str) -> String {
let mut name = StrBuf::new(); let mut name = String::new();
for c in fullname.chars().rev() { for c in fullname.chars().rev() {
if c == '/' || c == '\\' { if c == '/' || c == '\\' {
@ -98,7 +98,7 @@ fn strip_dir(fullname: &str) -> StrBuf {
return name.as_slice().chars().rev().collect(); 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 { if name == suffix {
return name.into_strbuf(); return name.into_strbuf();
} }

View file

@ -96,7 +96,7 @@ fn is_newline_char(byte: u8) -> bool {
byte == LF 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 { if NumberNone != number || show_nonprint || show_ends || show_tabs || squeeze_blank {
let mut counter: uint = 1; let mut counter: uint = 1;

View file

@ -21,8 +21,8 @@ use std::path::Path;
static NAME : &'static str = "comm"; static NAME : &'static str = "comm";
static VERSION : &'static str = "1.0.0"; static VERSION : &'static str = "1.0.0";
fn mkdelim(col: uint, opts: &getopts::Matches) -> StrBuf { fn mkdelim(col: uint, opts: &getopts::Matches) -> String {
let mut s = StrBuf::new(); let mut s = String::new();
let delim = match opts.opt_str("output-delimiter") { let delim = match opts.opt_str("output-delimiter") {
Some(d) => d.clone(), Some(d) => d.clone(),
None => "\t".to_strbuf(), None => "\t".to_strbuf(),

View file

@ -73,7 +73,7 @@ extern {
pub fn getgrgid(gid: uid_t) -> *c_group; 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 { if free.len() == 1 {
let username = free.get(0).as_slice(); let username = free.get(0).as_slice();

View file

@ -32,7 +32,7 @@ static VERSION: &'static str = "1.0.0";
struct Options { struct Options {
all: bool, all: bool,
program_name: StrBuf, program_name: String,
max_depth: Option<uint>, max_depth: Option<uint>,
total: bool, total: bool,
separate_dirs: bool, separate_dirs: bool,
@ -268,7 +268,7 @@ ers of 1000).",
None => 1024 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 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!("{:.1f}M", (size as f64) / (MB as f64))

6
env/env.rs vendored
View file

@ -16,9 +16,9 @@
struct options { struct options {
ignore_env: bool, ignore_env: bool,
null: bool, null: bool,
unsets: Vec<StrBuf>, unsets: Vec<String>,
sets: Vec<(StrBuf, StrBuf)>, sets: Vec<(String, String)>,
program: Vec<StrBuf> program: Vec<String>
} }
fn usage(prog: &str) { fn usage(prog: &str) {

View file

@ -82,8 +82,8 @@ fn main() {
} }
} }
fn handle_obsolete(args: &[StrBuf]) -> (Vec<StrBuf>, Option<StrBuf>) { fn handle_obsolete(args: &[String]) -> (Vec<String>, Option<String>) {
let mut args = Vec::<StrBuf>::from_slice(args); let mut args = Vec::<String>::from_slice(args);
let mut i = 0; let mut i = 0;
while i < args.len() { 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() { 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) (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() { for filename in filenames.iter() {
let filename: &str = filename.as_slice(); let filename: &str = filename.as_slice();
let buffer = BufferedReader::new( let buffer = BufferedReader::new(
@ -137,7 +137,7 @@ fn fold_file<T: io::Reader>(file: BufferedReader<T>, bytes: bool, spaces: bool,
i += slice.len(); i += slice.len();
} }
} else { } else {
let mut output = StrBuf::new(); let mut output = String::new();
let mut count = 0; let mut count = 0;
for (i, ch) in line.chars().enumerate() { for (i, ch) in line.chars().enumerate() {
match ch { match ch {

View file

@ -96,8 +96,8 @@ fn main () {
// //
// In case is found, the options vector will get rid of that object so that // In case is found, the options vector will get rid of that object so that
// getopts works correctly. // getopts works correctly.
fn obsolete (options: &[StrBuf]) -> (Vec<StrBuf>, Option<uint>) { fn obsolete (options: &[String]) -> (Vec<String>, Option<uint>) {
let mut options: Vec<StrBuf> = Vec::from_slice(options); let mut options: Vec<String> = Vec::from_slice(options);
let mut a = 0; let mut a = 0;
let b = options.len(); let b = options.len();

View file

@ -50,7 +50,7 @@ extern {
} }
fn main() { 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 = [ let opts = [
optflag("", "help", "display this help and exit"), optflag("", "help", "display this help and exit"),
@ -87,7 +87,7 @@ fn version() {
println!("{} {}", NAME, 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) format!("Usage: \n {0} {1}", progname, usage)
} }

View file

@ -77,7 +77,7 @@ fn help_menu(program: &str, options: &[getopts::OptGroup]) {
print!("{:s}", usage("Print or set the system's host name.", options)); print!("{:s}", usage("Print or set the system's host name.", options));
} }
fn xgethostname() -> StrBuf { fn xgethostname() -> String {
let namelen = 256u; let namelen = 256u;
let mut name = Vec::from_elem(namelen, 0u8); let mut name = Vec::from_elem(namelen, 0u8);

View file

@ -149,14 +149,14 @@ fn print_signals() {
} }
} }
fn list(arg: Option<StrBuf>) { fn list(arg: Option<String>) {
match arg { match arg {
Some(x) => print_signal(x.as_slice()), Some(x) => print_signal(x.as_slice()),
None => print_signals(), 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) 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; 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 optional_signal_value = signal_by_name_or_value(signalname);
let signal_value = match optional_signal_value { let signal_value = match optional_signal_value {
Some(x) => x, Some(x) => x,

View file

@ -30,7 +30,7 @@ extern {
pub fn getlogin() -> *libc::c_char; pub fn getlogin() -> *libc::c_char;
} }
unsafe fn get_userlogin() -> StrBuf { unsafe fn get_userlogin() -> String {
let login: *libc::c_char = getlogin(); let login: *libc::c_char = getlogin();
str::raw::from_c_str(login) str::raw::from_c_str(login)

View file

@ -28,7 +28,7 @@ static NAME: &'static str = "md5sum";
static VERSION: &'static str = "1.0.0"; static VERSION: &'static str = "1.0.0";
fn main() { 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 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 mut md5 = crypto::md5::Md5::new();
let bytes = md5.output_bits() / 4; let bytes = md5.output_bits() / 4;
let mut bad_format = 0; 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 = let data =
if binary { if binary {
(safe_unwrap!(file.read_to_end())) (safe_unwrap!(file.read_to_end()))

View file

@ -29,7 +29,7 @@ static VERSION: &'static str = "1.0.0";
* Handles option parsing * Handles option parsing
*/ */
fn main() { 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 = ~[ let opts = ~[
// Linux-specific options, not implemented // Linux-specific options, not implemented
@ -95,7 +95,7 @@ fn print_help(opts: &[getopts::OptGroup]) {
/** /**
* Create the list of new directories * 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(); let mut parent_dirs = Vec::new();
if mk_parents { if mk_parents {
for dir in dirs.iter() { for dir in dirs.iter() {

View file

@ -24,7 +24,7 @@ static NAME: &'static str = "paste";
static VERSION: &'static str = "1.0.0"; static VERSION: &'static str = "1.0.0";
fn main() { 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 program = args.get(0).clone();
let opts = ~[ 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| let mut files: Vec<io::BufferedReader<Box<Reader>>> = filenames.move_iter().map(|name|
io::BufferedReader::new( io::BufferedReader::new(
if name.as_slice() == "-" { if name.as_slice() == "-" {
@ -66,11 +66,11 @@ fn paste(filenames: Vec<StrBuf>, serial: bool, delimiters: &str) {
} }
) )
).collect(); ).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; let mut delim_count = 0;
if serial { if serial {
for file in files.mut_iter() { for file in files.mut_iter() {
let mut output = StrBuf::new(); let mut output = String::new();
loop { loop {
match file.read_line() { match file.read_line() {
Ok(line) => { Ok(line) => {

View file

@ -25,7 +25,7 @@ mod util;
static NAME: &'static str = "printenv"; static NAME: &'static str = "printenv";
fn main() { 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 program = args.get(0).clone();
let opts = ~[ let opts = ~[
getopts::optflag("0", "null", "end each output line with 0 byte rather than newline"), getopts::optflag("0", "null", "end each output line with 0 byte rather than newline"),
@ -59,7 +59,7 @@ fn main() {
exec(matches.free, separator); exec(matches.free, separator);
} }
pub fn exec(args: Vec<StrBuf>, separator: &str) { 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.move_iter() { for (env_var, value) in vars.move_iter() {

View file

@ -24,7 +24,7 @@ static NAME: &'static str = "pwd";
static VERSION: &'static str = "1.0.0"; static VERSION: &'static str = "1.0.0";
fn main() { 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 program = args.get(0).clone();
let opts = ~[ let opts = ~[
getopts::optflag("", "help", "display this help and exit"), getopts::optflag("", "help", "display this help and exit"),

View file

@ -30,7 +30,7 @@ enum InteractiveMode {
static NAME: &'static str = "rm"; static NAME: &'static str = "rm";
fn main() { 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 program = args.get(0).clone();
// TODO: make getopts support -R in addition to -r // TODO: make getopts support -R in addition to -r
@ -120,7 +120,7 @@ fn main() {
} }
// TODO: implement one-file-system // 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() { for filename in files.iter() {
let filename = filename.as_slice(); let filename = filename.as_slice();
let file = Path::new(filename); let file = Path::new(filename);

View file

@ -23,7 +23,7 @@ mod util;
static NAME: &'static str = "rmdir"; static NAME: &'static str = "rmdir";
fn main() { 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 program = args.get(0).clone();
let opts = ~[ 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() { for dir in dirs.iter() {
let path = Path::new(dir.as_slice()); let path = Path::new(dir.as_slice());
if path.exists() { if path.exists() {

View file

@ -21,20 +21,20 @@ fn print_usage(opts: ~[getopts::OptGroup]) {
println!("{:s}", getopts::usage("Print sequences of numbers", opts)); 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) { 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}", s))
} }
} }
fn escape_sequences(s: &str) -> StrBuf { fn escape_sequences(s: &str) -> String {
s.replace("\\n", "\n"). s.replace("\\n", "\n").
replace("\\t", "\t") replace("\\t", "\t")
} }
fn main() { 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 = ~[ let opts = ~[
getopts::optopt("s", "separator", "Separator character (defaults to \\n)", ""), getopts::optopt("s", "separator", "Separator character (defaults to \\n)", ""),
getopts::optopt("t", "terminator", "Terminator character (defaults to separator)", ""), 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 mut i = first;
let maxlen = first.max(last).to_str().len(); let maxlen = first.max(last).to_str().len();
while !done_printing(i, step, last) { while !done_printing(i, step, last) {

View file

@ -24,7 +24,7 @@ mod util;
static NAME: &'static str = "sleep"; static NAME: &'static str = "sleep";
fn main() { 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 program = args.get(0).clone();
let opts = ~[ 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 sleep_time = args.iter().fold(0.0, |result, arg| {
let (arg, suffix_time) = match match_suffix(arg.as_slice()) { let (arg, suffix_time) = match match_suffix(arg.as_slice()) {
Ok(m) => m, Ok(m) => m,
@ -86,7 +86,7 @@ fn sleep(args: Vec<StrBuf>) {
timer::sleep((sleep_time * 1000.0) as u64); 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) { let result = match (arg).char_at_reverse(0) {
's' | 'S' => 1, 's' | 'S' => 1,
'm' | 'M' => 60, 'm' | 'M' => 60,

View file

@ -24,7 +24,7 @@ static NAME: &'static str = "tac";
static VERSION: &'static str = "1.0.0"; static VERSION: &'static str = "1.0.0";
fn main() { 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 program = args.get(0).clone();
let opts = ~[ 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() { for filename in filenames.move_iter() {
let mut file = io::BufferedReader::new( let mut file = io::BufferedReader::new(
if filename.as_slice() == "-" { if filename.as_slice() == "-" {
@ -87,7 +87,7 @@ fn tac(filenames: Vec<StrBuf>, before: bool, _: bool, separator: &str) {
data = buf.into_owned(); data = buf.into_owned();
} }
let split_vec: Vec<&str> = data.as_slice().split_str(separator).collect(); 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 { if before {
a.push_str(separator); a.push_str(separator);
a.push_str(b); a.push_str(b);

View file

@ -32,14 +32,14 @@ fn main() {
} }
struct Options { struct Options {
program: StrBuf, program: String,
append: bool, append: bool,
ignore_interrupts: bool, ignore_interrupts: bool,
print_and_exit: Option<StrBuf>, print_and_exit: Option<String>,
files: Box<Vec<Path>> files: Box<Vec<Path>>
} }
fn options(args: &[StrBuf]) -> Result<Options, ()> { fn options(args: &[String]) -> Result<Options, ()> {
let opts = ~[ let opts = ~[
optflag("a", "append", "append to the given FILEs, do not overwrite"), optflag("a", "append", "append to the given FILEs, do not overwrite"),
optflag("i", "ignore-interrupts", "ignore interrupt signals"), 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"), 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| { getopts(args.tail(), opts).map_err(|e| e.to_err_msg()).and_then(|m| {
let version = format!("{} {}", NAME, VERSION); let version = format!("{} {}", NAME, VERSION);
@ -58,7 +58,7 @@ fn options(args: &[StrBuf]) -> Result<Options, ()> {
let help = format!("{}\n\nUsage:\n {} {}\n\n{}\n{}", let help = format!("{}\n\nUsage:\n {} {}\n\n{}\n{}",
version, program, arguments, usage(brief, opts), version, program, arguments, usage(brief, opts),
comment); 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) } let to_print = if m.opt_present("help") { Some(help) }
else if m.opt_present("version") { Some(version) } else if m.opt_present("version") { Some(version) }
else { None }; else { None };

View file

@ -147,7 +147,7 @@ fn usage(opts: &[OptGroup]) {
} }
pub fn main() { 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 = [ let opts = [
getopts::optflag("c", "complement", "use the complement of SET1"), getopts::optflag("c", "complement", "use the complement of SET1"),
getopts::optflag("C", "", "same as -c"), getopts::optflag("C", "", "same as -c"),

View file

@ -47,7 +47,7 @@ enum TruncateMode {
static NAME: &'static str = "truncate"; static NAME: &'static str = "truncate";
fn main() { 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 program = args.get(0).clone();
let opts = ~[ 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 { let (refsize, mode) = match reference {
Some(rfilename) => { Some(rfilename) => {
let rfile = match File::open(&Path::new(rfilename.clone())) { let rfile = match File::open(&Path::new(rfilename.clone())) {

View file

@ -35,7 +35,7 @@ extern {
static NAME: &'static str = "tty"; static NAME: &'static str = "tty";
fn main () { 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 = [ let options = [
optflag("s", "silent", "print nothing, only return an exit status") optflag("s", "silent", "print nothing, only return an exit status")

View file

@ -27,11 +27,11 @@ use c_types::utsname;
#[path = "../common/c_types.rs"] mod c_types; #[path = "../common/c_types.rs"] mod c_types;
struct utsrust { struct utsrust {
sysname: StrBuf, sysname: String,
nodename: StrBuf, nodename: String,
release: StrBuf, release: String,
version: StrBuf, version: String,
machine: StrBuf machine: String
} }
extern { extern {
@ -52,7 +52,7 @@ unsafe fn getuname() -> utsrust {
static NAME: &'static str = "uname"; static NAME: &'static str = "uname";
fn main() { 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 program = args.get(0).as_slice();
let opts = ~[ let opts = ~[
getopts::optflag("h", "help", "display this help and exit"), getopts::optflag("h", "help", "display this help and exit"),
@ -78,7 +78,7 @@ fn main() {
return; return;
} }
let uname = unsafe { getuname() }; let uname = unsafe { getuname() };
let mut output = StrBuf::new(); let mut output = String::new();
if matches.opt_present("sysname") || matches.opt_present("all") if matches.opt_present("sysname") || matches.opt_present("all")
|| !matches.opts_present(["nodename".to_strbuf(), "release".to_strbuf(), "version".to_strbuf(), "machine".to_strbuf()]) { || !matches.opts_present(["nodename".to_strbuf(), "release".to_strbuf(), "version".to_strbuf(), "machine".to_strbuf()]) {
output.push_str(uname.sysname.as_slice()); output.push_str(uname.sysname.as_slice());

View file

@ -27,7 +27,7 @@ mod util;
static NAME: &'static str = "unlink"; static NAME: &'static str = "unlink";
fn main() { 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 program = args.get(0).clone();
let opts = ~[ let opts = ~[
getopts::optflag("h", "help", "display this help and exit"), getopts::optflag("h", "help", "display this help and exit"),

View file

@ -48,7 +48,7 @@ extern {
} }
fn main() { 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 program = args.get(0).clone();
let opts = ~[ let opts = ~[
getopts::optflag("v", "version", "output version information and exit"), getopts::optflag("v", "version", "output version information and exit"),

View file

@ -48,7 +48,7 @@ extern {
static NAME: &'static str = "users"; static NAME: &'static str = "users";
fn main() { 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 program = args.get(0).as_slice();
let opts = ~[ let opts = ~[
getopts::optflag("h", "help", "display this help and exit"), getopts::optflag("h", "help", "display this help and exit"),

View file

@ -23,7 +23,7 @@ use getopts::Matches;
mod util; mod util;
struct Result { struct Result {
filename: StrBuf, filename: String,
bytes: uint, bytes: uint,
chars: uint, chars: uint,
lines: uint, lines: uint,
@ -34,7 +34,7 @@ struct Result {
static NAME: &'static str = "wc"; static NAME: &'static str = "wc";
fn main() { 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 program = args.get(0).clone();
let opts = ~[ let opts = ~[
getopts::optflag("c", "bytes", "print the byte counts"), 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 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_line_count: uint = 0;
let mut total_word_count: uint = 0; let mut total_word_count: uint = 0;
let mut total_char_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() { if "-" == path.as_slice() {
let reader = box stdin() as Box<Reader>; let reader = box stdin() as Box<Reader>;
return Some(BufferedReader::new(reader)); return Some(BufferedReader::new(reader));

View file

@ -30,7 +30,7 @@ extern {
pub fn geteuid() -> libc::c_int; pub fn geteuid() -> libc::c_int;
} }
unsafe fn getusername() -> StrBuf { unsafe fn getusername() -> String {
let passwd: *c_passwd = getpwuid(geteuid()); let passwd: *c_passwd = getpwuid(geteuid());
let pw_name: *libc::c_char = (*passwd).pw_name; let pw_name: *libc::c_char = (*passwd).pw_name;
@ -42,7 +42,7 @@ unsafe fn getusername() -> StrBuf {
static NAME: &'static str = "whoami"; static NAME: &'static str = "whoami";
fn main() { 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 program = args.get(0).as_slice();
let opts = ~[ let opts = ~[
getopts::optflag("h", "help", "display this help and exit"), getopts::optflag("h", "help", "display this help and exit"),

View file

@ -25,7 +25,7 @@ mod util;
static NAME: &'static str = "yes"; static NAME: &'static str = "yes";
fn main() { 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 program = args.get(0).clone();
let opts = ~[ let opts = ~[
getopts::optflag("h", "help", "display this help and exit"), getopts::optflag("h", "help", "display this help and exit"),