about summary refs log tree commit diff
path: root/src/libstd/sys
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2015-08-11 11:20:11 +0000
committerbors <bors@rust-lang.org>2015-08-11 11:20:11 +0000
commitc756526eb2aed91e96d2b5d9461898cb33565707 (patch)
tree3f609da8d07cf04617e277e56890b794e2345062 /src/libstd/sys
parent23f43896ce92830173e503eab8b2f7fba8137e37 (diff)
parentaebd6d5106243a926c39d02c84917b473b65dcc0 (diff)
downloadrust-c756526eb2aed91e96d2b5d9461898cb33565707.tar.gz
rust-c756526eb2aed91e96d2b5d9461898cb33565707.zip
Auto merge of #27658 - Manishearth:rollup, r=Manishearth
- Successful merges: #27542, #27571, #27572, #27577, #27611, #27612, #27617, #27633, #27647, #27648, #27651
- Failed merges: 
Diffstat (limited to 'src/libstd/sys')
-rw-r--r--src/libstd/sys/windows/os.rs10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/libstd/sys/windows/os.rs b/src/libstd/sys/windows/os.rs
index 8a8cf9e7c53..694d873d0d2 100644
--- a/src/libstd/sys/windows/os.rs
+++ b/src/libstd/sys/windows/os.rs
@@ -84,9 +84,13 @@ pub fn error_string(errnum: i32) -> String {
         }
 
         let b = buf.iter().position(|&b| b == 0).unwrap_or(buf.len());
-        let msg = String::from_utf16(&buf[..b]);
-        match msg {
-            Ok(msg) => msg,
+        match String::from_utf16(&buf[..b]) {
+            Ok(mut msg) => {
+                // Trim trailing CRLF inserted by FormatMessageW
+                let len = msg.trim_right().len();
+                msg.truncate(len);
+                msg
+            },
             Err(..) => format!("OS Error {} (FormatMessageW() returned \
                                 invalid UTF-16)", errnum),
         }