summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2015-08-25 16:31:40 +0200
committerBram Moolenaar <Bram@vim.org>2015-08-25 16:31:40 +0200
commitf6470c288cb6f8efd60a507baf2c070f9d209ae6 (patch)
tree9cce4dad7812c2537f5a613abd547de61c655ee8
parent7e47d1ac6a9ae0e5a7167aa34ff651a9c39c1641 (diff)
patch 7.4.835v7.4.835
Problem: Comparing utf-8 sequences does not handle different byte sizes correctly. Solution: Get the byte size of each character. (Dominique Pelle)
-rw-r--r--src/misc2.c24
-rw-r--r--src/version.c2
2 files changed, 16 insertions, 10 deletions
diff --git a/src/misc2.c b/src/misc2.c
index 79bc379911..a4a65d6aa6 100644
--- a/src/misc2.c
+++ b/src/misc2.c
@@ -5058,7 +5058,7 @@ ff_wc_equal(s1, s2)
char_u *s1;
char_u *s2;
{
- int i;
+ int i, j;
int prev1 = NUL;
int prev2 = NUL;
@@ -5068,19 +5068,19 @@ ff_wc_equal(s1, s2)
if (s1 == NULL || s2 == NULL)
return FALSE;
- if (STRLEN(s1) != STRLEN(s2))
- return FAIL;
-
- for (i = 0; s1[i] != NUL && s2[i] != NUL; i += MB_PTR2LEN(s1 + i))
+ for (i = 0, j = 0; s1[i] != NUL;)
{
int c1 = PTR2CHAR(s1 + i);
- int c2 = PTR2CHAR(s2 + i);
+ int c2 = PTR2CHAR(s2 + j);
if ((p_fic ? MB_TOLOWER(c1) != MB_TOLOWER(c2) : c1 != c2)
&& (prev1 != '*' || prev2 != '*'))
return FAIL;
prev2 = prev1;
prev1 = c1;
+
+ i += MB_PTR2LEN(s1 + i);
+ j += MB_PTR2LEN(s2 + j);
}
return TRUE;
}
@@ -5814,14 +5814,14 @@ pathcmp(p, q, maxlen)
const char *p, *q;
int maxlen;
{
- int i;
+ int i, j;
int c1, c2;
const char *s = NULL;
- for (i = 0; maxlen < 0 || i < maxlen; i += MB_PTR2LEN((char_u *)p + i))
+ for (i = 0, j = 0; maxlen < 0 || (i < maxlen && j < maxlen);)
{
c1 = PTR2CHAR((char_u *)p + i);
- c2 = PTR2CHAR((char_u *)q + i);
+ c2 = PTR2CHAR((char_u *)q + j);
/* End of "p": check if "q" also ends or just has a slash. */
if (c1 == NUL)
@@ -5829,6 +5829,7 @@ pathcmp(p, q, maxlen)
if (c2 == NUL) /* full match */
return 0;
s = q;
+ i = j;
break;
}
@@ -5854,8 +5855,11 @@ pathcmp(p, q, maxlen)
return p_fic ? MB_TOUPPER(c1) - MB_TOUPPER(c2)
: c1 - c2; /* no match */
}
+
+ i += MB_PTR2LEN((char_u *)p + i);
+ j += MB_PTR2LEN((char_u *)q + j);
}
- if (s == NULL) /* "i" ran into "maxlen" */
+ if (s == NULL) /* "i" or "j" ran into "maxlen" */
return 0;
c1 = PTR2CHAR((char_u *)s + i);
diff --git a/src/version.c b/src/version.c
index 3e46e0fddc..1301f2bf2c 100644
--- a/src/version.c
+++ b/src/version.c
@@ -742,6 +742,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 835,
+/**/
834,
/**/
833,