diff options
| -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; |
