Implement strpbrk(), add strpbrk test

This commit is contained in:
Andrii Zymohliad
2018-03-12 18:01:12 +08:00
parent a1de0ef8a1
commit 1e969afd43
5 changed files with 34 additions and 2 deletions
+9 -2
View File
@@ -250,8 +250,15 @@ pub unsafe extern "C" fn strncpy(s1: *mut c_char, s2: *const c_char, n: usize) -
}
#[no_mangle]
pub extern "C" fn strpbrk(s1: *const c_char, s2: *const c_char) -> *mut c_char {
unimplemented!();
pub unsafe extern "C" fn strpbrk(s1: *const c_char, s2: *const c_char) -> *mut c_char {
let mut i = 0;
while *s1.offset(i) != 0 {
if !strchr(s2, *s1.offset(i) as i32).is_null() {
return s1.offset(i) as *mut c_char;
}
i += 1;
}
ptr::null_mut()
}
#[no_mangle]