std: win32 os::env() str parsing to str::raw::from_c_multistring + test

This commit is contained in:
Jeff Olson
2013-09-14 09:35:11 -07:00
parent b49fc4cf4e
commit daf4974628
2 changed files with 38 additions and 10 deletions

View File

@@ -196,16 +196,7 @@ pub fn env() -> ~[(~str,~str)] {
if (ch as uint == 0) {
fail!("os::env() failure getting env string from OS: %s", os::last_os_error());
}
let mut curr_ptr: uint = ch as uint;
let mut result = ~[];
while(*(curr_ptr as *libc::c_char) != 0 as libc::c_char) {
let env_pair = str::raw::from_c_str(
curr_ptr as *libc::c_char);
result.push(env_pair);
curr_ptr +=
libc::strlen(curr_ptr as *libc::c_char) as uint
+ 1;
}
result = unsafe { str::raw::from_c_multistring(ch as *libc::c_char) };
FreeEnvironmentStringsA(ch);
result
}