commit 05e2a6d25940adb81543a6078d03577160acad56
parent 21d9bd1107436ff67a97467b4320aeca1007ea47
Author: Benno Schulenberg <bensberg@justemail.net>
Date: Mon, 30 May 2016 12:52:00 +0200
chars: a control character can never be an invalid multibyte sequence
The function is_cntrl_mbchar() has always been called successfully before
calling control_mbrep(), so the passed character *is* a valid sequence.
Diffstat:
1 file changed, 3 insertions(+), 15 deletions(-)
diff --git a/src/chars.c b/src/chars.c
@@ -250,9 +250,7 @@ wchar_t control_wrep(wchar_t wc)
#endif
/* c is a multibyte control character. It displays as ^@, ^?, or ^[ch],
- * where ch is (c + 64). We return that multibyte character. If crep
- * is an invalid multibyte sequence, it will be replaced with Unicode
- * 0xFFFD (Replacement Character). */
+ * where ch is (c + 64). We return that multibyte character. */
char *control_mbrep(const char *c, char *crep, int *crep_len)
{
assert(c != NULL && crep != NULL && crep_len != NULL);
@@ -261,18 +259,8 @@ char *control_mbrep(const char *c, char *crep, int *crep_len)
if (use_utf8) {
wchar_t wc;
- if (mbtowc(&wc, c, MB_CUR_MAX) < 0) {
- mbtowc_reset();
- *crep_len = bad_mbchar_len;
- strncpy(crep, bad_mbchar, *crep_len);
- } else {
- *crep_len = wctomb(crep, control_wrep(wc));
-
- if (*crep_len < 0) {
- wctomb_reset();
- *crep_len = 0;
- }
- }
+ IGNORE_CALL_RESULT(mbtowc(&wc, c, MB_CUR_MAX));
+ *crep_len = wctomb(crep, control_wrep(wc));
} else
#endif
{