Skip to content

Commit 08eaa2c

Browse files
committed
Split out strcase* into unix, MSVC and Windows-GNU
1 parent d931cd2 commit 08eaa2c

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

src/unix/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,9 @@ extern {
475475
pub fn strdup(cs: *const c_char) -> *mut c_char;
476476
pub fn strpbrk(cs: *const c_char, ct: *const c_char) -> *mut c_char;
477477
pub fn strstr(cs: *const c_char, ct: *const c_char) -> *mut c_char;
478+
pub fn strcasecmp(s1: *const c_char, s2: *const c_char) -> c_int;
479+
pub fn strncasecmp(s1: *const c_char, s2: *const c_char,
480+
n: size_t) -> c_int;
478481
pub fn strlen(cs: *const c_char) -> size_t;
479482
pub fn strnlen(cs: *const c_char, maxlen: size_t) -> size_t;
480483
#[cfg_attr(

src/windows.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,22 @@ extern {
379379
#[link_name = "_wsetlocale"]
380380
pub fn wsetlocale(category: ::c_int,
381381
locale: *const wchar_t) -> *mut wchar_t;
382+
383+
cfg_if! {
384+
if #[cfg(all(target_env = "gnu"))] {
385+
pub fn strcasecmp(s1: *const c_char, s2: *const c_char) -> c_int;
386+
pub fn strncasecmp(s1: *const c_char, s2: *const c_char,
387+
n: size_t) -> c_int;
388+
} else if #[cfg(all(target_env = "msvc"))] {
389+
#[link_name = "_stricmp"]
390+
pub fn stricmp(s1: *const c_char, s2: *const c_char) -> c_int;
391+
#[link_name = "_strnicmp"]
392+
pub fn strnicmp(s1: *const c_char, s2: *const c_char,
393+
n: size_t) -> c_int;
394+
} else {
395+
// Unknown target_env
396+
}
397+
}
382398
}
383399

384400
cfg_if! {

0 commit comments

Comments
 (0)