Skip to content

Commit cd6b95d

Browse files
committed
Split out windows strcase* work into gnu/msvc files
1 parent d75fc9c commit cd6b95d

File tree

3 files changed

+30
-30
lines changed

3 files changed

+30
-30
lines changed

src/windows/gnu.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
pub const L_tmpnam: ::c_uint = 14;
2+
pub const TMP_MAX: ::c_uint = 0x7fff;
3+
4+
extern {
5+
pub fn strcasecmp(s1: *const ::c_char, s2: *const ::c_char) -> ::c_int;
6+
pub fn strncasecmp(s1: *const ::c_char, s2: *const ::c_char,
7+
n: ::size_t) -> ::c_int;
8+
}

src/windows.rs renamed to src/windows/mod.rs

Lines changed: 12 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -111,18 +111,6 @@ pub const BUFSIZ: ::c_uint = 512;
111111
pub const FOPEN_MAX: ::c_uint = 20;
112112
pub const FILENAME_MAX: ::c_uint = 260;
113113

114-
cfg_if! {
115-
if #[cfg(all(target_env = "gnu"))] {
116-
pub const L_tmpnam: ::c_uint = 14;
117-
pub const TMP_MAX: ::c_uint = 0x7fff;
118-
} else if #[cfg(all(target_env = "msvc"))] {
119-
pub const L_tmpnam: ::c_uint = 260;
120-
pub const TMP_MAX: ::c_uint = 0x7fff_ffff;
121-
} else {
122-
// Unknown target_env
123-
}
124-
}
125-
126114
pub const O_RDONLY: ::c_int = 0;
127115
pub const O_WRONLY: ::c_int = 1;
128116
pub const O_RDWR: ::c_int = 2;
@@ -381,24 +369,6 @@ extern {
381369
locale: *const wchar_t) -> *mut wchar_t;
382370
}
383371

384-
cfg_if! {
385-
extern {
386-
if #[cfg(all(target_env = "gnu"))] {
387-
pub fn strcasecmp(s1: *const c_char, s2: *const c_char) -> c_int;
388-
pub fn strncasecmp(s1: *const c_char, s2: *const c_char,
389-
n: size_t) -> c_int;
390-
} else if #[cfg(all(target_env = "msvc"))] {
391-
#[link_name = "_stricmp"]
392-
pub fn stricmp(s1: *const c_char, s2: *const c_char) -> c_int;
393-
#[link_name = "_strnicmp"]
394-
pub fn strnicmp(s1: *const c_char, s2: *const c_char,
395-
n: size_t) -> c_int;
396-
} else {
397-
// Unknown target_env
398-
}
399-
}
400-
}
401-
402372
cfg_if! {
403373
if #[cfg(core_cvoid)] {
404374
pub use core::ffi::c_void;
@@ -416,3 +386,15 @@ cfg_if! {
416386
}
417387
}
418388
}
389+
390+
cfg_if! {
391+
if #[cfg(all(target_env = "gnu"))] {
392+
mod gnu;
393+
pub use self::gnu::*;
394+
} else if #[cfg(all(target_env = "msvc"))] {
395+
mod msvc;
396+
pub use self::msvc::*;
397+
} else {
398+
// Unknown target_env
399+
}
400+
}

src/windows/msvc.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
pub const L_tmpnam: ::c_uint = 260;
2+
pub const TMP_MAX: ::c_uint = 0x7fff_ffff;
3+
4+
extern {
5+
#[link_name = "_stricmp"]
6+
pub fn stricmp(s1: *const ::c_char, s2: *const ::c_char) -> ::c_int;
7+
#[link_name = "_strnicmp"]
8+
pub fn strnicmp(s1: *const ::c_char, s2: *const ::c_char,
9+
n: ::size_t) -> ::c_int;
10+
}

0 commit comments

Comments
 (0)