// FIXME #2238 Make run only accept source that emits an executable
#[link(name = "rust",
- vers = "0.7",
+ vers = "0.8-pre",
uuid = "4a24da33-5cc8-4037-9352-2cbe9bd9d27c",
url = "https://github.com/mozilla/rust/tree/master/src/rust")];
}
}
-enum Action<'self> {
- Call(&'self fn:Copy(args: &[~str]) -> ValidUsage),
- CallMain(&'static str, &'self fn:Copy()),
+enum Action {
+ Call(extern "Rust" fn(args: &[~str]) -> ValidUsage),
+ CallMain(&'static str, extern "Rust" fn()),
}
enum UsageSource<'self> {
UsgStr(&'self str),
- UsgCall(&'self fn:Copy()),
+ UsgCall(extern "Rust" fn()),
}
struct Command<'self> {
cmd: &'self str,
- action: Action<'self>,
+ action: Action,
usage_line: &'self str,
usage_full: UsageSource<'self>,
}
-static commands: &'static [Command<'static>] = &[
+static NUM_OF_COMMANDS: uint = 7;
+
+// FIXME(#7617): should just be &'static [Command<'static>]
+// but mac os doesn't seem to like that and tries to loop
+// past the end of COMMANDS in usage thus passing garbage
+// to str::repeat and eventually malloc and crashing.
+static COMMANDS: [Command<'static>, .. NUM_OF_COMMANDS] = [
Command{
cmd: "build",
action: CallMain("rustc", rustc::main),
];
fn rustc_help() {
- rustc::usage(copy os::args()[0])
+ rustc::usage(os::args()[0].clone())
}
fn find_cmd(command_string: &str) -> Option<Command> {
- do commands.iter().find_ |command| {
+ do COMMANDS.iter().find_ |command| {
command.cmd == command_string
- }.map_consume(|x| copy *x)
+ }.map_consume(|x| *x)
}
fn cmd_help(args: &[~str]) -> ValidUsage {
match find_cmd(command_string) {
Some(command) => {
match command.action {
- CallMain(prog, _) => io::println(fmt!(
+ CallMain(prog, _) => printfln!(
"The %s command is an alias for the %s program.",
- command.cmd, prog)),
+ command.cmd, prog),
_ => ()
}
match command.usage_full {
- UsgStr(msg) => io::println(fmt!("%s\n", msg)),
+ UsgStr(msg) => printfln!("%s\n", msg),
UsgCall(f) => f(),
}
Valid(0)
}
match args {
- [ref command_string] => print_usage(copy *command_string),
+ [ref command_string] => print_usage((*command_string).clone()),
_ => Invalid
}
}
}
fn usage() {
- static indent: uint = 8;
+ static INDENT: uint = 8;
io::print(
"The rust tool is a convenience for managing rust source code.\n\
\n"
);
- for commands.iter().advance |command| {
- let padding = " ".repeat(indent - command.cmd.len());
- io::println(fmt!(" %s%s%s",
- command.cmd, padding, command.usage_line));
+ for COMMANDS.iter().advance |command| {
+ let padding = " ".repeat(INDENT - command.cmd.len());
+ printfln!(" %s%s%s", command.cmd, padding, command.usage_line);
}
io::print(