diff --git a/src/ctype/src/lib.rs b/src/ctype/src/lib.rs index 73e28517129a64f3309c30a0ac9663b0cece8aa9..19ee5e1a28e114fde8ee0f75ebdc197ece206c64 100644 --- a/src/ctype/src/lib.rs +++ b/src/ctype/src/lib.rs @@ -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]