diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2016-02-17 03:49:57 -0500 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2016-02-17 03:49:57 -0500 |
commit | 5f54519b4f2e4768e2541be39f67a33331f98bc4 (patch) | |
tree | 9aa4587fb621218f1042022a82d7ccfbc7db5278 /src/nvim/path.c | |
parent | 6dc39d84cf03ecc64f768638dab33157d4398195 (diff) | |
parent | a21becf7ee1cb9079b1d97da282538ad43d74352 (diff) | |
download | rneovim-5f54519b4f2e4768e2541be39f67a33331f98bc4.tar.gz rneovim-5f54519b4f2e4768e2541be39f67a33331f98bc4.tar.bz2 rneovim-5f54519b4f2e4768e2541be39f67a33331f98bc4.zip |
Merge pull request #4213 from jbradaric/vim-7.4.835
vim-patch:7.4.{835,843,877}
Diffstat (limited to 'src/nvim/path.c')
-rw-r--r-- | src/nvim/path.c | 13 |
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)); |