aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMark Bainter <mbainter+github@gmail.com>2015-04-20 15:05:21 +0000
committerMark Bainter <mbainter+github@gmail.com>2015-05-06 21:25:05 -0500
commit7774b97d5773a98996ff5d30007570c181546cb1 (patch)
treefb744120a34a756cd2e6da719b6da11b15923af0 /src
parent80180bf94e84df7d8732a786065c8e3e3dd17b09 (diff)
downloadrneovim-7774b97d5773a98996ff5d30007570c181546cb1.tar.gz
rneovim-7774b97d5773a98996ff5d30007570c181546cb1.tar.bz2
rneovim-7774b97d5773a98996ff5d30007570c181546cb1.zip
Remove char_u: fix_fname()
Diffstat (limited to 'src')
-rw-r--r--src/nvim/buffer.c2
-rw-r--r--src/nvim/ex_cmds.c4
-rw-r--r--src/nvim/ex_cmds2.c6
-rw-r--r--src/nvim/memline.c2
-rw-r--r--src/nvim/path.c38
5 files changed, 25 insertions, 27 deletions
diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c
index eadee8465f..094e80086c 100644
--- a/src/nvim/buffer.c
+++ b/src/nvim/buffer.c
@@ -3569,7 +3569,7 @@ void fname_expand(buf_T *buf, char_u **ffname, char_u **sfname)
return;
if (*sfname == NULL) /* if no short file name given, use ffname */
*sfname = *ffname;
- *ffname = fix_fname(*ffname); /* expand to full path */
+ *ffname = (char_u *)fix_fname((char *)*ffname); /* expand to full path */
#ifdef FEAT_SHORTCUT
if (!buf->b_p_bin) {
diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c
index bc2485afc6..62c2d4ac98 100644
--- a/src/nvim/ex_cmds.c
+++ b/src/nvim/ex_cmds.c
@@ -2080,7 +2080,7 @@ int do_write(exarg_T *eap)
other = FALSE;
} else {
fname = ffname;
- free_fname = fix_fname(ffname);
+ free_fname = (char_u *)fix_fname((char *)ffname);
/*
* When out-of-memory, keep unexpanded file name, because we MUST be
* able to write the file in this situation.
@@ -2579,7 +2579,7 @@ do_ecmd (
ffname = curbuf->b_ffname;
sfname = curbuf->b_fname;
}
- free_fname = fix_fname(ffname); /* may expand to full path name */
+ free_fname = (char_u *)fix_fname((char *)ffname); /* may expand to full path name */
if (free_fname != NULL)
ffname = free_fname;
other_file = otherfile(ffname);
diff --git a/src/nvim/ex_cmds2.c b/src/nvim/ex_cmds2.c
index 6f60b1189a..08d84c2440 100644
--- a/src/nvim/ex_cmds2.c
+++ b/src/nvim/ex_cmds2.c
@@ -495,7 +495,7 @@ dbg_parsearg (
if (p == NULL)
return FAIL;
if (*p != '*') {
- bp->dbg_name = fix_fname(p);
+ bp->dbg_name = (char_u *)fix_fname((char *)p);
xfree(p);
} else
bp->dbg_name = p;
@@ -1692,7 +1692,7 @@ void do_argfile(exarg_T *eap, int argn)
*/
other = TRUE;
if (P_HID(curbuf)) {
- p = fix_fname(alist_name(&ARGLIST[argn]));
+ p = (char_u *)fix_fname((char *)alist_name(&ARGLIST[argn]));
other = otherfile(p);
xfree(p);
}
@@ -2313,7 +2313,7 @@ do_source (
p = expand_env_save(fname);
if (p == NULL)
return retval;
- fname_exp = fix_fname(p);
+ fname_exp = (char_u *)fix_fname((char *)p);
xfree(p);
if (fname_exp == NULL)
return retval;
diff --git a/src/nvim/memline.c b/src/nvim/memline.c
index 3b4ee502cf..daaaebc4db 100644
--- a/src/nvim/memline.c
+++ b/src/nvim/memline.c
@@ -1445,7 +1445,7 @@ static char_u *make_percent_swname(char_u *dir, char_u *name)
{
char_u *d, *s, *f;
- f = fix_fname(name != NULL ? name : (char_u *) "");
+ f = (char_u *)fix_fname(name != NULL ? (char *)name : "");
d = NULL;
if (f != NULL) {
s = (char_u *)xstrdup((char *)f);
diff --git a/src/nvim/path.c b/src/nvim/path.c
index 01d4bad0f1..3d1d1629dc 100644
--- a/src/nvim/path.c
+++ b/src/nvim/path.c
@@ -1578,36 +1578,34 @@ int vim_FullName(char *fname, char *buf, int len, bool force)
return retval;
}
-/*
- * If fname is not a full path, make it a full path.
- * Returns pointer to allocated memory (NULL for failure).
- */
-char_u *fix_fname(char_u *fname)
+/// Get the full resolved path for `fname`
+///
+/// Even filenames that appear to be absolute based on starting from
+/// the root may have relative paths (like dir/../subdir) or symlinks
+/// embedded, or even extra separators (//). This function addresses
+/// those possibilities, returning a resolved absolute path.
+/// For MS-Windows, this also expands names like "longna~1".
+///
+/// @param fname is the filename to expand
+/// @return [allocated] Full path (NULL for failure).
+char *fix_fname(char *fname)
{
- /*
- * Force expanding the path always for Unix, because symbolic links may
- * mess up the full path name, even though it starts with a '/'.
- * Also expand when there is ".." in the file name, try to remove it,
- * because "c:/src/../README" is equal to "c:/README".
- * Similarly "c:/src//file" is equal to "c:/src/file".
- * For MS-Windows also expand names like "longna~1" to "longname".
- */
#ifdef UNIX
- return (char_u *)FullName_save((char *)fname, TRUE);
+ return FullName_save(fname, TRUE);
#else
- if (!vim_isAbsName(fname)
- || strstr((char *)fname, "..") != NULL
- || strstr((char *)fname, "//") != NULL
+ if (!vim_isAbsName((char_u *)fname)
+ || strstr(fname, "..") != NULL
+ || strstr(fname, "//") != NULL
# ifdef BACKSLASH_IN_FILENAME
- || strstr((char *)fname, "\\\\") != NULL
+ || strstr(fname, "\\\\") != NULL
# endif
)
return FullName_save(fname, FALSE);
- fname = vim_strsave(fname);
+ fname = xstrdup(fname);
# ifdef USE_FNAME_CASE
- path_fix_case(fname); // set correct case for file name
+ path_fix_case((char_u *)fname); // set correct case for file name
# endif
return fname;