Skip to content
Snippets Groups Projects
Unverified Commit b09435f1 authored by Jeremy Soller's avatar Jeremy Soller Committed by GitHub
Browse files

Merge pull request #78 from Tommoa/master

Yet another fix for strcspn and strspn.
parents 010e1710 d3c2e99e
No related branches found
No related tags found
No related merge requests found
...@@ -125,7 +125,7 @@ pub unsafe extern "C" fn strcspn(s1: *const c_char, s2: *const c_char) -> c_ulon ...@@ -125,7 +125,7 @@ pub unsafe extern "C" fn strcspn(s1: *const c_char, s2: *const c_char) -> c_ulon
// The below logic is effectively ripped from the musl implementation // The below logic is effectively ripped from the musl implementation
let mut byteset = [0u8; 32 / mem::size_of::<usize>()]; let mut byteset = [0usize; 32 / mem::size_of::<usize>()];
let mut i = 0; let mut i = 0;
while *s2.offset(i) != 0 { while *s2.offset(i) != 0 {
...@@ -135,9 +135,9 @@ pub unsafe extern "C" fn strcspn(s1: *const c_char, s2: *const c_char) -> c_ulon ...@@ -135,9 +135,9 @@ pub unsafe extern "C" fn strcspn(s1: *const c_char, s2: *const c_char) -> c_ulon
} }
i = 0; // reset i = 0; // reset
while *s2.offset(i) != 0 { while *s1.offset(i) != 0 {
if byteset[(*s2.offset(i) as usize) / (8 * byteset.len())] if byteset[(*s1.offset(i) as usize) / (8 * byteset.len())]
& 1 << (*s2.offset(i) as usize % (8 * byteset.len())) > 0 & 1 << (*s1.offset(i) as usize % (8 * byteset.len())) > 0
{ {
break; break;
} }
...@@ -277,7 +277,7 @@ pub unsafe extern "C" fn strspn(s1: *const c_char, s2: *const c_char) -> c_ulong ...@@ -277,7 +277,7 @@ pub unsafe extern "C" fn strspn(s1: *const c_char, s2: *const c_char) -> c_ulong
// The below logic is effectively ripped from the musl implementation // The below logic is effectively ripped from the musl implementation
let mut byteset = [0u8; 32 / mem::size_of::<usize>()]; let mut byteset = [0usize; 32 / mem::size_of::<usize>()];
let mut i = 0; let mut i = 0;
while *s2.offset(i) != 0 { while *s2.offset(i) != 0 {
...@@ -287,9 +287,9 @@ pub unsafe extern "C" fn strspn(s1: *const c_char, s2: *const c_char) -> c_ulong ...@@ -287,9 +287,9 @@ pub unsafe extern "C" fn strspn(s1: *const c_char, s2: *const c_char) -> c_ulong
} }
i = 0; // reset i = 0; // reset
while *s2.offset(i) != 0 { while *s1.offset(i) != 0 {
if byteset[(*s2.offset(i) as usize) / (8 * byteset.len())] if byteset[(*s1.offset(i) as usize) / (8 * byteset.len())]
& 1 << (*s2.offset(i) as usize % (8 * byteset.len())) < 1 & 1 << (*s1.offset(i) as usize % (8 * byteset.len())) < 1
{ {
break; break;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment