diff options
author | Rob Landley <rob@landley.net> | 2021-05-15 11:14:03 -0500 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2021-05-15 11:14:03 -0500 |
commit | d3025b14b9c13286b79f256d019a99da9425ea0e (patch) | |
tree | 02a40c59346677cb5f6a51137f4a39d16ae6b743 /toys/pending | |
parent | 08481ee37ad5070ff1033d57351c3fa456d0729d (diff) | |
download | toybox-d3025b14b9c13286b79f256d019a99da9425ea0e.tar.gz |
Convert utf8towc from wchar_t to unsigned (to match wctoutf8).
The maximum unicode code point is 0x10ffff which is 21 bits.
Diffstat (limited to 'toys/pending')
-rw-r--r-- | toys/pending/vi.c | 5 |
1 files changed, 2 insertions, 3 deletions
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<col) break; |