Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
R
relibc
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Peter Limkilde Svendsen
relibc
Commits
89ca696f
Commit
89ca696f
authored
5 years ago
by
Michał Zwonek
Browse files
Options
Downloads
Patches
Plain Diff
Changed while loops to for
Changed while loops to for -
https://gitlab.redox-os.org/redox-os/relibc/issues/128
parent
b9e03cba
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/header/string/mod.rs
+2
-6
2 additions, 6 deletions
src/header/string/mod.rs
src/header/wchar/mod.rs
+4
-12
4 additions, 12 deletions
src/header/wchar/mod.rs
with
6 additions
and
18 deletions
src/header/string/mod.rs
+
2
−
6
View file @
89ca696f
...
@@ -139,10 +139,8 @@ pub unsafe extern "C" fn memmove(s1: *mut c_void, s2: *const c_void, n: size_t)
...
@@ -139,10 +139,8 @@ pub unsafe extern "C" fn memmove(s1: *mut c_void, s2: *const c_void, n: size_t)
#[no_mangle]
#[no_mangle]
pub
unsafe
extern
"C"
fn
memset
(
s
:
*
mut
c_void
,
c
:
c_int
,
n
:
size_t
)
->
*
mut
c_void
{
pub
unsafe
extern
"C"
fn
memset
(
s
:
*
mut
c_void
,
c
:
c_int
,
n
:
size_t
)
->
*
mut
c_void
{
let
mut
i
=
0
;
for
i
in
0
..
n
{
while
i
<
n
{
*
(
s
as
*
mut
u8
)
.add
(
i
)
=
c
as
u8
;
*
(
s
as
*
mut
u8
)
.add
(
i
)
=
c
as
u8
;
i
+=
1
;
}
}
s
s
}
}
...
@@ -235,10 +233,8 @@ pub unsafe extern "C" fn strndup(s1: *const c_char, size: size_t) -> *mut c_char
...
@@ -235,10 +233,8 @@ pub unsafe extern "C" fn strndup(s1: *const c_char, size: size_t) -> *mut c_char
platform
::
errno
=
ENOMEM
as
c_int
;
platform
::
errno
=
ENOMEM
as
c_int
;
}
else
{
}
else
{
//memcpy(buffer, s1, len)
//memcpy(buffer, s1, len)
let
mut
i
=
0
;
for
i
in
0
..
len
{
while
i
<
len
{
*
buffer
.add
(
i
)
=
*
s1
.add
(
i
);
*
buffer
.add
(
i
)
=
*
s1
.add
(
i
);
i
+=
1
;
}
}
*
buffer
.add
(
len
)
=
0
;
*
buffer
.add
(
len
)
=
0
;
}
}
...
...
This diff is collapsed.
Click to expand it.
src/header/wchar/mod.rs
+
4
−
12
View file @
89ca696f
...
@@ -389,8 +389,7 @@ pub unsafe extern "C" fn wcsncat(
...
@@ -389,8 +389,7 @@ pub unsafe extern "C" fn wcsncat(
#[no_mangle]
#[no_mangle]
pub
unsafe
extern
"C"
fn
wcsncmp
(
ws1
:
*
const
wchar_t
,
ws2
:
*
const
wchar_t
,
n
:
size_t
)
->
c_int
{
pub
unsafe
extern
"C"
fn
wcsncmp
(
ws1
:
*
const
wchar_t
,
ws2
:
*
const
wchar_t
,
n
:
size_t
)
->
c_int
{
let
mut
i
=
0
;
for
i
in
0
..
n
{
while
i
<
n
{
let
wc1
=
*
ws1
.add
(
i
);
let
wc1
=
*
ws1
.add
(
i
);
let
wc2
=
*
ws2
.add
(
i
);
let
wc2
=
*
ws2
.add
(
i
);
if
wc1
!=
wc2
{
if
wc1
!=
wc2
{
...
@@ -398,7 +397,6 @@ pub unsafe extern "C" fn wcsncmp(ws1: *const wchar_t, ws2: *const wchar_t, n: si
...
@@ -398,7 +397,6 @@ pub unsafe extern "C" fn wcsncmp(ws1: *const wchar_t, ws2: *const wchar_t, n: si
}
else
if
wc1
==
0
{
}
else
if
wc1
==
0
{
break
;
break
;
}
}
i
+=
1
;
}
}
0
0
}
}
...
@@ -520,26 +518,22 @@ pub extern "C" fn wcwidth(wc: wchar_t) -> c_int {
...
@@ -520,26 +518,22 @@ pub extern "C" fn wcwidth(wc: wchar_t) -> c_int {
#[no_mangle]
#[no_mangle]
pub
unsafe
extern
"C"
fn
wmemchr
(
ws
:
*
const
wchar_t
,
wc
:
wchar_t
,
n
:
size_t
)
->
*
mut
wchar_t
{
pub
unsafe
extern
"C"
fn
wmemchr
(
ws
:
*
const
wchar_t
,
wc
:
wchar_t
,
n
:
size_t
)
->
*
mut
wchar_t
{
let
mut
i
=
0
;
for
i
in
0
..
n
{
while
i
<
n
{
if
*
ws
.add
(
i
)
==
wc
{
if
*
ws
.add
(
i
)
==
wc
{
return
ws
.add
(
i
)
as
*
mut
wchar_t
;
return
ws
.add
(
i
)
as
*
mut
wchar_t
;
}
}
i
+=
1
;
}
}
0
as
*
mut
wchar_t
0
as
*
mut
wchar_t
}
}
#[no_mangle]
#[no_mangle]
pub
unsafe
extern
"C"
fn
wmemcmp
(
ws1
:
*
const
wchar_t
,
ws2
:
*
const
wchar_t
,
n
:
size_t
)
->
c_int
{
pub
unsafe
extern
"C"
fn
wmemcmp
(
ws1
:
*
const
wchar_t
,
ws2
:
*
const
wchar_t
,
n
:
size_t
)
->
c_int
{
let
mut
i
=
0
;
for
i
in
0
..
n
{
while
i
<
n
{
let
wc1
=
*
ws1
.add
(
i
);
let
wc1
=
*
ws1
.add
(
i
);
let
wc2
=
*
ws2
.add
(
i
);
let
wc2
=
*
ws2
.add
(
i
);
if
wc1
!=
wc2
{
if
wc1
!=
wc2
{
return
wc1
-
wc2
;
return
wc1
-
wc2
;
}
}
i
+=
1
;
}
}
0
0
}
}
...
@@ -572,10 +566,8 @@ pub unsafe extern "C" fn wmemmove(
...
@@ -572,10 +566,8 @@ pub unsafe extern "C" fn wmemmove(
#[no_mangle]
#[no_mangle]
pub
unsafe
extern
"C"
fn
wmemset
(
ws
:
*
mut
wchar_t
,
wc
:
wchar_t
,
n
:
size_t
)
->
*
mut
wchar_t
{
pub
unsafe
extern
"C"
fn
wmemset
(
ws
:
*
mut
wchar_t
,
wc
:
wchar_t
,
n
:
size_t
)
->
*
mut
wchar_t
{
let
mut
i
=
0
;
for
i
in
0
..
n
{
while
i
<
n
{
*
ws
.add
(
i
)
=
wc
;
*
ws
.add
(
i
)
=
wc
;
i
+=
1
;
}
}
ws
ws
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment