From: David Lawrence Ramsey Date: Wed, 8 Dec 2004 16:52:52 +0000 (+0000) Subject: reset the mbtowc() and wctomb() state machines at the right places X-Git-Tag: v1.3.6~224 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=60448895f62eac33e75b6b2173695c6baa51b9c0;p=nano.git 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 --- diff --git a/src/nano.c b/src/nano.c index 74427851..3f94a6a7 100644 --- a/src/nano.c +++ b/src/nano.c @@ -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) diff --git a/src/winio.c b/src/winio.c index 283eef7c..aad629f5 100644 --- a/src/winio.c +++ b/src/winio.c @@ -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;