aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/path.c
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2015-01-26 21:08:52 -0500
committerJustin M. Keyes <justinkz@gmail.com>2015-01-26 21:08:52 -0500
commit6bc8c7be3a808f66d2c47bfe463a1346490da7f4 (patch)
tree80d0fde12c759fa9e64e40fae2c2bcad13591398 /src/nvim/path.c
parent75a1006a20c5be7add44ed709ad34ae9fb3fce7b (diff)
parent5deb06597ce72470a5cc86d4f52ee9b025288228 (diff)
downloadrneovim-6bc8c7be3a808f66d2c47bfe463a1346490da7f4.tar.gz
rneovim-6bc8c7be3a808f66d2c47bfe463a1346490da7f4.tar.bz2
rneovim-6bc8c7be3a808f66d2c47bfe463a1346490da7f4.zip
Merge pull request #1867 from elmart/nonnull-deadcode
Remove deadcode due to nonnullret funcs.
Diffstat (limited to 'src/nvim/path.c')
-rw-r--r--src/nvim/path.c26
1 files changed, 11 insertions, 15 deletions
diff --git a/src/nvim/path.c b/src/nvim/path.c
index 219dac12de..e5f78440c2 100644
--- a/src/nvim/path.c
+++ b/src/nvim/path.c
@@ -239,33 +239,31 @@ int vim_ispathlistsep(int c)
* Shorten the path of a file from "~/foo/../.bar/fname" to "~/f/../.b/fname"
* It's done in-place.
*/
-void shorten_dir(char_u *str)
+char_u *shorten_dir(char_u *str)
{
- char_u *tail, *s, *d;
- int skip = FALSE;
-
- tail = path_tail(str);
- d = str;
- for (s = str;; ++s) {
+ char_u *tail = path_tail(str);
+ char_u *d = str;
+ bool skip = false;
+ for (char_u *s = str;; ++s) {
if (s >= tail) { /* copy the whole tail */
*d++ = *s;
if (*s == NUL)
break;
} else if (vim_ispathsep(*s)) { /* copy '/' and next char */
*d++ = *s;
- skip = FALSE;
+ skip = false;
} else if (!skip) {
*d++ = *s; /* copy next char */
if (*s != '~' && *s != '.') /* and leading "~" and "." */
- skip = TRUE;
+ skip = true;
if (has_mbyte) {
int l = mb_ptr2len(s);
-
while (--l > 0)
*d++ = *++s;
}
}
}
+ return str;
}
/*
@@ -883,11 +881,9 @@ static void uniquefy_paths(garray_T *gap, char_u *pattern)
}
free(curdir);
- if (in_curdir != NULL) {
- for (int i = 0; i < gap->ga_len; i++)
- free(in_curdir[i]);
- free(in_curdir);
- }
+ for (int i = 0; i < gap->ga_len; i++)
+ free(in_curdir[i]);
+ free(in_curdir);
ga_clear_strings(&path_ga);
vim_regfree(regmatch.regprog);