tweaks: elide a function call, by copying a byte directly
Now all remaining calls of measured_copy() have a "+ 1" in their second argument, and can thus be simplified. And each of those calls is followed by terminating the string with a NUL byte, so thát can be pulled into the function.master
parent
76f1a4af4f
commit
1d4411a474
|
@ -204,11 +204,10 @@ int mbwidth(const char *c)
|
||||||
* allocated) multibyte character and a length of zero. */
|
* allocated) multibyte character and a length of zero. */
|
||||||
char *make_mbchar(long code, int *length)
|
char *make_mbchar(long code, int *length)
|
||||||
{
|
{
|
||||||
char *mb_char;
|
char *mb_char = charalloc(MAXCHARLEN);
|
||||||
|
|
||||||
#ifdef ENABLE_UTF8
|
#ifdef ENABLE_UTF8
|
||||||
if (use_utf8) {
|
if (use_utf8) {
|
||||||
mb_char = charalloc(MAXCHARLEN);
|
|
||||||
*length = wctomb(mb_char, (wchar_t)code);
|
*length = wctomb(mb_char, (wchar_t)code);
|
||||||
|
|
||||||
/* Reject invalid Unicode characters. */
|
/* Reject invalid Unicode characters. */
|
||||||
|
@ -219,7 +218,7 @@ char *make_mbchar(long code, int *length)
|
||||||
} else
|
} else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
mb_char = measured_copy((char *)&code, 1);
|
*mb_char = (char)code;
|
||||||
*length = 1;
|
*length = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue