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
redox-os
relibc
Commits
ec6243bc
Commit
ec6243bc
authored
2 years ago
by
David CARLIER
Browse files
Options
Downloads
Patches
Plain Diff
wctrans/towctrans implementation proposal.
close #32
parent
2c3561e8
No related branches found
Branches containing commit
No related tags found
1 merge request
!356
wctrans/towctrans implementation proposal.
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/header/wctype/mod.rs
+23
-0
23 additions, 0 deletions
src/header/wctype/mod.rs
tests/wctype/towlower.c
+2
-2
2 additions, 2 deletions
tests/wctype/towlower.c
tests/wctype/towupper.c
+2
-2
2 additions, 2 deletions
tests/wctype/towupper.c
with
27 additions
and
4 deletions
src/header/wctype/mod.rs
+
23
−
0
View file @
ec6243bc
...
...
@@ -8,6 +8,7 @@ mod casecmp;
mod
punct
;
pub
type
wctype_t
=
u32
;
pub
type
wctrans_t
=
*
const
i32
;
pub
const
WEOF
:
wint_t
=
0xFFFF_FFFFu32
;
...
...
@@ -24,6 +25,9 @@ pub const WCTYPE_SPACE: wctype_t = 10;
pub
const
WCTYPE_UPPER
:
wctype_t
=
11
;
pub
const
WCTYPE_XDIGIT
:
wctype_t
=
12
;
const
WCTRANSUP
:
wctrans_t
=
1
as
wctrans_t
;
const
WCTRANSLW
:
wctrans_t
=
2
as
wctrans_t
;
#[no_mangle]
pub
extern
"C"
fn
iswctype
(
wc
:
wint_t
,
desc
:
wctype_t
)
->
c_int
{
match
desc
{
...
...
@@ -173,3 +177,22 @@ pub extern "C" fn towlower(wc: wint_t) -> wint_t {
pub
extern
"C"
fn
towupper
(
wc
:
wint_t
)
->
wint_t
{
casemap
(
wc
,
1
)
}
#[no_mangle]
pub
extern
"C"
fn
wctrans
(
class
:
*
const
c_char
)
->
wctrans_t
{
let
class_cstr
=
unsafe
{
CStr
::
from_ptr
(
class
)
};
match
class_cstr
.to_bytes
()
{
b"toupper"
=>
WCTRANSUP
,
b"tolower"
=>
WCTRANSLW
,
_
=>
0
as
wctrans_t
,
}
}
#[no_mangle]
pub
extern
"C"
fn
towctrans
(
wc
:
wint_t
,
trans
:
wctrans_t
)
->
wint_t
{
match
trans
{
WCTRANSUP
=>
towupper
(
wc
),
WCTRANSLW
=>
towlower
(
wc
),
_
=>
wc
,
}
}
This diff is collapsed.
Click to expand it.
tests/wctype/towlower.c
+
2
−
2
View file @
ec6243bc
...
...
@@ -6,7 +6,7 @@ int main() {
wchar_t
*
str
=
L"HaLf WiDe ChAr StRiNg!
\n
"
;
fputws
(
str
,
stdout
);
for
(
int
i
=
0
;
i
<
wcslen
(
str
);
i
++
)
{
putwchar
(
tow
lower
(
str
[
i
]));
putwchar
(
tow
ctrans
(
str
[
i
]
,
wctrans
(
"tolower"
)
));
}
return
0
;
}
\ No newline at end of file
}
This diff is collapsed.
Click to expand it.
tests/wctype/towupper.c
+
2
−
2
View file @
ec6243bc
...
...
@@ -6,7 +6,7 @@ int main() {
wchar_t
*
str
=
L"HaLf WiDe ChAr StRiNg!
\n
"
;
fputws
(
str
,
stdout
);
for
(
int
i
=
0
;
i
<
wcslen
(
str
);
i
++
)
{
putwchar
(
tow
upper
(
str
[
i
]));
putwchar
(
tow
ctrans
(
str
[
i
]
,
wctrans
(
"toupper"
)
));
}
return
0
;
}
\ No newline at end of file
}
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