mirror of
https://github.com/neovim/neovim.git
synced 2024-12-20 03:05:11 -07:00
Remove char_u: fix_fname()
This commit is contained in:
parent
80180bf94e
commit
7774b97d57
@ -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) {
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user