diff options
Diffstat (limited to 'src/libcore/os.rs')
| -rw-r--r-- | src/libcore/os.rs | 85 |
1 files changed, 42 insertions, 43 deletions
diff --git a/src/libcore/os.rs b/src/libcore/os.rs index aa4a6feb76f..17ec9df9d56 100644 --- a/src/libcore/os.rs +++ b/src/libcore/os.rs @@ -208,8 +208,8 @@ pub fn env() -> ~[(~str,~str)] { let mut result = ~[]; ptr::array_each(environ, |e| { let env_pair = str::raw::from_c_str(e); - log(debug, fmt!("get_env_pairs: %s", - env_pair)); + debug!("get_env_pairs: %s", + env_pair); result.push(env_pair); }); result @@ -219,9 +219,8 @@ pub fn env() -> ~[(~str,~str)] { let mut pairs = ~[]; for input.each |p| { let vs = str::splitn_char(*p, '=', 1); - log(debug, - fmt!("splitting: len: %u", - vs.len())); + debug!("splitting: len: %u", + vs.len()); fail_unless!(vs.len() == 2); pairs.push((copy vs[0], copy vs[1])); } @@ -682,10 +681,10 @@ pub fn list_dir(p: &Path) -> ~[~str] { let input = p.to_str(); let mut strings = ~[]; let input_ptr = ::cast::transmute(&input[0]); - log(debug, "os::list_dir -- BEFORE OPENDIR"); + debug!("os::list_dir -- BEFORE OPENDIR"); let dir_ptr = opendir(input_ptr); if (dir_ptr as uint != 0) { - log(debug, "os::list_dir -- opendir() SUCCESS"); + debug!("os::list_dir -- opendir() SUCCESS"); let mut entry_ptr = readdir(dir_ptr); while (entry_ptr as uint != 0) { strings.push( @@ -697,11 +696,11 @@ pub fn list_dir(p: &Path) -> ~[~str] { closedir(dir_ptr); } else { - log(debug, "os::list_dir -- opendir() FAILURE"); + debug!("os::list_dir -- opendir() FAILURE"); } - log(debug, - fmt!("os::list_dir -- AFTER -- #: %?", - strings.len())); + debug!( + "os::list_dir -- AFTER -- #: %?", + strings.len()); strings } #[cfg(windows)] @@ -1171,11 +1170,11 @@ pub mod consts { pub use os::consts::windows::*; pub mod unix { - pub const FAMILY: &static/str = "unix"; + pub const FAMILY: &'static str = "unix"; } pub mod windows { - pub const FAMILY: &static/str = "windows"; + pub const FAMILY: &'static str = "windows"; } #[cfg(target_os = "macos")] @@ -1194,38 +1193,38 @@ pub mod consts { pub use os::consts::win32::*; pub mod macos { - pub const SYSNAME: &static/str = "macos"; - pub const DLL_PREFIX: &static/str = "lib"; - pub const DLL_SUFFIX: &static/str = ".dylib"; - pub const EXE_SUFFIX: &static/str = ""; + pub const SYSNAME: &'static str = "macos"; + pub const DLL_PREFIX: &'static str = "lib"; + pub const DLL_SUFFIX: &'static str = ".dylib"; + pub const EXE_SUFFIX: &'static str = ""; } pub mod freebsd { - pub const SYSNAME: &static/str = "freebsd"; - pub const DLL_PREFIX: &static/str = "lib"; - pub const DLL_SUFFIX: &static/str = ".so"; - pub const EXE_SUFFIX: &static/str = ""; + pub const SYSNAME: &'static str = "freebsd"; + pub const DLL_PREFIX: &'static str = "lib"; + pub const DLL_SUFFIX: &'static str = ".so"; + pub const EXE_SUFFIX: &'static str = ""; } pub mod linux { - pub const SYSNAME: &static/str = "linux"; - pub const DLL_PREFIX: &static/str = "lib"; - pub const DLL_SUFFIX: &static/str = ".so"; - pub const EXE_SUFFIX: &static/str = ""; + pub const SYSNAME: &'static str = "linux"; + pub const DLL_PREFIX: &'static str = "lib"; + pub const DLL_SUFFIX: &'static str = ".so"; + pub const EXE_SUFFIX: &'static str = ""; } pub mod android { - pub const SYSNAME: &static/str = "android"; - pub const DLL_PREFIX: &static/str = "lib"; - pub const DLL_SUFFIX: &static/str = ".so"; - pub const EXE_SUFFIX: &static/str = ""; + pub const SYSNAME: &'static str = "android"; + pub const DLL_PREFIX: &'static str = "lib"; + pub const DLL_SUFFIX: &'static str = ".so"; + pub const EXE_SUFFIX: &'static str = ""; } pub mod win32 { - pub const SYSNAME: &static/str = "win32"; - pub const DLL_PREFIX: &static/str = ""; - pub const DLL_SUFFIX: &static/str = ".dll"; - pub const EXE_SUFFIX: &static/str = ".exe"; + pub const SYSNAME: &'static str = "win32"; + pub const DLL_PREFIX: &'static str = ""; + pub const DLL_SUFFIX: &'static str = ".dll"; + pub const EXE_SUFFIX: &'static str = ".exe"; } @@ -1258,7 +1257,6 @@ pub mod consts { #[cfg(test)] #[allow(non_implicitly_copyable_typarams)] mod tests { - use debug; use libc::{c_int, c_void, size_t}; use libc; use option::{None, Option, Some}; @@ -1267,6 +1265,7 @@ mod tests { use os::{remove_file, setenv}; use os; use path::Path; + use rand::RngUtil; use rand; use run; use str; @@ -1274,7 +1273,7 @@ mod tests { #[test] pub fn last_os_error() { - log(debug, os::last_os_error()); + debug!(os::last_os_error()); } #[test] @@ -1284,7 +1283,7 @@ mod tests { } fn make_rand_name() -> ~str { - let rng: rand::Rng = rand::Rng(); + let rng: @rand::Rng = rand::Rng(); let n = ~"TEST" + rng.gen_str(10u); fail_unless!(getenv(n).is_none()); n @@ -1320,7 +1319,7 @@ mod tests { while i < 100 { s += ~"aaaaaaaaaa"; i += 1; } let n = make_rand_name(); setenv(n, s); - log(debug, copy s); + debug!(copy s); fail_unless!(getenv(n) == option::Some(s)); } @@ -1329,7 +1328,7 @@ mod tests { let path = os::self_exe_path(); fail_unless!(path.is_some()); let path = path.get(); - log(debug, copy path); + debug!(copy path); // Hard to test this function fail_unless!(path.is_absolute); @@ -1342,7 +1341,7 @@ mod tests { fail_unless!(vec::len(e) > 0u); for vec::each(e) |p| { let (n, v) = copy *p; - log(debug, copy n); + debug!(copy n); let v2 = getenv(n); // MingW seems to set some funky environment variables like // "=C:=C:\MinGW\msys\1.0\bin" and "!::=::\" that are returned @@ -1367,10 +1366,10 @@ mod tests { fn test() { fail_unless!((!Path("test-path").is_absolute)); - log(debug, ~"Current working directory: " + getcwd().to_str()); + debug!(~"Current working directory: " + getcwd().to_str()); - log(debug, make_absolute(&Path("test-path"))); - log(debug, make_absolute(&Path("/usr/bin"))); + debug!(make_absolute(&Path("test-path"))); + debug!(make_absolute(&Path("/usr/bin"))); } #[test] @@ -1433,7 +1432,7 @@ mod tests { fail_unless!((vec::len(dirs) > 0u)); for vec::each(dirs) |dir| { - log(debug, copy *dir); + debug!(copy *dir); } } |
