diff options
| author | WormHeamer | 2025-11-08 02:49:24 -0500 |
|---|---|---|
| committer | WormHeamer | 2025-11-08 02:49:24 -0500 |
| commit | 5c080072bc1a7e3e7179fc092700fb1975e0f8d7 (patch) | |
| tree | 464a5d517bf3b745dd30cc1a088d34af98ffe92c | |
| parent | ade7974392223a3b81e7e9875fa6942c95c19df8 (diff) | |
don't truncate too much; relocate UTF8_* to utf8 section
| -rw-r--r-- | vui.c | 14 |
1 files changed, 7 insertions, 7 deletions
@@ -320,10 +320,6 @@ static void vui_outf(const char *fmt, ...) { * len(cp) = 1 + (0xFFEAA550000 >> (2 * (32 - clz(cp)))) & 3 */ -#define UTF8_CP_LEN_BITS ((uint64_t)0xFFEAA550000) -#define UTF8_CP_SHIFT(cp) ((32 - stdc_leading_zeros((uint32_t)(cp))) << 1) -#define UTF8_CP_LEN(cp) (1 + ((UTF8_CP_LEN_BITS >> UTF8_CP_SHIFT(cp)) & 3)) - static inline void vui_outc(char c) { vui_out_fit(vui_outn + 1); vui_out[vui_outn++] = c; @@ -618,12 +614,12 @@ static void truncate_span(int *x, unsigned *nptr) { *nptr = 0; return; } - if (*x + n >= (int)COLS) { - n = COLS - *x - 1; + if (*x + n > (int)COLS) { + n = COLS - *x; } if (n < 0) n = 0; assert(n >= 0); - assert(*x + n < (int)COLS); + //assert(*x + n < (int)COLS); *nptr = n; } @@ -838,6 +834,10 @@ VuiKey vui_key(void) { /* utf8 */ +#define UTF8_CP_LEN_BITS ((uint64_t)0xFFEAA550000) +#define UTF8_CP_SHIFT(cp) ((32 - stdc_leading_zeros((uint32_t)(cp))) << 1) +#define UTF8_CP_LEN(cp) (1 + ((UTF8_CP_LEN_BITS >> UTF8_CP_SHIFT(cp)) & 3)) + static u32 utf8_decode_len(const char *src, u32 n) { u32 i = 0; u32 len = 0; |
