From b9613842c3ac1a874b56dff4d1f8ce80c2dbab9d Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Tue, 5 Sep 2017 21:04:43 -0500 Subject: Replace remaining mb*towc() calls with utf8towc(). --- toys/posix/expand.c | 2 +- toys/posix/file.c | 2 +- toys/posix/paste.c | 3 +-- toys/posix/wc.c | 1 - 4 files changed, 3 insertions(+), 5 deletions(-) (limited to 'toys/posix') diff --git a/toys/posix/expand.c b/toys/posix/expand.c index a25848ad..d4914ab5 100644 --- a/toys/posix/expand.c +++ b/toys/posix/expand.c @@ -49,7 +49,7 @@ static void do_expand(int fd, char *name) if (CFG_TOYBOX_I18N) { wchar_t blah; - width = mbrtowc(&blah, toybuf+i, len-i, 0); + width = utf8towc(&blah, toybuf+i, len-i); if (width > 1) { if (width != fwrite(toybuf+i, width, 1, stdout)) perror_exit("stdout"); diff --git a/toys/posix/file.c b/toys/posix/file.c index 658708cb..9958d044 100644 --- a/toys/posix/file.c +++ b/toys/posix/file.c @@ -267,7 +267,7 @@ static void do_regular_file(int fd, char *name, struct stat *sb) } else for (i = 0; i0 && wcwidth(wc)>=0) { + if ((bytes = utf8towc(&wc, s+i, len-i))>0 && wcwidth(wc)>=0) { i += bytes-1; if (!what) what = "UTF-8 text"; } else { diff --git a/toys/posix/paste.c b/toys/posix/paste.c index 42e6a287..ea04f02e 100644 --- a/toys/posix/paste.c +++ b/toys/posix/paste.c @@ -42,7 +42,6 @@ static void paste_files(void) // Start of each line/file resets delimiter cycle dpos = TT.d; - mbtowc(0, 0, 0); for (i = any = dcount = dlen = 0; seq || i