From: David Lawrence Ramsey Date: Wed, 12 Jan 2005 05:10:53 +0000 (+0000) Subject: make the "smart home" routines handle multibyte blank characters X-Git-Tag: v1.3.6~152 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=8a31afdc55f4bff02e5951bd32108b70059ce1f0;p=nano.git make the "smart home" routines handle multibyte blank characters git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@2250 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- diff --git a/ChangeLog b/ChangeLog index 2258d3b1..33f4e35c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -97,11 +97,12 @@ CVS code - control_mbrep(), control_wrep(), mbwidth(), mb_cur_max(), and make_mbchar(); changes to is_blank_char() (moved to chars.c), is_cntrl_char() (moved to chars.c), parse_char() (renamed - parse_mbchar() and moved to chars.c), do_verbatim_input(), - do_delete(), do_tab(), do_input(), do_output(), get_buffer(), - unget_input(), unget_kbinput(), get_input(), parse_kbinput(), - unparse_kbinput(), parse_verbatim_kbinput(), - do_statusbar_input(), do_statusbar_verbatim_kbinput(), + parse_mbchar() and moved to chars.c), do_home(), + do_verbatim_input(), do_delete(), do_tab(), do_input(), + do_output(), get_buffer(), unget_input(), unget_kbinput(), + get_input(), parse_kbinput(), unparse_kbinput(), + parse_verbatim_kbinput(), do_statusbar_input(), + do_statusbar_home(), do_statusbar_verbatim_kbinput(), do_statusbar_output(), and display_string(); removal of buffer_to_keys() and keys_to_buffer(). (DLR) - cut.c: diff --git a/src/move.c b/src/move.c index 73729030..3a811592 100644 --- a/src/move.c +++ b/src/move.c @@ -57,10 +57,26 @@ void do_home(void) #ifndef NANO_SMALL if (ISSET(SMART_HOME)) { size_t current_x_save = current_x; + char *blank_mb = charalloc(mb_cur_max()); + int blank_mb_len; - for (current_x = 0; is_blank_char(current->data[current_x]) && - current->data[current_x] != '\0'; current_x++) - ; + current_x = 0; + + while (current->data[current_x] != '\0') { + blank_mb_len = parse_mbchar(current->data + current_x, + blank_mb +#ifdef NANO_WIDE + , NULL +#endif + , NULL); + + if (!is_blank_mbchar(blank_mb)) + break; + + current_x += blank_mb_len; + } + + free(blank_mb); if (current_x == current_x_save || current->data[current_x] == '\0') diff --git a/src/winio.c b/src/winio.c index 328fafc3..f670e33f 100644 --- a/src/winio.c +++ b/src/winio.c @@ -1803,9 +1803,27 @@ void do_statusbar_home(void) #ifndef NANO_SMALL if (ISSET(SMART_HOME)) { size_t statusbar_x_save = statusbar_x; - for (statusbar_x = 0; is_blank_char(answer[statusbar_x]) && - statusbar_x < statusbar_xend; statusbar_x++) - ; + char *blank_mb = charalloc(mb_cur_max()); + int blank_mb_len; + + statusbar_x = 0; + + while (statusbar_x < statusbar_xend) { + blank_mb_len = parse_mbchar(answer + statusbar_x, + blank_mb +#ifdef NANO_WIDE + , NULL +#endif + , NULL); + + if (!is_blank_mbchar(blank_mb)) + break; + + statusbar_x += blank_mb_len; + } + + free(blank_mb); + if (statusbar_x == statusbar_x_save || statusbar_x == statusbar_xend) statusbar_x = 0;