Commit eae97caa authored by David Lawrence Ramsey's avatar David Lawrence Ramsey
Browse files

go back to storing multibyte characters in non-dynamically allocated

arrays of MB_LEN_MAX length, as it's less complex


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@2175 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
No related merge requests found
Showing with 5 additions and 8 deletions
+5 -8
...@@ -3567,13 +3567,13 @@ void do_output(int *kbinput, size_t kbinput_len) ...@@ -3567,13 +3567,13 @@ void do_output(int *kbinput, size_t kbinput_len)
/* Do we have to call edit_refresh(), or can we get away with /* Do we have to call edit_refresh(), or can we get away with
* update_line()? */ * update_line()? */
char *key = charalloc( char key[
#ifdef NANO_WIDE #ifdef NANO_WIDE
MB_CUR_MAX MB_LEN_MAX
#else #else
1 1
#endif #endif
); /* The current multibyte character we have. */ ]; /* The current multibyte character we have. */
int key_len; /* The length of the current multibyte int key_len; /* The length of the current multibyte
* character. */ * character. */
...@@ -3665,8 +3665,6 @@ void do_output(int *kbinput, size_t kbinput_len) ...@@ -3665,8 +3665,6 @@ void do_output(int *kbinput, size_t kbinput_len)
#endif #endif
} }
free(key);
/* Turn constant cursor position display back on if it was on /* Turn constant cursor position display back on if it was on
* before. */ * before. */
if (old_constupdate) if (old_constupdate)
......
...@@ -263,18 +263,17 @@ void unget_input(buffer *input, size_t input_len) ...@@ -263,18 +263,17 @@ void unget_input(buffer *input, size_t input_len)
#ifdef NANO_WIDE #ifdef NANO_WIDE
if (!ISSET(NO_UTF8)) { if (!ISSET(NO_UTF8)) {
size_t i; size_t i;
char *key = charalloc(MB_CUR_MAX);
/* Change all invalid wide character values to -1. */ /* Change all invalid wide character values to -1. */
for (i = 0; i < input_len; i++) { for (i = 0; i < input_len; i++) {
char key[MB_LEN_MAX];
if (!input[i].key_code) { if (!input[i].key_code) {
if (wctomb(key, input[i].key) == -1) if (wctomb(key, input[i].key) == -1)
input[i].key = -1; input[i].key = -1;
} }
} }
free(key);
/* Save all of the non-(-1) wide characters in another /* Save all of the non-(-1) wide characters in another
* buffer. */ * buffer. */
for (i = 0; i < input_len; i++) { for (i = 0; i < input_len; i++) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment