Skip to content

Commit 7a89eff

Browse files
committed
---
yaml --- r: 130842 b: refs/heads/auto c: 8baff54 h: refs/heads/master v: v3
1 parent 011477c commit 7a89eff

File tree

5 files changed

+59
-41
lines changed

5 files changed

+59
-41
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0
1313
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1414
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1515
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
16-
refs/heads/auto: 4067252def4251d7c2f4afc79ae1716093fe27ac
16+
refs/heads/auto: 8baff5412861e2013c245ccffcbba84be3186c06
1717
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1818
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
1919
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336

branches/auto/src/liblibc/lib.rs

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ pub use funcs::bsd43::{shutdown};
249249
#[cfg(windows)] pub use types::os::arch::extra::{LARGE_INTEGER, LPVOID, LONG};
250250
#[cfg(windows)] pub use types::os::arch::extra::{time64_t, OVERLAPPED, LPCWSTR};
251251
#[cfg(windows)] pub use types::os::arch::extra::{LPOVERLAPPED, SIZE_T, LPDWORD};
252-
#[cfg(windows)] pub use types::os::arch::extra::{SECURITY_ATTRIBUTES, WIN32_FIND_DATAW};
252+
#[cfg(windows)] pub use types::os::arch::extra::{SECURITY_ATTRIBUTES};
253253
#[cfg(windows)] pub use funcs::c95::string::{wcslen};
254254
#[cfg(windows)] pub use funcs::posix88::stat_::{wstat, wutime, wchmod, wrmdir};
255255
#[cfg(windows)] pub use funcs::bsd43::{closesocket};
@@ -1638,22 +1638,6 @@ pub mod types {
16381638
pub type LPWSAPROTOCOL_INFO = *mut WSAPROTOCOL_INFO;
16391639

16401640
pub type GROUP = c_uint;
1641-
1642-
#[repr(C)]
1643-
pub struct WIN32_FIND_DATAW {
1644-
pub dwFileAttributes: DWORD,
1645-
pub ftCreationTime: FILETIME,
1646-
pub ftLastAccessTime: FILETIME,
1647-
pub ftLastWriteTime: FILETIME,
1648-
pub nFileSizeHigh: DWORD,
1649-
pub nFileSizeLow: DWORD,
1650-
pub dwReserved0: DWORD,
1651-
pub dwReserved1: DWORD,
1652-
pub cFileName: [wchar_t, ..260], // #define MAX_PATH 260
1653-
pub cAlternateFileName: [wchar_t, ..14],
1654-
}
1655-
1656-
pub type LPWIN32_FIND_DATAW = *mut WIN32_FIND_DATAW;
16571641
}
16581642
}
16591643
}
@@ -4779,7 +4763,7 @@ pub mod funcs {
47794763
LPMEMORY_BASIC_INFORMATION,
47804764
LPSYSTEM_INFO, HANDLE, LPHANDLE,
47814765
LARGE_INTEGER, PLARGE_INTEGER,
4782-
LPFILETIME, LPWIN32_FIND_DATAW};
4766+
LPFILETIME};
47834767

