mirror of https://github.com/flysand7/ciabatta.git
Improve unicode compile times
This commit is contained in:
parent
59e70ebfc9
commit
bc1c0bcc11
69260
code/unicode/unicode.h
69260
code/unicode/unicode.h
File diff suppressed because it is too large
Load Diff
|
@ -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();
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue