summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2017-02-01 21:13:33 +0200
committerArnold D. Robbins <arnold@skeeve.com>2017-02-01 21:13:33 +0200
commit85e1012dab425dc50bc3faa2a3f28a9a47dac017 (patch)
treed01318ac5832af2574e989226b7eca9d9369307c
parent6e6ac2dccf7048f501e19490c90ea31c3f527633 (diff)
downloadgawk-85e1012dab425dc50bc3faa2a3f28a9a47dac017.tar.gz
Fix up mbc_char_count to be correct.
-rw-r--r--ChangeLog6
-rw-r--r--builtin.c4
2 files changed, 8 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index bbec422b..1d42e9ed 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2017-02-01 Arnold D. Robbins <arnold@skeeve.com>
+
+ * builtin.c (mbc_char_count): Remove spurious multiplies by
+ gawk_mb_cur_max. Thanks to Andrew Schorr for making me look
+ at this code.
+
2017-01-27 Andrew J. Schorr <aschorr@telemetry-investments.com>
* interpret.h [UNFIELD]: Fix condition for assignment from
diff --git a/builtin.c b/builtin.c
index f71d71dd..f4104764 100644
--- a/builtin.c
+++ b/builtin.c
@@ -4076,12 +4076,12 @@ mbc_char_count(const char *ptr, size_t numbytes)
memset(& cur_state, 0, sizeof(cur_state));
- mb_len = mbrlen(ptr, numbytes * gawk_mb_cur_max, &cur_state);
+ mb_len = mbrlen(ptr, numbytes, &cur_state);
if (mb_len <= 0)
return numbytes; /* no valid m.b. char */
for (; numbytes > 0; numbytes--) {
- mb_len = mbrlen(ptr, numbytes * gawk_mb_cur_max, &cur_state);
+ mb_len = mbrlen(ptr, numbytes, &cur_state);
if (mb_len <= 0)
break;
sum++;