mirror of
git://git.sv.gnu.org/nano.git
synced 2024-11-22 12:51:23 +03:00
tweaks: elide a small function that is used just once
This commit is contained in:
parent
b6a32fbd5f
commit
c75a3839da
15
src/chars.c
15
src/chars.c
@ -251,21 +251,6 @@ bool is_zerowidth(const char *ch)
|
||||
{
|
||||
return (use_utf8 && mbwidth(ch) == 0);
|
||||
}
|
||||
|
||||
/* Convert the given Unicode value to a multibyte character, if possible.
|
||||
* If the conversion succeeds, return the (dynamically allocated) multibyte
|
||||
* character and its length. Otherwise, return a length of zero. */
|
||||
char *make_mbchar(long code, int *length)
|
||||
{
|
||||
char *mb_char = nmalloc(MAXCHARLEN);
|
||||
|
||||
*length = wctomb(mb_char, (wchar_t)code);
|
||||
|
||||
if (*length < 0)
|
||||
*length = 0;
|
||||
|
||||
return mb_char;
|
||||
}
|
||||
#endif /* ENABLE_UTF8 */
|
||||
|
||||
/* Return the number of bytes in the character that starts at *pointer. */
|
||||
|
@ -207,7 +207,6 @@ char control_mbrep(const char *c, bool isdata);
|
||||
int mbtowide(wchar_t *wc, const char *c);
|
||||
int mbwidth(const char *c);
|
||||
bool is_zerowidth(const char *ch);
|
||||
char *make_mbchar(long code, int *length);
|
||||
#endif
|
||||
int char_length(const char *pointer);
|
||||
size_t mbstrlen(const char *pointer);
|
||||
|
@ -1381,7 +1381,7 @@ int *parse_verbatim_kbinput(WINDOW *win, size_t *count)
|
||||
* commence Unicode input. Otherwise, put the code back. */
|
||||
if (using_utf8() && (keycode == '0' || keycode == '1')) {
|
||||
long unicode = assemble_unicode(keycode);
|
||||
char *multibyte;
|
||||
char multibyte[MB_CUR_MAX];
|
||||
|
||||
reveal_cursor = FALSE;
|
||||
|
||||
@ -1411,14 +1411,15 @@ int *parse_verbatim_kbinput(WINDOW *win, size_t *count)
|
||||
}
|
||||
|
||||
/* Convert the Unicode value to a multibyte sequence. */
|
||||
multibyte = make_mbchar(unicode, (int *)count);
|
||||
*count = wctomb(multibyte, unicode);
|
||||
|
||||
if (*count > MAXCHARLEN)
|
||||
*count = 0;
|
||||
|
||||
/* Change the multibyte character into a series of integers. */
|
||||
for (size_t i = 0; i < *count; i++)
|
||||
yield[i] = (int)multibyte[i];
|
||||
|
||||
free(multibyte);
|
||||
|
||||
return yield;
|
||||
}
|
||||
#endif /* ENABLE_UTF8 */
|
||||
|
Loading…
Reference in New Issue
Block a user