reset the mbtowc() and wctomb() state machines at the right places

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@2178 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
master
David Lawrence Ramsey 2004-12-08 16:52:52 +00:00
parent 263240c7c7
commit 60448895f6
2 changed files with 17 additions and 7 deletions

View File

@ -3582,6 +3582,10 @@ void do_output(int *kbinput, size_t kbinput_len)
/* Turn off constant cursor position display. */
UNSET(CONSTUPDATE);
#ifdef NANO_WIDE
wctomb(NULL, 0);
#endif
for (i = 0; i < kbinput_len; i++) {
#ifdef NANO_WIDE
/* Change the wide character to its multibyte value. If it's
@ -3665,6 +3669,10 @@ void do_output(int *kbinput, size_t kbinput_len)
#endif
}
#ifdef NANO_WIDE
wctomb(NULL, 0);
#endif
/* Turn constant cursor position display back on if it was on
* before. */
if (old_constupdate)

View File

@ -112,13 +112,6 @@ static bool resetstatuspos = FALSE;
/* Reset all the input routines that rely on character sequences. */
void reset_kbinput(void)
{
#ifdef NANO_WIDE
/* Reset the multibyte and wide character interpreter states. */
if (!ISSET(NO_UTF8)) {
mbtowc(NULL, NULL, 0);
wctomb(NULL, 0);
}
#endif
parse_kbinput(NULL, NULL, NULL, TRUE);
get_word_kbinput(0, TRUE);
}
@ -191,6 +184,8 @@ void get_buffer(WINDOW *win)
buffer *clean_key_buffer = NULL;
size_t clean_key_buffer_len = 0;
mbtowc(NULL, NULL, 0);
/* Change all complete and valid multibyte keystrokes to
* their wide character values, discarding the others. */
for (i = 0; i < key_buffer_len; i++) {
@ -216,6 +211,8 @@ void get_buffer(WINDOW *win)
}
}
mbtowc(NULL, NULL, 0);
/* Replace the default keystroke buffer with the non-(-1)
* keystroke buffer. */
key_buffer_len = clean_key_buffer_len;
@ -260,6 +257,8 @@ void unget_input(buffer *input, size_t input_len)
if (!ISSET(NO_UTF8)) {
size_t i;
wctomb(NULL, 0);
/* Keep all valid wide keystrokes, discarding the others. */
for (i = 0; i < input_len; i++) {
char key[MB_LEN_MAX];
@ -276,6 +275,9 @@ void unget_input(buffer *input, size_t input_len)
input[i].key_code;
}
}
wctomb(NULL, 0);
} else {
#endif
clean_input = input;