mirror of git://git.sv.gnu.org/nano.git
store multibyte characters in dynamically allocated arrays of MB_CUR_MAX
length, and add a few comment fixes git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@2174 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
This commit is contained in:
parent
91851f3e60
commit
43953bba6f
13
src/nano.c
13
src/nano.c
|
@ -3567,14 +3567,15 @@ void do_output(int *kbinput, size_t kbinput_len)
|
|||
/* Do we have to call edit_refresh(), or can we get away with
|
||||
* update_line()? */
|
||||
|
||||
char key[
|
||||
char *key = charalloc(
|
||||
#ifdef NANO_WIDE
|
||||
MB_LEN_MAX
|
||||
MB_CUR_MAX
|
||||
#else
|
||||
1
|
||||
#endif
|
||||
]; /* The current character we have. */
|
||||
int key_len; /* The length of the current character. */
|
||||
); /* The current multibyte character we have. */
|
||||
int key_len; /* The length of the current multibyte
|
||||
* character. */
|
||||
|
||||
assert(current != NULL && current->data != NULL);
|
||||
|
||||
|
@ -3635,6 +3636,8 @@ void do_output(int *kbinput, size_t kbinput_len)
|
|||
#endif
|
||||
|
||||
{
|
||||
/* FIXME: The movement functions should take multibyte
|
||||
* characters into account. */
|
||||
int j;
|
||||
for (j = 0; j < key_len; j++)
|
||||
do_right(FALSE);
|
||||
|
@ -3662,6 +3665,8 @@ void do_output(int *kbinput, size_t kbinput_len)
|
|||
#endif
|
||||
}
|
||||
|
||||
free(key);
|
||||
|
||||
/* Turn constant cursor position display back on if it was on
|
||||
* before. */
|
||||
if (old_constupdate)
|
||||
|
|
|
@ -263,17 +263,18 @@ void unget_input(buffer *input, size_t input_len)
|
|||
#ifdef NANO_WIDE
|
||||
if (!ISSET(NO_UTF8)) {
|
||||
size_t i;
|
||||
char *key = charalloc(MB_CUR_MAX);
|
||||
|
||||
/* Change all invalid wide character values to -1. */
|
||||
for (i = 0; i < input_len; i++) {
|
||||
char key[MB_LEN_MAX];
|
||||
|
||||
if (!input[i].key_code) {
|
||||
if (wctomb(key, input[i].key) == -1)
|
||||
input[i].key = -1;
|
||||
}
|
||||
}
|
||||
|
||||
free(key);
|
||||
|
||||
/* Save all of the non-(-1) wide characters in another
|
||||
* buffer. */
|
||||
for (i = 0; i < input_len; i++) {
|
||||
|
|
Loading…
Reference in New Issue