From e0e06865d08f44a748ef0f0cd8f650cfb7d4e10e Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Sun, 18 Jun 2017 22:17:49 +0300 Subject: Fix multibyte char printf problem, add test. --- builtin.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'builtin.c') diff --git a/builtin.c b/builtin.c index 87d9dcb8..724be058 100644 --- a/builtin.c +++ b/builtin.c @@ -4152,12 +4152,13 @@ mbc_char_count(const char *ptr, size_t numbytes) if (mb_len <= 0) return numbytes; /* no valid m.b. char */ - for (; numbytes > 0; numbytes--) { + while (numbytes > 0) { mb_len = mbrlen(ptr, numbytes, &cur_state); if (mb_len <= 0) break; sum++; ptr += mb_len; + numbytes -= mb_len; } return sum; -- cgit v1.2.3