fix multibyte bracket search breakage, and add documentation fixes
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3261 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
Этот коммит содержится в:
родитель
1a16df9284
Коммит
db2dc81cee
@ -79,8 +79,9 @@ strings.
|
||||
.TP
|
||||
.B set matchbrackets "\fIstring\fP"
|
||||
Set the opening and closing brackets that can be found by bracket
|
||||
searches. The former set must come before the latter set, and both must
|
||||
be in the same order. The default value is "\fI(<[{)>]}\fP".
|
||||
searches. They cannot contain blank characters. The former set must
|
||||
come before the latter set, and both must be in the same order. The
|
||||
default value is "\fI(<[{)>]}\fP".
|
||||
.TP
|
||||
.B set/unset morespace
|
||||
Allow use of the blank line below the titlebar as extra editing space.
|
||||
|
@ -46,8 +46,8 @@
|
||||
# set historylog
|
||||
|
||||
## The opening and closing brackets that can be found by bracket
|
||||
## searches. The former set must come before the latter set, and both
|
||||
## must be in the same order.
|
||||
## searches. They cannot contain blank characters. The former set must
|
||||
## come before the latter set, and both must be in the same order.
|
||||
##
|
||||
# set matchbrackets "(<[{)>]}"
|
||||
|
||||
|
20
src/prompt.c
20
src/prompt.c
@ -723,8 +723,14 @@ void do_statusbar_find_bracket(void)
|
||||
/* The length of wanted_ch in bytes. */
|
||||
char *bracket_set;
|
||||
/* The pair of characters in ch and wanted_ch. */
|
||||
size_t i;
|
||||
/* Generic loop variable. */
|
||||
size_t matchhalf;
|
||||
/* The number of characters in one half of matchbrackets. */
|
||||
/* The number of single-byte characters in one half of
|
||||
* matchbrackets. */
|
||||
size_t mbmatchhalf;
|
||||
/* The number of multibyte characters in one half of
|
||||
* matchbrackets. */
|
||||
size_t count = 1;
|
||||
/* The initial bracket count. */
|
||||
bool reverse;
|
||||
@ -748,7 +754,13 @@ void do_statusbar_find_bracket(void)
|
||||
* bracket. If we're on a closing bracket, which must be in the
|
||||
* second half of matchbrackets, we want to search backwards for an
|
||||
* opening bracket. */
|
||||
matchhalf = mbstrlen(matchbrackets) / 2;
|
||||
matchhalf = 0;
|
||||
mbmatchhalf = mbstrlen(matchbrackets) / 2;
|
||||
|
||||
for (i = 0; i < mbmatchhalf; i++)
|
||||
matchhalf += parse_mbchar(matchbrackets + matchhalf, NULL,
|
||||
NULL);
|
||||
|
||||
reverse = ((ch - matchbrackets) > matchhalf);
|
||||
|
||||
/* If we're on an opening bracket, set wanted_ch to the character
|
||||
@ -757,14 +769,14 @@ void do_statusbar_find_bracket(void)
|
||||
* characters before ch. */
|
||||
wanted_ch = ch;
|
||||
|
||||
while (matchhalf > 0) {
|
||||
while (mbmatchhalf > 0) {
|
||||
if (reverse)
|
||||
wanted_ch = matchbrackets + move_mbleft(matchbrackets,
|
||||
wanted_ch - matchbrackets);
|
||||
else
|
||||
wanted_ch += move_mbright(wanted_ch, 0);
|
||||
|
||||
matchhalf--;
|
||||
mbmatchhalf--;
|
||||
}
|
||||
|
||||
ch_len = parse_mbchar(ch, NULL, NULL);
|
||||
|
20
src/search.c
20
src/search.c
@ -1142,8 +1142,14 @@ void do_find_bracket(void)
|
||||
/* The length of wanted_ch in bytes. */
|
||||
char *bracket_set;
|
||||
/* The pair of characters in ch and wanted_ch. */
|
||||
size_t i;
|
||||
/* Generic loop variable. */
|
||||
size_t matchhalf;
|
||||
/* The number of characters in one half of matchbrackets. */
|
||||
/* The number of single-byte characters in one half of
|
||||
* matchbrackets. */
|
||||
size_t mbmatchhalf;
|
||||
/* The number of multibyte characters in one half of
|
||||
* matchbrackets. */
|
||||
size_t count = 1;
|
||||
/* The initial bracket count. */
|
||||
bool reverse;
|
||||
@ -1170,7 +1176,13 @@ void do_find_bracket(void)
|
||||
* bracket. If we're on a closing bracket, which must be in the
|
||||
* second half of matchbrackets, we want to search backwards for an
|
||||
* opening bracket. */
|
||||
matchhalf = mbstrlen(matchbrackets) / 2;
|
||||
matchhalf = 0;
|
||||
mbmatchhalf = mbstrlen(matchbrackets) / 2;
|
||||
|
||||
for (i = 0; i < mbmatchhalf; i++)
|
||||
matchhalf += parse_mbchar(matchbrackets + matchhalf, NULL,
|
||||
NULL);
|
||||
|
||||
reverse = ((ch - matchbrackets) > matchhalf);
|
||||
|
||||
/* If we're on an opening bracket, set wanted_ch to the character
|
||||
@ -1179,14 +1191,14 @@ void do_find_bracket(void)
|
||||
* characters before ch. */
|
||||
wanted_ch = ch;
|
||||
|
||||
while (matchhalf > 0) {
|
||||
while (mbmatchhalf > 0) {
|
||||
if (reverse)
|
||||
wanted_ch = matchbrackets + move_mbleft(matchbrackets,
|
||||
wanted_ch - matchbrackets);
|
||||
else
|
||||
wanted_ch += move_mbright(wanted_ch, 0);
|
||||
|
||||
matchhalf--;
|
||||
mbmatchhalf--;
|
||||
}
|
||||
|
||||
ch_len = parse_mbchar(ch, NULL, NULL);
|
||||
|
Загрузка…
Ссылка в новой задаче
Block a user