about summary refs log tree commit diff
path: root/src/libstd/sys_common
diff options
context:
space:
mode:
authorJoshua Barretto <barry.of.smith@gmail.com>2018-04-05 20:59:32 +0100
committerGitHub <noreply@github.com>2018-04-05 20:59:32 +0100
commit5e94d5498d3a24418185a1783f2819cbb2280ddd (patch)
treead100bc79003d246837e5fc080b23f675d8c17c6 /src/libstd/sys_common
parent446285e45c02f71392c7084328dc167d2e1ff58c (diff)
parent7222241e7c2d7caf9ad6ee6e34748e4addfb8dd3 (diff)
downloadrust-5e94d5498d3a24418185a1783f2819cbb2280ddd.tar.gz
rust-5e94d5498d3a24418185a1783f2819cbb2280ddd.zip
Merge pull request #1 from rust-lang/master
Merge upstream changes
Diffstat (limited to 'src/libstd/sys_common')
-rw-r--r--src/libstd/sys_common/process.rs12
-rw-r--r--src/libstd/sys_common/thread_info.rs4
-rw-r--r--src/libstd/sys_common/wtf8.rs22
3 files changed, 28 insertions, 10 deletions
diff --git a/src/libstd/sys_common/process.rs b/src/libstd/sys_common/process.rs
index fd1a5fdb410..d0c5951bd6c 100644
--- a/src/libstd/sys_common/process.rs
+++ b/src/libstd/sys_common/process.rs
@@ -47,6 +47,7 @@ impl EnvKey for DefaultEnvKey {}
 #[derive(Clone, Debug)]
 pub struct CommandEnv<K> {
     clear: bool,
+    saw_path: bool,
     vars: BTreeMap<K, Option<OsString>>
 }
 
@@ -54,6 +55,7 @@ impl<K: EnvKey> Default for CommandEnv<K> {
     fn default() -> Self {
         CommandEnv {
             clear: false,
+            saw_path: false,
             vars: Default::default()
         }
     }
@@ -108,9 +110,11 @@ impl<K: EnvKey> CommandEnv<K> {
 
     // The following functions build up changes
     pub fn set(&mut self, key: &OsStr, value: &OsStr) {
+        self.maybe_saw_path(&key);
         self.vars.insert(key.to_owned().into(), Some(value.to_owned()));
     }
     pub fn remove(&mut self, key: &OsStr) {
+        self.maybe_saw_path(&key);
         if self.clear {
             self.vars.remove(key);
         } else {
@@ -121,4 +125,12 @@ impl<K: EnvKey> CommandEnv<K> {
         self.clear = true;
         self.vars.clear();
     }
+    pub fn have_changed_path(&self) -> bool {
+        self.saw_path || self.clear
+    }
+    fn maybe_saw_path(&mut self, key: &OsStr) {
+        if !self.saw_path && key == "PATH" {
+            self.saw_path = true;
+        }
+    }
 }
diff --git a/src/libstd/sys_common/thread_info.rs b/src/libstd/sys_common/thread_info.rs
index 6a2b6742367..d75cbded734 100644
--- a/src/libstd/sys_common/thread_info.rs
+++ b/src/libstd/sys_common/thread_info.rs
@@ -50,3 +50,7 @@ pub fn set(stack_guard: Option<Guard>, thread: Thread) {
         thread,
     }));
 }
+
+pub fn reset_guard(stack_guard: Option<Guard>) {
+    THREAD_INFO.with(move |c| c.borrow_mut().as_mut().unwrap().stack_guard = stack_guard);
+}
diff --git a/src/libstd/sys_common/wtf8.rs b/src/libstd/sys_common/wtf8.rs
index 9fff8b91f96..dda4e1bab3b 100644
--- a/src/libstd/sys_common/wtf8.rs
+++ b/src/libstd/sys_common/wtf8.rs
@@ -27,7 +27,6 @@
 
 use core::str::next_code_point;
 
-use ascii::*;
 use borrow::Cow;
 use char;
 use fmt;
@@ -254,6 +253,11 @@ impl Wtf8Buf {
         self.bytes.shrink_to_fit()
     }
 
+    #[inline]
+    pub fn shrink_to(&mut self, min_capacity: usize) {
+        self.bytes.shrink_to(min_capacity)
+    }
+
     /// Returns the number of bytes that this string buffer can hold without reallocating.
     #[inline]
     pub fn capacity(&self) -> usize {
@@ -871,24 +875,22 @@ impl Hash for Wtf8 {
     }
 }
 
-impl AsciiExt for Wtf8 {
-    type Owned = Wtf8Buf;
-
-    fn is_ascii(&self) -> bool {
+impl Wtf8 {
+    pub fn is_ascii(&self) -> bool {
         self.bytes.is_ascii()
     }
-    fn to_ascii_uppercase(&self) -> Wtf8Buf {
+    pub fn to_ascii_uppercase(&self) -> Wtf8Buf {
         Wtf8Buf { bytes: self.bytes.to_ascii_uppercase() }
     }
-    fn to_ascii_lowercase(&self) -> Wtf8Buf {
+    pub fn to_ascii_lowercase(&self) -> Wtf8Buf {
         Wtf8Buf { bytes: self.bytes.to_ascii_lowercase() }
     }
-    fn eq_ignore_ascii_case(&self, other: &Wtf8) -> bool {
+    pub fn eq_ignore_ascii_case(&self, other: &Wtf8) -> bool {
         self.bytes.eq_ignore_ascii_case(&other.bytes)
     }
 
-    fn make_ascii_uppercase(&mut self) { self.bytes.make_ascii_uppercase() }
-    fn make_ascii_lowercase(&mut self) { self.bytes.make_ascii_lowercase() }
+    pub fn make_ascii_uppercase(&mut self) { self.bytes.make_ascii_uppercase() }
+    pub fn make_ascii_lowercase(&mut self) { self.bytes.make_ascii_lowercase() }
 }
 
 #[cfg(test)]