Finish ctype impls; Solve #31

This commit is contained in:
MggMuggins
2018-03-08 16:16:51 -06:00
parent 8812c2148f
commit 40558b2608
+13 -6
View File
@@ -23,7 +23,7 @@ pub extern "C" fn isascii(c: c_int) -> c_int {
#[no_mangle]
pub extern "C" fn iscntrl(c: c_int) -> c_int {
unimplemented!();
((c as c_uint) < 0x20 || c == 0x7f) as c_int
}
#[no_mangle]
@@ -33,7 +33,7 @@ pub extern "C" fn isdigit(c: c_int) -> c_int {
#[no_mangle]
pub extern "C" fn isgraph(c: c_int) -> c_int {
unimplemented!();
(((c - 0x21) as c_uint) < 0x5e) as c_int
}
#[no_mangle]
@@ -43,12 +43,12 @@ pub extern "C" fn islower(c: c_int) -> c_int {
#[no_mangle]
pub extern "C" fn isprint(c: c_int) -> c_int {
unimplemented!();
(((c - 0x20) as c_uint) < 0x5f) as c_int
}
#[no_mangle]
pub extern "C" fn ispunct(c: c_int) -> c_int {
unimplemented!();
(isgraph(c) == 0 && !isalnum(c) == 0) as c_int
}
#[no_mangle]
@@ -63,12 +63,19 @@ pub extern "C" fn isupper(c: c_int) -> c_int {
#[no_mangle]
pub extern "C" fn isxdigit(c: c_int) -> c_int {
unimplemented!();
(isdigit(c) == 0 || ((c as c_int) | 32) - ('a' as c_int) < 6) as c_int
}
#[no_mangle]
pub extern "C" fn isblank(c: c_int) -> c_int {
(c == ' ' as c_int || c == '\t' as c_int) as c_int
}
#[no_mangle]
/// The comment in musl:
/// `/* nonsense function that should NEVER be used! */`
pub extern "C" fn toascii(c: c_int) -> c_int {
unimplemented!();
c & 0x7f
}
#[no_mangle]