mirror of
https://github.com/neovim/neovim.git
synced 2025-09-12 14:28:18 +00:00
Fix seperator->separator, path_tail_with_separator->path_tail_with_sep.
This commit is contained in:

committed by
Thiago de Arruda

parent
955d6a2949
commit
865e3280a8
@@ -2713,7 +2713,7 @@ void maketitle(void)
|
||||
off += 2;
|
||||
#endif
|
||||
/* remove the file name */
|
||||
p = path_tail_with_seperator(buf + off);
|
||||
p = path_tail_with_sep(buf + off);
|
||||
if (p == buf + off)
|
||||
/* must be a help buffer */
|
||||
vim_strncpy(buf + off, (char_u *)_("help"),
|
||||
|
@@ -11657,7 +11657,7 @@ static int mkdir_recurse(char_u *dir, int prot)
|
||||
|
||||
/* Get end of directory name in "dir".
|
||||
* We're done when it's "/" or "c:/". */
|
||||
p = path_tail_with_seperator(dir);
|
||||
p = path_tail_with_sep(dir);
|
||||
if (p <= get_past_head(dir))
|
||||
return OK;
|
||||
|
||||
@@ -11693,7 +11693,7 @@ static void f_mkdir(typval_T *argvars, typval_T *rettv)
|
||||
else {
|
||||
if (*path_tail(dir) == NUL)
|
||||
/* remove trailing slashes */
|
||||
*path_tail_with_seperator(dir) = NUL;
|
||||
*path_tail_with_sep(dir) = NUL;
|
||||
|
||||
if (argvars[1].v_type != VAR_UNKNOWN) {
|
||||
if (argvars[2].v_type != VAR_UNKNOWN)
|
||||
@@ -12544,7 +12544,7 @@ static void f_resolve(typval_T *argvars, typval_T *rettv)
|
||||
if (!has_trailing_pathsep) {
|
||||
q = p + STRLEN(p);
|
||||
if (after_pathsep(p, q))
|
||||
*path_tail_with_seperator(p) = NUL;
|
||||
*path_tail_with_sep(p) = NUL;
|
||||
}
|
||||
|
||||
rettv->vval.v_string = p;
|
||||
|
@@ -1609,7 +1609,7 @@ int vim_chdirfile(char_u *fname)
|
||||
char_u dir[MAXPATHL];
|
||||
|
||||
vim_strncpy(dir, fname, MAXPATHL - 1);
|
||||
*path_tail_with_seperator(dir) = NUL;
|
||||
*path_tail_with_sep(dir) = NUL;
|
||||
return os_chdir((char *)dir) == 0 ? OK : FAIL;
|
||||
}
|
||||
#endif
|
||||
|
@@ -78,7 +78,7 @@ char_u *path_tail(char_u *fname)
|
||||
return tail;
|
||||
}
|
||||
|
||||
char_u *path_tail_with_seperator(char_u *fname)
|
||||
char_u *path_tail_with_sep(char_u *fname)
|
||||
{
|
||||
assert(fname != NULL);
|
||||
char_u *past_head;
|
||||
@@ -210,7 +210,7 @@ int dir_of_file_exists(char_u *fname)
|
||||
int c;
|
||||
int retval;
|
||||
|
||||
p = path_tail_with_seperator(fname);
|
||||
p = path_tail_with_sep(fname);
|
||||
if (p == fname)
|
||||
return TRUE;
|
||||
c = *p;
|
||||
@@ -1644,8 +1644,8 @@ int same_directory(char_u *f1, char_u *f2)
|
||||
return FALSE;
|
||||
|
||||
(void)vim_FullName(f1, ffname, MAXPATHL, FALSE);
|
||||
t1 = path_tail_with_seperator(ffname);
|
||||
t2 = path_tail_with_seperator(f2);
|
||||
t1 = path_tail_with_sep(ffname);
|
||||
t2 = path_tail_with_sep(f2);
|
||||
return t1 - ffname == t2 - f2
|
||||
&& pathcmp((char *)ffname, (char *)f2, (int)(t1 - ffname)) == 0;
|
||||
}
|
||||
|
14
src/path.h
14
src/path.h
@@ -24,27 +24,27 @@ FileComparison path_full_compare(char_u *s1, char_u *s2, int checkname);
|
||||
/// @param fname A file path.
|
||||
/// @return
|
||||
/// - Empty string, if fname is NULL.
|
||||
/// - The position of the last path seperator + 1. (i.e. empty string, if
|
||||
/// - The position of the last path separator + 1. (i.e. empty string, if
|
||||
/// fname ends in a slash).
|
||||
/// - Never NULL.
|
||||
char_u *path_tail(char_u *fname);
|
||||
|
||||
/// Get pointer to tail of "fname", including path separators.
|
||||
///
|
||||
/// Takes care of "c:/" and "//". That means `path_tail_with_seperator("dir///file.txt")`
|
||||
/// Takes care of "c:/" and "//". That means `path_tail_with_sep("dir///file.txt")`
|
||||
/// will return a pointer to `"///file.txt"`.
|
||||
/// @param fname A file path. (Must be != NULL.)
|
||||
/// @return
|
||||
/// - Pointer to the last path seperator of `fname`, if there is any.
|
||||
/// - `fname` if it contains no path seperator.
|
||||
/// - Pointer to the last path separator of `fname`, if there is any.
|
||||
/// - `fname` if it contains no path separator.
|
||||
/// - Never NULL.
|
||||
char_u *path_tail_with_seperator(char_u *fname);
|
||||
char_u *path_tail_with_sep(char_u *fname);
|
||||
|
||||
/// Get the next path component of a path name.
|
||||
///
|
||||
/// @param fname A file path. (Must be != NULL.)
|
||||
/// @return Pointer to first found path seperator + 1.
|
||||
/// An empty string, if `fname` doesn't contain a path seperator,
|
||||
/// @return Pointer to first found path separator + 1.
|
||||
/// An empty string, if `fname` doesn't contain a path separator,
|
||||
char_u *path_next_component(char_u *fname);
|
||||
|
||||
int vim_ispathsep(int c);
|
||||
|
@@ -8507,7 +8507,7 @@ spell_add_word (
|
||||
* file. We may need to create the "spell" directory first. We
|
||||
* already checked the runtime directory is writable in
|
||||
* init_spellfile(). */
|
||||
if (!dir_of_file_exists(fname) && (p = path_tail_with_seperator(fname)) != fname) {
|
||||
if (!dir_of_file_exists(fname) && (p = path_tail_with_sep(fname)) != fname) {
|
||||
int c = *p;
|
||||
|
||||
/* The directory doesn't exist. Try creating it and opening
|
||||
|
@@ -8,7 +8,7 @@ typedef enum file_comparison {
|
||||
} FileComparison;
|
||||
FileComparison path_full_compare(char_u *s1, char_u *s2, int checkname);
|
||||
char_u *path_tail(char_u *fname);
|
||||
char_u *path_tail_with_seperator(char_u *fname);
|
||||
char_u *path_tail_with_sep(char_u *fname);
|
||||
char_u *path_next_component(char_u *fname);
|
||||
]]
|
||||
|
||||
@@ -65,27 +65,27 @@ describe 'path function', ->
|
||||
it 'returns an empty string if file ends in a slash', ->
|
||||
eq '', path_tail 'directory/'
|
||||
|
||||
describe 'path_tail_with_seperator', ->
|
||||
path_tail_with_seperator = (file) ->
|
||||
res = path.path_tail_with_seperator (to_cstr file)
|
||||
describe 'path_tail_with_sep', ->
|
||||
path_tail_with_sep = (file) ->
|
||||
res = path.path_tail_with_sep (to_cstr file)
|
||||
neq NULL, res
|
||||
ffi.string res
|
||||
|
||||
it 'returns the tail of a file together with its seperator', ->
|
||||
eq '///file.txt', path_tail_with_seperator 'directory///file.txt'
|
||||
eq '///file.txt', path_tail_with_sep 'directory///file.txt'
|
||||
|
||||
it 'returns an empty string when given an empty file name', ->
|
||||
eq '', path_tail_with_seperator ''
|
||||
eq '', path_tail_with_sep ''
|
||||
|
||||
it 'returns only the seperator if there is a traling seperator', ->
|
||||
eq '/', path_tail_with_seperator 'some/directory/'
|
||||
eq '/', path_tail_with_sep 'some/directory/'
|
||||
|
||||
it 'cuts a leading seperator', ->
|
||||
eq 'file.txt', path_tail_with_seperator '/file.txt'
|
||||
eq '', path_tail_with_seperator '/'
|
||||
eq 'file.txt', path_tail_with_sep '/file.txt'
|
||||
eq '', path_tail_with_sep '/'
|
||||
|
||||
it 'returns the whole file name if there is no seperator', ->
|
||||
eq 'file.txt', path_tail_with_seperator 'file.txt'
|
||||
eq 'file.txt', path_tail_with_sep 'file.txt'
|
||||
|
||||
describe 'path_next_component', ->
|
||||
path_next_component = (file) ->
|
||||
|
Reference in New Issue
Block a user