47844768
extern "system" {
47854769
pub fn GetEnvironmentVariableW(n: LPCWSTR,
@@ -4809,9 +4793,9 @@ pub mod funcs {
48094793
-> DWORD;
48104794
pub fn SetCurrentDirectoryW(lpPathName: LPCWSTR) -> BOOL;
48114795
pub fn GetLastError() -> DWORD;
4812-
pub fn FindFirstFileW(fileName: LPCWSTR, findFileData: LPWIN32_FIND_DATAW)
4796+
pub fn FindFirstFileW(fileName: LPCWSTR, findFileData: HANDLE)
48134797
-> HANDLE;
4814-
pub fn FindNextFileW(findFile: HANDLE, findFileData: LPWIN32_FIND_DATAW)
4798+
pub fn FindNextFileW(findFile: HANDLE, findFileData: HANDLE)
48154799
-> BOOL;
48164800
pub fn FindClose(findFile: HANDLE) -> BOOL;
48174801
pub fn DuplicateHandle(hSourceProcessHandle: HANDLE,

branches/auto/src/libnative/io/file_windows.rs

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,16 @@
1111
//! Blocking Windows-based file I/O
1212
1313
use alloc::arc::Arc;
14-
use libc::{mod, c_int};
14+
use libc::{c_int, c_void};
15+
use libc;
1516
use std::c_str::CString;
1617
use std::mem;
1718
use std::os::windows::fill_utf16_buf_and_decode;
1819
use std::ptr;
1920
use std::rt::rtio;
2021
use std::rt::rtio::{IoResult, IoError};
2122
use std::str;
23+
use std::vec;
2224

2325
pub type fd_t = libc::c_int;
2426

@@ -342,6 +344,8 @@ pub fn mkdir(p: &CString, _mode: uint) -> IoResult<()> {
342344
}
343345

344346
pub fn readdir(p: &CString) -> IoResult<Vec<CString>> {
347+
use std::rt::libc_heap::malloc_raw;
348+
345349
fn prune(root: &CString, dirs: Vec<Path>) -> Vec<CString> {
346350
let root = unsafe { CString::new(root.as_ptr(), false) };
347351
let root = Path::new(root);
@@ -351,35 +355,38 @@ pub fn readdir(p: &CString) -> IoResult<Vec<CString>> {
351355
}).map(|path| root.join(path).to_c_str()).collect()
352356
}
353357

358+
extern {
359+
fn rust_list_dir_wfd_size() -> libc::size_t;
360+
fn rust_list_dir_wfd_fp_buf(wfd: *mut libc::c_void) -> *const u16;
361+
}
354362
let star = Path::new(unsafe {
355363
CString::new(p.as_ptr(), false)
356364
}).join("*");
357365
let path = try!(to_utf16(&star.to_c_str()));
358366

359367
unsafe {
360-
let mut wfd = mem::zeroed();
361-
let find_handle = libc::FindFirstFileW(path.as_ptr(), &mut wfd);
368+
let wfd_ptr = malloc_raw(rust_list_dir_wfd_size() as uint);
369+
let find_handle = libc::FindFirstFileW(path.as_ptr(),
370+
wfd_ptr as libc::HANDLE);
362371
if find_handle != libc::INVALID_HANDLE_VALUE {
363-
let mut paths = vec![];
364-
let mut more_files = 1 as libc::BOOL;
372+
let mut paths = vec!();
373+
let mut more_files = 1 as libc::c_int;
365374
while more_files != 0 {
366-
{
367-
let filename = str::truncate_utf16_at_nul(wfd.cFileName);
368-
match String::from_utf16(filename) {
369-
Some(filename) => paths.push(Path::new(filename)),
370-
None => {
371-
assert!(libc::FindClose(find_handle) != 0);
372-
return Err(IoError {
373-
code: super::c::ERROR_ILLEGAL_CHARACTER as uint,
374-
extra: 0,
375-
detail: Some(format!("path was not valid UTF-16: {}", filename)),
376-
})
377-
}, // FIXME #12056: Convert the UCS-2 to invalid utf-8 instead of erroring
378-
}
375+
let fp_buf = rust_list_dir_wfd_fp_buf(wfd_ptr as *mut c_void);
376+
if fp_buf as uint == 0 {
377+
fail!("os::list_dir() failure: got null ptr from wfd");
378+
} else {
379+
let fp_vec = vec::raw::from_buf(fp_buf, libc::wcslen(fp_buf) as uint);
380+
let fp_trimmed = str::truncate_utf16_at_nul(fp_vec.as_slice());
381+
let fp_str = String::from_utf16(fp_trimmed)
382+
.expect("rust_list_dir_wfd_fp_buf returned invalid UTF-16");
383+
paths.push(Path::new(fp_str));
379384
}
380-
more_files = libc::FindNextFileW(find_handle, &mut wfd);
385+
more_files = libc::FindNextFileW(find_handle,
386+
wfd_ptr as libc::HANDLE);
381387
}
382388
assert!(libc::FindClose(find_handle) != 0);
389+
libc::free(wfd_ptr as *mut c_void);
383390
Ok(prune(p, paths))
384391
} else {
385392
Err(super::last_error())

branches/auto/src/libsyntax/parse/parser.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4780,7 +4780,7 @@ impl<'a> Parser<'a> {
47804780
self.span_warn(span,
47814781
format!("this extern crate syntax is deprecated. \
47824782
Use: extern crate \"{}\" as {};",
4783-
the_ident.as_str(), path.ref0().get() ).as_slice()
4783+
path.ref0().get(), the_ident.as_str() ).as_slice()
47844784
);
47854785
Some(path)
47864786
} else {None};

branches/auto/src/rt/rust_builtin.c

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,33 @@ rust_list_dir_val(struct dirent* entry_ptr) {
100100
}
101101
#endif
102102

103+
size_t
104+
#if defined(__WIN32__)
105+
rust_list_dir_wfd_size() {
106+
return sizeof(WIN32_FIND_DATAW);
107+
}
108+
#else
109+
rust_list_dir_wfd_size() {
110+
return 0;
111+
}
112+
#endif
113+
114+
void*
115+
#if defined(__WIN32__)
116+
rust_list_dir_wfd_fp_buf(WIN32_FIND_DATAW* wfd) {
117+
if(wfd == NULL) {
118+
return 0;
119+
}
120+
else {
121+
return wfd->cFileName;
122+
}
123+
}
124+
#else
125+
rust_list_dir_wfd_fp_buf(void* wfd) {
126+
return 0;
127+
}
128+
#endif
129+
103130
typedef struct {
104131
int32_t tm_sec;
105132
int32_t tm_min;

0 commit comments

Comments
 (0)