diff options
| author | bors <bors@rust-lang.org> | 2014-04-10 21:01:41 -0700 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2014-04-10 21:01:41 -0700 |
| commit | cea8def62068b405495ecd1810124ebc88b4f90b (patch) | |
| tree | 65d5755bd532a9213799c52572db6d6683d5e942 /src/libnative | |
| parent | 0156af156d70efd5a3c96d0c5b8fc9bec39a7ae5 (diff) | |
| parent | def90f43e2df9968cda730a2a30cb7ccb9513002 (diff) | |
| download | rust-cea8def62068b405495ecd1810124ebc88b4f90b.tar.gz rust-cea8def62068b405495ecd1810124ebc88b4f90b.zip | |
auto merge of #13440 : huonw/rust/strbuf, r=alexcrichton
libstd: Implement `StrBuf`, a new string buffer type like `Vec`, and port all code over to use it. Rebased & tests-fixed version of https://github.com/mozilla/rust/pull/13269
Diffstat (limited to 'src/libnative')
| -rw-r--r-- | src/libnative/io/process.rs | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/libnative/io/process.rs b/src/libnative/io/process.rs index fcf59cb0548..e3bb938995b 100644 --- a/src/libnative/io/process.rs +++ b/src/libnative/io/process.rs @@ -20,6 +20,7 @@ use super::IoResult; 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.into_owned(); - 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 make_command_line(prog: &str, args: &[~str]) -> ~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. |
