aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/nvim/buffer.c2
-rw-r--r--src/nvim/diff.c2
-rw-r--r--src/nvim/eval.c6
-rw-r--r--src/nvim/ex_docmd.c2
-rw-r--r--src/nvim/file_search.c2
-rw-r--r--src/nvim/fileio.c4
-rw-r--r--src/nvim/memfile.c2
-rw-r--r--src/nvim/option.c2
-rw-r--r--src/nvim/path.c40
-rw-r--r--src/nvim/tag.c2
10 files changed, 31 insertions, 33 deletions
diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c
index 395b20b219..eadee8465f 100644
--- a/src/nvim/buffer.c
+++ b/src/nvim/buffer.c
@@ -1661,7 +1661,7 @@ buf_T *buflist_findname_exp(char_u *fname)
buf_T *buf = NULL;
/* First make the name into a full path name */
- ffname = FullName_save(fname,
+ ffname = (char_u *)FullName_save((char *)fname,
#ifdef UNIX
TRUE /* force expansion, get rid of symbolic links */
#else
diff --git a/src/nvim/diff.c b/src/nvim/diff.c
index d4fbb290c1..b21bc1f2f4 100644
--- a/src/nvim/diff.c
+++ b/src/nvim/diff.c
@@ -867,7 +867,7 @@ void ex_diffpatch(exarg_T *eap)
#ifdef UNIX
// Get the absolute path of the patchfile, changing directory below.
- fullname = FullName_save(eap->arg, FALSE);
+ fullname = (char_u *)FullName_save((char *)eap->arg, FALSE);
#endif // ifdef UNIX
#ifdef UNIX
diff --git a/src/nvim/eval.c b/src/nvim/eval.c
index f782259c0d..f291d9f302 100644
--- a/src/nvim/eval.c
+++ b/src/nvim/eval.c
@@ -15484,7 +15484,7 @@ static void f_undofile(typval_T *argvars, typval_T *rettv)
/* If there is no file name there will be no undo file. */
rettv->vval.v_string = NULL;
} else {
- char_u *ffname = FullName_save(fname, FALSE);
+ char_u *ffname = (char_u *)FullName_save((char *)fname, FALSE);
if (ffname != NULL)
rettv->vval.v_string = u_get_undo_file_name(ffname, FALSE);
@@ -19906,7 +19906,7 @@ repeat:
/* FullName_save() is slow, don't use it when not needed. */
if (*p != NUL || !vim_isAbsName(*fnamep)) {
- *fnamep = FullName_save(*fnamep, *p != NUL);
+ *fnamep = (char_u *)FullName_save((char *)*fnamep, *p != NUL);
xfree(*bufp); /* free any allocated file name */
*bufp = *fnamep;
if (*fnamep == NULL)
@@ -19940,7 +19940,7 @@ repeat:
if (c == '.' && **fnamep == '~')
p = pbuf = expand_env_save(*fnamep);
else
- p = pbuf = FullName_save(*fnamep, FALSE);
+ p = pbuf = (char_u *)FullName_save((char *)*fnamep, FALSE);
} else
p = *fnamep;
diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c
index 5fe45154dc..289bb85f4d 100644
--- a/src/nvim/ex_docmd.c
+++ b/src/nvim/ex_docmd.c
@@ -8155,7 +8155,7 @@ eval_vars (
/* Still need to turn the fname into a full path. It is
* postponed to avoid a delay when <afile> is not used. */
autocmd_fname_full = TRUE;
- result = FullName_save(autocmd_fname, FALSE);
+ result = (char_u *)FullName_save((char *)autocmd_fname, FALSE);
xfree(autocmd_fname);
autocmd_fname = result;
}
diff --git a/src/nvim/file_search.c b/src/nvim/file_search.c
index 32e4bb4a9e..855de6595f 100644
--- a/src/nvim/file_search.c
+++ b/src/nvim/file_search.c
@@ -313,7 +313,7 @@ vim_findfile_init (
if (!vim_isAbsName(rel_fname) && len + 1 < MAXPATHL) {
/* Make the start dir an absolute path name. */
STRLCPY(ff_expand_buffer, rel_fname, len + 1);
- search_ctx->ffsc_start_dir = FullName_save(ff_expand_buffer, FALSE);
+ search_ctx->ffsc_start_dir = (char_u *)FullName_save((char *)ff_expand_buffer, FALSE);
} else
search_ctx->ffsc_start_dir = vim_strnsave(rel_fname, len);
if (*++path != NUL)
diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c
index 6506bbbae8..511f3c8927 100644
--- a/src/nvim/fileio.c
+++ b/src/nvim/fileio.c
@@ -6599,7 +6599,7 @@ apply_autocmds_group (
|| event == EVENT_TABCLOSED)
fname = vim_strsave(fname);
else
- fname = FullName_save(fname, FALSE);
+ fname = (char_u *)FullName_save((char *)fname, FALSE);
}
if (fname == NULL) { /* out of memory */
xfree(sfname);
@@ -6925,7 +6925,7 @@ int has_autocmd(event_T event, char_u *sfname, buf_T *buf)
char_u *tail = path_tail(sfname);
int retval = FALSE;
- fname = FullName_save(sfname, FALSE);
+ fname = (char_u *)FullName_save((char *)sfname, FALSE);
if (fname == NULL)
return FALSE;
diff --git a/src/nvim/memfile.c b/src/nvim/memfile.c
index bbe2e62021..b6a341d5e8 100644
--- a/src/nvim/memfile.c
+++ b/src/nvim/memfile.c
@@ -893,7 +893,7 @@ blocknr_T mf_trans_del(memfile_T *mfp, blocknr_T old_nr)
/// name so we must work out the full path name.
void mf_set_ffname(memfile_T *mfp)
{
- mfp->mf_ffname = FullName_save(mfp->mf_fname, false);
+ mfp->mf_ffname = (char_u *)FullName_save((char *)mfp->mf_fname, false);
}
/// Make name of memfile's swapfile a full path.
diff --git a/src/nvim/option.c b/src/nvim/option.c
index 33e3f5b459..dcf02513dd 100644
--- a/src/nvim/option.c
+++ b/src/nvim/option.c
@@ -7390,7 +7390,7 @@ void vimrc_found(char_u *fname, char_u *envname)
p = (char_u *)vim_getenv((char *)envname);
if (p == NULL) {
/* Set $MYVIMRC to the first vimrc file found. */
- p = FullName_save(fname, FALSE);
+ p = (char_u *)FullName_save((char *)fname, FALSE);
if (p != NULL) {
vim_setenv((char *)envname, (char *)p);
xfree(p);
diff --git a/src/nvim/path.c b/src/nvim/path.c
index e3aaa30ac8..01d4bad0f1 100644
--- a/src/nvim/path.c
+++ b/src/nvim/path.c
@@ -358,28 +358,26 @@ void add_pathsep(char *p)
strcat(p, PATHSEPSTR);
}
-/*
- * FullName_save - Make an allocated copy of a full file name.
- * Returns NULL when fname is NULL.
- */
-char_u *
-FullName_save (
- char_u *fname,
- int force /* force expansion, even when it already looks
- * like a full path name */
-)
+/// Get an allocated copy of the full path to a file.
+///
+/// @param fname is the filename to save
+/// @param force is a flag to expand `fname` even if it looks absolute
+///
+/// @return [allocated] Copy of absolute path to `fname` or NULL when
+/// `fname` is NULL.
+char *FullName_save(char *fname, bool force)
+ FUNC_ATTR_NONNULL_RET FUNC_ATTR_MALLOC FUNC_ATTR_NONNULL_ALL
{
- char_u *new_fname = NULL;
-
- if (fname == NULL)
+ if (fname == NULL) {
return NULL;
+ }
- char_u *buf = xmalloc(MAXPATHL);
-
- if (vim_FullName((char *)fname, (char *)buf, MAXPATHL, force) != FAIL) {
- new_fname = vim_strsave(buf);
+ char *buf = xmalloc(MAXPATHL);
+ char *new_fname = NULL;
+ if (vim_FullName(fname, buf, MAXPATHL, force) != FAIL) {
+ new_fname = xstrdup(buf);
} else {
- new_fname = vim_strsave(fname);
+ new_fname = xstrdup(fname);
}
xfree(buf);
@@ -393,7 +391,7 @@ char_u *save_absolute_path(const char_u *name)
FUNC_ATTR_MALLOC FUNC_ATTR_NONNULL_RET FUNC_ATTR_NONNULL_ALL
{
if (!path_is_absolute_path(name)) {
- return FullName_save((char_u *) name, true);
+ return (char_u *)FullName_save((char *)name, true);
}
return vim_strsave((char_u *) name);
}
@@ -1595,7 +1593,7 @@ char_u *fix_fname(char_u *fname)
* For MS-Windows also expand names like "longna~1" to "longname".
*/
#ifdef UNIX
- return FullName_save(fname, TRUE);
+ return (char_u *)FullName_save((char *)fname, TRUE);
#else
if (!vim_isAbsName(fname)
|| strstr((char *)fname, "..") != NULL
@@ -1892,7 +1890,7 @@ int expand_wildcards(int num_pat, char_u **pat, int *num_file, char_u ***file,
/* check all files in (*file)[] */
for (i = 0; i < *num_file; ++i) {
- ffname = FullName_save((*file)[i], FALSE);
+ ffname = (char_u *)FullName_save((char *)(*file)[i], FALSE);
if (ffname == NULL) /* out of memory */
break;
if (match_file_list(p_wig, (*file)[i], ffname)) {
diff --git a/src/nvim/tag.c b/src/nvim/tag.c
index df583c66ef..a087986685 100644
--- a/src/nvim/tag.c
+++ b/src/nvim/tag.c
@@ -2380,7 +2380,7 @@ jumpto_tag (
* into a fullpath
*/
if (!curwin->w_p_pvw) {
- full_fname = FullName_save(fname, FALSE);
+ full_fname = (char_u *)FullName_save((char *)fname, FALSE);
fname = full_fname;
/*