|
@@ -24,27 +24,27 @@ pub extern "C" fn isblank(c: c_int) -> c_int {
|
|
|
|
|
|
#[no_mangle]
|
|
|
pub extern "C" fn iscntrl(c: c_int) -> c_int {
|
|
|
- ((c as c_uint) < 0x20 || c == 0x7f) as c_int
|
|
|
+ (c < 0x20 || c == 0x7f) as c_int
|
|
|
}
|
|
|
|
|
|
#[no_mangle]
|
|
|
pub extern "C" fn isdigit(c: c_int) -> c_int {
|
|
|
- (((c - 0x30) as c_uint) < 10) as c_int
|
|
|
+ (c >= b'0' as c_int && c <= b'9' as c_int) as c_int
|
|
|
}
|
|
|
|
|
|
#[no_mangle]
|
|
|
pub extern "C" fn isgraph(c: c_int) -> c_int {
|
|
|
- (((c - 0x21) as c_uint) < 0x5e) as c_int
|
|
|
+ (c >= 0x21 && c < 0x7e) as c_int
|
|
|
}
|
|
|
|
|
|
#[no_mangle]
|
|
|
pub extern "C" fn islower(c: c_int) -> c_int {
|
|
|
- (((c - 0x61) as c_uint) < 26) as c_int
|
|
|
+ (c >= b'a' as c_int && c <= b'z' as c_int) as c_int
|
|
|
}
|
|
|
|
|
|
#[no_mangle]
|
|
|
pub extern "C" fn isprint(c: c_int) -> c_int {
|
|
|
- (((c - 0x20) as c_uint) < 0x5f) as c_int
|
|
|
+ (c >= 0x20 && c < 0x7f) as c_int
|
|
|
}
|
|
|
|
|
|
#[no_mangle]
|
|
@@ -59,12 +59,12 @@ pub extern "C" fn isspace(c: c_int) -> c_int {
|
|
|
|
|
|
#[no_mangle]
|
|
|
pub extern "C" fn isupper(c: c_int) -> c_int {
|
|
|
- (((c - 0x41) as c_uint) < 26) as c_int
|
|
|
+ (c >= b'A' as c_int && c <= b'Z' as c_int) as c_int
|
|
|
}
|
|
|
|
|
|
#[no_mangle]
|
|
|
pub extern "C" fn isxdigit(c: c_int) -> c_int {
|
|
|
- (isdigit(c) != 0 || ((c as c_int) | 32) - ('a' as c_int) < 6) as c_int
|
|
|
+ (isdigit(c) != 0 || (c | 32 >= b'a' as c_int && c | 32 <= 'f' as c_int)) as c_int
|
|
|
}
|
|
|
|
|
|
#[no_mangle]
|
|
@@ -77,7 +77,7 @@ pub extern "C" fn toascii(c: c_int) -> c_int {
|
|
|
#[no_mangle]
|
|
|
pub extern "C" fn tolower(c: c_int) -> c_int {
|
|
|
if isupper(c) != 0 {
|
|
|
- c + 0x20
|
|
|
+ c | 0x20
|
|
|
} else {
|
|
|
c
|
|
|
}
|
|
@@ -86,7 +86,7 @@ pub extern "C" fn tolower(c: c_int) -> c_int {
|
|
|
#[no_mangle]
|
|
|
pub extern "C" fn toupper(c: c_int) -> c_int {
|
|
|
if islower(c) != 0 {
|
|
|
- c - 0x20
|
|
|
+ c & !0x20
|
|
|
} else {
|
|
|
c
|
|
|
}
|