From 2cb026c65c489743b3c5a4955dc9f276a18bd530 Mon Sep 17 00:00:00 2001 From: John Schmidt Date: Mon, 31 Mar 2014 00:27:50 +0200 Subject: [PATCH] Move fix_fname from buffer.c --- src/buffer.c | 42 ------------------------------------------ src/buffer.h | 1 - src/path.c | 42 ++++++++++++++++++++++++++++++++++++++++++ src/path.h | 1 + 4 files changed, 43 insertions(+), 43 deletions(-) diff --git a/src/buffer.c b/src/buffer.c index 4486611540..c181d1d7c5 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -3620,48 +3620,6 @@ append_arg_number ( return TRUE; } -/* - * 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) -{ - /* - * 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 FullName_save(fname, TRUE); -#else - if (!vim_isAbsName(fname) - || strstr((char *)fname, "..") != NULL - || strstr((char *)fname, "//") != NULL -# ifdef BACKSLASH_IN_FILENAME - || strstr((char *)fname, "\\\\") != NULL -# endif - ) - return FullName_save(fname, FALSE); - - fname = vim_strsave(fname); - -# ifdef USE_FNAME_CASE -# ifdef USE_LONG_FNAME - if (USE_LONG_FNAME) -# endif - { - if (fname != NULL) - fname_case(fname, 0); /* set correct case for file name */ - } -# endif - - return fname; -#endif -} - /* * Make "ffname" a full file name, set "sfname" to "ffname" if not NULL. * "ffname" becomes a pointer to allocated memory (or NULL). diff --git a/src/buffer.h b/src/buffer.h index f25a3a1b21..740d001b5e 100644 --- a/src/buffer.h +++ b/src/buffer.h @@ -54,7 +54,6 @@ int build_stl_str_hl(win_T *wp, char_u *out, size_t outlen, char_u *fmt, struct stl_hlrec *hltab, struct stl_hlrec *tabtab); void get_rel_pos(win_T *wp, char_u *buf, int buflen); -char_u *fix_fname(char_u *fname); void fname_expand(buf_T *buf, char_u **ffname, char_u **sfname); char_u *alist_name(aentry_T *aep); void do_arg_all(int count, int forceit, int keep_tabs); diff --git a/src/path.c b/src/path.c index f7d64fba45..a83f4f3fd9 100644 --- a/src/path.c +++ b/src/path.c @@ -1620,3 +1620,45 @@ vim_FullName ( 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) +{ + /* + * 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 FullName_save(fname, TRUE); +#else + if (!vim_isAbsName(fname) + || strstr((char *)fname, "..") != NULL + || strstr((char *)fname, "//") != NULL +# ifdef BACKSLASH_IN_FILENAME + || strstr((char *)fname, "\\\\") != NULL +# endif + ) + return FullName_save(fname, FALSE); + + fname = vim_strsave(fname); + +# ifdef USE_FNAME_CASE +# ifdef USE_LONG_FNAME + if (USE_LONG_FNAME) +# endif + { + if (fname != NULL) + fname_case(fname, 0); /* set correct case for file name */ + } +# endif + + return fname; +#endif +} + diff --git a/src/path.h b/src/path.h index 49ce94dcdf..18c52694b7 100644 --- a/src/path.h +++ b/src/path.h @@ -30,4 +30,5 @@ int path_is_url(char_u *p); int path_with_url(char_u *fname); int vim_isAbsName(char_u *name); int vim_FullName(char_u *fname, char_u *buf, int len, int force); +char_u *fix_fname(char_u *fname); #endif