mirror of
https://github.com/vim/vim.git
synced 2025-09-24 03:44:06 -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:
24
src/misc1.c
24
src/misc1.c
@@ -5049,20 +5049,28 @@ vim_fnamencmp(x, y, len)
|
|||||||
size_t len;
|
size_t len;
|
||||||
{
|
{
|
||||||
#ifdef BACKSLASH_IN_FILENAME
|
#ifdef BACKSLASH_IN_FILENAME
|
||||||
|
char_u *px = x;
|
||||||
|
char_u *py = y;
|
||||||
|
int cx = NUL;
|
||||||
|
int cy = NUL;
|
||||||
|
|
||||||
/* TODO: multi-byte characters. */
|
/* TODO: multi-byte characters. */
|
||||||
while (len > 0 && *x && *y)
|
while (len > 0)
|
||||||
{
|
{
|
||||||
if ((p_fic ? TOLOWER_LOC(*x) != TOLOWER_LOC(*y) : *x != *y)
|
cx = PTR2CHAR(px);
|
||||||
&& !(*x == '/' && *y == '\\')
|
cy = PTR2CHAR(py);
|
||||||
&& !(*x == '\\' && *y == '/'))
|
if (cx == NUL || cy == NUL
|
||||||
|
|| ((p_fic ? MB_TOLOWER(cx) != MB_TOLOWER(cy) : cx != cy)
|
||||||
|
&& !(cx == '/' && cy == '\\')
|
||||||
|
&& !(cx == '\\' && cy == '/')))
|
||||||
break;
|
break;
|
||||||
++x;
|
len -= MB_PTR2LEN(px);
|
||||||
++y;
|
px += MB_PTR2LEN(px);
|
||||||
--len;
|
py += MB_PTR2LEN(py);
|
||||||
}
|
}
|
||||||
if (len == 0)
|
if (len == 0)
|
||||||
return 0;
|
return 0;
|
||||||
return (*x - *y);
|
return (cx - cy);
|
||||||
#else
|
#else
|
||||||
if (p_fic)
|
if (p_fic)
|
||||||
return MB_STRNICMP(x, y, len);
|
return MB_STRNICMP(x, y, len);
|
||||||
|
24
src/misc2.c
24
src/misc2.c
@@ -5352,6 +5352,8 @@ ff_wc_equal(s1, s2)
|
|||||||
char_u *s2;
|
char_u *s2;
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
int prev1 = NUL;
|
||||||
|
int prev2 = NUL;
|
||||||
|
|
||||||
if (s1 == s2)
|
if (s1 == s2)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@@ -5362,20 +5364,16 @@ ff_wc_equal(s1, s2)
|
|||||||
if (STRLEN(s1) != STRLEN(s2))
|
if (STRLEN(s1) != STRLEN(s2))
|
||||||
return FAIL;
|
return FAIL;
|
||||||
|
|
||||||
/* TODO: handle multi-byte characters. */
|
for (i = 0; s1[i] != NUL && s2[i] != NUL; i += MB_PTR2LEN(s1 + i))
|
||||||
for (i = 0; s1[i] != NUL && s2[i] != NUL; i++)
|
|
||||||
{
|
{
|
||||||
if (s1[i] != s2[i]
|
int c1 = PTR2CHAR(s1 + i);
|
||||||
&& (!p_fic || TOUPPER_LOC(s1[i]) != TOUPPER_LOC(s2[i])))
|
int c2 = PTR2CHAR(s2 + i);
|
||||||
{
|
|
||||||
if (i >= 2)
|
if ((p_fic ? MB_TOLOWER(c1) != MB_TOLOWER(c2) : c1 != c2)
|
||||||
if (s1[i-1] == '*' && s1[i-2] == '*')
|
&& (prev1 != '*' || prev2 != '*'))
|
||||||
continue;
|
return FAIL;
|
||||||
else
|
prev2 = prev1;
|
||||||
return FAIL;
|
prev1 = c1;
|
||||||
else
|
|
||||||
return FAIL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@@ -728,6 +728,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
874,
|
||||||
/**/
|
/**/
|
||||||
873,
|
873,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user