about summary refs log tree commit diff
path: root/src/libstd/os.rs
AgeCommit message (Collapse)AuthorLines
2014-05-27std: Rename strbuf operations to stringRicho Healey-13/+13
[breaking-change]
2014-05-25De-realstd os::argsKevin Ballard-14/+1
With the test runner using ::std::os::args(), and std::std::os now being a re-export of realstd::os, there's no more need for realstd stuff mucking up rt::args. Remove the one test of os::args(), as it's not very useful and it won't work anymore now that rt::args doesn't use realstd.
2014-05-25libstd: Remove unnecessary re-exports under std::stdKevin Ballard-5/+5
2014-05-24core: rename strbuf::StrBuf to string::StringRicho Healey-16/+16
[breaking-change]
2014-05-23core: Finish stabilizing the `mem` module.Alex Crichton-2/+2
* All of the *_val functions have gone from #[unstable] to #[stable] * The overwrite and zeroed functions have gone from #[unstable] to #[stable] * The uninit function is now deprecated, replaced by its stable counterpart, uninitialized [breaking-change]
2014-05-22libcore: Remove all uses of `~str` from `libcore`.Patrick Walton-26/+35
[breaking-change]
2014-05-22libstd: Remove `~str` from all `libstd` modules except `fmt` and `str`.Patrick Walton-53/+65
2014-05-15Updates with core::fmt changesAlex Crichton-5/+5
1. Wherever the `buf` field of a `Formatter` was used, the `Formatter` is used instead. 2. The usage of `write_fmt` is minimized as much as possible, the `write!` macro is preferred wherever possible. 3. Usage of `fmt::write` is minimized, favoring the `write!` macro instead.
2014-05-14librand: Remove all uses of `~str` from `librand`Patrick Walton-3/+3
2014-05-13Use Get/FreeEnvironmentStringsW instead of Get/FreeEnvironmentStringsAPhil Ruffwind-9/+31
Changed libstd to use Get/FreeEnvironmentStringsW instead of Get/FreeEnvironmentStringsA to support Unicode environment variables.
2014-05-13Use CreateProcessW instead of CreateProcessAPhil Ruffwind-1/+5
Changed libnative to use CreateProcessW instead of CreateProcessA. In addition, the lpEnvironment parameter now uses Unicode. Added a helper function os::win32::as_mut_utf16_p, which does basically the same thing as os::win32::as_utf16_p except the pointer is mutable.
2014-05-12Test fixes from rollupAlex Crichton-2/+1
Closes #14163 (Fix typos in rustc manpage) Closes #14161 (Add the patch number to version strings. Closes #13289) Closes #14156 (rustdoc: Fix hiding implementations of traits) Closes #14152 (add shebang to scripts that have execute bit set) Closes #14150 (libcore: remove fails from slice.rs and remove duplicated length checking) Closes #14147 (Make ProcessOutput Eq, TotalEq, Clone) Closes #14142 (doc: updates rust manual (loop to continue)) Closes #14141 (doc: Update the linkage documentation) Closes #14139 (Remove an unnecessary .move_iter().collect()) Closes #14136 (Two minor fixes in parser.rs) Closes #14130 (Fixed typo in comments of driver.rs) Closes #14128 (Add `stat` method to `std::io::fs::File` to stat without a Path.) Closes #14114 (rustdoc: List macros in the sidebar) Closes #14113 (shootout-nbody improvement) Closes #14112 (Improved example code in Option) Closes #14104 (Remove reference to MutexArc) Closes #14087 (emacs: highlight `macro_name!` in macro invocations using [] delimiters)
2014-05-12Remove an unnecessary .move_iter().collect()Simon Sapin-1/+1
2014-05-09auto merge of #14054 : luqmana/rust/at, r=alexcrichtonbors-7/+9
`/data/local/tmp` seems to be more common.
2014-05-08libstd: Check TMPDIR for android as well and if not set use ↵Luqman Aden-7/+9
'/data/local/tmp' instead of '/data/tmp'.
2014-05-08Handle fallout in osKevin Ballard-24/+24
os::env(), os::args(), and related functions now use Vec<T> instead of ~[T].
2014-05-07Test fixes and rebase conflictsAlex Crichton-3/+5
2014-05-07core: Inherit possible string functionalityAlex Crichton-1/+1
This moves as much allocation as possible from teh std::str module into core::str. This includes essentially all non-allocating functionality, mostly iterators and slicing and such. This primarily splits the Str trait into only having the as_slice() method, adding a new StrAllocating trait to std::str which contains the relevant new allocation methods. This is a breaking change if any of the methods of "trait Str" were overriden. The old functionality can be restored by implementing both the Str and StrAllocating traits. [breaking-change]
2014-05-02Replace most ~exprs with 'box'. #11779Brian Anderson-2/+2
2014-04-25Cleaned up os::consts. The module only exposes constants for the target OS ↵Michael Darakananda-172/+130
and arch. Constants for other OS's and arch's must be defined manually. [breaking-change]
2014-04-19auto merge of #13613 : alexcrichton/rust/fix-freebsd-compile, r=brsonbors-3/+2
Ah, the wonders of not being gated on FreeBSD...
2014-04-18Replace all ~"" with "".to_owned()Richo Healey-7/+7
2014-04-18std: Fix compiling on FreeBSDAlex Crichton-3/+2
Ah, the wonders of not being gated on FreeBSD...
2014-04-18Update the rest of the compiler with ~[T] changesAlex Crichton-25/+20
2014-04-18std: Make ~[T] no longer a growable vectorAlex Crichton-14/+11
This removes all resizability support for ~[T] vectors in preparation of DST. The only growable vector remaining is Vec<T>. In summary, the following methods from ~[T] and various functions were removed. Each method/function has an equivalent on the Vec type in std::vec unless otherwise stated. * slice::OwnedCloneableVector * slice::OwnedEqVector * slice::append * slice::append_one * slice::build (no replacement) * slice::bytes::push_bytes * slice::from_elem * slice::from_fn * slice::with_capacity * ~[T].capacity() * ~[T].clear() * ~[T].dedup() * ~[T].extend() * ~[T].grow() * ~[T].grow_fn() * ~[T].grow_set() * ~[T].insert() * ~[T].pop() * ~[T].push() * ~[T].push_all() * ~[T].push_all_move() * ~[T].remove() * ~[T].reserve() * ~[T].reserve_additional() * ~[T].reserve_exect() * ~[T].retain() * ~[T].set_len() * ~[T].shift() * ~[T].shrink_to_fit() * ~[T].swap_remove() * ~[T].truncate() * ~[T].unshift() * ~str.clear() * ~str.set_len() * ~str.truncate() Note that no other API changes were made. Existing apis that took or returned ~[T] continue to do so. [breaking-change]
2014-04-15std: Remove pub use globsBrian Anderson-11/+21
2014-04-04Fix fallout from std::libc separationCorey Richardson-2/+4
2014-04-01auto merge of #13115 : huonw/rust/rand-errors, r=alexcrichtonbors-11/+15
move errno -> IoError converter into std, bubble up OSRng errors Also adds a general errno -> `~str` converter to `std::os`, and makes the failure messages for the things using `OSRng` (e.g. (transitively) the task-local RNG, meaning hashmap initialisation failures aren't such a black box).
2014-04-01std: migrate the errno -> IoError converter from libnative.Huon Wilson-11/+15
This also adds a direct `errno` -> `~str` converter, rather than only being possible to get a string for the very last error.
2014-03-31std: Switch field privacy as necessaryAlex Crichton-5/+5
2014-03-28Convert most code to new inner attribute syntax.Brian Anderson-1/+1
Closes #2569
2014-03-25std: Touch various I/O documentation blocksAlex Crichton-8/+4
These are mostly touchups from the previous commit.
2014-03-25libstd: Document the following modules:Patrick Walton-3/+123
* native::io * std::char * std::fmt * std::fmt::parse * std::io * std::io::extensions * std::io::net::ip * std::io::net::udp * std::io::net::unix * std::io::pipe * std::num * std::num::f32 * std::num::f64 * std::num::strconv * std::os
2014-03-22std::os: Handle FormatMessage failureklutzy-3/+8
`FormatMessageW()` is called by `std::os::last_os_error()` to convert errno into string, but the function may fail on non-english locale. I don't know why it fails, but anyway it's better to return errno than to `fail!()` in the case. Fixes #13075 Fixes #13073
2014-03-20rename std::vec -> std::sliceDaniel Micay-10/+10
Closes #12702
2014-03-15Test fixes and rebase conflictsAlex Crichton-7/+4
This commit switches over the backtrace infrastructure from piggy-backing off the RUST_LOG environment variable to using the RUST_BACKTRACE environment variable (logging is now disabled in libstd).
2014-03-15log: Introduce liblog, the old std::loggingAlex Crichton-8/+2
This commit moves all logging out of the standard library into an external crate. This crate is the new crate which is responsible for all logging macros and logging implementation. A few reasons for this change are: * The crate map has always been a bit of a code smell among rust programs. It has difficulty being loaded on almost all platforms, and it's used almost exclusively for logging and only logging. Removing the crate map is one of the end goals of this movement. * The compiler has a fair bit of special support for logging. It has the __log_level() expression as well as generating a global word per module specifying the log level. This is unfairly favoring the built-in logging system, and is much better done purely in libraries instead of the compiler itself. * Initialization of logging is much easier to do if there is no reliance on a magical crate map being available to set module log levels. * If the logging library can be written outside of the standard library, there's no reason that it shouldn't be. It's likely that we're not going to build the highest quality logging library of all time, so third-party libraries should be able to provide just as high-quality logging systems as the default one provided in the rust distribution. With a migration such as this, the change does not come for free. There are some subtle changes in the behavior of liblog vs the previous logging macros: * The core change of this migration is that there is no longer a physical log-level per module. This concept is still emulated (it is quite useful), but there is now only a global log level, not a local one. This global log level is a reflection of the maximum of all log levels specified. The previously generated logging code looked like: if specified_level <= __module_log_level() { println!(...) } The newly generated code looks like: if specified_level <= ::log::LOG_LEVEL { if ::log::module_enabled(module_path!()) { println!(...) } } Notably, the first layer of checking is still intended to be "super fast" in that it's just a load of a global word and a compare. The second layer of checking is executed to determine if the current module does indeed have logging turned on. This means that if any module has a debug log level turned on, all modules with debug log levels get a little bit slower (they all do more expensive dynamic checks to determine if they're turned on or not). Semantically, this migration brings no change in this respect, but runtime-wise, this will have a perf impact on some code. * A `RUST_LOG=::help` directive will no longer print out a list of all modules that can be logged. This is because the crate map will no longer specify the log levels of all modules, so the list of modules is not known. Additionally, warnings can no longer be provided if a malformed logging directive was supplied. The new "hello world" for logging looks like: #[phase(syntax, link)] extern crate log; fn main() { debug!("Hello, world!"); }
2014-03-14extra: Put the nail in the coffin, delete libextraAlex Crichton-1/+0
This commit shreds all remnants of libextra from the compiler and standard distribution. Two modules, c_vec/tempfile, were moved into libstd after some cleanup, and the other modules were moved to separate crates as seen fit. Closes #8784 Closes #12413 Closes #12576
2014-03-12Remove remaining nolink usages.(fixes #12810)lpy-4/+0
2014-03-12rand: deprecate `rng`.Huon Wilson-1/+1
This should be called far less than it is because it does expensive OS interactions and seeding of the internal RNG, `task_rng` amortises this cost. The main problem is the name is so short and suggestive. The direct equivalent is `StdRng::new`, which does precisely the same thing. The deprecation will make migrating away from the function easier.
2014-02-28std: Change assert_eq!() to use {} instead of {:?}Alex Crichton-4/+4
Formatting via reflection has been a little questionable for some time now, and it's a little unfortunate that one of the standard macros will silently use reflection when you weren't expecting it. This adds small bits of code bloat to libraries, as well as not always being necessary. In light of this information, this commit switches assert_eq!() to using {} in the error message instead of {:?}. In updating existing code, there were a few error cases that I encountered: * It's impossible to define Show for [T, ..N]. I think DST will alleviate this because we can define Show for [T]. * A few types here and there just needed a #[deriving(Show)] * Type parameters needed a Show bound, I often moved this to `assert!(a == b)` * `Path` doesn't implement `Show`, so assert_eq!() cannot be used on two paths. I don't think this is much of a regression though because {:?} on paths looks awful (it's a byte array). Concretely speaking, this shaved 10K off a 656K binary. Not a lot, but sometime significant for smaller binaries.
2014-02-22Warn about unnecessary parentheses upon assignmentEduard Bopp-2/+2
Closes #12366. Parentheses around assignment statements such as let mut a = (0); a = (1); a += (2); are not necessary and therefore an unnecessary_parens warning is raised when statements like this occur. The warning mechanism was refactored along the way to allow for code reuse between the routines for checking expressions and statements. Code had to be adopted throughout the compiler and standard libraries to comply with this modification of the lint.
2014-02-19Fix getting/setting huge env vars on windowsAlex Crichton-1/+13
On windows, the GetEnvironmentVariable function will return the necessary buffer size if the buffer provided was too small. This case previously fell through the checks inside of fill_utf16_buf_and_decode, tripping an assertion in the `slice` method. This adds an extra case for when the return value is >= the buffer size, in which case we assume the return value as the new buffer size and try again. Closes #12376
2014-02-19str: add a function for truncating a vector of u16 at NUL.Huon Wilson-3/+7
Many of the functions interacting with Windows APIs allocate a vector of 0's and do not retrieve a length directly from the API call, and so need to be sure to remove the unmodified junk at the end of the vector.
2014-02-18std: make str::from_utf16 return an Option.Huon Wilson-5/+10
The rest of the codebase is moving toward avoiding `fail!` so we do it here too!
2014-02-16std: Rename unstable::mutex::Mutex to StaticNativeMutex.Huon Wilson-2/+2
This better reflects its purpose and design.
2014-02-16std: add an RAII unlocker to Mutex.Huon Wilson-6/+2
This automatically unlocks its lock when it goes out of scope, and provides a safe(ish) method to call .wait.
2014-02-14Use str::from_utf8_lossy() for os::env() and friendsKevin Ballard-11/+60
Parse the environment by default with from_utf8_lossy. Also provide byte-vector equivalents (e.g. os::env_as_bytes()). Unfortunately, setenv() can't have a byte-vector equivalent because of Windows support, unless we want to define a setenv_bytes() that fails under Windows for non-UTF8 (or non-UTF16).
2014-02-14Use str::from_utf8_lossy() in os::args(), add os::args_as_bytes()Kevin Ballard-4/+27
os::args() was using str::raw::from_c_str(), which would assert if the C-string wasn't valid UTF-8. Switch to using from_utf8_lossy() instead, and add a separate function os::args_as_bytes() that returns the ~[u8] byte-vectors instead.
2014-02-08std::fmt: convert the formatting traits to a proper self.Huon Wilson-2/+2
Poly and String have polymorphic `impl`s and so require different method names.