|
6 | 6 |
|
7 | 7 | #include "utf8n.h" |
8 | 8 |
|
9 | | -struct utf8data { |
10 | | - unsigned int maxage; |
11 | | - unsigned int offset; |
12 | | -}; |
13 | | - |
14 | | -#define __INCLUDED_FROM_UTF8NORM_C__ |
15 | | -#include "utf8data.h" |
16 | | -#undef __INCLUDED_FROM_UTF8NORM_C__ |
17 | | - |
18 | | -int utf8version_is_supported(unsigned int version) |
| 9 | +int utf8version_is_supported(const struct unicode_map *um, unsigned int version) |
19 | 10 | { |
20 | | - int i = ARRAY_SIZE(utf8agetab) - 1; |
| 11 | + int i = um->tables->utf8agetab_size - 1; |
21 | 12 |
|
22 | | - while (i >= 0 && utf8agetab[i] != 0) { |
23 | | - if (version == utf8agetab[i]) |
| 13 | + while (i >= 0 && um->tables->utf8agetab[i] != 0) { |
| 14 | + if (version == um->tables->utf8agetab[i]) |
24 | 15 | return 1; |
25 | 16 | i--; |
26 | 17 | } |
@@ -161,7 +152,7 @@ typedef const unsigned char utf8trie_t; |
161 | 152 | * underlying datatype: unsigned char. |
162 | 153 | * |
163 | 154 | * leaf[0]: The unicode version, stored as a generation number that is |
164 | | - * an index into utf8agetab[]. With this we can filter code |
| 155 | + * an index into ->utf8agetab[]. With this we can filter code |
165 | 156 | * points based on the unicode version in which they were |
166 | 157 | * defined. The CCC of a non-defined code point is 0. |
167 | 158 | * leaf[1]: Canonical Combining Class. During normalization, we need |
@@ -313,7 +304,7 @@ static utf8leaf_t *utf8nlookup(const struct unicode_map *um, |
313 | 304 | enum utf8_normalization n, unsigned char *hangul, const char *s, |
314 | 305 | size_t len) |
315 | 306 | { |
316 | | - utf8trie_t *trie = utf8data + um->ntab[n]->offset; |
| 307 | + utf8trie_t *trie = um->tables->utf8data + um->ntab[n]->offset; |
317 | 308 | int offlen; |
318 | 309 | int offset; |
319 | 310 | int mask; |
@@ -404,7 +395,8 @@ ssize_t utf8nlen(const struct unicode_map *um, enum utf8_normalization n, |
404 | 395 | leaf = utf8nlookup(um, n, hangul, s, len); |
405 | 396 | if (!leaf) |
406 | 397 | return -1; |
407 | | - if (utf8agetab[LEAF_GEN(leaf)] > um->ntab[n]->maxage) |
| 398 | + if (um->tables->utf8agetab[LEAF_GEN(leaf)] > |
| 399 | + um->ntab[n]->maxage) |
408 | 400 | ret += utf8clen(s); |
409 | 401 | else if (LEAF_CCC(leaf) == DECOMPOSE) |
410 | 402 | ret += strlen(LEAF_STR(leaf)); |
@@ -520,7 +512,7 @@ int utf8byte(struct utf8cursor *u8c) |
520 | 512 |
|
521 | 513 | ccc = LEAF_CCC(leaf); |
522 | 514 | /* Characters that are too new have CCC 0. */ |
523 | | - if (utf8agetab[LEAF_GEN(leaf)] > |
| 515 | + if (u8c->um->tables->utf8agetab[LEAF_GEN(leaf)] > |
524 | 516 | u8c->um->ntab[u8c->n]->maxage) { |
525 | 517 | ccc = STOPPER; |
526 | 518 | } else if (ccc == DECOMPOSE) { |
@@ -597,25 +589,3 @@ int utf8byte(struct utf8cursor *u8c) |
597 | 589 | } |
598 | 590 | } |
599 | 591 | EXPORT_SYMBOL(utf8byte); |
600 | | - |
601 | | -const struct utf8data *utf8nfdi(unsigned int maxage) |
602 | | -{ |
603 | | - int i = ARRAY_SIZE(utf8nfdidata) - 1; |
604 | | - |
605 | | - while (maxage < utf8nfdidata[i].maxage) |
606 | | - i--; |
607 | | - if (maxage > utf8nfdidata[i].maxage) |
608 | | - return NULL; |
609 | | - return &utf8nfdidata[i]; |
610 | | -} |
611 | | - |
612 | | -const struct utf8data *utf8nfdicf(unsigned int maxage) |
613 | | -{ |
614 | | - int i = ARRAY_SIZE(utf8nfdicfdata) - 1; |
615 | | - |
616 | | - while (maxage < utf8nfdicfdata[i].maxage) |
617 | | - i--; |
618 | | - if (maxage > utf8nfdicfdata[i].maxage) |
619 | | - return NULL; |
620 | | - return &utf8nfdicfdata[i]; |
621 | | -} |
0 commit comments