]> git.lizzy.rs Git - rust.git/blobdiff - src/libnative/io/process.rs
libstd: Implement `StrBuf`, a new string buffer type like `Vec`, and
[rust.git] / src / libnative / io / process.rs
index fcf59cb05485915d22d625131f66a87691818f8d..8ef46239e6161f6b09ee043f92e20a62a13cfe94 100644 (file)
@@ -20,6 +20,7 @@
 use super::file;
 
 #[cfg(windows)] use std::cast;
+#[cfg(windows)] use std::strbuf::StrBuf;
 #[cfg(not(windows))] use super::retry;
 
 /**
@@ -395,15 +396,15 @@ fn zeroed_process_information() -> libc::types::os::arch::extra::PROCESS_INFORMA
 
 #[cfg(windows)]
 fn make_command_line(prog: &str, args: &[~str]) -> ~str {
-    let mut cmd = ~"";
+    let mut cmd = StrBuf::new();
     append_arg(&mut cmd, prog);
     for arg in args.iter() {
         cmd.push_char(' ');
         append_arg(&mut cmd, *arg);
     }
-    return cmd;
+    return cmd.to_owned_str();
 
-    fn append_arg(cmd: &mut ~str, arg: &str) {
+    fn append_arg(cmd: &mut StrBuf, arg: &str) {
         let quote = arg.chars().any(|c| c == ' ' || c == '\t');
         if quote {
             cmd.push_char('"');
@@ -416,7 +417,7 @@ fn append_arg(cmd: &mut ~str, arg: &str) {
         }
     }
 
-    fn append_char_at(cmd: &mut ~str, arg: &str, i: uint) {
+    fn append_char_at(cmd: &mut StrBuf, arg: &str, i: uint) {
         match arg[i] as char {
             '"' => {
                 // Escape quotes.