From: David Levine Date: Thu, 3 Nov 2016 00:08:27 +0000 (-0400) Subject: Fixed display of header field values with multibyte characters. X-Git-Url: https://diplodocus.org/git/nmh/commitdiff_plain/a362ecdd2e3df304885b3d520e56cfb5963bf1a8 Fixed display of header field values with multibyte characters. --- diff --git a/test/mhl/test-rfc6532 b/test/mhl/test-rfc6532 index 978f291a..05dae7bc 100755 --- a/test/mhl/test-rfc6532 +++ b/test/mhl/test-rfc6532 @@ -22,11 +22,14 @@ mhl="${MH_LIBEXEC_DIR}/mhl" require_locale en_US.UTF-8 en_US.UTF8 en_US.utf-8 en_US.utf8 -# check UTF-8 headers start_test 'UTF-8 headers' -cat >"$MH_TEST_DIR"/Mail/inbox/11 <`mhpath new` < 0) { while (lm > 0) if (lm >= 8) { @@ -1471,8 +1476,33 @@ putstr (char *string, long flags) } } lm = 0; - while (*string) - putch (*string++, flags); + +#ifdef MULTIBYTE_SUPPORT + (void) mbtowc (NULL, NULL, 0); /* reset shift state */ + char_len = 0; +#else + NMH_UNUSED (char_len); +#endif + + while (*string) { + flags &= ~INVISIBLE; +#ifdef MULTIBYTE_SUPPORT + /* mbtowc should never return 0, because *string is non-NULL. */ + if (char_len <= 0) { + /* Find number of bytes in next character. */ + if ((char_len = + mbtowc (NULL, string, (size_t) MB_CUR_MAX)) == -1) { + char_len = 1; + } + } else { + /* Multibyte character, after the first byte. */ + flags |= INVISIBLE; + } + + --char_len; +#endif + putch (*string++, flags); + } } @@ -1531,8 +1561,10 @@ putch (char ch, long flags) putchar ('-'); putchar (' '); } - if (ch >= ' ') - column++; + if ((flags & INVISIBLE) == 0) { + /* If multibyte character, its first byte only. */ + ++column; + } break; }