diff options
| author | Tyge Løvset <[email protected]> | 2022-05-30 17:08:09 +0200 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2022-05-30 17:08:09 +0200 |
| commit | 6a5ec101dc606a9bb13ef5a5ee64ab001decc666 (patch) | |
| tree | 7b368fdcc1e7055bd1d327f29c4c108eb604c751 /src | |
| parent | 58bb58e7980d1eae175ed66dbe873893a05ab81e (diff) | |
| download | STC-modified-6a5ec101dc606a9bb13ef5a5ee64ab001decc666.tar.gz STC-modified-6a5ec101dc606a9bb13ef5a5ee64ab001decc666.zip | |
Updated benchmarks and renamed utf8utils.c to utf8code.c
Diffstat (limited to 'src')
| -rw-r--r-- | src/utf8code.c (renamed from src/utf8utils.c) | 4 | ||||
| -rw-r--r-- | src/utf8tabs.h | 10 | ||||
| -rw-r--r-- | src/utf8tabs.inc (renamed from src/utf8tabs.c) | 9 | ||||
| -rw-r--r-- | src/utf8tabs.py | 11 |
4 files changed, 12 insertions, 22 deletions
diff --git a/src/utf8utils.c b/src/utf8code.c index 3b01ae39..c58f78b6 100644 --- a/src/utf8utils.c +++ b/src/utf8code.c @@ -1,9 +1,7 @@ #include <ctype.h> #define i_header #include <stc/cstr.h> - -#include "utf8tabs.h" -#include "utf8tabs.c" +#include "utf8tabs.inc" // https://news.ycombinator.com/item?id=15423674 // https://gist.github.com/s4y/344a355f8c1f99c6a4cb2347ec4323cc diff --git a/src/utf8tabs.h b/src/utf8tabs.h deleted file mode 100644 index 95251f75..00000000 --- a/src/utf8tabs.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef utf8tabs_included -#define utf8tabs_included - -#include <stdint.h> -struct CaseFold { uint16_t c0, c1, m1; } ; - -extern struct CaseFold casefold[188]; -extern uint8_t cfold_low[188]; - -#endif diff --git a/src/utf8tabs.c b/src/utf8tabs.inc index 8168f78f..84b69eec 100644 --- a/src/utf8tabs.c +++ b/src/utf8tabs.inc @@ -1,6 +1,8 @@ -#include "utf8tabs.h" +#include <stdint.h> -struct CaseFold casefold[] = { +struct CaseFold { uint16_t c0, c1, m1; }; + +static struct CaseFold casefold[] = { {65, 90, 122}, {181, 181, 956}, {192, 214, 246}, {216, 222, 254}, {256, 302, 303}, {306, 310, 311}, {313, 327, 328}, {330, 374, 375}, {376, 376, 255}, {377, 381, 382}, {383, 383, 115}, {385, 385, 595}, {386, 388, 389}, {390, 390, 596}, @@ -45,7 +47,8 @@ struct CaseFold casefold[] = { {42948, 42948, 42900}, {42949, 42949, 642}, {42950, 42950, 7566}, {42951, 42953, 42954}, {42960, 42962, 42963}, {42968, 42970, 42971}, {43888, 43913, 5049}, {65313, 65338, 65370}, }; // 188 -uint8_t cfold_low[] = { + +static uint8_t cfold_low[] = { 0, 138, 10, 111, 2, 139, 3, 8, 4, 5, 6, 7, 9, 59, 12, 14, 16, 20, 49, 25, 56, 52, 29, 31, 33, 35, 37, 39, 50, 40, 41, 42, 43, 44, 45, 17, 46, 47, 48, 51, 53, 55, 155, 58, 62, 152, 150, 153, 11, 13, 15, 18, 19, 171, 21, 172, 22, 167, 170, 24, diff --git a/src/utf8tabs.py b/src/utf8tabs.py index 563180e3..c4c48113 100644 --- a/src/utf8tabs.py +++ b/src/utf8tabs.py @@ -83,13 +83,13 @@ def make_casefold(letters): def print_casefold(cfold): - print(''' -struct CaseFold casefold[] = {''') + print('#include <stdint.h>\n') + print('struct CaseFold { uint16_t c0, c1, m1; };\n') + print('static struct CaseFold casefold[] = {\n ', end='') n = 1 s = 5 count = 0 table = [] - print(' ', end='') for x in cfold: d = 2 if abs(x[2]) == 1 else 1 a = x[0] @@ -113,7 +113,7 @@ struct CaseFold casefold[] = {''') print('') count += 1 n += 1 - print('\n}; // %d' % (count)) + print('\n}; // %d\n' % (count)) return table @@ -129,7 +129,7 @@ def print_casefold_low(table): cfold_low = [i for i in range(len(table))] cfold_low.sort(key=lambda i: table[i][2] - (table[i][1] - table[i][0])) - print('uint8_t cfold_low[] = {\n ', end='') + print('static uint8_t cfold_low[] = {\n ', end='') for i in range(len(cfold_low)): print(" %d," % (cfold_low[i]), end='\n ' if (i+1) % 20 == 0 else '') print('\n};') @@ -138,7 +138,6 @@ def print_casefold_low(table): ########### main: if __name__ == "__main__": - print('#include "utf8tabs.h"') cfold = make_casetable() table = print_casefold(cfold) print_casefold_low(table) |
