summaryrefslogtreecommitdiff
path: root/src/misc1.c
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
commitd0e2d94589d11cad514d1d66ade76d497e9d7567 (patch)
tree158439512a9e8af7f411f006d12a22335dadaee0 /src/misc1.c
parentc2c355df6f094cdb9e599fd395a78c14486ec697 (diff)
downloadvim-git-d0e2d94589d11cad514d1d66ade76d497e9d7567.tar.gz
updated for version 7.3.874v7.3.874
Problem: Comparing file names does not handle multi-byte characters properly. Solution: Implement multi-byte handling.
Diffstat (limited to 'src/misc1.c')
-rw-r--r--src/misc1.c26
1 files changed, 17 insertions, 9 deletions
diff --git a/src/misc1.c b/src/misc1.c
index 1cad0f53b..7c2d35052 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);