diff options
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | builtin.c | 3 | ||||
-rw-r--r-- | test/ChangeLog | 5 | ||||
-rw-r--r-- | test/Makefile.am | 12 | ||||
-rw-r--r-- | test/Makefile.in | 12 | ||||
-rw-r--r-- | test/mbprintf5.awk | 1 | ||||
-rw-r--r-- | test/mbprintf5.in | 3 | ||||
-rw-r--r-- | test/mbprintf5.ok | 3 |
8 files changed, 41 insertions, 3 deletions
@@ -1,3 +1,8 @@ +2017-06-18 Arnold D. Robbins <arnold@skeeve.com> + + * builtin.c (mbc_char_count): Fix code to correctly traverse + the string. Thanks to Hermann Peifer for the bug report. + 2017-05-30 Arnold D. Robbins <arnold@skeeve.com> * NEWS: Mention PROCINFO["argv"]. @@ -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; diff --git a/test/ChangeLog b/test/ChangeLog index 0d8978fe..d2dd6abd 100644 --- a/test/ChangeLog +++ b/test/ChangeLog @@ -1,3 +1,8 @@ +2017-06-18 Arnold D. Robbins <arnold@skeeve.com> + + * Makefile.am (mbprintf5): New test. + * mbprintf5.awk, mbprintf5.in, mbprintf5.ok: New files. + 2017-05-24 Andrew J. Schorr <aschorr@telemetry-investments.com> * fwtest8.ok: Fix field number in error message, thanks to a bug diff --git a/test/Makefile.am b/test/Makefile.am index 443580b5..1fcdba3d 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -626,6 +626,9 @@ EXTRA_DIST = \ mbprintf4.awk \ mbprintf4.in \ mbprintf4.ok \ + mbprintf5.awk \ + mbprintf5.in \ + mbprintf5.ok \ mbstr1.awk \ mbstr1.ok \ mbstr2.awk \ @@ -1283,7 +1286,8 @@ MPFR_TESTS = mpfrnr mpfrnegzero mpfrmemok1 mpfrrem mpfrrnd mpfrieee \ LOCALE_CHARSET_TESTS = \ asort asorti backbigs1 backsmalls1 backsmalls2 \ fmttest fnarydel fnparydl jarebug lc_num1 mbfw1 \ - mbprintf1 mbprintf2 mbprintf3 mbprintf4 rebt8b2 rtlenmb sort1 sprintfc + mbprintf1 mbprintf2 mbprintf3 mbprintf4 mbprintf5 \ + rebt8b2 rtlenmb sort1 sprintfc SHLIB_TESTS = \ apiterm fnmatch filefuncs fork fork2 fts functab4 getfile inplace1 inplace2 inplace3 \ @@ -1905,6 +1909,12 @@ mbprintf4:: $(AWK) -f "$(srcdir)"/$@.awk "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >> _$@ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ +mbprintf5:: + @echo $@ + @GAWKLOCALE=en_US.UTF-8 ; export GAWKLOCALE ; \ + $(AWK) -f "$(srcdir)"/$@.awk "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >> _$@ + @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ + mbfw1:: @echo $@ @GAWKLOCALE=en_US.UTF-8 ; export GAWKLOCALE ; \ diff --git a/test/Makefile.in b/test/Makefile.in index e3fe9cbe..7bddf5a9 100644 --- a/test/Makefile.in +++ b/test/Makefile.in @@ -884,6 +884,9 @@ EXTRA_DIST = \ mbprintf4.awk \ mbprintf4.in \ mbprintf4.ok \ + mbprintf5.awk \ + mbprintf5.in \ + mbprintf5.ok \ mbstr1.awk \ mbstr1.ok \ mbstr2.awk \ @@ -1536,7 +1539,8 @@ MPFR_TESTS = mpfrnr mpfrnegzero mpfrmemok1 mpfrrem mpfrrnd mpfrieee \ LOCALE_CHARSET_TESTS = \ asort asorti backbigs1 backsmalls1 backsmalls2 \ fmttest fnarydel fnparydl jarebug lc_num1 mbfw1 \ - mbprintf1 mbprintf2 mbprintf3 mbprintf4 rebt8b2 rtlenmb sort1 sprintfc + mbprintf1 mbprintf2 mbprintf3 mbprintf4 mbprintf5 \ + rebt8b2 rtlenmb sort1 sprintfc SHLIB_TESTS = \ apiterm fnmatch filefuncs fork fork2 fts functab4 getfile inplace1 inplace2 inplace3 \ @@ -2345,6 +2349,12 @@ mbprintf4:: $(AWK) -f "$(srcdir)"/$@.awk "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >> _$@ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ +mbprintf5:: + @echo $@ + @GAWKLOCALE=en_US.UTF-8 ; export GAWKLOCALE ; \ + $(AWK) -f "$(srcdir)"/$@.awk "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >> _$@ + @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ + mbfw1:: @echo $@ @GAWKLOCALE=en_US.UTF-8 ; export GAWKLOCALE ; \ diff --git a/test/mbprintf5.awk b/test/mbprintf5.awk new file mode 100644 index 00000000..c9a57b48 --- /dev/null +++ b/test/mbprintf5.awk @@ -0,0 +1 @@ +{printf "%-5s%s\n", $1, $2} diff --git a/test/mbprintf5.in b/test/mbprintf5.in new file mode 100644 index 00000000..c63daaf6 --- /dev/null +++ b/test/mbprintf5.in @@ -0,0 +1,3 @@ +Ö ABC +• ABC +🜁 ABC diff --git a/test/mbprintf5.ok b/test/mbprintf5.ok new file mode 100644 index 00000000..252d95e6 --- /dev/null +++ b/test/mbprintf5.ok @@ -0,0 +1,3 @@ +Ö ABC +• ABC +🜁 ABC |