summaryrefslogtreecommitdiff
path: root/builtin.c
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2017-06-18 22:17:49 +0300
committerArnold D. Robbins <arnold@skeeve.com>2017-06-18 22:17:49 +0300
commite0e06865d08f44a748ef0f0cd8f650cfb7d4e10e (patch)
tree8834987c3bb75bc024cbd8646c8843bf89937e7a /builtin.c
parent58ccf1fe579707c1eb78f7d18ee410d28d88d5e9 (diff)
downloadgawk-e0e06865d08f44a748ef0f0cd8f650cfb7d4e10e.tar.gz
Fix multibyte char printf problem, add test.
Diffstat (limited to 'builtin.c')
-rw-r--r--builtin.c3
1 files changed, 2 insertions, 1 deletions
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;