about summary refs log tree commit diff
path: root/src/libnative
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2014-07-10 21:41:36 +0000
committerbors <bors@rust-lang.org>2014-07-10 21:41:36 +0000
commita672456c40d28f051ecbdb2caf5bf6733371d494 (patch)
tree1ce9d7ff9d26425e9c581d7ce377531c1155da0b /src/libnative
parent8bbf598d50960087342667fc47f5d38f4a9c2165 (diff)
parentbfa853f8ed45d1908c98ec350f52c7a6790661da (diff)
downloadrust-a672456c40d28f051ecbdb2caf5bf6733371d494.tar.gz
rust-a672456c40d28f051ecbdb2caf5bf6733371d494.zip
auto merge of #15353 : aturon/rust/env-hashmap, r=alexcrichton
This commit adds `env_insert` and `env_remove` methods to the `Command`
builder, easing updates to the environment variables for the child
process. The existing method, `env`, is still available for overriding
the entire environment in one shot (after which the `env_insert` and
`env_remove` methods can be used to make further adjustments).

To support these new methods, the internal `env` representation for
`Command` has been changed to an optional `HashMap` holding owned
`CString`s (to support non-utf8 data). The `HashMap` is only
materialized if the environment is updated. The implementation does not
try hard to avoid allocation, since the cost of launching a process will
dwarf any allocation cost.

This patch also adds `PartialOrd`, `Eq`, and `Hash` implementations for
`CString`.
Diffstat (limited to 'src/libnative')
-rw-r--r--src/libnative/io/process.rs4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/libnative/io/process.rs b/src/libnative/io/process.rs
index 71702d180b9..21da0104c2f 100644
--- a/src/libnative/io/process.rs
+++ b/src/libnative/io/process.rs
@@ -729,7 +729,7 @@ fn with_argv<T>(prog: &CString, args: &[CString],
 }
 
 #[cfg(unix)]
-fn with_envp<T>(env: Option<&[(CString, CString)]>,
+fn with_envp<T>(env: Option<&[(&CString, &CString)]>,
                 cb: proc(*const c_void) -> T) -> T {
     // On posixy systems we can pass a char** for envp, which is a
     // null-terminated array of "k=v\0" strings. Since we must create
@@ -762,7 +762,7 @@ fn with_envp<T>(env: Option<&[(CString, CString)]>,
 }
 
 #[cfg(windows)]
-fn with_envp<T>(env: Option<&[(CString, CString)]>, cb: |*mut c_void| -> T) -> T {
+fn with_envp<T>(env: Option<&[(&CString, &CString)]>, cb: |*mut c_void| -> T) -> T {
     // On win32 we pass an "environment block" which is not a char**, but
     // rather a concatenation of null-terminated k=v\0 sequences, with a final
     // \0 to terminate.