summaryrefslogtreecommitdiff
path: root/src/ctype
diff options
context:
space:
mode:
authorVladimir Azarov <avm@intermediate-node.net>2024-10-01 15:47:05 +0200
committerVladimir Azarov <avm@intermediate-node.net>2024-10-01 15:47:05 +0200
commit4abab5ad6c8465a7528ccdd5f49367da05f78bbd (patch)
treeebf009bf1376a5a223a915bc27cbbd791a1316bc /src/ctype
Initial version
Diffstat (limited to 'src/ctype')
-rw-r--r--src/ctype/__ctype_b_loc.c41
-rw-r--r--src/ctype/__ctype_get_mb_cur_max.c7
-rw-r--r--src/ctype/__ctype_tolower_loc.c30
-rw-r--r--src/ctype/__ctype_toupper_loc.c30
-rw-r--r--src/ctype/alpha.h172
-rw-r--r--src/ctype/casemap.h297
-rw-r--r--src/ctype/isalnum.c13
-rw-r--r--src/ctype/isalpha.c14
-rw-r--r--src/ctype/isascii.c7
-rw-r--r--src/ctype/isblank.c13
-rw-r--r--src/ctype/iscntrl.c13
-rw-r--r--src/ctype/isdigit.c14
-rw-r--r--src/ctype/isgraph.c14
-rw-r--r--src/ctype/islower.c14
-rw-r--r--src/ctype/isprint.c14
-rw-r--r--src/ctype/ispunct.c13
-rw-r--r--src/ctype/isspace.c14
-rw-r--r--src/ctype/isupper.c14
-rw-r--r--src/ctype/iswalnum.c13
-rw-r--r--src/ctype/iswalpha.c21
-rw-r--r--src/ctype/iswblank.c14
-rw-r--r--src/ctype/iswcntrl.c16
-rw-r--r--src/ctype/iswctype.c75
-rw-r--r--src/ctype/iswdigit.c15
-rw-r--r--src/ctype/iswgraph.c14
-rw-r--r--src/ctype/iswlower.c13
-rw-r--r--src/ctype/iswprint.c26
-rw-r--r--src/ctype/iswpunct.c19
-rw-r--r--src/ctype/iswspace.c24
-rw-r--r--src/ctype/iswupper.c13
-rw-r--r--src/ctype/iswxdigit.c13
-rw-r--r--src/ctype/isxdigit.c13
-rw-r--r--src/ctype/nonspacing.h91
-rw-r--r--src/ctype/punct.h141
-rw-r--r--src/ctype/toascii.c7
-rw-r--r--src/ctype/tolower.c14
-rw-r--r--src/ctype/toupper.c14
-rw-r--r--src/ctype/towctrans.c84
-rw-r--r--src/ctype/wcswidth.c8
-rw-r--r--src/ctype/wctrans.c29
-rw-r--r--src/ctype/wcwidth.c29
-rw-r--r--src/ctype/wide.h65
42 files changed, 1505 insertions, 0 deletions
diff --git a/src/ctype/__ctype_b_loc.c b/src/ctype/__ctype_b_loc.c
new file mode 100644
index 0000000..f43795e
--- /dev/null
+++ b/src/ctype/__ctype_b_loc.c
@@ -0,0 +1,41 @@
+#include <endian.h>
+
+#if __BYTE_ORDER == __BIG_ENDIAN
+#define X(x) x
+#else
+#define X(x) (((x)/256 | (x)*256) % 65536)
+#endif
+
+static const unsigned short table[] = {
+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,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,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,
+X(0x200),X(0x200),X(0x200),X(0x200),X(0x200),X(0x200),X(0x200),X(0x200),
+X(0x200),X(0x320),X(0x220),X(0x220),X(0x220),X(0x220),X(0x200),X(0x200),
+X(0x200),X(0x200),X(0x200),X(0x200),X(0x200),X(0x200),X(0x200),X(0x200),
+X(0x200),X(0x200),X(0x200),X(0x200),X(0x200),X(0x200),X(0x200),X(0x200),
+X(0x160),X(0x4c0),X(0x4c0),X(0x4c0),X(0x4c0),X(0x4c0),X(0x4c0),X(0x4c0),
+X(0x4c0),X(0x4c0),X(0x4c0),X(0x4c0),X(0x4c0),X(0x4c0),X(0x4c0),X(0x4c0),
+X(0x8d8),X(0x8d8),X(0x8d8),X(0x8d8),X(0x8d8),X(0x8d8),X(0x8d8),X(0x8d8),
+X(0x8d8),X(0x8d8),X(0x4c0),X(0x4c0),X(0x4c0),X(0x4c0),X(0x4c0),X(0x4c0),
+X(0x4c0),X(0x8d5),X(0x8d5),X(0x8d5),X(0x8d5),X(0x8d5),X(0x8d5),X(0x8c5),
+X(0x8c5),X(0x8c5),X(0x8c5),X(0x8c5),X(0x8c5),X(0x8c5),X(0x8c5),X(0x8c5),
+X(0x8c5),X(0x8c5),X(0x8c5),X(0x8c5),X(0x8c5),X(0x8c5),X(0x8c5),X(0x8c5),
+X(0x8c5),X(0x8c5),X(0x8c5),X(0x4c0),X(0x4c0),X(0x4c0),X(0x4c0),X(0x4c0),
+X(0x4c0),X(0x8d6),X(0x8d6),X(0x8d6),X(0x8d6),X(0x8d6),X(0x8d6),X(0x8c6),
+X(0x8c6),X(0x8c6),X(0x8c6),X(0x8c6),X(0x8c6),X(0x8c6),X(0x8c6),X(0x8c6),
+X(0x8c6),X(0x8c6),X(0x8c6),X(0x8c6),X(0x8c6),X(0x8c6),X(0x8c6),X(0x8c6),
+X(0x8c6),X(0x8c6),X(0x8c6),X(0x4c0),X(0x4c0),X(0x4c0),X(0x4c0),X(0x200),
+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,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,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,
+};
+
+static const unsigned short *const ptable = table+128;
+
+const unsigned short **__ctype_b_loc(void)
+{
+ return (void *)&ptable;
+}
diff --git a/src/ctype/__ctype_get_mb_cur_max.c b/src/ctype/__ctype_get_mb_cur_max.c
new file mode 100644
index 0000000..8e946fc
--- /dev/null
+++ b/src/ctype/__ctype_get_mb_cur_max.c
@@ -0,0 +1,7 @@
+#include <stdlib.h>
+#include "locale_impl.h"
+
+size_t __ctype_get_mb_cur_max()
+{
+ return MB_CUR_MAX;
+}
diff --git a/src/ctype/__ctype_tolower_loc.c b/src/ctype/__ctype_tolower_loc.c
new file mode 100644
index 0000000..efb9910
--- /dev/null
+++ b/src/ctype/__ctype_tolower_loc.c
@@ -0,0 +1,30 @@
+#include <stdint.h>
+
+static const int32_t table[] = {
+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,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,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,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,
+16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,
+32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,
+48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,
+64,
+'a','b','c','d','e','f','g','h','i','j','k','l','m',
+'n','o','p','q','r','s','t','u','v','w','x','y','z',
+91,92,93,94,95,96,
+'a','b','c','d','e','f','g','h','i','j','k','l','m',
+'n','o','p','q','r','s','t','u','v','w','x','y','z',
+123,124,125,126,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,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,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,0,0,0,0,0,0,0,0,0,0,
+};
+
+static const int32_t *const ptable = table+128;
+
+const int32_t **__ctype_tolower_loc(void)
+{
+ return (void *)&ptable;
+}
diff --git a/src/ctype/__ctype_toupper_loc.c b/src/ctype/__ctype_toupper_loc.c
new file mode 100644
index 0000000..ffaef0e
--- /dev/null
+++ b/src/ctype/__ctype_toupper_loc.c
@@ -0,0 +1,30 @@
+#include <stdint.h>
+
+static const int32_t table[] = {
+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,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,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,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,
+16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,
+32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,
+48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,
+64,
+'A','B','C','D','E','F','G','H','I','J','K','L','M',
+'N','O','P','Q','R','S','T','U','V','W','X','Y','Z',
+91,92,93,94,95,96,
+'A','B','C','D','E','F','G','H','I','J','K','L','M',
+'N','O','P','Q','R','S','T','U','V','W','X','Y','Z',
+123,124,125,126,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,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,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,0,0,0,0,0,0,0,0,0,0,
+};
+
+static const int32_t *const ptable = table+128;
+
+const int32_t **__ctype_toupper_loc(void)
+{
+ return (void *)&ptable;
+}
diff --git a/src/ctype/alpha.h b/src/ctype/alpha.h
new file mode 100644
index 0000000..4167f38
--- /dev/null
+++ b/src/ctype/alpha.h
@@ -0,0 +1,172 @@
+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,
diff --git a/src/ctype/casemap.h b/src/ctype/casemap.h
new file mode 100644
index 0000000..6ee1209
--- /dev/null
+++ b/src/ctype/casemap.h
@@ -0,0 +1,297 @@
+static const unsigned char tab[] = {
+ 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, 6, 6, 6, 6, 6,
+ 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
+ 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
+ 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
+ 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
+ 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
+ 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
+ 6, 6, 6, 6, 6, 6, 22, 23, 6, 6, 6, 24, 6, 6, 6, 6,
+ 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
+ 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
+ 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
+ 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
+ 6, 6, 6,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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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 36,
+ 43, 43, 43, 43, 43, 43, 43, 43, 1, 0, 84, 86, 86, 86, 86, 86,
+ 86, 86, 86, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 24, 0, 0, 0, 43, 43, 43, 43, 43, 43,
+ 43, 7, 43, 43, 91, 86, 86, 86, 86, 86, 86, 86, 74, 86, 86, 5,
+ 49, 80, 49, 80, 49, 80, 49, 80, 49, 80, 49, 80, 49, 80, 49, 80,
+ 36, 80, 121, 49, 80, 49, 80, 49, 56, 80, 49, 80, 49, 80, 49, 80,
+ 49, 80, 49, 80, 49, 80, 49, 80, 78, 49, 2, 78, 13, 13, 78, 3,
+ 78, 0, 36, 110, 0, 78, 49, 38, 110, 81, 78, 36, 80, 78, 57, 20,
+ 129, 27, 29, 29, 83, 49, 80, 49, 80, 13, 49, 80, 49, 80, 49, 80,
+ 27, 83, 36, 80, 49, 2, 92, 123, 92, 123, 92, 123, 92, 123, 92, 123,
+ 20, 121, 92, 123, 92, 123, 92, 45, 43, 73, 3, 72, 3, 120, 92, 123,
+ 20, 0, 150, 10, 1, 43, 40, 6, 6, 0, 42, 6, 42, 42, 43, 7,
+ 187, 181, 43, 30, 0, 43, 7, 43, 43, 43, 1, 43, 43, 43, 43, 43,
+ 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43,
+ 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 1, 43, 43, 43, 43,
+ 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43,
+ 43, 43, 43, 42, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43,
+ 43, 205, 70, 205, 43, 0, 37, 43, 7, 1, 6, 1, 85, 86, 86, 86,
+ 86, 86, 85, 86, 86, 2, 36, 129, 129, 129, 129, 129, 21, 129, 129, 129,
+ 0, 0, 43, 0, 178, 209, 178, 209, 178, 209, 178, 209, 0, 0, 205, 204,
+ 1, 0, 215, 215, 215, 215, 215, 131, 129, 129, 129, 129, 129, 129, 129, 129,
+ 129, 129, 172, 172, 172, 172, 172, 172, 172, 172, 172, 172, 28, 0, 0, 0,
+ 0, 0, 49, 80, 49, 80, 49, 80, 49, 80, 49, 80, 49, 2, 0, 0,
+ 49, 80, 49, 80, 49, 80, 49, 80, 49, 80, 49, 80, 49, 80, 49, 80,
+ 49, 80, 78, 49, 80, 49, 80, 78, 49, 80, 49, 80, 49, 80, 49, 80,
+ 49, 80, 49, 80, 49, 80, 49, 2, 135, 166, 135, 166, 135, 166, 135, 166,
+ 135, 166, 135, 166, 135, 166, 135, 166, 42, 43, 43, 43, 43, 43, 43, 43,
+ 43, 43, 43, 43, 43, 0, 0, 0, 84, 86, 86, 86, 86, 86, 86, 86,
+ 86, 86, 86, 86, 86, 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, 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, 0, 0, 84, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86,
+ 12, 0, 12, 42, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43,
+ 43, 7, 42, 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, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 42, 43, 43, 43, 43, 43, 43,
+ 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43,
+ 43, 43, 43, 43, 86, 86, 108, 129, 21, 0, 43, 43, 43, 43, 43, 43,
+ 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43,
+ 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43,
+ 43, 43, 43, 43, 7, 108, 3, 65, 43, 43, 86, 86, 86, 86, 86, 86,
+ 86, 86, 86, 86, 86, 86, 86, 86, 44, 86, 43, 43, 43, 43, 43, 43,
+ 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 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, 0, 0, 0, 0, 12, 108, 0, 0, 0, 0, 0, 6,
+ 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, 6, 37, 6, 37, 6, 37, 6, 37, 6, 37,
+ 6, 37, 6, 37, 6, 37, 6, 37, 6, 37, 6, 37, 6, 37, 6, 37,
+ 6, 37, 6, 37, 6, 37, 6, 37, 6, 37, 6, 37, 6, 37, 6, 37,
+ 6, 37, 6, 37, 6, 37, 6, 37, 86, 122, 158, 38, 6, 37, 6, 37,
+ 6, 37, 6, 37, 6, 37, 6, 37, 6, 37, 6, 37, 6, 37, 6, 37,
+ 6, 37, 6, 37, 6, 37, 6, 37, 6, 37, 6, 1, 43, 43, 79, 86,
+ 86, 44, 43, 127, 86, 86, 57, 43, 43, 85, 86, 86, 43, 43, 79, 86,
+ 86, 44, 43, 127, 86, 86, 129, 55, 117, 91, 123, 92, 43, 43, 79, 86,
+ 86, 2, 172, 4, 0, 0, 57, 43, 43, 85, 86, 86, 43, 43, 79, 86,
+ 86, 44, 43, 43, 86, 86, 50, 19, 129, 87, 0, 111, 129, 126, 201, 215,
+ 126, 45, 129, 129, 14, 126, 57, 127, 111, 87, 0, 129, 129, 126, 21, 0,
+ 126, 3, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 7, 43,
+ 36, 43, 151, 43, 43, 43, 43, 43, 43, 43, 43, 43, 42, 43, 43, 43,
+ 43, 43, 86, 86, 86, 86, 86, 128, 129, 129, 129, 129, 57, 187, 42, 43,
+ 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43,
+ 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43,
+ 43, 43, 43, 43, 43, 43, 43, 1, 129, 129, 129, 129, 129, 129, 129, 129,
+ 129, 129, 129, 129, 129, 129, 129, 201, 172, 172, 172, 172, 172, 172, 172, 172,
+ 172, 172, 172, 172, 172, 172, 172, 208, 13, 0, 78, 49, 2, 180, 193, 193,
+ 215, 215, 36, 80, 49, 80, 49, 80, 49, 80, 49, 80, 49, 80, 49, 80,
+ 49, 80, 49, 80, 49, 80, 49, 80, 49, 80, 49, 80, 49, 80, 49, 80,
+ 49, 80, 49, 80, 215, 215, 83, 193, 71, 212, 215, 215, 215, 5, 43, 43,
+ 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 7, 1, 0, 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, 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,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 78, 49, 80, 49, 80, 49, 80,
+ 49, 80, 49, 80, 49, 80, 49, 80, 13, 0, 0, 0, 0, 0, 36, 80,
+ 49, 80, 49, 80, 49, 80, 49, 80, 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, 43, 43, 43, 43, 43, 43,
+ 43, 43, 43, 43, 43, 121, 92, 123, 92, 123, 79, 123, 92, 123, 92, 123,
+ 92, 123, 92, 123, 92, 123, 92, 123, 92, 123, 92, 123, 92, 123, 92, 45,
+ 43, 43, 121, 20, 92, 123, 92, 45, 121, 42, 92, 39, 92, 123, 92, 123,
+ 92, 123, 164, 0, 10, 180, 92, 123, 92, 123, 79, 3, 42, 43, 43, 43,
+ 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 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, 72, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 42, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43,
+ 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43,
+ 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, 43, 43, 43, 43, 43, 43, 43, 43, 7, 0,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0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 42, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 86, 86,
+ 86, 86, 86, 86, 86, 86, 86, 86, 14, 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, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 85,
+ 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 14, 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, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const int rules[] = {
+ 0x0, 0x2001, -0x2000, 0x1dbf00, 0x2e700, 0x7900,
+ 0x2402, 0x101, -0x100, 0x0, 0x201, -0x200,
+ -0xc6ff, -0xe800, -0x78ff, -0x12c00, 0xc300, 0xd201,
+ 0xce01, 0xcd01, 0x4f01, 0xca01, 0xcb01, 0xcf01,
+ 0x6100, 0xd301, 0xd101, 0xa300, 0xd501, 0x8200,
+ 0xd601, 0xda01, 0xd901, 0xdb01, 0x3800, 0x3,
+ -0x4f00, -0x60ff, -0x37ff, 0x242802, 0x0, 0x101,
+ -0x100, -0xcd00, -0xda00, -0x81ff, 0x2a2b01, -0xa2ff,
+ 0x2a2801, 0x2a3f00, -0xc2ff, 0x4501, 0x4701, 0x2a1f00,
+ 0x2a1c00, 0x2a1e00, -0xd200, -0xce00, -0xca00, -0xcb00,
+ 0xa54f00, 0xa54b00, -0xcf00, 0xa52800, 0xa54400, -0xd100,
+ -0xd300, 0x29f700, 0xa54100, 0x29fd00, -0xd500, -0xd600,
+ 0x29e700, 0xa54300, 0xa52a00, -0x4500, -0xd900, -0x4700,
+ -0xdb00, 0xa51500, 0xa51200, 0x4c2402, 0x0, 0x2001,
+ -0x2000, 0x101, -0x100, 0x5400, 0x7401, 0x2601,
+ 0x2501, 0x4001, 0x3f01, -0x2600, -0x2500, -0x1f00,
+ -0x4000, -0x3f00, 0x801, -0x3e00, -0x3900, -0x2f00,
+ -0x3600, -0x800, -0x5600, -0x5000, 0x700, -0x7400,
+ -0x3bff, -0x6000, -0x6ff, 0x701a02, 0x101, -0x100,
+ 0x2001, -0x2000, 0x5001, 0xf01, -0xf00, 0x0,
+ 0x3001, -0x3000, 0x101, -0x100, 0x0, 0xbc000,
+ 0x1c6001, 0x0, 0x97d001, 0x801, -0x800, 0x8a0502,
+ 0x0, -0xbbfff, -0x186200, 0x89c200, -0x182500, -0x186e00,
+ -0x186d00, -0x186400, -0x186300, -0x185c00, 0x0, 0x8a3800,
+ 0x8a0400, 0xee600, 0x101, -0x100, 0x0, -0x3b00,
+ -0x1dbeff, 0x8f1d02, 0x800, -0x7ff, 0x0, 0x5600,
+ -0x55ff, 0x4a00, 0x6400, 0x8000, 0x7000, 0x7e00,
+ 0x900, -0x49ff, -0x8ff, -0x1c2500, -0x63ff, -0x6fff,
+ -0x7fff, -0x7dff, 0xac0502, 0x0, 0x1001, -0x1000,
+ 0x1c01, 0x101, -0x1d5cff, -0x20beff, -0x2045ff, -0x1c00,
+ 0xb10b02, 0x101, -0x100, 0x3001, -0x3000, 0x0,
+ -0x29f6ff, -0xee5ff, -0x29e6ff, -0x2a2b00, -0x2a2800, -0x2a1bff,
+ -0x29fcff, -0x2a1eff, -0x2a1dff, -0x2a3eff, 0x0, -0x1c6000,
+ 0x0, 0x101, -0x100, 0xbc0c02, 0x0, 0x101,
+ -0x100, -0xa543ff, 0x3a001, -0x8a03ff, -0xa527ff, 0x3000,
+ -0x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, { 156, 25 }, { 157, 28 },
+ { 158, 29 }, { 159, 30 }, { 166, 31 }, { 169, 31 },
+ { 174, 31 }, { 177, 32 }, { 178, 32 }, { 183, 33 },
+ { 191, 34 }, { 197, 35 }, { 200, 35 }, { 203, 35 },
+ { 221, 36 }, { 242, 35 }, { 246, 37 }, { 247, 38 },
+ { 32, 45 }, { 58, 46 }, { 61, 47 }, { 62, 48 },
+ { 63, 49 }, { 64, 49 }, { 67, 50 }, { 68, 51 },
+ { 69, 52 }, { 80, 53 }, { 81, 54 }, { 82, 55 },
+ { 83, 56 }, { 84, 57 }, { 89, 58 }, { 91, 59 },
+ { 92, 60 }, { 97, 61 }, { 99, 62 }, { 101, 63 },
+ { 102, 64 }, { 104, 65 }, { 105, 66 }, { 106, 64 },
+ { 107, 67 }, { 108, 68 }, { 111, 66 }, { 113, 69 },
+ { 114, 70 }, { 117, 71 }, { 125, 72 }, { 130, 73 },
+ { 135, 74 }, { 137, 75 }, { 138, 76 }, { 139, 76 },
+ { 140, 77 }, { 146, 78 }, { 157, 79 }, { 158, 80 },
+ { 69, 87 }, { 123, 29 }, { 124, 29 }, { 125, 29 },
+ { 127, 88 }, { 134, 89 }, { 136, 90 }, { 137, 90 },
+ { 138, 90 }, { 140, 91 }, { 142, 92 }, { 143, 92 },
+ { 172, 93 }, { 173, 94 }, { 174, 94 }, { 175, 94 },
+ { 194, 95 }, { 204, 96 }, { 205, 97 }, { 206, 97 },
+ { 207, 98 }, { 208, 99 }, { 209, 100 }, { 213, 101 },
+ { 214, 102 }, { 215, 103 }, { 240, 104 }, { 241, 105 },
+ { 242, 106 }, { 243, 107 }, { 244, 108 }, { 245, 109 },
+ { 249, 110 }, { 253, 45 }, { 254, 45 }, { 255, 45 },
+ { 80, 105 }, { 81, 105 }, { 82, 105 }, { 83, 105 },
+ { 84, 105 }, { 85, 105 }, { 86, 105 }, { 87, 105 },
+ { 88, 105 }, { 89, 105 }, { 90, 105 }, { 91, 105 },
+ { 92, 105 }, { 93, 105 }, { 94, 105 }, { 95, 105 },
+ { 130, 0 }, { 131, 0 }, { 132, 0 }, { 133, 0 },
+ { 134, 0 }, { 135, 0 }, { 136, 0 }, { 137, 0 },
+ { 192, 117 }, { 207, 118 }, { 128, 137 }, { 129, 138 },
+ { 130, 139 }, { 133, 140 }, { 134, 141 }, { 112, 157 },
+ { 113, 157 }, { 118, 158 }, { 119, 158 }, { 120, 159 },
+ { 121, 159 }, { 122, 160 }, { 123, 160 }, { 124, 161 },
+ { 125, 161 }, { 179, 162 }, { 186, 163 }, { 187, 163 },
+ { 188, 164 }, { 190, 165 }, { 195, 162 }, { 204, 164 },
+ { 218, 166 }, { 219, 166 }, { 229, 106 }, { 234, 167 },
+ { 235, 167 }, { 236, 110 }, { 243, 162 }, { 248, 168 },
+ { 249, 168 }, { 250, 169 }, { 251, 169 }, { 252, 164 },
+ { 38, 176 }, { 42, 177 }, { 43, 178 }, { 78, 179 },
+ { 132, 8 }, { 98, 186 }, { 99, 187 }, { 100, 188 },
+ { 101, 189 }, { 102, 190 }, { 109, 191 }, { 110, 192 },
+ { 111, 193 }, { 112, 194 }, { 126, 195 }, { 127, 195 },
+ { 125, 207 }, { 141, 208 }, { 148, 209 }, { 171, 210 },
+ { 172, 211 }, { 173, 212 }, { 176, 213 }, { 177, 214 },
+ { 178, 215 }, { 196, 216 }, { 197, 217 }, { 198, 218 },
+};
diff --git a/src/ctype/isalnum.c b/src/ctype/isalnum.c
new file mode 100644
index 0000000..8018a2b
--- /dev/null
+++ b/src/ctype/isalnum.c
@@ -0,0 +1,13 @@
+#include <ctype.h>
+
+int isalnum(int c)
+{
+ return isalpha(c) || isdigit(c);
+}
+
+int __isalnum_l(int c, locale_t l)
+{
+ return isalnum(c);
+}
+
+weak_alias(__isalnum_l, isalnum_l);
diff --git a/src/ctype/isalpha.c b/src/ctype/isalpha.c
new file mode 100644
index 0000000..a87a937
--- /dev/null
+++ b/src/ctype/isalpha.c
@@ -0,0 +1,14 @@
+#include <ctype.h>
+#undef isalpha
+
+int isalpha(int c)
+{
+ return ((unsigned)c|32)-'a' < 26;
+}
+
+int __isalpha_l(int c, locale_t l)
+{
+ return isalpha(c);
+}
+
+weak_alias(__isalpha_l, isalpha_l);
diff --git a/src/ctype/isascii.c b/src/ctype/isascii.c
new file mode 100644
index 0000000..54ad3bf
--- /dev/null
+++ b/src/ctype/isascii.c
@@ -0,0 +1,7 @@
+#include <ctype.h>
+#undef isascii
+
+int isascii(int c)
+{
+ return !(c&~0x7f);
+}
diff --git a/src/ctype/isblank.c b/src/ctype/isblank.c
new file mode 100644
index 0000000..716da23
--- /dev/null
+++ b/src/ctype/isblank.c
@@ -0,0 +1,13 @@
+#include <ctype.h>
+
+int isblank(int c)
+{
+ return (c == ' ' || c == '\t');
+}
+
+int __isblank_l(int c, locale_t l)
+{
+ return isblank(c);
+}
+
+weak_alias(__isblank_l, isblank_l);
diff --git a/src/ctype/iscntrl.c b/src/ctype/iscntrl.c
new file mode 100644
index 0000000..f27837e
--- /dev/null
+++ b/src/ctype/iscntrl.c
@@ -0,0 +1,13 @@
+#include <ctype.h>
+
+int iscntrl(int c)
+{
+ return (unsigned)c < 0x20 || c == 0x7f;
+}
+
+int __iscntrl_l(int c, locale_t l)
+{
+ return iscntrl(c);
+}
+
+weak_alias(__iscntrl_l, iscntrl_l);
diff --git a/src/ctype/isdigit.c b/src/ctype/isdigit.c
new file mode 100644
index 0000000..16beddb
--- /dev/null
+++ b/src/ctype/isdigit.c
@@ -0,0 +1,14 @@
+#include <ctype.h>
+#undef isdigit
+
+int isdigit(int c)
+{
+ return (unsigned)c-'0' < 10;
+}
+
+int __isdigit_l(int c, locale_t l)
+{
+ return isdigit(c);
+}
+
+weak_alias(__isdigit_l, isdigit_l);
diff --git a/src/ctype/isgraph.c b/src/ctype/isgraph.c
new file mode 100644
index 0000000..292d198
--- /dev/null
+++ b/src/ctype/isgraph.c
@@ -0,0 +1,14 @@
+#include <ctype.h>
+#undef isgraph
+
+int isgraph(int c)
+{
+ return (unsigned)c-0x21 < 0x5e;
+}
+
+int __isgraph_l(int c, locale_t l)
+{
+ return isgraph(c);
+}
+
+weak_alias(__isgraph_l, isgraph_l);
diff --git a/src/ctype/islower.c b/src/ctype/islower.c
new file mode 100644
index 0000000..c3fa74c
--- /dev/null
+++ b/src/ctype/islower.c
@@ -0,0 +1,14 @@
+#include <ctype.h>
+#undef islower
+
+int islower(int c)
+{
+ return (unsigned)c-'a' < 26;
+}
+
+int __islower_l(int c, locale_t l)
+{
+ return islower(c);
+}
+
+weak_alias(__islower_l, islower_l);
diff --git a/src/ctype/isprint.c b/src/ctype/isprint.c
new file mode 100644
index 0000000..b950816
--- /dev/null
+++ b/src/ctype/isprint.c
@@ -0,0 +1,14 @@
+#include <ctype.h>
+#undef isprint
+
+int isprint(int c)
+{
+ return (unsigned)c-0x20 < 0x5f;
+}
+
+int __isprint_l(int c, locale_t l)
+{
+ return isprint(c);
+}
+
+weak_alias(__isprint_l, isprint_l);
diff --git a/src/ctype/ispunct.c b/src/ctype/ispunct.c
new file mode 100644
index 0000000..a491d5d
--- /dev/null
+++ b/src/ctype/ispunct.c
@@ -0,0 +1,13 @@
+#include <ctype.h>
+
+int ispunct(int c)
+{
+ return isgraph(c) && !isalnum(c);
+}
+
+int __ispunct_l(int c, locale_t l)
+{
+ return ispunct(c);
+}
+
+weak_alias(__ispunct_l, ispunct_l);
diff --git a/src/ctype/isspace.c b/src/ctype/isspace.c
new file mode 100644
index 0000000..428813e
--- /dev/null
+++ b/src/ctype/isspace.c
@@ -0,0 +1,14 @@
+#include <ctype.h>
+#undef isspace
+
+int isspace(int c)
+{
+ return c == ' ' || (unsigned)c-'\t' < 5;
+}
+
+int __isspace_l(int c, locale_t l)
+{
+ return isspace(c);
+}
+
+weak_alias(__isspace_l, isspace_l);
diff --git a/src/ctype/isupper.c b/src/ctype/isupper.c
new file mode 100644
index 0000000..bfd15ac
--- /dev/null
+++ b/src/ctype/isupper.c
@@ -0,0 +1,14 @@
+#include <ctype.h>
+#undef isupper
+
+int isupper(int c)
+{
+ return (unsigned)c-'A' < 26;
+}
+
+int __isupper_l(int c, locale_t l)
+{
+ return isupper(c);
+}
+
+weak_alias(__isupper_l, isupper_l);
diff --git a/src/ctype/iswalnum.c b/src/ctype/iswalnum.c
new file mode 100644
index 0000000..046c399
--- /dev/null
+++ b/src/ctype/iswalnum.c
@@ -0,0 +1,13 @@
+#include <wctype.h>
+
+int iswalnum(wint_t wc)
+{
+ return iswdigit(wc) || iswalpha(wc);
+}
+
+int __iswalnum_l(wint_t c, locale_t l)
+{
+ return iswalnum(c);
+}
+
+weak_alias(__iswalnum_l, iswalnum_l);
diff --git a/src/ctype/iswalpha.c b/src/ctype/iswalpha.c
new file mode 100644
index 0000000..1c5485d
--- /dev/null
+++ b/src/ctype/iswalpha.c
@@ -0,0 +1,21 @@
+#include <wctype.h>
+
+static const unsigned char table[] = {
+#include "alpha.h"
+};
+
+int iswalpha(wint_t wc)
+{
+ if (wc<0x20000U)
+ return (table[table[wc>>8]*32+((wc&255)>>3)]>>(wc&7))&1;
+ if (wc<0x2fffeU)
+ return 1;
+ return 0;
+}
+
+int __iswalpha_l(wint_t c, locale_t l)
+{
+ return iswalpha(c);
+}
+
+weak_alias(__iswalpha_l, iswalpha_l);
diff --git a/src/ctype/iswblank.c b/src/ctype/iswblank.c
new file mode 100644
index 0000000..68c8800
--- /dev/null
+++ b/src/ctype/iswblank.c
@@ -0,0 +1,14 @@
+#include <wctype.h>
+#include <ctype.h>
+
+int iswblank(wint_t wc)
+{
+ return isblank(wc);
+}
+
+int __iswblank_l(wint_t c, locale_t l)
+{
+ return iswblank(c);
+}
+
+weak_alias(__iswblank_l, iswblank_l);
diff --git a/src/ctype/iswcntrl.c b/src/ctype/iswcntrl.c
new file mode 100644
index 0000000..feccfcd
--- /dev/null
+++ b/src/ctype/iswcntrl.c
@@ -0,0 +1,16 @@
+#include <wctype.h>
+
+int iswcntrl(wint_t wc)
+{
+ return (unsigned)wc < 32
+ || (unsigned)(wc-0x7f) < 33
+ || (unsigned)(wc-0x2028) < 2
+ || (unsigned)(wc-0xfff9) < 3;
+}
+
+int __iswcntrl_l(wint_t c, locale_t l)
+{
+ return iswcntrl(c);
+}
+
+weak_alias(__iswcntrl_l, iswcntrl_l);
diff --git a/src/ctype/iswctype.c b/src/ctype/iswctype.c
new file mode 100644
index 0000000..71b09b8
--- /dev/null
+++ b/src/ctype/iswctype.c
@@ -0,0 +1,75 @@
+#include <wctype.h>
+#include <string.h>
+
+#define WCTYPE_ALNUM 1
+#define WCTYPE_ALPHA 2
+#define WCTYPE_BLANK 3
+#define WCTYPE_CNTRL 4
+#define WCTYPE_DIGIT 5
+#define WCTYPE_GRAPH 6
+#define WCTYPE_LOWER 7
+#define WCTYPE_PRINT 8
+#define WCTYPE_PUNCT 9
+#define WCTYPE_SPACE 10
+#define WCTYPE_UPPER 11
+#define WCTYPE_XDIGIT 12
+
+int iswctype(wint_t wc, wctype_t type)
+{
+ switch (type) {
+ case WCTYPE_ALNUM:
+ return iswalnum(wc);
+ case WCTYPE_ALPHA:
+ return iswalpha(wc);
+ case WCTYPE_BLANK:
+ return iswblank(wc);
+ case WCTYPE_CNTRL:
+ return iswcntrl(wc);
+ case WCTYPE_DIGIT:
+ return iswdigit(wc);
+ case WCTYPE_GRAPH:
+ return iswgraph(wc);
+ case WCTYPE_LOWER:
+ return iswlower(wc);
+ case WCTYPE_PRINT:
+ return iswprint(wc);
+ case WCTYPE_PUNCT:
+ return iswpunct(wc);
+ case WCTYPE_SPACE:
+ return iswspace(wc);
+ case WCTYPE_UPPER:
+ return iswupper(wc);
+ case WCTYPE_XDIGIT:
+ return iswxdigit(wc);
+ }
+ return 0;
+}
+
+wctype_t wctype(const char *s)
+{
+ int i;
+ const char *p;
+ /* order must match! */
+ static const char names[] =
+ "alnum\0" "alpha\0" "blank\0"
+ "cntrl\0" "digit\0" "graph\0"
+ "lower\0" "print\0" "punct\0"
+ "space\0" "upper\0" "xdigit";
+ for (i=1, p=names; *p; i++, p+=6)
+ if (*s == *p && !strcmp(s, p))
+ return i;
+ return 0;
+}
+
+int __iswctype_l(wint_t c, wctype_t t, locale_t l)
+{
+ return iswctype(c, t);
+}
+
+wctype_t __wctype_l(const char *s, locale_t l)
+{
+ return wctype(s);
+}
+
+weak_alias(__iswctype_l, iswctype_l);
+weak_alias(__wctype_l, wctype_l);
diff --git a/src/ctype/iswdigit.c b/src/ctype/iswdigit.c
new file mode 100644
index 0000000..db817ed
--- /dev/null
+++ b/src/ctype/iswdigit.c
@@ -0,0 +1,15 @@
+#include <wctype.h>
+
+#undef iswdigit
+
+int iswdigit(wint_t wc)
+{
+ return (unsigned)wc-'0' < 10;
+}
+
+int __iswdigit_l(wint_t c, locale_t l)
+{
+ return iswdigit(c);
+}
+
+weak_alias(__iswdigit_l, iswdigit_l);
diff --git a/src/ctype/iswgraph.c b/src/ctype/iswgraph.c
new file mode 100644
index 0000000..ecdf466
--- /dev/null
+++ b/src/ctype/iswgraph.c
@@ -0,0 +1,14 @@
+#include <wctype.h>
+
+int iswgraph(wint_t wc)
+{
+ /* ISO C defines this function as: */
+ return !iswspace(wc) && iswprint(wc);
+}
+
+int __iswgraph_l(wint_t c, locale_t l)
+{
+ return iswgraph(c);
+}
+
+weak_alias(__iswgraph_l, iswgraph_l);
diff --git a/src/ctype/iswlower.c b/src/ctype/iswlower.c
new file mode 100644
index 0000000..f02a436
--- /dev/null
+++ b/src/ctype/iswlower.c
@@ -0,0 +1,13 @@
+#include <wctype.h>
+
+int iswlower(wint_t wc)
+{
+ return towupper(wc) != wc;
+}
+
+int __iswlower_l(wint_t c, locale_t l)
+{
+ return iswlower(c);
+}
+
+weak_alias(__iswlower_l, iswlower_l);
diff --git a/src/ctype/iswprint.c b/src/ctype/iswprint.c
new file mode 100644
index 0000000..86f9d64
--- /dev/null
+++ b/src/ctype/iswprint.c
@@ -0,0 +1,26 @@
+#include <wctype.h>
+
+/* Consider all legal codepoints as printable except for:
+ * - C0 and C1 control characters
+ * - U+2028 and U+2029 (line/para break)
+ * - U+FFF9 through U+FFFB (interlinear annotation controls)
+ * The following code is optimized heavily to make hot paths for the
+ * expected printable characters. */
+
+int iswprint(wint_t wc)
+{
+ if (wc < 0xffU)
+ return (wc+1 & 0x7f) >= 0x21;
+ if (wc < 0x2028U || wc-0x202aU < 0xd800-0x202a || wc-0xe000U < 0xfff9-0xe000)
+ return 1;
+ if (wc-0xfffcU > 0x10ffff-0xfffc || (wc&0xfffe)==0xfffe)
+ return 0;
+ return 1;
+}
+
+int __iswprint_l(wint_t c, locale_t l)
+{
+ return iswprint(c);
+}
+
+weak_alias(__iswprint_l, iswprint_l);
diff --git a/src/ctype/iswpunct.c b/src/ctype/iswpunct.c
new file mode 100644
index 0000000..f0b9ea0
--- /dev/null
+++ b/src/ctype/iswpunct.c
@@ -0,0 +1,19 @@
+#include <wctype.h>
+
+static const unsigned char table[] = {
+#include "punct.h"
+};
+
+int iswpunct(wint_t wc)
+{
+ if (wc<0x20000U)
+ return (table[table[wc>>8]*32+((wc&255)>>3)]>>(wc&7))&1;
+ return 0;
+}
+
+int __iswpunct_l(wint_t c, locale_t l)
+{
+ return iswpunct(c);
+}
+
+weak_alias(__iswpunct_l, iswpunct_l);
diff --git a/src/ctype/iswspace.c b/src/ctype/iswspace.c
new file mode 100644
index 0000000..263afa1
--- /dev/null
+++ b/src/ctype/iswspace.c
@@ -0,0 +1,24 @@
+#include <wchar.h>
+#include <wctype.h>
+
+/* Our definition of whitespace is the Unicode White_Space property,
+ * minus non-breaking spaces (U+00A0, U+2007, and U+202F) and script-
+ * specific characters with non-blank glyphs (U+1680 and U+180E). */
+
+int iswspace(wint_t wc)
+{
+ static const wchar_t spaces[] = {
+ ' ', '\t', '\n', '\r', 11, 12, 0x0085,
+ 0x2000, 0x2001, 0x2002, 0x2003, 0x2004, 0x2005,
+ 0x2006, 0x2008, 0x2009, 0x200a,
+ 0x2028, 0x2029, 0x205f, 0x3000, 0
+ };
+ return wc && wcschr(spaces, wc);
+}
+
+int __iswspace_l(wint_t c, locale_t l)
+{
+ return iswspace(c);
+}
+
+weak_alias(__iswspace_l, iswspace_l);
diff --git a/src/ctype/iswupper.c b/src/ctype/iswupper.c
new file mode 100644
index 0000000..7e48666
--- /dev/null
+++ b/src/ctype/iswupper.c
@@ -0,0 +1,13 @@
+#include <wctype.h>
+
+int iswupper(wint_t wc)
+{
+ return towlower(wc) != wc;
+}
+
+int __iswupper_l(wint_t c, locale_t l)
+{
+ return iswupper(c);
+}
+
+weak_alias(__iswupper_l, iswupper_l);
diff --git a/src/ctype/iswxdigit.c b/src/ctype/iswxdigit.c
new file mode 100644
index 0000000..62bc9e7
--- /dev/null
+++ b/src/ctype/iswxdigit.c
@@ -0,0 +1,13 @@
+#include <wctype.h>
+
+int iswxdigit(wint_t wc)
+{
+ return (unsigned)(wc-'0') < 10 || (unsigned)((wc|32)-'a') < 6;
+}
+
+int __iswxdigit_l(wint_t c, locale_t l)
+{
+ return iswxdigit(c);
+}
+
+weak_alias(__iswxdigit_l, iswxdigit_l);
diff --git a/src/ctype/isxdigit.c b/src/ctype/isxdigit.c
new file mode 100644
index 0000000..aab1a74
--- /dev/null
+++ b/src/ctype/isxdigit.c
@@ -0,0 +1,13 @@
+#include <ctype.h>
+
+int isxdigit(int c)
+{
+ return isdigit(c) || ((unsigned)c|32)-'a' < 6;
+}
+
+int __isxdigit_l(int c, locale_t l)
+{
+ return isxdigit(c);
+}
+
+weak_alias(__isxdigit_l, isxdigit_l);
diff --git a/src/ctype/nonspacing.h b/src/ctype/nonspacing.h
new file mode 100644
index 0000000..7746f3b
--- /dev/null
+++ b/src/ctype/nonspacing.h
@@ -0,0 +1,91 @@
+16,16,16,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,16,33,16,16,16,34,35,36,
+37,38,39,40,16,16,41,16,16,16,16,16,16,16,16,16,16,16,42,43,16,16,44,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,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,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,16,16,16,16,16,16,45,16,46,47,48,49,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,16,16,16,16,16,16,50,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,51,16,16,52,
+53,16,54,55,56,16,16,16,16,16,16,57,16,16,58,16,59,60,61,62,63,64,65,66,67,68,
+69,70,16,71,72,73,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
+16,74,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,16,16,16,16,16,16,16,16,16,16,16,16,16,
+16,16,16,75,76,16,16,16,77,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,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,16,16,78,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
+16,16,79,80,16,16,16,16,16,16,16,81,16,16,16,16,16,82,83,84,16,16,16,16,16,85,
+86,16,16,16,16,16,16,16,16,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,255,255,255,255,255,255,255,255,
+255,255,255,255,255,255,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,248,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,254,255,255,255,255,191,182,0,0,0,0,0,0,0,63,0,255,23,0,0,0,0,0,248,255,
+255,0,0,1,0,0,0,0,0,0,0,0,0,0,0,192,191,159,61,0,0,0,128,2,0,0,0,255,255,255,
+7,0,0,0,0,0,0,0,0,0,0,192,255,1,0,0,0,0,0,0,248,15,32,0,0,192,251,239,62,0,0,
+0,0,0,14,0,0,0,0,0,0,0,0,0,0,0,0,0,0,248,255,255,255,255,
+255,7,0,0,0,0,0,0,20,254,33,254,0,12,0,0,0,2,0,0,0,0,0,0,16,30,32,0,0,12,0,0,
+64,6,0,0,0,0,0,0,16,134,57,2,0,0,0,35,0,6,0,0,0,0,0,0,16,190,33,0,0,12,0,0,
+252,2,0,0,0,0,0,0,144,30,32,64,0,12,0,0,0,4,0,0,0,0,0,0,0,1,32,0,0,0,0,0,0,17,
+0,0,0,0,0,0,192,193,61,96,0,12,0,0,0,2,0,0,0,0,0,0,144,64,48,0,0,12,0,0,0,3,0,
+0,0,0,0,0,24,30,32,0,0,12,0,0,0,0,0,0,0,0,0,0,0,0,4,92,0,0,0,0,0,0,0,0,0,0,0,
+242,7,128,127,0,0,0,0,0,0,0,0,0,0,0,0,242,31,0,63,0,0,0,0,0,0,0,0,0,3,0,0,160,
+2,0,0,0,0,0,0,254,127,223,224,255,254,255,255,255,31,64,0,0,0,0,0,0,0,0,0,0,0,
+0,224,253,102,0,0,0,195,1,0,30,0,100,32,0,32,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,0,0,0,0,0,0,0,0,0,0,0,224,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,28,0,0,0,28,0,0,0,12,0,0,0,12,0,0,0,0,0,0,0,176,63,64,254,
+15,32,0,0,0,0,0,120,0,0,0,0,0,0,0,0,0,0,0,0,0,0,96,0,0,0,0,2,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,135,1,4,14,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,
+128,9,0,0,0,0,0,0,64,127,229,31,248,159,0,0,0,0,0,0,255,127,0,0,0,0,0,0,0,0,
+15,0,0,0,0,0,208,23,4,0,0,0,0,248,15,0,3,0,0,0,60,59,0,0,0,0,0,0,64,163,3,0,0,
+0,0,0,0,240,207,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,247,255,253,33,16,
+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,
+251,0,248,0,0,0,124,0,0,0,0,0,0,223,255,0,0,0,0,0,0,0,0,0,0,0,0,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,128,3,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,128,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,0,0,0,0,
+0,60,0,0,0,0,0,0,0,0,0,0,0,0,0,6,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,128,247,63,0,0,0,192,0,0,0,0,0,0,0,0,0,0,3,0,68,8,0,0,96,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,48,0,0,0,255,255,3,128,0,0,0,0,192,63,0,0,128,255,3,0,
+0,0,0,0,7,0,0,0,0,0,200,51,0,0,0,0,32,0,0,
+0,0,0,0,0,0,126,102,0,8,16,0,0,0,0,0,16,0,0,0,0,0,0,157,193,2,0,0,0,0,48,64,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0,0,0,0,0,0,0,0,28,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,127,248,255,255,255,255,255,31,32,0,16,0,0,248,254,255,0,0,0,
+0,0,0,0,0,0,0,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,0,0,0,0,0,0,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,
+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,240,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,127,0,0,0,0,0,0,0,0,0,0,0,0,0,240,7,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
diff --git a/src/ctype/punct.h b/src/ctype/punct.h
new file mode 100644
index 0000000..6792947
--- /dev/null
+++ b/src/ctype/punct.h
@@ -0,0 +1,141 @@
+18,16,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,16,16,34,35,16,36,37,38,39,
+40,41,42,43,16,44,45,46,17,17,47,17,17,17,17,17,17,48,49,50,51,52,53,54,55,17,
+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,56,
+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,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,16,16,16,16,
+16,16,16,16,16,16,16,16,57,16,58,59,60,61,62,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,16,16,16,
+16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,64,16,16,16,16,16,16,16,16,16,
+16,16,16,16,16,16,16,16,16,16,16,16,16,16,65,16,16,66,16,67,68,
+69,16,70,71,72,16,73,16,16,74,75,76,77,78,16,79,80,81,82,83,84,85,86,87,88,89,
+90,91,16,92,93,94,95,16,16,16,16,96,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
+16,97,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,16,16,16,16,16,16,16,16,16,16,16,16,16,
+16,16,16,98,99,16,16,100,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,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,16,16,16,16,16,16,102,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
+16,16,16,103,104,105,106,16,16,107,108,17,17,109,16,16,16,16,16,16,110,111,16,
+16,16,16,16,112,113,16,16,114,115,116,16,117,118,119,17,17,17,120,121,122,123,
+124,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,254,255,0,252,1,0,0,248,1,
+0,0,120,0,0,0,0,255,251,223,251,0,0,128,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,60,0,252,255,224,175,255,255,255,255,255,255,255,255,
+255,255,223,255,255,255,255,255,32,64,176,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,252,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,252,0,0,0,0,0,230,254,255,255,255,0,64,73,0,0,0,0,0,24,0,255,255,0,216,
+0,0,0,0,0,0,0,1,0,60,0,0,0,0,0,0,0,0,0,0,0,0,16,224,1,30,0,
+96,255,191,0,0,0,0,0,0,255,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,248,207,
+227,0,0,0,3,0,32,255,127,0,0,0,78,0,0,0,0,0,0,0,0,0,0,0,0,0,0,8,0,7,252,0,0,0,
+0,0,0,0,0,0,16,0,32,30,0,48,0,1,0,0,0,0,0,0,0,0,16,0,32,0,0,0,0,252,111,0,0,0,
+0,0,0,0,16,0,32,0,0,0,0,64,0,0,0,0,0,0,0,0,16,0,32,0,0,0,0,3,224,0,0,0,0,0,0,
+0,16,0,32,0,0,0,0,253,0,0,0,0,0,0,0,0,0,0,32,0,0,0,0,255,7,16,0,0,0,0,0,0,0,0,
+32,0,0,0,0,128,255,16,0,0,0,0,0,0,16,0,32,0,0,0,0,0,0,0,0,0,0,0,0,0,24,0,160,
+0,127,0,0,255,3,0,0,0,0,0,0,0,0,0,4,0,0,0,0,16,0,0,0,0,0,0,128,0,128,192,223,
+0,12,0,0,0,0,0,0,0,0,0,0,0,4,0,31,0,0,0,0,0,
+0,254,255,255,255,0,252,255,255,0,0,0,0,0,0,0,0,252,0,0,0,0,0,0,192,255,223,
+255,7,0,0,0,0,0,0,0,0,0,0,128,6,0,252,0,0,0,0,0,0,0,0,0,192,0,0,0,0,0,0,0,0,0,
+0,0,8,0,0,0,0,0,0,0,0,0,0,0,224,255,255,255,31,0,0,255,3,0,0,0,0,0,0,0,0,0,0,
+0,0,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,
+0,0,0,0,0,0,0,0,96,0,0,1,0,0,24,0,0,0,0,0,0,0,0,0,56,0,0,0,0,16,0,0,0,112,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,48,0,0,254,127,47,0,0,255,3,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,0,0,0,0,0,0,0,0,0,0,0,14,49,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,196,255,255,255,
+255,0,0,0,192,0,0,0,0,0,0,0,0,1,0,224,159,0,0,0,0,127,63,255,127,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,16,0,16,0,0,252,255,255,255,31,0,0,0,0,0,12,0,0,0,0,0,0,64,0,
+12,240,0,0,0,0,0,0,128,248,0,0,0,0,0,0,0,192,0,0,0,0,0,0,0,0,255,0,255,255,
+255,33,144,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,
+127,0,224,251,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,160,3,224,0,224,0,
+224,0,96,128,248,255,255,255,252,255,255,255,255,255,127,223,255,241,127,255,
+127,0,0,255,255,255,255,0,0,255,255,255,255,1,0,123,3,208,193,175,66,0,12,31,
+188,255,255,0,0,0,0,0,14,255,255,255,255,255,255,255,255,255,255,255,255,255,
+255,255,255,255,255,127,0,0,0,255,7,0,0,255,255,255,255,255,255,255,255,255,
+255,63,0,0,0,0,0,0,252,255,
+255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,207,255,255,255,
+63,255,255,255,255,255,255,255,255,255,255,255,255,255,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,224,135,3,254,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,
+128,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,255,127,255,255,255,255,0,
+0,0,0,0,0,255,255,255,251,255,255,255,255,255,255,255,255,255,255,15,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,63,0,0,0,255,15,30,255,255,255,1,252,193,224,0,0,0,0,
+0,0,0,0,0,0,0,30,1,0,0,0,0,0,0,0,0,0,0,8,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+255,255,0,0,0,0,255,255,255,255,15,0,0,0,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,255,255,
+255,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,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,0,0,
+0,0,0,192,0,224,0,0,0,0,0,0,0,0,0,0,0,128,15,112,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+255,0,255,255,127,0,3,0,0,0,0,0,0,0,0,0,0,0,0,6,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+64,0,0,0,0,15,255,3,0,0,0,0,0,0,240,0,0,0,0,0,0,0,0,0,16,192,0,0,255,255,3,23,
+0,0,0,0,0,248,0,0,0,0,8,128,0,0,0,0,0,0,0,0,0,0,8,0,255,63,0,192,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,240,0,0,128,3,0,0,0,0,0,0,0,128,2,0,0,192,0,0,67,0,0,0,0,0,
+0,0,0,0,0,0,0,8,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,56,0,
+0,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,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,128,0,0,0,0,0,2,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,252,255,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,48,255,255,255,3,255,255,255,255,255,255,247,
+255,127,15,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,128,254,255,0,252,1,0,0,248,1,0,
+0,248,63,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,127,127,0,48,135,255,255,255,255,255,
+143,255,0,0,0,0,0,0,224,255,255,127,255,15,1,0,0,0,0,0,255,255,255,255,255,63,
+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,
+15,0,0,0,0,15,0,0,0,0,0,0,0,0,0,0,0,0,0,0,128,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,
+0,0,0,0,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,0,0,
+128,255,0,0,128,255,0,0,0,0,128,255,0,0,0,0,0,0,0,0,0,248,0,0,192,143,0,0,0,
+128,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,48,255,255,252,255,255,255,255,255,0,0,0,0,
+0,0,0,135,255,1,255,1,0,0,0,224,0,0,0,224,0,0,0,0,0,1,0,0,96,248,127,0,0,0,0,
+0,0,0,0,254,0,0,0,255,0,0,0,255,0,0,0,30,0,254,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,252,0,0,0,0,0,0,0,0,0,0,0,
+0,255,255,255,127,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,224,127,0,0,0,192,255,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,192,63,252,255,63,0,0,128,3,0,0,0,0,0,0,254,3,32,0,0,0,0,0,0,0,
+0,0,0,0,0,24,0,15,0,0,0,0,0,56,0,0,0,0,0,0,0,0,0,225,63,0,232,254,255,31,0,0,
+0,0,0,0,0,96,63,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,6,0,0,0,0,0,0,0,0,0,
+24,0,32,0,0,192,31,31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,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,
+255,255,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,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,176,15,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,63,
+0,255,255,255,255,127,254,255,255,255,255,255,255,255,255,255,255,255,255,255,
+255,255,255,255,255,255,255,255,255,255,1,0,0,255,255,255,255,255,255,255,255,
+63,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,15,0,255,255,255,255,255,255,
+255,255,255,255,127,0,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,0,0,0,0,2,0,0,8,0,0,0,8,0,0,32,0,0,0,32,0,0,128,
+0,0,0,128,0,0,0,2,0,0,0,2,0,0,8,0,0,0,0,0,0,0,255,255,255,255,255,255,255,255,
+255,255,255,255,255,255,255,255,255,15,0,248,254,255,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,127,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,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,240,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,128,255,127,0,0,0,0,0,0,0,
+0,0,0,0,0,0,112,7,0,192,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,254,255,255,255,255,255,255,255,31,0,0,0,0,0,0,0,0,0,254,255,
+255,255,255,255,255,63,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,0,0,0,0,0,0,0,0,3,0,255,255,255,255,255,
+15,255,255,255,255,255,255,255,255,255,255,255,255,15,0,255,127,254,255,254,
+255,254,255,255,255,63,0,255,31,255,255,255,255,0,0,0,252,0,0,0,28,0,0,0,252,
+255,255,255,31,0,0,0,0,0,0,192,255,255,255,7,0,255,255,255,255,255,15,255,1,3,
+0,63,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,63,0,255,31,255,7,255,255,255,255,255,255,255,255,
+255,255,255,255,255,255,15,0,255,255,255,255,255,255,255,255,255,255,255,1,
+255,15,0,0,255,15,255,255,255,255,255,255,255,0,255,3,255,255,255,255,255,0,
+255,255,255,63,0,0,0,0,0,0,0,0,0,0,255,239,255,255,255,255,255,255,255,255,
+255,255,255,255,123,252,255,255,255,255,231,199,255,255,255,231,255,255,255,
+255,255,255,255,255,255,255,255,255,255,255,255,255,15,0,255,63,15,7,7,0,63,0,
+0,0,0,0,0,0,0,0,0,0,0,0,
diff --git a/src/ctype/toascii.c b/src/ctype/toascii.c
new file mode 100644
index 0000000..f0e48e8
--- /dev/null
+++ b/src/ctype/toascii.c
@@ -0,0 +1,7 @@
+#include <ctype.h>
+
+/* nonsense function that should NEVER be used! */
+int toascii(int c)
+{
+ return c & 0x7f;
+}
diff --git a/src/ctype/tolower.c b/src/ctype/tolower.c
new file mode 100644
index 0000000..f10132e
--- /dev/null
+++ b/src/ctype/tolower.c
@@ -0,0 +1,14 @@
+#include <ctype.h>
+
+int tolower(int c)
+{
+ if (isupper(c)) return c | 32;
+ return c;
+}
+
+int __tolower_l(int c, locale_t l)
+{
+ return tolower(c);
+}
+
+weak_alias(__tolower_l, tolower_l);
diff --git a/src/ctype/toupper.c b/src/ctype/toupper.c
new file mode 100644
index 0000000..4e74a55
--- /dev/null
+++ b/src/ctype/toupper.c
@@ -0,0 +1,14 @@
+#include <ctype.h>
+
+int toupper(int c)
+{
+ if (islower(c)) return c & 0x5f;
+ return c;
+}
+
+int __toupper_l(int c, locale_t l)
+{
+ return toupper(c);
+}
+
+weak_alias(__toupper_l, toupper_l);
diff --git a/src/ctype/towctrans.c b/src/ctype/towctrans.c
new file mode 100644
index 0000000..76d1376
--- /dev/null
+++ b/src/ctype/towctrans.c
@@ -0,0 +1,84 @@
+#include <wctype.h>
+
+static const unsigned char tab[];
+
+static const unsigned char rulebases[512];
+static const int rules[];
+
+static const unsigned char exceptions[][2];
+
+#include "casemap.h"
+
+static int casemap(unsigned c, int dir)
+{
+ unsigned b, x, y, v, rt, xb, xn;
+ int r, rd, c0 = c;
+
+ if (c >= 0x20000) return c;
+
+ b = c>>8;
+ c &= 255;
+ x = c/3;
+ y = c%3;
+
+ /* lookup entry in two-level base-6 table */
+ v = tab[tab[b]*86+x];
+ static const int mt[] = { 2048, 342, 57 };
+ v = (v*mt[y]>>11)%6;
+
+ /* use the bit vector out of the tables as an index into
+ * a block-specific set of rules and decode the rule into
+ * a type and a case-mapping delta. */
+ r = rules[rulebases[b]+v];
+ rt = r & 255;
+ rd = r >> 8;
+
+ /* rules 0/1 are simple lower/upper case with a delta.
+ * apply according to desired mapping direction. */
+ if (rt < 2) return c0 + (rd & -(rt^dir));
+
+ /* binary search. endpoints of the binary search for
+ * this block are stored in the rule delta field. */
+ xn = rd & 0xff;
+ xb = (unsigned)rd >> 8;
+ while (xn) {
+ unsigned try = exceptions[xb+xn/2][0];
+ if (try == c) {
+ r = rules[exceptions[xb+xn/2][1]];
+ rt = r & 255;
+ rd = r >> 8;
+ if (rt < 2) return c0 + (rd & -(rt^dir));
+ /* Hard-coded for the four exceptional titlecase */
+ return c0 + (dir ? -1 : 1);
+ } else if (try > c) {
+ xn /= 2;
+ } else {
+ xb += xn/2;
+ xn -= xn/2;
+ }
+ }
+ return c0;
+}
+
+wint_t towlower(wint_t wc)
+{
+ return casemap(wc, 0);
+}
+
+wint_t towupper(wint_t wc)
+{
+ return casemap(wc, 1);
+}
+
+wint_t __towupper_l(wint_t c, locale_t l)
+{
+ return towupper(c);
+}
+
+wint_t __towlower_l(wint_t c, locale_t l)
+{
+ return towlower(c);
+}
+
+weak_alias(__towupper_l, towupper_l);
+weak_alias(__towlower_l, towlower_l);
diff --git a/src/ctype/wcswidth.c b/src/ctype/wcswidth.c
new file mode 100644
index 0000000..5c8a5a4
--- /dev/null
+++ b/src/ctype/wcswidth.c
@@ -0,0 +1,8 @@
+#include <wchar.h>
+
+int wcswidth(const wchar_t *wcs, size_t n)
+{
+ int l=0, k=0;
+ for (; n-- && *wcs && (k = wcwidth(*wcs)) >= 0; l+=k, wcs++);
+ return (k < 0) ? k : l;
+}
diff --git a/src/ctype/wctrans.c b/src/ctype/wctrans.c
new file mode 100644
index 0000000..d3eda52
--- /dev/null
+++ b/src/ctype/wctrans.c
@@ -0,0 +1,29 @@
+#include <wctype.h>
+#include <string.h>
+
+wctrans_t wctrans(const char *class)
+{
+ if (!strcmp(class, "toupper")) return (wctrans_t)1;
+ if (!strcmp(class, "tolower")) return (wctrans_t)2;
+ return 0;
+}
+
+wint_t towctrans(wint_t wc, wctrans_t trans)
+{
+ if (trans == (wctrans_t)1) return towupper(wc);
+ if (trans == (wctrans_t)2) return towlower(wc);
+ return wc;
+}
+
+wctrans_t __wctrans_l(const char *s, locale_t l)
+{
+ return wctrans(s);
+}
+
+wint_t __towctrans_l(wint_t c, wctrans_t t, locale_t l)
+{
+ return towctrans(c, t);
+}
+
+weak_alias(__wctrans_l, wctrans_l);
+weak_alias(__towctrans_l, towctrans_l);
diff --git a/src/ctype/wcwidth.c b/src/ctype/wcwidth.c
new file mode 100644
index 0000000..36256a5
--- /dev/null
+++ b/src/ctype/wcwidth.c
@@ -0,0 +1,29 @@
+#include <wchar.h>
+
+static const unsigned char table[] = {
+#include "nonspacing.h"
+};
+
+static const unsigned char wtable[] = {
+#include "wide.h"
+};
+
+int wcwidth(wchar_t wc)
+{
+ if (wc < 0xffU)
+ return (wc+1 & 0x7f) >= 0x21 ? 1 : wc ? -1 : 0;
+ if ((wc & 0xfffeffffU) < 0xfffe) {
+ if ((table[table[wc>>8]*32+((wc&255)>>3)]>>(wc&7))&1)
+ return 0;
+ if ((wtable[wtable[wc>>8]*32+((wc&255)>>3)]>>(wc&7))&1)
+ return 2;
+ return 1;
+ }
+ if ((wc & 0xfffe) == 0xfffe)
+ return -1;
+ if (wc-0x20000U < 0x20000)
+ return 2;
+ if (wc == 0xe0001 || wc-0xe0020U < 0x5f || wc-0xe0100U < 0xef)
+ return 0;
+ return 1;
+}
diff --git a/src/ctype/wide.h b/src/ctype/wide.h
new file mode 100644
index 0000000..e403c9a
--- /dev/null
+++ b/src/ctype/wide.h
@@ -0,0 +1,65 @@
+16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,18,16,16,16,16,16,16,16,16,
+16,16,16,16,16,16,16,16,16,19,16,20,21,22,16,16,16,23,16,16,24,25,26,27,28,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,29,
+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,17,17,17,17,17,30,16,16,16,16,31,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,17,17,17,17,17,17,17,17,17,17,17,
+17,17,17,17,17,17,17,32,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,16,16,16,33,
+34,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,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,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,35,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,
+17,17,17,17,17,17,36,17,17,37,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,38,39,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,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
+16,16,16,16,16,16,16,40,41,42,43,44,45,46,47,16,48,49,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,255,255,255,255,255,255,255,255,
+255,255,255,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,12,0,6,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,30,9,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,96,0,0,48,0,0,0,0,0,0,255,15,0,0,0,0,128,0,0,8,
+0,2,12,0,96,48,64,16,0,0,4,44,36,32,12,0,0,0,1,0,0,0,80,184,0,0,0,0,0,0,0,224,
+0,0,0,1,128,0,0,0,0,0,0,0,0,0,0,0,24,0,0,0,0,0,0,33,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,251,255,255,255,255,255,255,255,
+255,255,255,15,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,63,0,0,0,255,15,255,255,255,255,
+255,255,255,127,254,255,255,255,255,255,255,255,255,255,127,254,255,255,255,
+255,255,255,255,255,255,255,255,255,224,255,255,255,255,255,254,255,255,255,
+255,255,255,255,255,255,255,127,255,255,255,255,255,7,255,255,255,255,15,0,
+255,255,255,255,255,127,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,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,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,31,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,255,
+255,255,31,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,15,0,0,0,0,0,0,0,0,0,0,0,0,0,255,3,0,0,255,255,255,255,247,255,127,15,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,254,255,255,255,255,255,255,255,255,255,255,
+255,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,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,0,0,0,0,0,15,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,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,128,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,64,254,7,0,0,0,0,0,0,0,0,0,0,0,0,7,0,255,255,255,
+255,255,15,255,1,3,0,63,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,
+1,224,191,255,255,255,255,255,255,255,255,223,255,255,15,0,255,255,255,255,
+255,135,15,0,255,255,17,255,255,255,255,255,255,255,255,127,253,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,255,255,255,255,255,63,0,120,255,255,255,0,0,4,0,0,96,0,16,0,0,0,
+0,0,0,0,0,0,0,248,255,255,255,255,255,255,255,255,255,255,0,0,0,0,0,0,255,255,
+255,255,255,255,255,255,63,16,39,0,0,24,240,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,0,0,255,15,0,
+0,0,224,255,255,255,255,255,255,255,255,255,255,255,255,123,252,255,255,255,
+255,231,199,255,255,255,231,255,255,255,255,255,255,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,15,7,7,0,63,0,0,0,0,0,0,0,0,0,0,0,0,0,