Commit e051b184 authored by Jeremy Soller's avatar Jeremy Soller
Browse files

Merge branch 'wctype' into 'master'

wctype

See merge request !339
parents 606bfc9c fe287cd2
Pipeline #9538 failed with stages
in 1 minute and 15 seconds
......@@ -2,6 +2,7 @@
#define _BITS_WCTYPE_H
#include <stdint.h>
#define __need_wctype_t
#define __need_wint_t
#endif /* _BITS_WCTYPE_H */
......@@ -12,7 +12,8 @@ typedef __PTRDIFF_TYPE__ ptrdiff_t;
#ifndef __cplusplus
typedef int32_t wchar_t;
#endif /* #ifndef __cplusplus */
typedef int32_t wint_t;
typedef uint32_t wctype_t;
typedef uint32_t wint_t;
typedef long unsigned int size_t;
......
nightly-2021-03-15
nightly-2020-07-27
sys_includes = []
include_guard = "_RELIBC_WCTYPE_H"
language = "C"
style = "Tag"
no_includes = true
cpp_compat = true
[enum]
prefix_with_name = true
//! wctype implementation for Redox, following http://pubs.opengroup.org/onlinepubs/7908799/xsh/wctype.h.html
use crate::platform::types::*;
// #[no_mangle]
pub extern "C" fn iswalnum(wc: wint_t) -> c_int {
unimplemented!();
}
// #[no_mangle]
pub extern "C" fn iswalpha(wc: wint_t) -> c_int {
unimplemented!();
}
// #[no_mangle]
pub extern "C" fn iswcntrl(wc: wint_t) -> c_int {
unimplemented!();
}
// #[no_mangle]
pub extern "C" fn iswdigit(wc: wint_t) -> c_int {
unimplemented!();
}
// #[no_mangle]
pub extern "C" fn iswgraph(wc: wint_t) -> c_int {
unimplemented!();
}
// #[no_mangle]
pub extern "C" fn iswlower(wc: wint_t) -> c_int {
unimplemented!();
}
// #[no_mangle]
pub extern "C" fn iswprint(wc: wint_t) -> c_int {
unimplemented!();
}
// #[no_mangle]
pub extern "C" fn iswpunct(wc: wint_t) -> c_int {
unimplemented!();
}
// #[no_mangle]
pub extern "C" fn iswspace(wc: wint_t) -> c_int {
unimplemented!();
}
// #[no_mangle]
pub extern "C" fn iswupper(wc: wint_t) -> c_int {
unimplemented!();
}
// #[no_mangle]
pub extern "C" fn iswxdigit(wc: wint_t) -> c_int {
unimplemented!();
}
// #[no_mangle]
pub extern "C" fn iswctype(wc: wint_t, charclass: wctype_t) -> c_int {
unimplemented!();
}
// #[no_mangle]
pub extern "C" fn towlower(wc: wint_t) -> wint_t {
unimplemented!();
}
// #[no_mangle]
pub extern "C" fn towupper(wc: wint_t) -> wint_t {
unimplemented!();
}
// #[no_mangle]
pub extern "C" fn wctype(property: *const c_char) -> c_int {
unimplemented!();
}
......@@ -47,7 +47,6 @@ pub mod sys_statvfs;
pub mod sys_time;
pub mod sys_timeb;
//pub mod sys_times;
pub mod _wctype;
pub mod arch_aarch64_user;
pub mod arch_x64_user;
pub mod sys_procfs;
......
// From musl src/ctype/alpha.h
// Licensed under the MIT license
// Copyright 2005-2020 Rich Felker, et al.
use crate::platform::types::*;
pub fn is(wc: usize) -> c_uchar {
if wc < 0x20000 {
return (table[(table[wc>>8] as usize)*32+((wc&255)>>3)]>>(wc&7))&1;
}
if wc < 0x2fffe {
return 1;
}
return 0;
}
const table: [c_uchar; 3904] = [
18,17,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,17,34,35,36,17,37,38,39,40,
41,42,43,44,17,45,46,47,16,16,48,16,16,16,16,16,16,16,49,50,51,16,52,53,16,16,
17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,54,
17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,
17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,
17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,
17,17,17,55,17,17,17,17,56,17,57,58,59,60,61,62,17,17,17,17,17,17,17,17,17,17,
17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,
17,17,17,17,17,17,17,63,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,17,64,65,17,66,67,
68,69,70,71,72,73,74,17,75,76,77,78,79,80,81,16,82,83,84,85,86,87,88,89,90,91,
92,93,16,94,95,96,16,17,17,17,97,98,99,16,16,16,16,16,16,16,16,16,16,17,17,17,
17,100,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,17,17,101,16,16,16,16,16,
16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
16,16,17,17,102,103,16,16,104,105,17,17,17,17,17,17,17,17,17,17,17,17,17,17,
17,17,17,17,17,17,17,17,17,106,17,17,107,16,16,16,16,16,16,16,16,16,16,16,16,
16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,17,
108,109,16,16,16,16,16,16,16,16,16,110,16,16,16,16,16,16,16,16,16,16,16,16,16,
16,16,16,16,16,16,16,16,16,16,111,112,113,114,16,16,16,16,16,16,16,16,115,116,
117,16,16,16,16,16,118,119,16,16,16,16,120,16,16,121,16,16,16,16,16,16,16,16,
16,16,16,16,16,
16,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
255,255,255,255,255,255,255,255,255,255,255,0,0,0,0,0,0,0,0,254,255,255,7,254,
255,255,7,0,0,0,0,0,4,32,4,255,255,127,255,255,255,127,255,255,255,255,255,
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
255,195,255,3,0,31,80,0,0,0,0,0,0,0,0,0,0,32,0,0,0,0,0,223,188,64,215,255,255,
251,255,255,255,255,255,255,255,255,255,191,255,255,255,255,255,255,255,255,
255,255,255,255,255,255,255,255,255,3,252,255,255,255,255,255,255,255,255,255,
255,255,255,255,255,255,255,255,255,255,255,254,255,255,255,127,2,255,255,255,
255,255,1,0,0,0,0,255,191,182,0,255,255,255,135,7,0,0,0,255,7,255,255,255,255,
255,255,255,254,255,195,255,255,255,255,255,255,255,255,255,255,255,255,239,
31,254,225,255,
159,0,0,255,255,255,255,255,255,0,224,255,255,255,255,255,255,255,255,255,255,
255,255,3,0,255,255,255,255,255,7,48,4,255,255,255,252,255,31,0,0,255,255,255,
1,255,7,0,0,0,0,0,0,255,255,223,63,0,0,240,255,248,3,255,255,255,255,255,255,
255,255,255,239,255,223,225,255,207,255,254,255,239,159,249,255,255,253,197,
227,159,89,128,176,207,255,3,16,238,135,249,255,255,253,109,195,135,25,2,94,
192,255,63,0,238,191,251,255,255,253,237,227,191,27,1,0,207,255,0,30,238,159,
249,255,255,253,237,227,159,25,192,176,207,255,2,0,236,199,61,214,24,199,255,
195,199,29,129,0,192,255,0,0,239,223,253,255,255,253,255,227,223,29,96,7,207,
255,0,0,239,223,253,255,255,253,239,227,223,29,96,64,207,255,6,0,239,223,253,
255,255,255,255,231,223,93,240,128,207,255,0,252,236,255,127,252,255,255,251,
47,127,128,95,255,192,255,12,0,254,255,255,255,255,127,255,7,63,32,255,3,0,0,
0,0,214,247,255,255,175,255,255,59,95,32,255,243,0,0,0,
0,1,0,0,0,255,3,0,0,255,254,255,255,255,31,254,255,3,255,255,254,255,255,255,
31,0,0,0,0,0,0,0,0,255,255,255,255,255,255,127,249,255,3,255,255,255,255,255,
255,255,255,255,63,255,255,255,255,191,32,255,255,255,255,255,247,255,255,255,
255,255,255,255,255,255,61,127,61,255,255,255,255,255,61,255,255,255,255,61,
127,61,255,127,255,255,255,255,255,255,255,61,255,255,255,255,255,255,255,255,
7,0,0,0,0,255,255,0,0,255,255,255,255,255,255,255,255,255,255,63,63,254,255,
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
255,255,255,255,255,159,255,255,254,255,255,7,255,255,255,255,255,255,255,255,
255,199,255,1,255,223,15,0,255,255,15,0,255,255,15,0,255,223,13,0,255,255,255,
255,255,255,207,255,255,1,128,16,255,3,0,0,0,0,255,3,255,255,255,255,255,255,
255,255,255,255,255,1,255,255,255,255,255,7,255,255,255,255,255,255,255,255,
63,
0,255,255,255,127,255,15,255,1,192,255,255,255,255,63,31,0,255,255,255,255,
255,15,255,255,255,3,255,3,0,0,0,0,255,255,255,15,255,255,255,255,255,255,255,
127,254,255,31,0,255,3,255,3,128,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,255,
255,239,255,239,15,255,3,0,0,0,0,255,255,255,255,255,243,255,255,255,255,255,
255,191,255,3,0,255,255,255,255,255,255,127,0,255,227,255,255,255,255,255,63,
255,1,255,255,255,255,255,231,0,0,0,0,0,222,111,4,255,255,255,255,255,255,255,
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0,0,0,0,
128,255,31,0,255,255,63,63,255,255,255,255,63,63,255,170,255,255,255,63,255,
255,255,255,255,255,223,95,220,31,207,15,255,31,220,31,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,2,128,0,0,255,31,0,0,0,0,0,0,0,0,0,0,0,0,132,252,47,62,80,189,255,243,
224,67,0,0,255,255,255,255,255,1,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,255,255,255,255,255,255,3,0,
0,255,255,255,255,255,127,255,255,255,255,255,127,255,255,255,255,255,255,255,
255,255,255,255,255,255,255,255,255,31,120,12,0,255,255,255,255,191,32,255,
255,255,255,255,255,255,128,0,0,255,255,127,0,127,127,127,127,127,127,127,127,
255,255,255,255,0,0,0,0,0,128,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,224,0,0,0,254,3,62,31,254,255,255,255,255,255,255,255,255,255,127,224,254,
255,255,255,255,255,255,255,255,255,255,247,224,255,255,255,255,255,254,255,
255,255,255,255,255,255,255,255,255,127,0,0,255,255,255,7,0,0,0,0,0,0,255,255,
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
255,255,255,63,0,0,0,0,0,0,0,0,0,255,255,255,255,255,255,255,255,255,255,255,
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0,
0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,31,0,0,
0,0,0,0,0,0,255,255,255,255,255,63,255,31,255,255,255,15,0,0,255,255,255,255,
255,127,240,143,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0,0,0,
0,128,255,252,255,255,255,255,255,255,255,255,255,255,255,255,249,255,255,255,
255,255,255,124,0,0,0,0,0,128,255,191,255,255,255,255,0,0,0,255,255,255,255,
255,255,15,0,255,255,255,255,255,255,255,255,47,0,255,3,0,0,252,232,255,255,
255,255,255,7,255,255,255,255,7,0,255,255,255,31,255,255,255,255,255,255,247,
255,0,128,255,3,255,255,255,127,255,255,255,255,255,255,127,0,255,63,255,3,
255,255,127,252,255,255,255,255,255,255,255,127,5,0,0,56,255,255,60,0,126,126,
126,0,127,127,255,255,255,255,255,247,255,0,255,255,255,255,255,255,255,255,
255,255,255,255,255,255,255,7,255,3,255,255,255,255,255,255,255,255,255,255,
255,255,255,255,255,255,255,255,255,255,15,0,255,255,127,248,255,255,255,255,
255,
15,255,255,255,255,255,255,255,255,255,255,255,255,255,63,255,255,255,255,255,
255,255,255,255,255,255,255,255,3,0,0,0,0,127,0,248,224,255,253,127,95,219,
255,255,255,255,255,255,255,255,255,255,255,255,255,3,0,0,0,248,255,255,255,
255,255,255,255,255,255,255,255,255,63,0,0,255,255,255,255,255,255,255,255,
252,255,255,255,255,255,255,0,0,0,0,0,255,15,0,0,0,0,0,0,0,0,0,0,0,0,0,0,223,
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,31,0,0,255,3,
254,255,255,7,254,255,255,7,192,255,255,255,255,255,255,255,255,255,255,127,
252,252,252,28,0,0,0,0,255,239,255,255,127,255,255,183,255,63,255,63,0,0,0,0,
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,7,0,0,0,0,0,0,0,0,
255,255,255,255,255,255,31,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,255,255,255,31,255,255,255,255,255,255,1,0,0,0,0,
0,255,255,255,255,0,224,255,255,255,7,255,255,255,255,255,7,255,255,255,63,
255,255,255,255,15,255,62,0,0,0,0,0,255,255,255,255,255,255,255,255,255,255,
255,255,255,255,255,255,255,255,255,63,255,3,255,255,255,255,15,255,255,255,
255,15,255,255,255,255,255,0,255,255,255,255,255,255,15,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,255,255,255,255,255,255,127,0,255,255,63,0,255,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,63,253,255,255,255,255,191,145,255,255,63,0,255,255,
127,0,255,255,255,127,0,0,0,0,0,0,0,0,255,255,55,0,255,255,63,0,255,255,255,3,
0,0,0,0,0,0,0,0,255,255,255,255,255,255,255,192,0,0,0,0,0,0,0,0,111,240,239,
254,255,255,63,0,0,0,0,0,255,255,255,31,255,255,255,31,0,0,0,0,255,254,255,
255,31,0,0,0,255,255,255,255,255,255,63,0,255,255,63,0,255,255,7,0,255,255,3,
0,0,0,0,0,0,0,0,0,0,0,0,
0,255,255,255,255,255,255,255,255,255,1,0,0,0,0,0,0,255,255,255,255,255,255,7,
0,255,255,255,255,255,255,7,0,255,255,255,255,255,0,255,3,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,31,128,0,255,255,63,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,255,255,127,0,255,255,255,255,255,255,255,255,63,0,0,0,
192,255,0,0,252,255,255,255,255,255,255,1,0,0,255,255,255,1,255,3,255,255,255,
255,255,255,199,255,112,0,255,255,255,255,71,0,255,255,255,255,255,255,255,
255,30,0,255,23,0,0,0,0,255,255,251,255,255,255,159,64,0,0,0,0,0,0,0,0,127,
189,255,191,255,1,255,255,255,255,255,255,255,1,255,3,239,159,249,255,255,253,
237,227,159,25,129,224,15,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,
255,255,255,255,255,187,7,255,131,0,0,0,0,255,255,255,255,255,255,255,255,179,
0,255,3,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,255,255,63,127,0,0,0,63,0,0,
0,0,255,255,255,255,255,255,255,127,17,0,255,3,0,0,0,0,255,255,255,255,255,
255,63,1,255,3,0,0,0,0,0,0,255,255,255,231,255,7,255,3,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,255,255,255,1,0,0,0,0,0,0,0,0,0,0,0,
0,255,255,255,255,255,255,255,255,255,3,0,128,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,255,252,255,255,255,255,255,252,26,0,0,0,255,255,255,255,255,255,231,
127,0,0,255,255,255,255,255,255,255,255,255,32,0,0,0,0,255,255,255,255,255,
255,255,1,255,253,255,255,255,255,127,127,1,0,255,3,0,0,252,255,255,255,252,
255,255,254,127,0,0,0,0,0,0,0,0,0,127,251,255,255,255,255,127,180,203,0,255,3,
191,253,255,255,255,127,123,1,255,3,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,127,0,255,
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,3,0,0,
0,0,0,0,0,0,0,0,0,0,255,255,255,255,255,255,255,255,255,255,255,255,255,127,0,
0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
255,255,255,255,255,15,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,
255,255,255,127,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,
255,255,255,255,255,255,127,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,
255,255,255,255,255,255,1,255,255,255,127,255,3,0,0,0,0,0,0,0,0,0,0,0,0,255,
255,255,63,0,0,255,255,255,255,255,255,0,0,15,0,255,3,248,255,255,224,255,255,
0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,255,255,255,255,255,255,255,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,255,255,255,255,255,255,255,255,255,135,255,255,255,255,255,255,255,128,
255,255,0,0,0,0,0,0,0,0,11,0,0,0,255,255,255,255,255,255,255,255,255,255,255,
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
255,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
255,255,255,255,255,255,255,255,255,255,255,255,7,0,255,255,255,127,0,0,0,0,0,
0,7,0,240,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
255,255,255,255,255,255,255,255,255,255,255,255,255,255,15,255,255,255,255,
255,255,255,255,255,255,255,255,255,7,255,31,255,1,255,67,0,0,0,0,0,0,0,0,0,0,
0,0,255,255,255,255,255,255,255,255,255,255,223,255,255,255,255,255,255,255,
255,223,100,222,255,235,239,255,255,255,255,255,255,
255,191,231,223,223,255,255,255,123,95,252,253,255,255,255,255,255,255,255,
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,63,255,255,255,
253,255,255,247,255,255,255,247,255,255,223,255,255,255,223,255,255,127,255,
255,255,127,255,255,255,253,255,255,255,253,255,255,247,207,255,255,255,255,
255,255,127,255,255,249,219,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,255,255,255,255,255,31,128,63,255,67,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,255,
15,255,3,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
255,255,255,255,255,255,255,31,0,0,0,0,0,0,0,255,255,255,255,255,255,255,255,
143,8,255,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,239,255,255,255,150,254,247,10,132,234,150,170,150,247,247,94,255,251,255,
15,238,251,255,15,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,3,255,255,255,3,255,
255,255,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
];
// From musl src/ctype/casemap.h
// Licensed under the MIT license
// Copyright 2005-2020 Rich Felker, et al.
use crate::platform::types::*;
const tab: [c_uchar; 2666] = [
7, 8, 9, 10, 11, 12, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 13, 6, 6, 14, 6, 6, 6, 6, 6, 6, 6, 6, 15,
16, 17, 18, 6, 19, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 20, 21, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
......@@ -100,6 +105,7 @@ const tab: [c_uchar; 2666] = [
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
];
const rules: [c_int; 240] = [
0x0, 0x2001, -0x2000, 0x1dbf00, 0x2e700, 0x7900, 0x2402, 0x101, -0x100, 0x0, 0x201, -0x200,
-0xc6ff, -0xe800, -0x78ff, -0x12c00, 0xc300, 0xd201, 0xce01, 0xcd01, 0x4f01, 0xca01, 0xcb01,
......@@ -125,6 +131,7 @@ const rules: [c_int; 240] = [
-0x2000, 0x0, 0x2801, -0x2800, 0x0, 0x4001, -0x4000, 0x0, 0x2001, -0x2000, 0x0, 0x2001,
-0x2000, 0x0, 0x2201, -0x2200,
];
const rulebases: [c_uchar; 512] = [
0, 6, 39, 81, 111, 119, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 124, 0, 0, 127, 0, 0, 0, 0, 0, 0, 0, 0,
131, 142, 146, 151, 0, 170, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 180, 196, 0, 0, 0, 0, 0, 0, 0, 0, 0,
......@@ -144,6 +151,7 @@ const rulebases: [c_uchar; 512] = [
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 237, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
];
const exceptions: [[c_uchar; 2]; 200] = [
[48, 12],
[49, 13],
......
sys_includes = ["stddef.h", "stdint.h", "time.h", "stdio.h" ]
sys_includes = ["wchar.h" ]
include_guard = "_RELIBC_WCTYPE_H"
header = "#include <bits/wctype.h>"
language = "C"
......
//! wchar implementation for Redox, following http://pubs.opengroup.org/onlinepubs/7908799/xsh/wchar.h.html
//! wchar implementation for Redox, following http://pubs.opengroup.org/onlinepubs/7908799/xsh/wctype.h.html
use crate::platform::types::*;
use crate::{
c_str::CStr,
header::ctype,
platform::types::*,
};
use self::casecmp::casemap;
mod alpha;
mod casecmp;
use casecmp::casemap;
mod punct;
pub const WEOF: wint_t = 0xFFFF_FFFFu32;
pub const WCTYPE_ALNUM: wctype_t = 1;
pub const WCTYPE_ALPHA: wctype_t = 2;
pub const WCTYPE_BLANK: wctype_t = 3;
pub const WCTYPE_CNTRL: wctype_t = 4;
pub const WCTYPE_DIGIT: wctype_t = 5;
pub const WCTYPE_GRAPH: wctype_t = 6;
pub const WCTYPE_LOWER: wctype_t = 7;
pub const WCTYPE_PRINT: wctype_t = 8;
pub const WCTYPE_PUNCT: wctype_t = 9;
pub const WCTYPE_SPACE: wctype_t = 10;
pub const WCTYPE_UPPER: wctype_t = 11;
pub const WCTYPE_XDIGIT: wctype_t = 12;
#[no_mangle]
pub extern "C" fn iswctype(wc: wint_t, desc: wctype_t) -> c_int {
match desc {
WCTYPE_ALNUM => iswalnum(wc),
WCTYPE_ALPHA => iswalpha(wc),
WCTYPE_BLANK => iswblank(wc),
WCTYPE_CNTRL => iswcntrl(wc),
WCTYPE_DIGIT => iswdigit(wc),
WCTYPE_GRAPH => iswgraph(wc),
WCTYPE_LOWER => iswlower(wc),
WCTYPE_PRINT => iswprint(wc),
WCTYPE_PUNCT => iswpunct(wc),
WCTYPE_SPACE => iswspace(wc),
WCTYPE_UPPER => iswupper(wc),
WCTYPE_XDIGIT => iswxdigit(wc),
_ => 0,
}
}
#[no_mangle]
pub unsafe extern "C" fn wctype(name: *const c_char) -> wctype_t {
let name_cstr = CStr::from_ptr(name);
match name_cstr.to_bytes() {
b"alnum" => WCTYPE_ALNUM,
b"alpha" => WCTYPE_ALPHA,
b"blank" => WCTYPE_BLANK,
b"cntrl" => WCTYPE_CNTRL,
b"digit" => WCTYPE_DIGIT,
b"graph" => WCTYPE_GRAPH,
b"lower" => WCTYPE_LOWER,
b"print" => WCTYPE_PRINT,
b"punct" => WCTYPE_PUNCT,
b"space" => WCTYPE_SPACE,
b"upper" => WCTYPE_UPPER,
b"xdigit" => WCTYPE_XDIGIT,
_ => 0
}
}
#[no_mangle]
pub extern "C" fn iswalnum(wc: wint_t) -> c_int {
c_int::from(iswdigit(wc) != 0 || iswalpha(wc) != 0)
}
#[no_mangle]
pub extern "C" fn iswalpha(wc: wint_t) -> c_int {
c_int::from(alpha::is(wc as usize))
}
#[no_mangle]
pub extern "C" fn iswblank(wc: wint_t) -> c_int {
ctype::isblank(wc as c_int)
}
#[no_mangle]
pub extern "C" fn iswcntrl(wc: wint_t) -> c_int {
c_int::from(
wc < 32 ||
wc.wrapping_sub(0x7f) < 33 ||
wc.wrapping_sub(0x2028) < 2 ||
wc.wrapping_sub(0xfff9) < 3
)
}
#[no_mangle]
pub extern "C" fn iswdigit(wc: wint_t) -> c_int {
c_int::from(wc.wrapping_sub('0' as wint_t) < 10)
}
#[no_mangle]
pub extern "C" fn iswgraph(wc: wint_t) -> c_int {
c_int::from(iswspace(wc) == 0 && iswprint(wc) != 0)
}
#[no_mangle]
pub extern "C" fn iswlower(wc: wint_t) -> c_int {
c_int::from(towupper(wc) != wc)
}
#[no_mangle]
pub extern "C" fn iswprint(wc: wint_t) -> c_int {
if wc < 0xff {
c_int::from((wc+1 & 0x7f) >= 0x21)
} else if wc < 0x2028
|| wc.wrapping_sub(0x202a) < 0xd800-0x202a
|| wc.wrapping_sub(0xe000) < 0xfff9-0xe000 {
1
} else if wc.wrapping_sub(0xfffc) > 0x10ffff-0xfffc
|| (wc&0xfffe)==0xfffe {
0
} else {
1
}
}
#[no_mangle]
pub extern "C" fn iswpunct(wc: wint_t) -> c_int {
c_int::from(punct::is(wc as usize))
}
#[no_mangle]
pub extern "C" fn iswspace(wc: wint_t) -> c_int {
c_int::from([
' ' as wint_t, '\t' as wint_t, '\n' as wint_t, '\r' as wint_t,
11, 12, 0x0085,
0x2000, 0x2001, 0x2002, 0x2003, 0x2004, 0x2005,
0x2006, 0x2008, 0x2009, 0x200a,
0x2028, 0x2029, 0x205f, 0x3000
].contains(&wc))
}
#[no_mangle]