aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/path.c
diff options
context:
space:
mode:
authorJurica Bradaric <jbradaric@gmail.com>2016-02-09 20:25:08 +0100
committerJurica Bradaric <jbradaric@gmail.com>2016-02-09 23:08:24 +0100
commite8dd9967034c89d0493c7dffe13cfd08bab9e83a (patch)
tree185930f72340ee04c1ad822e2e89ebf825accbee /src/nvim/path.c
parent84281bf675f77f417d26a68611406ef43fd82f7f (diff)
downloadrneovim-e8dd9967034c89d0493c7dffe13cfd08bab9e83a.tar.gz
rneovim-e8dd9967034c89d0493c7dffe13cfd08bab9e83a.tar.bz2
rneovim-e8dd9967034c89d0493c7dffe13cfd08bab9e83a.zip
vim-patch:7.4.835
Problem: Comparing utf-8 sequences does not handle different byte sizes correctly. Solution: Get the byte size of each character. (Dominique Pelle) https://github.com/vim/vim/commit/f6470c288cb6f8efd60a507baf2c070f9d209ae6
Diffstat (limited to 'src/nvim/path.c')
-rw-r--r--src/nvim/path.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/nvim/path.c b/src/nvim/path.c
index 8b9a49dfc0..e0e5f19911 100644
--- a/src/nvim/path.c
+++ b/src/nvim/path.c
@@ -1775,19 +1775,20 @@ bool same_directory(char_u *f1, char_u *f2)
*/
int pathcmp(const char *p, const char *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) {
if (c2 == NUL) /* full match */
return 0;
s = q;
+ i = j;
break;
}
@@ -1811,9 +1812,13 @@ int pathcmp(const char *p, const char *q, int maxlen)
return p_fic ? vim_toupper(c1) - vim_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);
c2 = PTR2CHAR((char_u *)s + i + MB_PTR2LEN((char_u *)s + i));