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 Zl 26\n');
 | 
				
			||||||
    header.write('#define Zp 27\n');
 | 
					    header.write('#define Zp 27\n');
 | 
				
			||||||
    header.write('#define Zs 28\n');
 | 
					    header.write('#define Zs 28\n');
 | 
				
			||||||
    header.write('\n');
 | 
					    header.write(
 | 
				
			||||||
    header.write('#define UNI_TAB \\\n');
 | 
					'''
 | 
				
			||||||
 | 
					struct _uni_elm {
 | 
				
			||||||
 | 
					    wint_t code;
 | 
				
			||||||
 | 
					    wint_t cat;
 | 
				
			||||||
 | 
					    wint_t lower;
 | 
				
			||||||
 | 
					    wint_t upper;
 | 
				
			||||||
 | 
					} uni_codepoints[] = {
 | 
				
			||||||
 | 
					''');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    with open('unicode_data.txt') as file:
 | 
					    with open('unicode_data.txt') as file:
 | 
				
			||||||
        for line in file:
 | 
					        for line in file:
 | 
				
			||||||
| 
						 | 
					@ -52,11 +59,11 @@ with open('unicode.h', 'w') as header:
 | 
				
			||||||
                lower = code
 | 
					                lower = code
 | 
				
			||||||
            if upper == '' or upper == '\n':
 | 
					            if upper == '' or upper == '\n':
 | 
				
			||||||
                upper = code
 | 
					                upper = code
 | 
				
			||||||
            header.write('    X(' + \
 | 
					            header.write('    {' + \
 | 
				
			||||||
                '0x' + code  + ', ' + \
 | 
					                '0x' + code  + ', ' + \
 | 
				
			||||||
                cat          + ', ' + \
 | 
					                cat          + ', ' + \
 | 
				
			||||||
                '0x' + lower + ', ' + \
 | 
					                '0x' + lower + ', ' + \
 | 
				
			||||||
                '0x' + upper + ')\\\n');
 | 
					                '0x' + upper + '},\n');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    header.write('\n');
 | 
					    header.write('};\n\n');
 | 
				
			||||||
    header.close();
 | 
					    header.close();
 | 
				
			||||||
| 
						 | 
					@ -5,12 +5,7 @@
 | 
				
			||||||
#include "unicode.h"
 | 
					#include "unicode.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static inline int char_cat(wint_t wc) {
 | 
					static inline int char_cat(wint_t wc) {
 | 
				
			||||||
    #define X(code, cat, l, u) case code: return cat;
 | 
					    return uni_codepoints[wc].cat;
 | 
				
			||||||
    switch(wc) {
 | 
					 | 
				
			||||||
        UNI_TAB
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    #undef X
 | 
					 | 
				
			||||||
    return -1;
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int iswctype(wint_t wc, wctype_t desc) {
 | 
					int iswctype(wint_t wc, wctype_t desc) {
 | 
				
			||||||
| 
						 | 
					@ -109,19 +104,9 @@ int iswxdigit(wint_t wc) {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
wint_t towlower(wint_t wc) {
 | 
					wint_t towlower(wint_t wc) {
 | 
				
			||||||
    #define X(code, cat, l, u) case code: return l;
 | 
					    return uni_codepoints[wc].lower;
 | 
				
			||||||
    switch(wc) {
 | 
					 | 
				
			||||||
        UNI_TAB
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    #undef X
 | 
					 | 
				
			||||||
    return wc;
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
wint_t towupper(wint_t wc) {
 | 
					wint_t towupper(wint_t wc) {
 | 
				
			||||||
    #define X(code, cat, l, u) case code: return u;
 | 
					    return uni_codepoints[wc].upper;
 | 
				
			||||||
    switch(wc) {
 | 
					 | 
				
			||||||
        UNI_TAB
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    #undef X
 | 
					 | 
				
			||||||
    return wc;
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue