Skip to content

Commit c14e14e

Browse files
committed
std: more windows fixes to os.rs and run.rs
1 parent 56730c0 commit c14e14e

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

src/libstd/os.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -640,7 +640,7 @@ pub fn make_dir(p: &Path, mode: c_int) -> bool {
640640
use os::win32::as_utf16_p;
641641
// FIXME: turn mode into something useful? #2623
642642
do as_utf16_p(p.to_str()) |buf| {
643-
libc::CreateDirectoryW(buf, ptr::null() as LPCWSTR)
643+
libc::CreateDirectoryW(buf, ptr::mut_null())
644644
!= (0 as libc::BOOL)
645645
}
646646
}
@@ -1080,8 +1080,8 @@ pub fn last_os_error() -> ~str {
10801080

10811081
let mut buf = [0 as c_char, ..TMPBUF_SZ];
10821082

1083-
do buf.as_mut_buf |buf, len| {
1084-
unsafe {
1083+
unsafe {
1084+
do buf.as_mut_buf |buf, len| {
10851085
let res = FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM |
10861086
FORMAT_MESSAGE_IGNORE_INSERTS,
10871087
ptr::mut_null(),
@@ -1093,7 +1093,9 @@ pub fn last_os_error() -> ~str {
10931093
if res == 0 {
10941094
fail!("[%?] FormatMessage failure", errno());
10951095
}
1096+
}
10961097

1098+
do buf.as_imm_buf |buf, _len| {
10971099
str::raw::from_c_str(buf)
10981100
}
10991101
}

src/libstd/run.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ use prelude::*;
2525
use ptr;
2626
use task;
2727
use vec::ImmutableVector;
28-
use vec;
2928

3029
/**
3130
* A value representing a child process.
@@ -691,6 +690,8 @@ fn spawn_process_os(prog: &str, args: &[~str],
691690

692691
#[cfg(unix)]
693692
fn with_argv<T>(prog: &str, args: &[~str], cb: &fn(**libc::c_char) -> T) -> T {
693+
use vec;
694+
694695
// We can't directly convert `str`s into `*char`s, as someone needs to hold
695696
// a reference to the intermediary byte buffers. So first build an array to
696697
// hold all the ~[u8] byte strings.
@@ -717,6 +718,8 @@ fn with_argv<T>(prog: &str, args: &[~str], cb: &fn(**libc::c_char) -> T) -> T {
717718

718719
#[cfg(unix)]
719720
fn with_envp<T>(env: Option<&[(~str, ~str)]>, cb: &fn(*c_void) -> T) -> T {
721+
use vec;
722+
720723
// On posixy systems we can pass a char** for envp, which is a
721724
// null-terminated array of "k=v\n" strings. Like `with_argv`, we have to
722725
// have a temporary buffer to hold the intermediary `~[u8]` byte strings.

0 commit comments

Comments
 (0)