From: David Lawrence Ramsey Date: Sun, 28 May 2006 16:25:15 +0000 (+0000) Subject: in parse_verbatim_kbinput(), don't include the ability to enter a X-Git-Tag: v1.3.12~92 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=5c7d88dc16361f251ff7d6fe2d4b315fe25215ca;p=nano.git in parse_verbatim_kbinput(), don't include the ability to enter a Unicode sequence via verbatim input mode if we're not in a UTF-8 locale git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3588 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- diff --git a/ChangeLog b/ChangeLog index 0b358e55..8eb724a8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -315,7 +315,8 @@ CVS code - - Simplify the if blocks wherever possible. (DLR) parse_verbatim_kbinput() - Don't include the ability to enter a Unicode sequence via - verbatim input mode if ENABLE_UTF8 isn't defined. (DLR) + verbatim input mode if ENABLE_UTF8 isn't defined or we're not + in a UTF-8 locale. (DLR) check_statusblank() - Avoid redundant updates when statusblank is 0. (DLR) display_string() diff --git a/src/winio.c b/src/winio.c index 01edb819..d659ac49 100644 --- a/src/winio.c +++ b/src/winio.c @@ -1449,49 +1449,52 @@ int *parse_verbatim_kbinput(WINDOW *win, size_t *kbinput_len) while ((kbinput = get_input(win, 1)) == NULL); #ifdef ENABLE_UTF8 - /* Check whether the first keystroke is a valid hexadecimal - * digit. */ - uni = get_unicode_kbinput(*kbinput); - - /* If the first keystroke isn't a valid hexadecimal digit, put back - * the first keystroke. */ - if (uni != ERR) -#endif /* ENABLE_UTF8 */ - - unget_input(kbinput, 1); - -#ifdef ENABLE_UTF8 - /* Otherwise, read in keystrokes until we have a complete Unicode - * sequence, and put back the corresponding Unicode value. */ - else { - char *uni_mb; - int uni_mb_len, *seq, i; + if (using_utf8()) { + /* Check whether the first keystroke is a valid hexadecimal + * digit. */ + uni = get_unicode_kbinput(*kbinput); + + /* If the first keystroke isn't a valid hexadecimal digit, put + * back the first keystroke. */ + if (uni != ERR) + unget_input(kbinput, 1); + + /* Otherwise, read in keystrokes until we have a complete + * Unicode sequence, and put back the corresponding Unicode + * value. */ + else { + char *uni_mb; + int uni_mb_len, *seq, i; - if (win == edit) - /* TRANSLATORS: This is displayed during the input of a - * six-digit Unicode code. */ - statusbar(_("Unicode Input")); + if (win == edit) + /* TRANSLATORS: This is displayed during the input of a + * six-digit hexadecimal Unicode character code. */ + statusbar(_("Unicode Input")); - while (uni == ERR) { - while ((kbinput = get_input(win, 1)) == NULL); + while (uni == ERR) { + while ((kbinput = get_input(win, 1)) == NULL); - uni = get_unicode_kbinput(*kbinput); - } + uni = get_unicode_kbinput(*kbinput); + } - /* Put back the multibyte equivalent of the Unicode value. */ - uni_mb = make_mbchar(uni, &uni_mb_len); + /* Put back the multibyte equivalent of the Unicode + * value. */ + uni_mb = make_mbchar(uni, &uni_mb_len); - seq = (int *)nmalloc(uni_mb_len * sizeof(int)); + seq = (int *)nmalloc(uni_mb_len * sizeof(int)); - for (i = 0; i < uni_mb_len; i++) - seq[i] = (unsigned char)uni_mb[i]; + for (i = 0; i < uni_mb_len; i++) + seq[i] = (unsigned char)uni_mb[i]; - unget_input(seq, uni_mb_len); + unget_input(seq, uni_mb_len); - free(seq); - free(uni_mb); - } -#endif /* ENABLE_UTF8 */ + free(seq); + free(uni_mb); + } + } else +#endif + /* Put back the first keystroke. */ + unget_input(kbinput, 1); /* Get the complete sequence, and save the characters in it as the * result. */