From 0de432528736590245c619ab1cfb489978171f07 Mon Sep 17 00:00:00 2001 From: Arcterus Date: Tue, 1 Jul 2014 13:13:41 -0700 Subject: [PATCH 1/2] uutils: handle prefixes instead of suffixes --- uutils/uutils.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/uutils/uutils.rs b/uutils/uutils.rs index b3c4033a0..9ecc9a2e0 100644 --- a/uutils/uutils.rs +++ b/uutils/uutils.rs @@ -58,8 +58,8 @@ fn main() { None => (), } - if binary_as_util.starts_with("uutils") - || binary_as_util.starts_with("busybox") { + if binary_as_util.ends_with("uutils") + || binary_as_util.ends_with("busybox") { // uutils can be called as either "uutils", "busybox" // "uutils-suffix" or "busybox-suffix". Not sure // what busybox uses the -suffix pattern for. From 2ea9dcfdc4b04678521aa153d79ba38dcfa1d160 Mon Sep 17 00:00:00 2001 From: Arcterus Date: Tue, 1 Jul 2014 13:20:21 -0700 Subject: [PATCH 2/2] uutils: auto-generate true and false --- mkuutils.rs | 4 ++-- uutils/uutils.rs | 3 --- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/mkuutils.rs b/mkuutils.rs index 2ca17b66c..67b7ca15c 100644 --- a/mkuutils.rs +++ b/mkuutils.rs @@ -22,8 +22,8 @@ fn main() { } util_map.push_str(format!("map.insert(\"{}\", hashsum::uumain);\n", prog).as_slice()); } - "true" => util_map.push_str("map.insert(\"true\", uutrue);\n"), - "false" => util_map.push_str("map.insert(\"false\", uufalse);\n"), + "true" => util_map.push_str("fn uutrue(_: Vec) -> int { 0 }\nmap.insert(\"true\", uutrue);\n"), + "false" => util_map.push_str("fn uufalse(_: Vec) -> int { 1 }\nmap.insert(\"false\", uufalse);\n"), "sync" => { crates.push_str("extern crate uusync;\n"); util_map.push_str("map.insert(\"sync\", uusync::uumain);\n"); diff --git a/uutils/uutils.rs b/uutils/uutils.rs index 9ecc9a2e0..15011ae56 100644 --- a/uutils/uutils.rs +++ b/uutils/uutils.rs @@ -20,9 +20,6 @@ static NAME: &'static str = "uutils"; static VERSION: &'static str = "1.0.0"; fn util_map() -> HashMap<&'static str, fn(Vec) -> int> { - fn uutrue(_: Vec) -> int { 0 } - fn uufalse(_: Vec) -> int { 1 } - let mut map = HashMap::new(); @UTIL_MAP@ map