summaryrefslogtreecommitdiff
path: root/src/search.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2013-01-17 17:02:05 +0100
committerBram Moolenaar <Bram@vim.org>2013-01-17 17:02:05 +0100
commit8c7694a8649cbd5ce91c150737b1f52b20631cb4 (patch)
tree6a476ff564c1af698be7b437c756761b2e47838e /src/search.c
parent3e37fd0950081e277fac44a0bd8e60815898945c (diff)
downloadvim-git-8c7694a8649cbd5ce91c150737b1f52b20631cb4.tar.gz
updated for version 7.3.769v7.3.769
Problem: 'matchpairs' does not work with multi-byte characters. Solution: Make it work. (Christian Brabandt)
Diffstat (limited to 'src/search.c')
-rw-r--r--src/search.c70
1 files changed, 16 insertions, 54 deletions
diff --git a/src/search.c b/src/search.c
index d7bfc43b1..0b1c519fb 100644
--- a/src/search.c
+++ b/src/search.c
@@ -1786,28 +1786,8 @@ findmatchlimit(oap, initc, flags, maxtravel)
}
else if (initc != '#' && initc != NUL)
{
- /* 'matchpairs' is "x:y,x:y" */
- for (ptr = curbuf->b_p_mps; *ptr; ptr += 2)
- {
- if (*ptr == initc)
- {
- findc = initc;
- initc = ptr[2];
- backwards = TRUE;
- break;
- }
- ptr += 2;
- if (*ptr == initc)
- {
- findc = initc;
- initc = ptr[-2];
- backwards = FALSE;
- break;
- }
- if (ptr[1] != ',')
- break;
- }
- if (!findc) /* invalid initc! */
+ find_mps_values(&initc, &findc, &backwards, TRUE);
+ if (findc == NUL)
return NULL;
}
/*
@@ -1886,36 +1866,14 @@ findmatchlimit(oap, initc, flags, maxtravel)
--pos.col;
for (;;)
{
- initc = linep[pos.col];
+ initc = PTR2CHAR(linep + pos.col);
if (initc == NUL)
break;
- for (ptr = curbuf->b_p_mps; *ptr; ++ptr)
- {
- if (*ptr == initc)
- {
- findc = ptr[2];
- backwards = FALSE;
- break;
- }
- ptr += 2;
- if (*ptr == initc)
- {
- findc = ptr[-2];
- backwards = TRUE;
- break;
- }
- if (!*++ptr)
- break;
- }
+ find_mps_values(&initc, &findc, &backwards, FALSE);
if (findc)
break;
-#ifdef FEAT_MBYTE
- if (has_mbyte)
- pos.col += (*mb_ptr2len)(linep + pos.col);
- else
-#endif
- ++pos.col;
+ pos.col += MB_PTR2LEN(linep + pos.col);
}
if (!findc)
{
@@ -2260,7 +2218,8 @@ findmatchlimit(oap, initc, flags, maxtravel)
* inquote if the number of quotes in a line is even, unless this
* line or the previous one ends in a '\'. Complicated, isn't it?
*/
- switch (c = linep[pos.col])
+ c = PTR2CHAR(linep + pos.col);
+ switch (c)
{
case NUL:
/* at end of line without trailing backslash, reset inquote */
@@ -2469,20 +2428,23 @@ showmatch(c)
* Only show match for chars in the 'matchpairs' option.
*/
/* 'matchpairs' is "x:y,x:y" */
- for (p = curbuf->b_p_mps; *p != NUL; p += 2)
+ for (p = curbuf->b_p_mps; *p != NUL; ++p)
{
+ if (PTR2CHAR(p) == c
#ifdef FEAT_RIGHTLEFT
- if (*p == c && (curwin->w_p_rl ^ p_ri))
- break;
+ && (curwin->w_p_rl ^ p_ri)
#endif
- p += 2;
- if (*p == c
+ )
+ break;
+ p += MB_PTR2LEN(p) + 1;
+ if (PTR2CHAR(p) == c
#ifdef FEAT_RIGHTLEFT
&& !(curwin->w_p_rl ^ p_ri)
#endif
)
break;
- if (p[1] != ',')
+ p += MB_PTR2LEN(p);
+ if (*p == NUL)
return;
}