commit dd1b16cd5439c67126b4a5eb9612a6abae006d1d
parent 43b39ed04f113e19453de5560f8ee7f7f51188f8
Author: Benno Schulenberg <bensberg@telfort.nl>
Date: Mon, 20 Jul 2020 19:37:40 +0200
tweaks: trim an ASCII case, as the function is called only for UTF-8
Diffstat:
2 files changed, 3 insertions(+), 12 deletions(-)
diff --git a/src/chars.c b/src/chars.c
@@ -196,18 +196,14 @@ int mbwidth(const char *c)
} else
return 1;
}
-#endif
/* Convert the Unicode value in code to a multibyte character, if possible.
* If the conversion succeeds, return the (dynamically allocated) multibyte
- * character and its length. Otherwise, return an undefined (dynamically
- * allocated) multibyte character and a length of zero. */
+ * character and its length. Otherwise, return a length of zero. */
char *make_mbchar(long code, int *length)
{
char *mb_char = charalloc(MAXCHARLEN);
-#ifdef ENABLE_UTF8
- if (use_utf8) {
*length = wctomb(mb_char, (wchar_t)code);
/* Reject invalid Unicode characters. */
@@ -215,15 +211,10 @@ char *make_mbchar(long code, int *length)
IGNORE_CALL_RESULT(wctomb(NULL, 0));
*length = 0;
}
- } else
-#endif
- {
- *mb_char = (char)code;
- *length = 1;
- }
return mb_char;
}
+#endif /* ENABLE_UTF8 */
/* Return the length (in bytes) of the character located at *pointer. */
int char_length(const char *pointer)
diff --git a/src/prototypes.h b/src/prototypes.h
@@ -209,8 +209,8 @@ bool is_word_char(const char *c, bool allow_punct);
char control_mbrep(const char *c, bool isdata);
#ifdef ENABLE_UTF8
int mbwidth(const char *c);
-#endif
char *make_mbchar(long code, int *length);
+#endif
int char_length(const char *pointer);
size_t mbstrlen(const char *pointer);
int collect_char(const char *string, char *thechar);