0
0
mirror of https://github.com/vim/vim.git synced 2025-09-23 03:43:49 -04:00

updated for version 7.3.874

Problem:    Comparing file names does not handle multi-byte characters
            properly.
Solution:   Implement multi-byte handling.
This commit is contained in:
Bram Moolenaar
2013-03-19 18:31:49 +01:00
parent c2c355df6f
commit d0e2d94589
3 changed files with 29 additions and 21 deletions

View File

@@ -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;
}