Improve unicode compile times

This commit is contained in:
bumbread 2022-06-16 20:34:46 +11:00
parent 59e70ebfc9
commit bc1c0bcc11
3 changed files with 34648 additions and 34650 deletions

File diff suppressed because it is too large Load Diff

View File

@ -38,8 +38,15 @@ with open('unicode.h', 'w') as header:
header.write('#define Zl 26\n');
header.write('#define Zp 27\n');
header.write('#define Zs 28\n');
header.write('\n');
header.write('#define UNI_TAB \\\n');
header.write(
'''
struct _uni_elm {
wint_t code;
wint_t cat;
wint_t lower;
wint_t upper;
} uni_codepoints[] = {
''');
with open('unicode_data.txt') as file:
for line in file:
@ -52,11 +59,11 @@ with open('unicode.h', 'w') as header:
lower = code
if upper == '' or upper == '\n':
upper = code
header.write(' X(' + \
header.write(' {' + \
'0x' + code + ', ' + \
cat + ', ' + \
'0x' + lower + ', ' + \
'0x' + upper + ')\\\n');
'0x' + upper + '},\n');
header.write('\n');
header.write('};\n\n');
header.close();

View File

@ -5,12 +5,7 @@
#include "unicode.h"
static inline int char_cat(wint_t wc) {
#define X(code, cat, l, u) case code: return cat;
switch(wc) {
UNI_TAB
}
#undef X
return -1;
return uni_codepoints[wc].cat;
}
int iswctype(wint_t wc, wctype_t desc) {
@ -109,19 +104,9 @@ int iswxdigit(wint_t wc) {
}
wint_t towlower(wint_t wc) {
#define X(code, cat, l, u) case code: return l;
switch(wc) {
UNI_TAB
}
#undef X
return wc;
return uni_codepoints[wc].lower;
}
wint_t towupper(wint_t wc) {
#define X(code, cat, l, u) case code: return u;
switch(wc) {
UNI_TAB
}
#undef X
return wc;
return uni_codepoints[wc].upper;
}