From d3025b14b9c13286b79f256d019a99da9425ea0e Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Sat, 15 May 2021 11:14:03 -0500 Subject: Convert utf8towc from wchar_t to unsigned (to match wctoutf8). The maximum unicode code point is 0x10ffff which is 21 bits. --- toys/pending/vi.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'toys/pending') diff --git a/toys/pending/vi.c b/toys/pending/vi.c index da43d5d5..87c49d13 100644 --- a/toys/pending/vi.c +++ b/toys/pending/vi.c @@ -84,7 +84,7 @@ static const char *specials = ",.:;=-+*/(){}<>[]!@#$%^&|\\?\"\'"; //get utf8 length and width at same time static int utf8_lnw(int *width, char *s, int bytes) { - wchar_t wc; + unsigned wc; int length = 1; if (*s == '\t') *width = TT.tabstop; @@ -1312,10 +1312,9 @@ static int crunch_nstr(char **str, int width, int n, FILE *out, char *escmore, { int columns = 0, col, bytes; char *start, *end; + unsigned wc; for (end = start = *str; *end && n>0; columns += col, end += bytes, n -= bytes) { - wchar_t wc; - if ((bytes = utf8towc(&wc, end, 4))>0 && (col = wcwidth(wc))>=0) { if (!escmore || wc>255 || !strchr(escmore, wc)) { if (width-columns