summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWormHeamer2025-11-08 02:49:24 -0500
committerWormHeamer2025-11-08 02:49:24 -0500
commit5c080072bc1a7e3e7179fc092700fb1975e0f8d7 (patch)
tree464a5d517bf3b745dd30cc1a088d34af98ffe92c
parentade7974392223a3b81e7e9875fa6942c95c19df8 (diff)
don't truncate too much; relocate UTF8_* to utf8 section
-rw-r--r--vui.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/vui.c b/vui.c
index a73e15f..7afd974 100644
--- a/vui.c
+++ b/vui.c
@@ -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;