diff options
| author | Tyge Lovset <[email protected]> | 2022-06-07 07:57:10 +0200 |
|---|---|---|
| committer | Tyge Lovset <[email protected]> | 2022-06-07 07:57:10 +0200 |
| commit | d5ab884da0c68361a4280783ad46dc357e1adb23 (patch) | |
| tree | a6dec0de3bd897490ca5427b49157b1215736774 /src/utf8code.c | |
| parent | bfcd2e3a6912ac392694c238fce8fc613d2f1525 (diff) | |
| download | STC-modified-d5ab884da0c68361a4280783ad46dc357e1adb23.tar.gz STC-modified-d5ab884da0c68361a4280783ad46dc357e1adb23.zip | |
Bugfixed / Updated utf8tabs.* and utf8code.c
Diffstat (limited to 'src/utf8code.c')
| -rw-r--r-- | src/utf8code.c | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/src/utf8code.c b/src/utf8code.c index cda730ce..4b55d2be 100644 --- a/src/utf8code.c +++ b/src/utf8code.c @@ -60,11 +60,12 @@ bool utf8_valid_n(const char* s, size_t n) { } uint32_t utf8_tolower(uint32_t c) { - for (size_t i=0; i < sizeof casefold/sizeof *casefold; ++i) { - if (c <= casefold[i].c1) { - if (c < casefold[i].c0) return c; - int d = casefold[i].m1 - casefold[i].c1; - if (d == 1) return c + ((casefold[i].c1 & 1) == (c & 1)); + for (size_t i=0; i < casefold_len; ++i) { + const struct CaseMapping entry = casemappings[i]; + if (c <= entry.c1) { + if (c < entry.c0) return c; + int d = entry.m1 - entry.c1; + if (d == 1) return c + ((entry.c1 & 1) == (c & 1)); return c + d; } } @@ -72,12 +73,12 @@ uint32_t utf8_tolower(uint32_t c) { } uint32_t utf8_toupper(uint32_t c) { - for (size_t i=0; i < sizeof cfold_low/sizeof *cfold_low; ++i) { - struct CaseFold cfold = casefold[cfold_low[i]]; - if (c <= cfold.m1) { - int d = cfold.m1 - cfold.c1; - if (c < (uint32_t)(cfold.c0 + d)) return c; - if (d == 1) return c - ((cfold.m1 & 1) == (c & 1)); + for (size_t i=0; i < sizeof upcase_ind/sizeof *upcase_ind; ++i) { + struct CaseMapping entry = casemappings[upcase_ind[i]]; + if (c <= entry.m1) { + int d = entry.m1 - entry.c1; + if (c < (uint32_t)(entry.c0 + d)) return c; + if (d == 1) return c - ((entry.m1 & 1) == (c & 1)); return c - d; } } |
