summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <bram@vim.org>2013-03-19 18:31:49 +0100
committerBram Moolenaar <bram@vim.org>2013-03-19 18:31:49 +0100
commitbe2b1c7ce5269dcd530156d41c56fa557c67fe9a (patch)
tree517a6db3b1d6b57a4261b6f4aa96aa06a48e203f
parent83594705df15f9ed65eda42f721435e47905780c (diff)
downloadvim-be2b1c7ce5269dcd530156d41c56fa557c67fe9a.tar.gz
updated for version 7.3.874v7.3.874v7-3-874
Problem: Comparing file names does not handle multi-byte characters properly. Solution: Implement multi-byte handling.
-rw-r--r--src/misc1.c26
-rw-r--r--src/misc2.c24
-rw-r--r--src/version.c2
3 files changed, 30 insertions, 22 deletions
diff --git a/src/misc1.c b/src/misc1.c
index 1cad0f53..7c2d3505 100644
--- a/src/misc1.c
+++ b/src/misc1.c
@@ -5049,20 +5049,28 @@ vim_fnamencmp(x, y, len)
size_t len;
{
#ifdef BACKSLASH_IN_FILENAME
+ char_u *px = x;
+ char_u *py = y;
+ int cx = NUL;
+ int cy = NUL;
+
/* TODO: multi-byte characters. */
- while (len > 0 && *x && *y)
- {
- if ((p_fic ? TOLOWER_LOC(*x) != TOLOWER_LOC(*y) : *x != *y)
- && !(*x == '/' && *y == '\\')
- && !(*x == '\\' && *y == '/'))
+ while (len > 0)
+ {
+ cx = PTR2CHAR(px);
+ cy = PTR2CHAR(py);
+ if (cx == NUL || cy == NUL
+ || ((p_fic ? MB_TOLOWER(cx) != MB_TOLOWER(cy) : cx != cy)
+ && !(cx == '/' && cy == '\\')
+ && !(cx == '\\' && cy == '/')))
break;
- ++x;
- ++y;
- --len;
+ len -= MB_PTR2LEN(px);
+ px += MB_PTR2LEN(px);
+ py += MB_PTR2LEN(py);
}
if (len == 0)
return 0;
- return (*x - *y);
+ return (cx - cy);
#else
if (p_fic)
return MB_STRNICMP(x, y, len);
diff --git a/src/misc2.c b/src/misc2.c
index f075639b..bfffd2e8 100644
--- a/src/misc2.c
+++ b/src/misc2.c
@@ -5352,6 +5352,8 @@ ff_wc_equal(s1, s2)
char_u *s2;
{
int i;
+ int prev1 = NUL;
+ int prev2 = NUL;
if (s1 == s2)
return TRUE;
@@ -5362,20 +5364,16 @@ ff_wc_equal(s1, s2)
if (STRLEN(s1) != STRLEN(s2))
return FAIL;
- /* TODO: handle multi-byte characters. */
- for (i = 0; s1[i] != NUL && s2[i] != NUL; i++)
+ for (i = 0; s1[i] != NUL && s2[i] != NUL; i += MB_PTR2LEN(s1 + i))
{
- if (s1[i] != s2[i]
- && (!p_fic || TOUPPER_LOC(s1[i]) != TOUPPER_LOC(s2[i])))
- {
- if (i >= 2)
- if (s1[i-1] == '*' && s1[i-2] == '*')
- continue;
- else
- return FAIL;
- else
- return FAIL;
- }
+ int c1 = PTR2CHAR(s1 + i);
+ int c2 = PTR2CHAR(s2 + i);
+
+ if ((p_fic ? MB_TOLOWER(c1) != MB_TOLOWER(c2) : c1 != c2)
+ && (prev1 != '*' || prev2 != '*'))
+ return FAIL;
+ prev2 = prev1;
+ prev1 = c1;
}
return TRUE;
}
diff --git a/src/version.c b/src/version.c
index 82eca728..d7e07550 100644
--- a/src/version.c
+++ b/src/version.c
@@ -729,6 +729,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 874,
+/**/
873,
/**/
872,