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

Fix build with rust master
This commit is contained in:
Heather 2014-05-16 03:26:16 -07:00
commit 27f1605c58
27 changed files with 49 additions and 51 deletions

View file

@ -17,7 +17,6 @@ extern crate getopts;
extern crate libc;
#[phase(syntax, link)] extern crate log;
use std::char;
use std::io::{println, File, stdin, stdout};
use std::os;
use std::str;
@ -55,7 +54,7 @@ fn main() {
}
};
let progname = args[0].clone();
let progname = args.get(0).clone();
let usage = usage("Base64 encode or decode FILE, or standard input, to standard output.", opts);
let mode = if matches.opt_present("help") {
Help
@ -101,13 +100,9 @@ fn decode(input: &mut Reader, ignore_garbage: bool) {
to_decode = str::replace(to_decode, "\n", "");
if ignore_garbage {
let standard_chars: ~[char] =
bytes!("ABCDEFGHIJKLMNOPQRSTUVWXYZ",
"abcdefghijklmnopqrstuvwxyz",
"0123456789+/").iter().map(|b| char::from_u32(*b as u32).unwrap()).collect();
let standard_chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
to_decode = to_decode
.trim_chars(|c| !standard_chars.contains(&c))
.trim_chars(|c| !standard_chars.contains_char(c))
.to_owned();
}
@ -115,7 +110,7 @@ fn decode(input: &mut Reader, ignore_garbage: bool) {
Ok(bytes) => {
let mut out = stdout();
match out.write(bytes) {
match out.write(bytes.as_slice()) {
Ok(_) => {}
Err(f) => { crash!(1, "{}", f.to_str()); }
}

View file

@ -25,7 +25,7 @@ static VERSION: &'static str = "1.0.0";
fn main() {
let args = os::args();
let program = strip_dir(&args[ 0 ].clone());
let program = strip_dir(args.get(0));
//
// Argument parsing
@ -64,7 +64,7 @@ fn main() {
}
// too many arguments
else if args.len() > 3 {
println(program + ": extra operand `" + args[ 3 ] + "'");
println(program + ": extra operand `" + args.get(3).clone() + "'");
println("Try `" + program + " --help' for more information.");
return;
}
@ -73,12 +73,12 @@ fn main() {
// Main Program Processing
//
let fullname = args[ 1 ].clone();
let fullname = args.get(1).clone();
let mut name = strip_dir(&fullname);
if args.len() > 2 {
let suffix = args[ 2 ].clone();
let suffix = args.get(2).clone();
name = strip_suffix(&name, &suffix);
}

View file

@ -21,7 +21,7 @@ use std::io::{BufferedWriter};
fn main() {
let args = os::args();
let program = args[0].clone();
let program = args.get(0).clone();
let opts = ~[
getopts::optflag("A", "show-all", "equivalent to -vET"),
getopts::optflag("b", "number-nonblank", "number nonempty output lines, overrides -n"),

View file

@ -18,7 +18,7 @@ static VERSION: &'static str = "1.0.0";
fn main() {
let args = os::args();
let program = args[0].clone();
let program = args.get(0).clone();
let opts = ~[
getopts::optflag("z", "zero", "separate output with NUL rather than newline"),
getopts::optflag("", "help", "display this help and exit"),

View file

@ -88,7 +88,7 @@ fn du(path: &Path, mut my_stat: FileStat,
fn main() {
let args = os::args();
let program = args[0].as_slice();
let program = args.get(0).as_slice();
let opts = ~[
// In task
getopts::optflag("a", "all", " write counts for all files, not just directories"),

View file

@ -71,7 +71,7 @@ fn convert_str(string: &str, index: uint, base: uint) -> (char, int) {
fn main() {
let args = os::args();
let program = args[0].clone();
let program = args.get(0).clone();
let opts = ~[
getopts::optflag("n", "", "do not output the trailing newline"),
getopts::optflag("e", "", "enable interpretation of backslash escapes"),

7
env/env.rs vendored
View file

@ -53,7 +53,7 @@ fn print_env(null: bool) {
fn main() {
let args = std::os::args();
let prog = args[0].as_slice();
let prog = args.get(0).as_slice();
// to handle arguments the same way than GNU env, we can't use getopts
let mut opts = box options {
@ -191,7 +191,10 @@ fn main() {
}
if opts.program.len() >= 1 {
match std::io::process::Process::status(opts.program.get(0).as_slice(), opts.program.slice_from(1)) {
use std::io::process::{Command, InheritFd};
let prog = opts.program.get(0).clone();
let args = opts.program.slice_from(1);
match Command::new(prog).args(args).stdin(InheritFd(0)).stdout(InheritFd(1)).stderr(InheritFd(2)).status() {
Ok(exit) =>
std::os::set_exit_status(match exit {
std::io::process::ExitStatus(s) => s,

View file

@ -29,9 +29,9 @@ static VERSION: &'static str = "1.0.0";
fn main() {
let args = os::args();
let program = args[0].clone();
let program = args.get(0).clone();
let (args, obs_width) = handle_obsolete(args);
let (args, obs_width) = handle_obsolete(args.as_slice().to_owned());
let opts = [
getopts::optflag("b", "bytes", "count using bytes rather than columns (meaning control characters such as newline are not treated specially)"),

View file

@ -25,7 +25,7 @@ extern {
fn main () {
let args = os::args();
let program = args[0].to_owned();
let program = args.get(0).to_owned();
let options = [
optflag("f", "full", "Default option to show full name"),
@ -96,7 +96,7 @@ fn xgethostname() -> ~str {
}
fn xsethostname(name: &~str) {
let vec_name: ~[libc::c_char] = name.bytes().map(|c| c as i8).collect();
let vec_name: Vec<libc::c_char> = name.bytes().map(|c| c as i8).collect();
let err = unsafe {
sethostname (vec_name.as_ptr(), vec_name.len() as i32)

View file

@ -45,7 +45,7 @@ fn version() {
fn main() {
let args = os::args();
let program = args[0].clone();
let program = args.get(0).clone();
//
// Argument parsing

View file

@ -30,7 +30,7 @@ static VERSION: &'static str = "1.0.0";
fn main() {
let args = os::args();
let program = args[0].clone();
let program = args.get(0).clone();
let opts = [
getopts::optflag("b", "binary", "read in binary mode"),

View file

@ -70,12 +70,12 @@ fn main() {
strconv::ExpNone,
false, false);
if res.is_some() {
unsafe { std::cast::transmute(res.unwrap()) }
unsafe { std::mem::transmute(res.unwrap()) }
} else {
crash!(1, "no mode given");
}
} else {
unsafe { std::cast::transmute(0o755 as u32) }
unsafe { std::mem::transmute(0o755 as u32) }
};
let dirs = matches.free;

View file

@ -25,7 +25,7 @@ static VERSION: &'static str = "1.0.0";
fn main() {
let args = os::args();
let program = args[0].clone();
let program = args.get(0).clone();
let opts = ~[
getopts::optflag("s", "serial", "paste one file at a time instead of in parallel"),
@ -57,7 +57,7 @@ fn main() {
}
fn paste(filenames: Vec<~str>, serial: bool, delimiters: ~str) {
let mut files: ~[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(
if name == "-".to_owned() {
box io::stdio::stdin_raw() as Box<Reader>
@ -66,14 +66,14 @@ fn paste(filenames: Vec<~str>, serial: bool, delimiters: ~str) {
}
)
).collect();
let delimiters: ~[~str] = delimiters.chars().map(|x| x.to_str()).collect();
let delimiters: Vec<~str> = delimiters.chars().map(|x| x.to_str()).collect();
let mut delim_count = 0;
if serial {
for file in files.mut_iter() {
let mut output = "".to_owned();
loop {
output = output + match file.read_line() {
Ok(line) => line.trim_right() + delimiters[delim_count % delimiters.len()],
Ok(line) => line.trim_right() + delimiters.get(delim_count % delimiters.len()).clone(),
Err(f) => if f.kind == io::EndOfFile {
break
} else {
@ -103,7 +103,7 @@ fn paste(filenames: Vec<~str>, serial: bool, delimiters: ~str) {
}
}
}
output = output + delimiters[delim_count % delimiters.len()];
output = output + delimiters.get(delim_count % delimiters.len()).clone();
delim_count += 1;
}
if files.len() == eof_count {

View file

@ -26,7 +26,7 @@ static NAME: &'static str = "printenv";
fn main() {
let args = os::args();
let program = args[0].clone();
let program = args.get(0).clone();
let opts = ~[
getopts::optflag("0", "null", "end each output line with 0 byte rather than newline"),
getopts::optflag("h", "help", "display this help and exit"),

View file

@ -25,7 +25,7 @@ static VERSION: &'static str = "1.0.0";
fn main() {
let args = os::args();
let program = args[0].clone();
let program = args.get(0).clone();
let opts = ~[
getopts::optflag("", "help", "display this help and exit"),
getopts::optflag("", "version", "output version information and exit"),

View file

@ -31,7 +31,7 @@ static NAME: &'static str = "rm";
fn main() {
let args = os::args();
let program = args[0].clone();
let program = args.get(0).clone();
// TODO: make getopts support -R in addition to -r
let opts = ~[

View file

@ -24,7 +24,7 @@ static NAME: &'static str = "rmdir";
fn main() {
let args = os::args();
let program = args[0].clone();
let program = args.get(0).clone();
let opts = ~[
getopts::optflag("", "ignore-fail-on-non-empty", "ignore each failure that is solely because a directory is non-empty"),

View file

@ -25,7 +25,7 @@ static NAME: &'static str = "sleep";
fn main() {
let args = os::args();
let program = args[0].clone();
let program = args.get(0).clone();
let opts = ~[
getopts::optflag("h", "help", "display this help and exit"),

View file

@ -25,7 +25,7 @@ static VERSION: &'static str = "1.0.0";
fn main() {
let args = os::args();
let program = args[0].clone();
let program = args.get(0).clone();
let opts = ~[
getopts::optflag("b", "before", "attach the separator before instead of after"),
@ -86,7 +86,7 @@ fn tac(filenames: Vec<~str>, before: bool, _: bool, separator: ~str) {
buf.truncate(len - 1);
data = buf.into_owned();
}
let split_vec: ~[&str] = data.split_str(separator).collect();
let split_vec: Vec<&str> = data.split_str(separator).collect();
let rev: ~str = split_vec.iter().rev().fold("".to_owned(), |a, &b|
a + if before {
separator + b

View file

@ -25,7 +25,7 @@ static NAME: &'static str = "tee";
static VERSION: &'static str = "1.0.0";
fn main() {
match options(args()).and_then(exec) {
match options(args().as_slice()).and_then(exec) {
Ok(_) => set_exit_status(0),
Err(_) => set_exit_status(1)
}
@ -149,5 +149,5 @@ fn with_path<T>(path: &Path, cb: || -> IoResult<T>) -> IoResult<T> {
}
fn warn(message: &str) {
error!("{}: {}", args()[0], message);
error!("{}: {}", args().get(0), message);
}

View file

@ -48,7 +48,7 @@ static NAME: &'static str = "truncate";
fn main() {
let args = os::args();
let program = args[0].clone();
let program = args.get(0).clone();
let opts = ~[
getopts::optflag("c", "no-create", "do not create files that do not exist"),

View file

@ -53,7 +53,7 @@ static NAME: &'static str = "uname";
fn main() {
let args = os::args();
let program = args[0].as_slice();
let program = args.get(0).as_slice();
let opts = ~[
getopts::optflag("h", "help", "display this help and exit"),
getopts::optflag("a", "all", "Behave as though all of the options -mnrsv were specified."),

View file

@ -18,7 +18,7 @@ extern crate getopts;
extern crate libc;
use std::os;
use std::cast::transmute;
use std::mem::transmute;
use std::io::{print, File};
use std::ptr::null;
use std::from_str::from_str;
@ -49,7 +49,7 @@ extern {
fn main() {
let args = os::args();
let program = args[0].clone();
let program = args.get(0).clone();
let opts = ~[
getopts::optflag("v", "version", "output version information and exit"),
getopts::optflag("h", "help", "display this help and exit"),

View file

@ -20,7 +20,7 @@ extern crate getopts;
extern crate libc;
use std::io::print;
use std::cast;
use std::mem;
use std::os;
use std::ptr;
use std::str;
@ -49,7 +49,7 @@ static NAME: &'static str = "users";
fn main() {
let args = os::args();
let program = args[0].as_slice();
let program = args.get(0).as_slice();
let opts = ~[
getopts::optflag("h", "help", "display this help and exit"),
getopts::optflag("V", "version", "output version information and exit"),
@ -103,7 +103,7 @@ fn exec(filename: &str) {
}
if (*line).ut_type == USER_PROCESS {
let user = str::raw::from_c_str(cast::transmute(&(*line).ut_user));
let user = str::raw::from_c_str(mem::transmute(&(*line).ut_user));
users.push(user);
}
}

View file

@ -35,7 +35,7 @@ static NAME: &'static str = "wc";
fn main() {
let args = os::args();
let program = args[0].clone();
let program = args.get(0).clone();
let opts = ~[
getopts::optflag("c", "bytes", "print the byte counts"),
getopts::optflag("m", "chars", "print the character counts"),

View file

@ -43,7 +43,7 @@ static NAME: &'static str = "whoami";
fn main() {
let args = os::args();
let program = args[0].as_slice();
let program = args.get(0).as_slice();
let opts = ~[
getopts::optflag("h", "help", "display this help and exit"),
getopts::optflag("V", "version", "output version information and exit"),

View file

@ -26,7 +26,7 @@ static NAME: &'static str = "yes";
fn main() {
let args = os::args();
let program = args[0].clone();
let program = args.get(0).clone();
let opts = ~[
getopts::optflag("h", "help", "display this help and exit"),
getopts::optflag("V", "version", "output version information and exit"),