diff options
| author | bors <bors@rust-lang.org> | 2013-08-23 01:31:26 -0700 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2013-08-23 01:31:26 -0700 |
| commit | db55cd92dec88c3ff025ecf8b4900aca4520bea6 (patch) | |
| tree | 4f5c19f1ed56124393012cf73bae99e2e2612e1d /src/libstd/os.rs | |
| parent | 5e5e2c71e403371ff8a5d5430e7696654214a438 (diff) | |
| parent | 77df8b809a3927ffcdd2c43d48783c97a25712a8 (diff) | |
| download | rust-db55cd92dec88c3ff025ecf8b4900aca4520bea6.tar.gz rust-db55cd92dec88c3ff025ecf8b4900aca4520bea6.zip | |
auto merge of #8681 : mrordinaire/rust/remove-set_args, r=brson
Diffstat (limited to 'src/libstd/os.rs')
| -rw-r--r-- | src/libstd/os.rs | 31 |
1 files changed, 6 insertions, 25 deletions
diff --git a/src/libstd/os.rs b/src/libstd/os.rs index f734a59f67f..0b5f53dbf19 100644 --- a/src/libstd/os.rs +++ b/src/libstd/os.rs @@ -36,7 +36,6 @@ use iterator::range; use libc; use libc::{c_char, c_void, c_int, size_t}; use libc::FILE; -use local_data; use option::{Some, None}; use os; use prelude::*; @@ -1188,7 +1187,7 @@ unsafe fn load_argc_and_argv(argc: c_int, argv: **c_char) -> ~[~str] { * Returns a list of the command line arguments. */ #[cfg(target_os = "macos")] -pub fn real_args() -> ~[~str] { +fn real_args() -> ~[~str] { #[fixed_stack_segment]; #[inline(never)]; unsafe { @@ -1201,7 +1200,7 @@ pub fn real_args() -> ~[~str] { #[cfg(target_os = "linux")] #[cfg(target_os = "android")] #[cfg(target_os = "freebsd")] -pub fn real_args() -> ~[~str] { +fn real_args() -> ~[~str] { use rt; match rt::args::clone() { @@ -1211,7 +1210,7 @@ pub fn real_args() -> ~[~str] { } #[cfg(windows)] -pub fn real_args() -> ~[~str] { +fn real_args() -> ~[~str] { #[fixed_stack_segment]; #[inline(never)]; let mut nArgs: c_int = 0; @@ -1261,28 +1260,10 @@ struct OverriddenArgs { val: ~[~str] } -static overridden_arg_key: local_data::Key<@OverriddenArgs> = &local_data::Key; - /// Returns the arguments which this program was started with (normally passed /// via the command line). -/// -/// The return value of the function can be changed by invoking the -/// `os::set_args` function. pub fn args() -> ~[~str] { - match local_data::get(overridden_arg_key, |k| k.map(|&k| *k)) { - None => real_args(), - Some(args) => args.val.clone() - } -} - -/// For the current task, overrides the task-local cache of the arguments this -/// program had when it started. These new arguments are only available to the -/// current task via the `os::args` method. -pub fn set_args(new_args: ~[~str]) { - let overridden_args = @OverriddenArgs { - val: new_args.clone() - }; - local_data::set(overridden_arg_key, overridden_args); + real_args() } // FIXME #6100 we should really use an internal implementation of this - using @@ -1770,7 +1751,7 @@ mod tests { use libc; use option::Some; use option; - use os::{env, getcwd, getenv, make_absolute, real_args}; + use os::{env, getcwd, getenv, make_absolute, args}; use os::{remove_file, setenv, unsetenv}; use os; use path::Path; @@ -1788,7 +1769,7 @@ mod tests { #[test] pub fn test_args() { - let a = real_args(); + let a = args(); assert!(a.len() >= 1); } |
