diff options
| author | Patrick Walton <pcwalton@mimiga.net> | 2014-04-02 16:54:22 -0700 |
|---|---|---|
| committer | Huon Wilson <dbau.pp+github@gmail.com> | 2014-04-10 22:10:10 +1000 |
| commit | d8e45ea7c054b4ad6fb82ec3a9fcf1736b4d7260 (patch) | |
| tree | 3ff220512aeae37710c8b1c783e1229e685bfce3 /src/libnative | |
| parent | 7fbcb400f0697621ece9f9773b0f0bf1ec73e9c1 (diff) | |
| download | rust-d8e45ea7c054b4ad6fb82ec3a9fcf1736b4d7260.tar.gz rust-d8e45ea7c054b4ad6fb82ec3a9fcf1736b4d7260.zip | |
libstd: Implement `StrBuf`, a new string buffer type like `Vec`, and
port all code over to use it.
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..8ef46239e61 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.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 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. |
