Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
redox-os
relibc
Commits
3c8cb95b
Verified
Commit
3c8cb95b
authored
Oct 07, 2018
by
jD91mZM2
Browse files
Cleanup strcasecmp
parent
0de7d306
Pipeline
#1447
failed with stages
in 8 minutes and 32 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/header/strings/mod.rs
View file @
3c8cb95b
...
...
@@ -67,22 +67,7 @@ pub unsafe extern "C" fn rindex(mut s: *const c_char, c: c_int) -> *mut c_char {
#[no_mangle]
pub
unsafe
extern
"C"
fn
strcasecmp
(
mut
first
:
*
const
c_char
,
mut
second
:
*
const
c_char
)
->
c_int
{
while
*
first
!=
0
&&
*
second
!=
0
{
let
mut
i
=
*
first
;
let
mut
j
=
*
second
;
if
i
&
!
32
!=
j
&
!
32
{
return
-
1
;
}
first
=
first
.offset
(
1
);
second
=
second
.offset
(
1
);
}
// Both strings didn't end with NUL bytes
if
*
first
!=
*
second
{
return
-
1
;
}
0
strncasecmp
(
first
,
second
,
size_t
::
max_value
())
}
#[no_mangle]
...
...
@@ -91,21 +76,14 @@ pub unsafe extern "C" fn strncasecmp(
mut
second
:
*
const
c_char
,
mut
n
:
size_t
,
)
->
c_int
{
while
*
first
!=
0
&&
*
second
!=
0
&&
n
>
0
{
let
mut
i
=
*
first
;
let
mut
j
=
*
second
;
if
i
&
!
32
!=
j
&
!
32
{
return
-
1
;
while
*
first
&
!
32
==
*
second
&
!
32
{
if
n
==
0
||
*
first
==
0
&&
*
second
==
0
{
return
0
;
}
first
=
first
.offset
(
1
);
second
=
second
.offset
(
1
);
n
-=
1
;
}
// Both strings didn't end with NUL bytes (unless we reached the limit)
if
n
>
0
&&
*
first
!=
*
second
{
return
-
1
;
}
0
-
1
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment