From cd6b95db83dd46fad581730c021bf5666a0d9e7b Mon Sep 17 00:00:00 2001 From: Tom Parker-Shemilt <palfrey@tevp.net> Date: Fri, 23 Nov 2018 22:33:20 +0000 Subject: [PATCH] Split out windows strcase* work into gnu/msvc files --- src/windows/gnu.rs | 8 ++++++ src/{windows.rs => windows/mod.rs} | 42 +++++++++--------------------- src/windows/msvc.rs | 10 +++++++ 3 files changed, 30 insertions(+), 30 deletions(-) create mode 100644 src/windows/gnu.rs rename src/{windows.rs => windows/mod.rs} (94%) create mode 100644 src/windows/msvc.rs diff --git a/src/windows/gnu.rs b/src/windows/gnu.rs new file mode 100644 index 00000000..a67af15a --- /dev/null +++ b/src/windows/gnu.rs @@ -0,0 +1,8 @@ +pub const L_tmpnam: ::c_uint = 14; +pub const TMP_MAX: ::c_uint = 0x7fff; + +extern { + pub fn strcasecmp(s1: *const ::c_char, s2: *const ::c_char) -> ::c_int; + pub fn strncasecmp(s1: *const ::c_char, s2: *const ::c_char, + n: ::size_t) -> ::c_int; +} diff --git a/src/windows.rs b/src/windows/mod.rs similarity index 94% rename from src/windows.rs rename to src/windows/mod.rs index 1d2d96b4..79ef4910 100644 --- a/src/windows.rs +++ b/src/windows/mod.rs @@ -111,18 +111,6 @@ pub const BUFSIZ: ::c_uint = 512; pub const FOPEN_MAX: ::c_uint = 20; pub const FILENAME_MAX: ::c_uint = 260; -cfg_if! { - if #[cfg(all(target_env = "gnu"))] { - pub const L_tmpnam: ::c_uint = 14; - pub const TMP_MAX: ::c_uint = 0x7fff; - } else if #[cfg(all(target_env = "msvc"))] { - pub const L_tmpnam: ::c_uint = 260; - pub const TMP_MAX: ::c_uint = 0x7fff_ffff; - } else { - // Unknown target_env - } -} - pub const O_RDONLY: ::c_int = 0; pub const O_WRONLY: ::c_int = 1; pub const O_RDWR: ::c_int = 2; @@ -381,24 +369,6 @@ extern { locale: *const wchar_t) -> *mut wchar_t; } -cfg_if! { - extern { - if #[cfg(all(target_env = "gnu"))] { - pub fn strcasecmp(s1: *const c_char, s2: *const c_char) -> c_int; - pub fn strncasecmp(s1: *const c_char, s2: *const c_char, - n: size_t) -> c_int; - } else if #[cfg(all(target_env = "msvc"))] { - #[link_name = "_stricmp"] - pub fn stricmp(s1: *const c_char, s2: *const c_char) -> c_int; - #[link_name = "_strnicmp"] - pub fn strnicmp(s1: *const c_char, s2: *const c_char, - n: size_t) -> c_int; - } else { - // Unknown target_env - } - } -} - cfg_if! { if #[cfg(core_cvoid)] { pub use core::ffi::c_void; @@ -416,3 +386,15 @@ cfg_if! { } } } + +cfg_if! { + if #[cfg(all(target_env = "gnu"))] { + mod gnu; + pub use self::gnu::*; + } else if #[cfg(all(target_env = "msvc"))] { + mod msvc; + pub use self::msvc::*; + } else { + // Unknown target_env + } +} \ No newline at end of file diff --git a/src/windows/msvc.rs b/src/windows/msvc.rs new file mode 100644 index 00000000..9e2a9b9e --- /dev/null +++ b/src/windows/msvc.rs @@ -0,0 +1,10 @@ +pub const L_tmpnam: ::c_uint = 260; +pub const TMP_MAX: ::c_uint = 0x7fff_ffff; + +extern { + #[link_name = "_stricmp"] + pub fn stricmp(s1: *const ::c_char, s2: *const ::c_char) -> ::c_int; + #[link_name = "_strnicmp"] + pub fn strnicmp(s1: *const ::c_char, s2: *const ::c_char, + n: ::size_t) -> ::c_int; +} \ No newline at end of file -- GitLab