aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThomas Wienecke <wienecke.t@gmail.com>2014-03-30 13:42:03 +0200
committerThiago de Arruda <tpadilha84@gmail.com>2014-04-03 10:32:41 -0300
commit77bfb6cd990c67e4191d4858af82de42303e1939 (patch)
treed7c6fbf45cbe581fbf4e3edabf506d8fcf153037 /src
parent6d712defa52e58627aca5c875677d14d705300e8 (diff)
downloadrneovim-77bfb6cd990c67e4191d4858af82de42303e1939.tar.gz
rneovim-77bfb6cd990c67e4191d4858af82de42303e1939.tar.bz2
rneovim-77bfb6cd990c67e4191d4858af82de42303e1939.zip
Test and refactor gettail -> path_tail.
Diffstat (limited to 'src')
-rw-r--r--src/buffer.c6
-rw-r--r--src/eval.c10
-rw-r--r--src/ex_cmds.c10
-rw-r--r--src/ex_cmds2.c2
-rw-r--r--src/ex_docmd.c2
-rw-r--r--src/ex_getln.c6
-rw-r--r--src/file_search.c6
-rw-r--r--src/fileio.c16
-rw-r--r--src/if_cscope.c2
-rw-r--r--src/main.c4
-rw-r--r--src/memline.c18
-rw-r--r--src/misc1.c4
-rw-r--r--src/misc2.c2
-rw-r--r--src/option.c2
-rw-r--r--src/os_unix.c2
-rw-r--r--src/path.c32
-rw-r--r--src/path.h11
-rw-r--r--src/quickfix.c4
-rw-r--r--src/spell.c16
-rw-r--r--src/tag.c6
-rw-r--r--src/undo.c2
21 files changed, 85 insertions, 78 deletions
diff --git a/src/buffer.c b/src/buffer.c
index 83b1928dd2..e084e2e4e4 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -2683,7 +2683,7 @@ void maketitle(void)
if (curbuf->b_fname == NULL)
vim_strncpy(buf, (char_u *)_("[No Name]"), SPACE_FOR_FNAME);
else {
- p = transstr(gettail(curbuf->b_fname));
+ p = transstr(path_tail(curbuf->b_fname));
vim_strncpy(buf, p, SPACE_FOR_FNAME);
vim_free(p);
}
@@ -2770,7 +2770,7 @@ void maketitle(void)
if (buf_spname(curbuf) != NULL)
i_name = buf_spname(curbuf);
else /* use file name only in icon */
- i_name = gettail(curbuf->b_ffname);
+ i_name = path_tail(curbuf->b_ffname);
*i_str = NUL;
/* Truncate name at 100 bytes. */
len = (int)STRLEN(i_name);
@@ -3143,7 +3143,7 @@ build_stl_str_hl (
if (opt != STL_FILENAME)
str = NameBuff;
else
- str = gettail(NameBuff);
+ str = path_tail(NameBuff);
break;
case STL_VIM_EXPR: /* '{' */
diff --git a/src/eval.c b/src/eval.c
index 787ef7b30a..60fc381f88 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -11691,7 +11691,7 @@ static void f_mkdir(typval_T *argvars, typval_T *rettv)
if (*dir == NUL)
rettv->vval.v_number = FAIL;
else {
- if (*gettail(dir) == NUL)
+ if (*path_tail(dir) == NUL)
/* remove trailing slashes */
*gettail_sep(dir) = NUL;
@@ -12470,18 +12470,18 @@ static void f_resolve(typval_T *argvars, typval_T *rettv)
q[-1] = NUL;
}
- q = gettail(p);
+ q = path_tail(p);
if (q > p && *q == NUL) {
/* Ignore trailing path separator. */
q[-1] = NUL;
- q = gettail(p);
+ q = path_tail(p);
}
if (q > p && !os_is_absolute_path(buf)) {
/* symlink is relative to directory of argument */
cpy = alloc((unsigned)(STRLEN(p) + STRLEN(buf) + 1));
if (cpy != NULL) {
STRCPY(cpy, p);
- STRCPY(gettail(cpy), buf);
+ STRCPY(path_tail(cpy), buf);
vim_free(p);
p = cpy;
}
@@ -19400,7 +19400,7 @@ repeat:
}
}
- tail = gettail(*fnamep);
+ tail = path_tail(*fnamep);
*fnamelen = (int)STRLEN(*fnamep);
/* ":h" - head, remove "/file_name", can be repeated */
diff --git a/src/ex_cmds.c b/src/ex_cmds.c
index e8eb458f70..2c3bed7143 100644
--- a/src/ex_cmds.c
+++ b/src/ex_cmds.c
@@ -1621,8 +1621,8 @@ void write_viminfo(char_u *file, int forceit)
* the same file as the original.
*/
wp = tempname + STRLEN(tempname) - 5;
- if (wp < gettail(tempname)) /* empty file name? */
- wp = gettail(tempname);
+ if (wp < path_tail(tempname)) /* empty file name? */
+ wp = path_tail(tempname);
for (*wp = 'z'; mch_stat((char *)tempname, &st_new) == 0;
--*wp) {
/*
@@ -5193,7 +5193,7 @@ void fix_help_buffer(void)
* In the "help.txt" and "help.abx" file, add the locally added help
* files. This uses the very first line in the help file.
*/
- fname = gettail(curbuf->b_fname);
+ fname = path_tail(curbuf->b_fname);
if (fnamecmp(fname, "help.txt") == 0
|| (fnamencmp(fname, "help.", 5) == 0
&& ASCII_ISALPHA(fname[5])
@@ -5246,11 +5246,11 @@ void fix_help_buffer(void)
continue;
f1 = fnames[i1];
f2 = fnames[i2];
- t1 = gettail(f1);
+ t1 = path_tail(f1);
if (fnamencmp(f1, f2, t1 - f1) != 0)
continue;
e1 = vim_strrchr(t1, '.');
- e2 = vim_strrchr(gettail(f2), '.');
+ e2 = vim_strrchr(path_tail(f2), '.');
if (e1 == NUL || e2 == NUL)
continue;
if (fnamecmp(e1, ".txt") != 0
diff --git a/src/ex_cmds2.c b/src/ex_cmds2.c
index 00f993168a..13e6f26a84 100644
--- a/src/ex_cmds2.c
+++ b/src/ex_cmds2.c
@@ -2519,7 +2519,7 @@ do_source (
* Try again, replacing file name ".vimrc" by "_vimrc" or vice versa,
* and ".exrc" by "_exrc" or vice versa.
*/
- p = gettail(fname_exp);
+ p = path_tail(fname_exp);
if ((*p == '.' || *p == '_')
&& (STRICMP(p + 1, "vimrc") == 0
|| STRICMP(p + 1, "gvimrc") == 0
diff --git a/src/ex_docmd.c b/src/ex_docmd.c
index ac6be1a84c..6d2a58b246 100644
--- a/src/ex_docmd.c
+++ b/src/ex_docmd.c
@@ -8058,7 +8058,7 @@ eval_vars (
resultlen = (int)STRLEN(result); /* length of new string */
if (src[*usedlen] == '<') { /* remove the file name extension */
++*usedlen;
- if ((s = vim_strrchr(result, '.')) != NULL && s >= gettail(result))
+ if ((s = vim_strrchr(result, '.')) != NULL && s >= path_tail(result))
resultlen = (int)(s - result);
} else if (!skip_mod) {
valid |= modify_fname(src, usedlen, &result, &resultbuf,
diff --git a/src/ex_getln.c b/src/ex_getln.c
index 89ff9b6c0e..75d400daba 100644
--- a/src/ex_getln.c
+++ b/src/ex_getln.c
@@ -3303,7 +3303,7 @@ static int showmatches(expand_T *xp, int wildmenu)
}
/*
- * Private gettail for showmatches() (and win_redr_status_matches()):
+ * Private path_tail for showmatches() (and win_redr_status_matches()):
* Find tail of file name path, but ignore trailing "/".
*/
char_u *sm_gettail(char_u *s)
@@ -3344,7 +3344,7 @@ static int expand_showtail(expand_T *xp)
&& xp->xp_context != EXPAND_DIRECTORIES)
return FALSE;
- end = gettail(xp->xp_pattern);
+ end = path_tail(xp->xp_pattern);
if (end == xp->xp_pattern) /* there is no path separator */
return FALSE;
@@ -3461,7 +3461,7 @@ addstar (
* ` could be anywhere in the file name.
* When the name ends in '$' don't add a star, remove the '$'.
*/
- tail = gettail(retval);
+ tail = path_tail(retval);
ends_in_star = (len > 0 && retval[len - 1] == '*');
#ifndef BACKSLASH_IN_FILENAME
for (i = len - 2; i >= 0; --i) {
diff --git a/src/file_search.c b/src/file_search.c
index 00b32d669f..5808c600dc 100644
--- a/src/file_search.c
+++ b/src/file_search.c
@@ -318,7 +318,7 @@ vim_findfile_init (
&& (vim_ispathsep(path[1]) || path[1] == NUL)
&& (!tagfile || vim_strchr(p_cpo, CPO_DOTTAG) == NULL)
&& rel_fname != NULL) {
- int len = (int)(gettail(rel_fname) - rel_fname);
+ int len = (int)(path_tail(rel_fname) - rel_fname);
if (!vim_isAbsName(rel_fname) && len + 1 < MAXPATHL) {
/* Make the start dir an absolute path name. */
@@ -503,7 +503,7 @@ vim_findfile_init (
STRCAT(ff_expand_buffer, search_ctx->ffsc_fix_path);
add_pathsep(ff_expand_buffer);
} else {
- char_u *p = gettail(search_ctx->ffsc_fix_path);
+ char_u *p = path_tail(search_ctx->ffsc_fix_path);
char_u *wc_path = NULL;
char_u *temp = NULL;
int len = 0;
@@ -1505,7 +1505,7 @@ find_file_in_path_option (
&& rel_fname != NULL
&& STRLEN(rel_fname) + l < MAXPATHL) {
STRCPY(NameBuff, rel_fname);
- STRCPY(gettail(NameBuff), ff_file_to_find);
+ STRCPY(path_tail(NameBuff), ff_file_to_find);
l = (int)STRLEN(NameBuff);
} else {
STRCPY(NameBuff, ff_file_to_find);
diff --git a/src/fileio.c b/src/fileio.c
index 1e8d1fb039..06a094e7b7 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -2957,7 +2957,7 @@ buf_write (
*/
STRCPY(IObuff, fname);
for (i = 4913;; i += 123) {
- sprintf((char *)gettail(IObuff), "%d", i);
+ sprintf((char *)path_tail(IObuff), "%d", i);
if (mch_lstat((char *)IObuff, &st) < 0)
break;
}
@@ -4872,7 +4872,7 @@ buf_modname (
/*
* Prepend the dot.
*/
- if (prepend_dot && !shortname && *(e = gettail(retval)) != '.'
+ if (prepend_dot && !shortname && *(e = path_tail(retval)) != '.'
#ifdef USE_LONG_FNAME
&& USE_LONG_FNAME
#endif
@@ -4994,7 +4994,7 @@ int vim_rename(char_u *from, char_u *to)
* the file name differs we need to go through a temp file.
*/
if (fnamecmp(from, to) == 0) {
- if (p_fic && STRCMP(gettail(from), gettail(to)) != 0)
+ if (p_fic && STRCMP(path_tail(from), path_tail(to)) != 0)
use_tmp_file = TRUE;
else
return 0;
@@ -5031,7 +5031,7 @@ int vim_rename(char_u *from, char_u *to)
return -1;
STRCPY(tempname, from);
for (n = 123; n < 99999; ++n) {
- sprintf((char *)gettail((char_u *)tempname), "%d", n);
+ sprintf((char *)path_tail((char_u *)tempname), "%d", n);
if (mch_stat(tempname, &st) < 0) {
if (rename((char *)from, tempname) == 0) {
if (rename(tempname, (char *)to) == 0)
@@ -5640,7 +5640,7 @@ void vim_deltempdir(void)
mch_remove(files[i]);
FreeWild(file_count, files);
}
- gettail(NameBuff)[-1] = NUL;
+ path_tail(NameBuff)[-1] = NUL;
(void)mch_rmdir(NameBuff);
vim_free(vim_tempdir);
@@ -7482,7 +7482,7 @@ apply_autocmds_group (
if (event == EVENT_FILETYPE)
did_filetype = TRUE;
- tail = gettail(fname);
+ tail = path_tail(fname);
/* Find first autocommand that matches */
patcmd.curpat = first_autopat[(int)event];
@@ -7739,7 +7739,7 @@ int has_autocmd(event_T event, char_u *sfname, buf_T *buf)
{
AutoPat *ap;
char_u *fname;
- char_u *tail = gettail(sfname);
+ char_u *tail = path_tail(sfname);
int retval = FALSE;
fname = FullName_save(sfname, FALSE);
@@ -8064,7 +8064,7 @@ int match_file_list(char_u *list, char_u *sfname, char_u *ffname)
int match;
char_u *p;
- tail = gettail(sfname);
+ tail = path_tail(sfname);
/* try all patterns in 'wildignore' */
p = list;
diff --git a/src/if_cscope.c b/src/if_cscope.c
index bcbd8da40d..c2a1b34c80 100644
--- a/src/if_cscope.c
+++ b/src/if_cscope.c
@@ -2231,7 +2231,7 @@ static char *cs_resolve_file(int i, char *name)
csdir = alloc(MAXPATHL);
if (csdir != NULL) {
vim_strncpy(csdir, (char_u *)csinfo[i].fname,
- gettail((char_u *)csinfo[i].fname)
+ path_tail((char_u *)csinfo[i].fname)
- (char_u *)csinfo[i].fname);
len += (int)STRLEN(csdir);
}
diff --git a/src/main.c b/src/main.c
index ccabd43d38..6ef59902ab 100644
--- a/src/main.c
+++ b/src/main.c
@@ -931,7 +931,7 @@ static void parse_command_name(mparm_T *parmp)
{
char_u *initstr;
- initstr = gettail((char_u *)parmp->argv[0]);
+ initstr = path_tail((char_u *)parmp->argv[0]);
set_vim_var_string(VV_PROGNAME, initstr, -1);
@@ -1440,7 +1440,7 @@ scripterror:
&& !os_isdir(alist_name(&GARGLIST[0]))) {
char_u *r;
- r = concat_fnames(p, gettail(alist_name(&GARGLIST[0])), TRUE);
+ r = concat_fnames(p, path_tail(alist_name(&GARGLIST[0])), TRUE);
if (r != NULL) {
vim_free(p);
p = r;
diff --git a/src/memline.c b/src/memline.c
index c9ab5e3920..c0a91bfa04 100644
--- a/src/memline.c
+++ b/src/memline.c
@@ -1589,7 +1589,7 @@ recover_names (
} else
#endif
{
- tail = gettail(fname_res);
+ tail = path_tail(fname_res);
tail = concat_fnames(dir_name, tail, TRUE);
}
if (tail == NULL)
@@ -1682,7 +1682,7 @@ recover_names (
/* print the swap file name */
msg_outnum((long)++file_count);
MSG_PUTS(". ");
- msg_puts(gettail(files[i]));
+ msg_puts(path_tail(files[i]));
msg_putchar('\n');
(void)swapfile_info(files[i]);
}
@@ -3398,7 +3398,7 @@ int resolve_symlink(char_u *fname, char_u *buf)
else {
char_u *tail;
- tail = gettail(tmp);
+ tail = path_tail(tmp);
if (STRLEN(tail) + STRLEN(buf) >= MAXPATHL)
return FAIL;
STRCPY(tail, buf);
@@ -3492,7 +3492,7 @@ get_file_in_dir (
char_u *retval;
int save_char;
- tail = gettail(fname);
+ tail = path_tail(fname);
if (dname[0] == '.' && dname[1] == NUL)
retval = vim_strsave(fname);
@@ -3697,10 +3697,10 @@ findswapname (
* It either contains two dots, is longer than 8 chars, or starts
* with a dot.
*/
- tail = gettail(buf_fname);
+ tail = path_tail(buf_fname);
if ( vim_strchr(tail, '.') != NULL
|| STRLEN(tail) > (size_t)8
- || *gettail(fname) == '.') {
+ || *path_tail(fname) == '.') {
fname2 = alloc(n + 2);
if (fname2 != NULL) {
STRCPY(fname2, fname);
@@ -3710,7 +3710,7 @@ findswapname (
*/
if (vim_strchr(tail, '.') != NULL)
fname2[n - 1] = 'x';
- else if (*gettail(fname) == '.') {
+ else if (*path_tail(fname) == '.') {
fname2[n] = 'x';
fname2[n + 1] = NUL;
} else
@@ -3835,8 +3835,8 @@ findswapname (
* have a different mountpoint.
*/
if (b0.b0_flags & B0_SAME_DIR) {
- if (fnamecmp(gettail(buf->b_ffname),
- gettail(b0.b0_fname)) != 0
+ if (fnamecmp(path_tail(buf->b_ffname),
+ path_tail(b0.b0_fname)) != 0
|| !same_directory(fname, buf->b_ffname)) {
#ifdef CHECK_INODE
/* Symlinks may point to the same file even
diff --git a/src/misc1.c b/src/misc1.c
index 2a8dae97d6..db8b9dc58f 100644
--- a/src/misc1.c
+++ b/src/misc1.c
@@ -3052,7 +3052,7 @@ char_u *vim_getenv(char_u *name, int *mustfree)
#endif
if (p != NULL) {
/* remove the file name */
- pend = gettail(p);
+ pend = path_tail(p);
/* remove "doc/" from 'helpfile', if present */
if (p == p_hf)
@@ -3285,7 +3285,7 @@ home_replace (
* If the file is a help file, remove the path completely.
*/
if (buf != NULL && buf->b_help) {
- STRCPY(dst, gettail(src));
+ STRCPY(dst, path_tail(src));
return;
}
diff --git a/src/misc2.c b/src/misc2.c
index 180ebedcd8..9c87dd46d4 100644
--- a/src/misc2.c
+++ b/src/misc2.c
@@ -994,7 +994,7 @@ char_u *vim_strsave_escaped_ext(char_u *string, char_u *esc_chars, int cc, int b
*/
int csh_like_shell(void)
{
- return strstr((char *)gettail(p_sh), "csh") != NULL;
+ return strstr((char *)path_tail(p_sh), "csh") != NULL;
}
/*
diff --git a/src/option.c b/src/option.c
index 0cf3c0d01b..afcab215ac 100644
--- a/src/option.c
+++ b/src/option.c
@@ -2493,7 +2493,7 @@ void set_init_3(void)
p = skiptowhite(p_sh);
if (*p == NUL) {
/* No white space, use the tail. */
- p = vim_strsave(gettail(p_sh));
+ p = vim_strsave(path_tail(p_sh));
} else {
char_u *p1, *p2;
diff --git a/src/os_unix.c b/src/os_unix.c
index 69c913e306..c29d1801f7 100644
--- a/src/os_unix.c
+++ b/src/os_unix.c
@@ -1943,7 +1943,7 @@ int flags; /* EW_* flags */
else if (STRCMP(p_sh + len - 3, "zsh") == 0)
shell_style = STYLE_PRINT;
}
- if (shell_style == STYLE_ECHO && strstr((char *)gettail(p_sh),
+ if (shell_style == STYLE_ECHO && strstr((char *)path_tail(p_sh),
"sh") != NULL)
shell_style = STYLE_VIMGLOB;
diff --git a/src/path.c b/src/path.c
index e5680d5073..d4abdd03b4 100644
--- a/src/path.c
+++ b/src/path.c
@@ -61,23 +61,21 @@ FileComparison path_full_compare(char_u *s1, char_u *s2, int checkname)
return FPC_DIFF;
}
-/*
- * Get the tail of a path: the file name.
- * When the path ends in a path separator the tail is the NUL after it.
- * Fail safe: never returns NULL.
- */
-char_u *gettail(char_u *fname)
+char_u *path_tail(char_u *fname)
{
- char_u *p1, *p2;
-
- if (fname == NULL)
+ if (fname == NULL) {
return (char_u *)"";
- for (p1 = p2 = get_past_head(fname); *p2; ) { /* find last part of path */
- if (vim_ispathsep_nocolon(*p2))
- p1 = p2 + 1;
+ }
+
+ char_u *tail, *p2;
+ // Find last part of path.
+ for (tail = p2 = get_past_head(fname); *p2; ) {
+ if (vim_ispathsep_nocolon(*p2)) {
+ tail = p2 + 1;
+ }
mb_ptr_adv(p2);
}
- return p1;
+ return tail;
}
/*
@@ -91,7 +89,7 @@ char_u *gettail_sep(char_u *fname)
char_u *t;
p = get_past_head(fname); /* don't remove the '/' from "c:/file" */
- t = gettail(fname);
+ t = path_tail(fname);
while (t > p && after_pathsep(fname, t))
--t;
return t;
@@ -178,7 +176,7 @@ void shorten_dir(char_u *str)
char_u *tail, *s, *d;
int skip = FALSE;
- tail = gettail(str);
+ tail = path_tail(str);
d = str;
for (s = str;; ++s) {
if (s >= tail) { /* copy the whole tail */
@@ -644,7 +642,7 @@ static void expand_path_option(char_u *curdir, garray_T *gap)
* "/path/file" + "./subdir" -> "/path/subdir" */
if (curbuf->b_ffname == NULL)
continue;
- p = gettail(curbuf->b_ffname);
+ p = path_tail(curbuf->b_ffname);
len = (int)(p - curbuf->b_ffname);
if (len + (int)STRLEN(buf) >= MAXPATHL)
continue;
@@ -1942,7 +1940,7 @@ int match_suffix(char_u *fname)
for (setsuf = p_su; *setsuf; ) {
setsuflen = copy_option_part(&setsuf, suf_buf, MAXSUFLEN, ".,");
if (setsuflen == 0) {
- char_u *tail = gettail(fname);
+ char_u *tail = path_tail(fname);
/* empty entry: match name without a '.' */
if (vim_strchr(tail, '.') == NULL) {
diff --git a/src/path.h b/src/path.h
index e4acfa62b2..8ae475a22f 100644
--- a/src/path.h
+++ b/src/path.h
@@ -19,6 +19,16 @@ typedef enum file_comparison {
/// @return Enum of type FileComparison. @see FileComparison.
FileComparison path_full_compare(char_u *s1, char_u *s2, int checkname);
+/// Get the tail of a path:the file name.
+///
+/// @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
+/// fname ends in a slash).
+/// - Never NULL.
+char_u *path_tail(char_u *fname);
+
int vim_ispathsep(int c);
int vim_ispathsep_nocolon(int c);
int vim_ispathlistsep(int c);
@@ -33,7 +43,6 @@ int gen_expand_wildcards(int num_pat, char_u **pat, int *num_file,
char_u ***file,
int flags);
void addfile(garray_T *gap, char_u *f, int flags);
-char_u *gettail(char_u *fname);
char_u *gettail_sep(char_u *fname);
char_u *getnextcomp(char_u *fname);
char_u *get_past_head(char_u *path);
diff --git a/src/quickfix.c b/src/quickfix.c
index a0ec091ec7..aa33a2073f 100644
--- a/src/quickfix.c
+++ b/src/quickfix.c
@@ -1800,7 +1800,7 @@ void qf_list(exarg_T *eap)
&& (buf = buflist_findnr(qfp->qf_fnum)) != NULL) {
fname = buf->b_fname;
if (qfp->qf_type == 1) /* :helpgrep */
- fname = gettail(fname);
+ fname = path_tail(fname);
}
if (fname == NULL)
sprintf((char *)IObuff, "%2d", i);
@@ -2347,7 +2347,7 @@ static void qf_fill_buffer(qf_info_T *qi)
&& (errbuf = buflist_findnr(qfp->qf_fnum)) != NULL
&& errbuf->b_fname != NULL) {
if (qfp->qf_type == 1) /* :helpgrep */
- STRCPY(IObuff, gettail(errbuf->b_fname));
+ STRCPY(IObuff, path_tail(errbuf->b_fname));
else
STRCPY(IObuff, errbuf->b_fname);
len = (int)STRLEN(IObuff);
diff --git a/src/spell.c b/src/spell.c
index 99258b4f88..fd33809b3a 100644
--- a/src/spell.c
+++ b/src/spell.c
@@ -2580,7 +2580,7 @@ spell_load_file (
goto endFAIL;
/* Check for .add.spl (_add.spl for VMS). */
- lp->sl_add = strstr((char *)gettail(fname), SPL_FNAME_ADD) != NULL;
+ lp->sl_add = strstr((char *)path_tail(fname), SPL_FNAME_ADD) != NULL;
} else
lp = old_lp;
@@ -3875,7 +3875,7 @@ char_u *did_set_spelllang(win_T *wp)
filename = TRUE;
/* Locate a region and remove it from the file name. */
- p = vim_strchr(gettail(lang), '_');
+ p = vim_strchr(path_tail(lang), '_');
if (p != NULL && ASCII_ISALPHA(p[1]) && ASCII_ISALPHA(p[2])
&& !ASCII_ISALPHA(p[3])) {
vim_strncpy(region_cp, p + 1, 2);
@@ -4006,7 +4006,7 @@ char_u *did_set_spelllang(win_T *wp)
if (round == 0)
STRCPY(lang, "internal wordlist");
else {
- vim_strncpy(lang, gettail(spf_name), MAXWLEN);
+ vim_strncpy(lang, path_tail(spf_name), MAXWLEN);
p = vim_strchr(lang, '.');
if (p != NULL)
*p = NUL; /* truncate at ".encoding.add" */
@@ -8199,17 +8199,17 @@ mkspell (
fnames[0], spin.si_ascii ? (char_u *)"ascii" : spell_enc());
/* Check for .ascii.spl. */
- if (strstr((char *)gettail(wfname), SPL_FNAME_ASCII) != NULL)
+ if (strstr((char *)path_tail(wfname), SPL_FNAME_ASCII) != NULL)
spin.si_ascii = TRUE;
/* Check for .add.spl. */
- if (strstr((char *)gettail(wfname), SPL_FNAME_ADD) != NULL)
+ if (strstr((char *)path_tail(wfname), SPL_FNAME_ADD) != NULL)
spin.si_add = TRUE;
}
if (incount <= 0)
EMSG(_(e_invarg)); /* need at least output and input names */
- else if (vim_strchr(gettail(wfname), '_') != NULL)
+ else if (vim_strchr(path_tail(wfname), '_') != NULL)
EMSG(_("E751: Output file name must not have region name"));
else if (incount > 8)
EMSG(_("E754: Only up to 8 regions supported"));
@@ -8238,7 +8238,7 @@ mkspell (
if (incount > 1) {
len = (int)STRLEN(innames[i]);
- if (STRLEN(gettail(innames[i])) < 5
+ if (STRLEN(path_tail(innames[i])) < 5
|| innames[i][len - 3] != '_') {
EMSG2(_("E755: Invalid region in %s"), innames[i]);
goto theend;
@@ -8607,7 +8607,7 @@ static void init_spellfile(void)
->lp_slang->sl_fname;
vim_snprintf((char *)buf + l, MAXPATHL - l, ".%s.add",
fname != NULL
- && strstr((char *)gettail(fname), ".ascii.") != NULL
+ && strstr((char *)path_tail(fname), ".ascii.") != NULL
? (char_u *)"ascii" : spell_enc());
set_option_value((char_u *)"spellfile", 0L, buf, OPT_LOCAL);
break;
diff --git a/src/tag.c b/src/tag.c
index 794dbd92c4..401f147e20 100644
--- a/src/tag.c
+++ b/src/tag.c
@@ -2113,7 +2113,7 @@ get_tagfname (
return FAIL;
++tnp->tn_hf_idx;
STRCPY(buf, p_hf);
- STRCPY(gettail(buf), "tags");
+ STRCPY(path_tail(buf), "tags");
} else
vim_strncpy(buf, ((char_u **)(tag_fnames.ga_data))[
tnp->tn_hf_idx++], MAXPATHL - 1);
@@ -2162,7 +2162,7 @@ get_tagfname (
r_ptr = vim_findfile_stopdir(buf);
/* move the filename one char forward and truncate the
* filepath with a NUL */
- filename = gettail(buf);
+ filename = path_tail(buf);
STRMOVE(filename + 1, filename);
*filename++ = NUL;
@@ -2702,7 +2702,7 @@ static char_u *expand_tag_fname(char_u *fname, char_u *tag_fname, int expand)
if ((p_tr || curbuf->b_help)
&& !vim_isAbsName(fname)
- && (p = gettail(tag_fname)) != tag_fname) {
+ && (p = path_tail(tag_fname)) != tag_fname) {
retval = alloc(MAXPATHL);
if (retval != NULL) {
STRCPY(retval, tag_fname);
diff --git a/src/undo.c b/src/undo.c
index 656b38d3cd..7cfefa2479 100644
--- a/src/undo.c
+++ b/src/undo.c
@@ -719,7 +719,7 @@ char_u *u_get_undo_file_name(char_u *buf_ffname, int reading)
undo_file_name = vim_strnsave(ffname, (int)(STRLEN(ffname) + 5));
if (undo_file_name == NULL)
break;
- p = gettail(undo_file_name);
+ p = path_tail(undo_file_name);
memmove(p + 1, p, STRLEN(p) + 1);
*p = '.';
STRCAT(p, ".un~");