tweaks: trim an ASCII case, as the function is called only for UTF-8
parent
43b39ed04f
commit
dd1b16cd54
13
src/chars.c
13
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)
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue