about summary refs log tree commit diff
path: root/src/libstd/env.rs
AgeCommit message (Collapse)AuthorLines
2016-07-27Auto merge of #33312 - Byron:double-ended-iterator-for-args, r=alexcrichtonbors-0/+11
DoubleEndedIterator for Args This PR implements the DoubleEndedIterator trait for the `std::env::Args[Os]` structure, as well as the internal implementations. It is primarily motivated by me, as I happened to implement a simple `reversor` program many times now, which so far had to use code like this: ```Rust for arg in std::env::args().skip(1).collect::<Vec<_>>().iter().rev() {} ``` ... even though I would have loved to do this instead: ```Rust for arg in std::env::args().skip(1).rev() {} ``` The latter is more natural, and I did not find a reason for not implementing it. After all, on every system, the number of arguments passed to the program are known at runtime. To my mind, it follows KISS, and does not try to be smart at all. Also, there are no unit-tests, primarily as I did not find any existing tests for the `Args` struct either. The windows implementation is basically a copy-pasted variant of the `next()` method implementation, and I could imagine sharing most of the code instead. Actually I would be happy if the reviewer would ask for it.
2016-07-26DoubleEndedIterator for ArgsSebastian Thiel-0/+11
The number of arguments given to a process is always known, which makes implementing DoubleEndedIterator possible. That way, the Iterator::rev() method becomes usable, among others. Signed-off-by: Sebastian Thiel <byronimo@gmail.com> Tidy for DoubleEndedIterator I chose to not create a new feature for it, even though technically, this makes me lie about the original availability of the implementation. Verify with @alexchrichton Setup feature flag for new std::env::Args iterators Add test for Args reverse iterator It's somewhat depending on the input of the test program, but made in such a way that should be somewhat flexible to changes to the way it is called. Deduplicate windows ArgsOS code for DEI DEI = DoubleEndedIterator Move env::args().rev() test to run-pass It must be controlling it's arguments for full isolation. Remove superfluous feature name Assert all arguments returned by env::args().rev() Let's be very sure it works as we expect, why take chances. Fix rval of os_string_from_ptr A trait cannot be returned, but only the corresponding object. Deref pointers to actually operate on the argument Put unsafe to correct location
2016-07-20Auto merge of #33526 - steveklabnik:gh21889, r=alexcrichtonbors-0/+38
Add some warnings to std::env::current_exe /cc #21889 @rust-lang/libs @semarie I started writing this up. I'm not sure if we want to go into other things and in what depth; we don't currently have a lot of security-specific documentation to model after. Thoughts?
2016-07-19re-work exampleSteve Klabnik-12/+35
2016-05-12Cleanup formatting and wording for `std::env::temp_dir` docs.Corey Farwell-10/+10
2016-05-09Add some warnings to std::env::current_exeSteve Klabnik-0/+15
/cc #21889
2016-04-06Rollup merge of #32691 - frewsxcv:patch-28, r=alexcrichtonSteve Klabnik-1/+1
Indicate `None` is code-like in doc comment.
2016-04-06Rollup merge of #31762 - tshepang:in-which-case, r=steveklabnikSteve Klabnik-8/+8
doc: there is no case that is shown, so something was likely missing … …from the change
2016-04-05doc: make env::consts summaries less confusingTshepang Lekhonkhobe-8/+8
2016-04-02Indicate `None` is code-like in doc comment.Corey Farwell-1/+1
2016-03-30doc: "of the" seems more correct than "to the"Tshepang Lekhonkhobe-8/+8
It's also less ambiguous
2016-02-28doc: "ref" not needed in the exampleTshepang Lekhonkhobe-1/+1
Also, `path` seems better than `p`
2016-02-26Rollup merge of #31896 - tshepang:idiom, r=steveklabnikManish Goregaokar-1/+1
2016-02-26Rollup merge of #31894 - tshepang:more-clear, r=steveklabnikManish Goregaokar-2/+1
2016-02-25doc: follow the idiom of adding a trailing commaTshepang Lekhonkhobe-1/+1
2016-02-25doc: that explanation was a messTshepang Lekhonkhobe-2/+1
2016-02-25doc: add missing commaTshepang Lekhonkhobe-1/+1
2016-02-24Auto merge of #31778 - aturon:snapshot, r=alexcrichtonbors-1/+1
r? @alexcrichton
2016-02-23Register new snapshotsAaron Turon-1/+1
2016-02-19Rollup merge of #31765 - tshepang:shorten, r=steveklabnikSteve Klabnik-1/+1
2016-02-19Rollup merge of #31764 - tshepang:overlong-sentence, r=steveklabnikSteve Klabnik-1/+1
2016-02-18doc: make the sentence more simpleTshepang Lekhonkhobe-1/+1
2016-02-18doc: reduce overlong sentenceTshepang Lekhonkhobe-1/+1
2016-02-18doc: remove a word that makes the sentence hard to readTshepang Lekhonkhobe-1/+1
2016-02-06Add the asmjs-unknown-emscripten triple. Add cfgs to libs.Brian Anderson-0/+16
Backtraces, and the compilation of libbacktrace for asmjs, are disabled. This port doesn't use jemalloc so, like pnacl, it disables jemalloc *for all targets* in the configure file. It disables stack protection.
2016-02-03Auto merge of #31078 - nbaksalyar:illumos, r=alexcrichtonbors-0/+12
This pull request adds support for [Illumos](http://illumos.org/)-based operating systems: SmartOS, OpenIndiana, and others. For now it's x86-64 only, as I'm not sure if 32-bit installations are widespread. This PR is based on #28589 by @potatosalad, and also closes #21000, #25845, and #25846. Required changes in libc are already merged: https://github.com/rust-lang-nursery/libc/pull/138 Here's a snapshot required to build a stage0 compiler: https://s3-eu-west-1.amazonaws.com/nbaksalyar/rustc-sunos-snapshot.tar.gz It passes all checks from `make check`. There are some changes I'm not quite sure about, e.g. macro usage in `src/libstd/num/f64.rs` and `DirEntry` structure in `src/libstd/sys/unix/fs.rs`, so any comments on how to rewrite it better would be greatly appreciated. Also, LLVM configure script might need to be patched to build it successfully, or a pre-built libLLVM should be used. Some details can be found here: https://llvm.org/bugs/show_bug.cgi?id=25409 Thanks! r? @brson
2016-02-01Remove "powerpc64le" and "mipsel" target_archAlex Crichton-12/+0
Currently the `mipsel-unknown-linux-gnu` target doesn't actually set the `target_arch` value to `mipsel` but it rather uses `mips`. Alternatively the `powerpc64le` target does indeed set the `target_arch` as `powerpc64le`, causing a bit of inconsistency between theset two. As these are just the same instance of one instruction set, let's use `target_endian` to switch between them and only set the `target_arch` as one value. This should cut down on the number of `#[cfg]` annotations necessary and all around be a little more ergonomic.
2016-01-31Rename sunos to solarisNikita Baksalyar-3/+3
2016-01-31Add Illumos supportNikita Baksalyar-0/+12
2016-01-15Auto merge of #30898 - petrochenkov:tvarfstab, r=alexcrichtonbors-1/+1
This wasn't done in https://github.com/rust-lang/rust/pull/29083 because attributes weren't parsed on fields of tuple variant back then. r? @alexcrichton
2016-01-14Require stability annotations on fields of tuple variantsVadim Petrochenkov-1/+1
2016-01-13Add powerpc64 and powerpc64le supportAnton Blanchard-0/+12
This adds support for big endian and little endian PowerPC64. make check runs clean apart from one big endian backtrace issue.
2015-12-01Small fix to EXE_SUFFIX and DLL_EXTENSION docsSteve Klabnik-4/+6
2015-11-29Fix #30093Jack Fransham-1/+1
2015-11-08Spell out the fallback of `std::env::home_dir` on POSIXTobias Bucher-1/+3
2015-11-06Auto merge of #29305 - alexcrichton:bad-getenv, r=brsonbors-10/+10
As discovered in #29298, `env::set_var("", "")` will panic, but it turns out that it *also* deadlocks on Unix systems. This happens because if a panic happens while holding the environment lock, we then go try to read RUST_BACKTRACE, grabbing the environment lock, causing a deadlock. Specifically, the changes made here are: * The environment lock is pushed into `std::sys` instead of `std::env`. This also only puts it in the Unix implementation, not Windows where the functions are already threadsafe. * The `std::sys` implementation now returns `io::Result` so panics are explicitly at the `std::env` level.
2015-10-30Tweak env docs a bitSteven Fackler-3/+3
The "optionally" stuff just makes things confusing.
2015-10-29Auto merge of #29289 - DiamondLovesYou:pnacl-std-crates, r=alexcrichtonbors-0/+26
2015-10-28Port the standard crates to PNaCl/NaCl.Richard Diamond-0/+26
2015-10-26std: Slightly more robust env var handlingAlex Crichton-10/+10
As discovered in #29298, `env::set_var("", "")` will panic, but it turns out that it *also* deadlocks on Unix systems. This happens because if a panic happens while holding the environment lock, we then go try to read RUST_BACKTRACE, grabbing the environment lock, causing a deadlock. Specifically, the changes made here are: * The environment lock is pushed into `std::sys` instead of `std::env`. This also only puts it in the Unix implementation, not Windows where the functions are already threadsafe. * The `std::sys` implementation now returns `io::Result` so panics are explicitly at the `std::env` level. The panic messages have also been improved in these situations.
2015-10-25Say that `std::env::{set_var, unset_var}` *may* panicTobias Bucher-4/+6
Previously the documentation suggested that the documentation about the panics are guarantees.
2015-10-25Document possible panics for `std::env::{set_var, unset_var}`Tobias Bucher-0/+10
2015-10-11Clarify the behavior of `std::env::home_dir` and `std::env::temp_dir`Barosl Lee-2/+9
This concern was raised by #28940.
2015-09-09Reduce code bloat from conversion traits in function parametersVadim Petrochenkov-3/+19
2015-08-12Remove all unstable deprecated functionalityAlex Crichton-33/+0
This commit removes all unstable and deprecated functions in the standard library. A release was recently cut (1.3) which makes this a good time for some spring cleaning of the deprecated functions.
2015-07-27std: Deprecate a number of unstable featuresAlex Crichton-0/+2
Many of these have long since reached their stage of being obsolete, so this commit starts the removal process for all of them. The unstable features that were deprecated are: * cmp_partial * fs_time * hash_default * int_slice * iter_min_max * iter_reset_fuse * iter_to_vec * map_in_place * move_from * owned_ascii_ext * page_size * read_and_zero * scan_state * slice_chars * slice_position_elem * subslice_offset
2015-07-16Fixed typoKristof Söderström-1/+1
2015-07-08Make `std::env::current_dir` work for path names longer than 2048 bytes on ↵Tobias Bucher-1/+0
non-Windows
2015-07-01Add netbsd amd64 supportAlex Newman-0/+12
2015-06-17std: Deprecate the `exit_status` featureAlex Crichton-0/+2
These two functions should be replaceable with the `process::exit` function.