Fix seperator->separator, path_tail_with_separator->path_tail_with_sep.

This commit is contained in:
Thomas Wienecke
2014-04-01 17:44:20 +02:00
committed by Thiago de Arruda
parent 955d6a2949
commit 865e3280a8
7 changed files with 27 additions and 27 deletions

View File

@@ -2713,7 +2713,7 @@ void maketitle(void)
off += 2; off += 2;
#endif #endif
/* remove the file name */ /* remove the file name */
p = path_tail_with_seperator(buf + off); p = path_tail_with_sep(buf + off);
if (p == buf + off) if (p == buf + off)
/* must be a help buffer */ /* must be a help buffer */
vim_strncpy(buf + off, (char_u *)_("help"), vim_strncpy(buf + off, (char_u *)_("help"),

View File

@@ -11657,7 +11657,7 @@ static int mkdir_recurse(char_u *dir, int prot)
/* Get end of directory name in "dir". /* Get end of directory name in "dir".
* We're done when it's "/" or "c:/". */ * 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)) if (p <= get_past_head(dir))
return OK; return OK;
@@ -11693,7 +11693,7 @@ static void f_mkdir(typval_T *argvars, typval_T *rettv)
else { else {
if (*path_tail(dir) == NUL) if (*path_tail(dir) == NUL)
/* remove trailing slashes */ /* remove trailing slashes */
*path_tail_with_seperator(dir) = NUL; *path_tail_with_sep(dir) = NUL;
if (argvars[1].v_type != VAR_UNKNOWN) { if (argvars[1].v_type != VAR_UNKNOWN) {
if (argvars[2].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) { if (!has_trailing_pathsep) {
q = p + STRLEN(p); q = p + STRLEN(p);
if (after_pathsep(p, q)) if (after_pathsep(p, q))
*path_tail_with_seperator(p) = NUL; *path_tail_with_sep(p) = NUL;
} }
rettv->vval.v_string = p; rettv->vval.v_string = p;

View File

@@ -1609,7 +1609,7 @@ int vim_chdirfile(char_u *fname)
char_u dir[MAXPATHL]; char_u dir[MAXPATHL];
vim_strncpy(dir, fname, MAXPATHL - 1); 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; return os_chdir((char *)dir) == 0 ? OK : FAIL;
} }
#endif #endif

View File

@@ -78,7 +78,7 @@ char_u *path_tail(char_u *fname)
return tail; return tail;
} }
char_u *path_tail_with_seperator(char_u *fname) char_u *path_tail_with_sep(char_u *fname)
{ {
assert(fname != NULL); assert(fname != NULL);
char_u *past_head; char_u *past_head;
@@ -210,7 +210,7 @@ int dir_of_file_exists(char_u *fname)
int c; int c;
int retval; int retval;
p = path_tail_with_seperator(fname); p = path_tail_with_sep(fname);
if (p == fname) if (p == fname)
return TRUE; return TRUE;
c = *p; c = *p;
@@ -1644,8 +1644,8 @@ int same_directory(char_u *f1, char_u *f2)
return FALSE; return FALSE;
(void)vim_FullName(f1, ffname, MAXPATHL, FALSE); (void)vim_FullName(f1, ffname, MAXPATHL, FALSE);
t1 = path_tail_with_seperator(ffname); t1 = path_tail_with_sep(ffname);
t2 = path_tail_with_seperator(f2); t2 = path_tail_with_sep(f2);
return t1 - ffname == t2 - f2 return t1 - ffname == t2 - f2
&& pathcmp((char *)ffname, (char *)f2, (int)(t1 - ffname)) == 0; && pathcmp((char *)ffname, (char *)f2, (int)(t1 - ffname)) == 0;
} }

View File

@@ -24,27 +24,27 @@ FileComparison path_full_compare(char_u *s1, char_u *s2, int checkname);
/// @param fname A file path. /// @param fname A file path.
/// @return /// @return
/// - Empty string, if fname is NULL. /// - 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). /// fname ends in a slash).
/// - Never NULL. /// - Never NULL.
char_u *path_tail(char_u *fname); char_u *path_tail(char_u *fname);
/// Get pointer to tail of "fname", including path separators. /// 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"`. /// will return a pointer to `"///file.txt"`.
/// @param fname A file path. (Must be != NULL.) /// @param fname A file path. (Must be != NULL.)
/// @return /// @return
/// - Pointer to the last path seperator of `fname`, if there is any. /// - Pointer to the last path separator of `fname`, if there is any.
/// - `fname` if it contains no path seperator. /// - `fname` if it contains no path separator.
/// - Never NULL. /// - 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. /// Get the next path component of a path name.
/// ///
/// @param fname A file path. (Must be != NULL.) /// @param fname A file path. (Must be != NULL.)
/// @return Pointer to first found path seperator + 1. /// @return Pointer to first found path separator + 1.
/// An empty string, if `fname` doesn't contain a path seperator, /// An empty string, if `fname` doesn't contain a path separator,
char_u *path_next_component(char_u *fname); char_u *path_next_component(char_u *fname);
int vim_ispathsep(int c); int vim_ispathsep(int c);

View File

@@ -8507,7 +8507,7 @@ spell_add_word (
* file. We may need to create the "spell" directory first. We * file. We may need to create the "spell" directory first. We
* already checked the runtime directory is writable in * already checked the runtime directory is writable in
* init_spellfile(). */ * 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; int c = *p;
/* The directory doesn't exist. Try creating it and opening /* The directory doesn't exist. Try creating it and opening

View File

@@ -8,7 +8,7 @@ typedef enum file_comparison {
} FileComparison; } FileComparison;
FileComparison path_full_compare(char_u *s1, char_u *s2, int checkname); FileComparison path_full_compare(char_u *s1, char_u *s2, int checkname);
char_u *path_tail(char_u *fname); 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); 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', -> it 'returns an empty string if file ends in a slash', ->
eq '', path_tail 'directory/' eq '', path_tail 'directory/'
describe 'path_tail_with_seperator', -> describe 'path_tail_with_sep', ->
path_tail_with_seperator = (file) -> path_tail_with_sep = (file) ->
res = path.path_tail_with_seperator (to_cstr file) res = path.path_tail_with_sep (to_cstr file)
neq NULL, res neq NULL, res
ffi.string res ffi.string res
it 'returns the tail of a file together with its seperator', -> 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', -> 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', -> 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', -> it 'cuts a leading seperator', ->
eq 'file.txt', path_tail_with_seperator '/file.txt' eq 'file.txt', path_tail_with_sep '/file.txt'
eq '', path_tail_with_seperator '/' eq '', path_tail_with_sep '/'
it 'returns the whole file name if there is no seperator', -> 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', -> describe 'path_next_component', ->
path_next_component = (file) -> path_next_component = (file) ->