Remove char_u: concat_fnames()

This commit is contained in:
Mark Bainter 2015-04-20 15:28:37 +00:00
parent 477b6a2c44
commit c55e488079
7 changed files with 44 additions and 36 deletions

View File

@ -2054,7 +2054,7 @@ static char *cs_resolve_file(int i, char *name)
} else if (csdir != NULL && csinfo[i].fname != NULL && *csdir != NUL) {
/* Check for csdir to be non empty to avoid empty path concatenated to
* cscope output. */
fullname = (char *)concat_fnames(csdir, (char_u *)name, TRUE);
fullname = concat_fnames((char *)csdir, name, TRUE);
} else {
fullname = xstrdup(name);
}

View File

@ -1282,7 +1282,7 @@ scripterror:
&& !os_isdir(alist_name(&GARGLIST[0]))) {
char_u *r;
r = concat_fnames(p, path_tail(alist_name(&GARGLIST[0])), TRUE);
r = (char_u *)concat_fnames((char *)p, (char *)path_tail(alist_name(&GARGLIST[0])), TRUE);
xfree(p);
p = r;
}

View File

@ -1332,11 +1332,11 @@ recover_names (
num_names = recov_file_names(names, fname_res, TRUE);
} else { /* check directory dir_name */
if (fname == NULL) {
names[0] = concat_fnames(dir_name, (char_u *)"*.sw?", TRUE);
names[0] = (char_u *)concat_fnames((char *)dir_name, "*.sw?", TRUE);
/* For Unix names starting with a dot are special. MS-Windows
* supports this too, on some file systems. */
names[1] = concat_fnames(dir_name, (char_u *)".*.sw?", TRUE);
names[2] = concat_fnames(dir_name, (char_u *)".sw?", TRUE);
names[1] = (char_u *)concat_fnames((char *)dir_name, ".*.sw?", TRUE);
names[2] = (char_u *)concat_fnames((char *)dir_name, ".sw?", TRUE);
num_names = 3;
} else {
p = dir_name + STRLEN(dir_name);
@ -1345,7 +1345,7 @@ recover_names (
tail = (char_u *)make_percent_swname((char *)dir_name, (char *)fname_res);
} else {
tail = path_tail(fname_res);
tail = concat_fnames(dir_name, tail, TRUE);
tail = (char_u *)concat_fnames((char *)dir_name, (char *)tail, TRUE);
}
num_names = recov_file_names(names, tail, FALSE);
xfree(tail);
@ -1453,7 +1453,7 @@ static char *make_percent_swname(const char *dir, char *name)
*d = '%';
}
}
d = (char *)concat_fnames((char_u *)dir, (char_u *)s, TRUE);
d = concat_fnames(dir, s, TRUE);
xfree(s);
xfree(f);
}
@ -1573,7 +1573,7 @@ static int recov_file_names(char_u **names, char_u *path, int prepend_dot)
}
// Form the normal swap file name pattern by appending ".sw?".
names[num_names] = concat_fnames(path, (char_u *)".sw?", FALSE);
names[num_names] = (char_u *)concat_fnames((char *)path, ".sw?", FALSE);
if (num_names >= 1) { /* check if we have the same name twice */
char_u *p = names[num_names - 1];
int i = (int)STRLEN(names[num_names - 1]) - (int)STRLEN(names[num_names]);
@ -3123,17 +3123,17 @@ get_file_in_dir (
retval = vim_strsave(fname);
else if (dname[0] == '.' && vim_ispathsep(dname[1])) {
if (tail == fname) /* no path before file name */
retval = concat_fnames(dname + 2, tail, TRUE);
retval = (char_u *)concat_fnames((char *)dname + 2, (char *)tail, TRUE);
else {
save_char = *tail;
*tail = NUL;
t = concat_fnames(fname, dname + 2, TRUE);
t = (char_u *)concat_fnames((char *)fname, (char *)dname + 2, TRUE);
*tail = save_char;
retval = concat_fnames(t, tail, TRUE);
retval = (char_u *)concat_fnames((char *)t, (char *)tail, TRUE);
xfree(t);
}
} else {
retval = concat_fnames(dname, tail, TRUE);
retval = (char_u *)concat_fnames((char *)dname, (char *)tail, TRUE);
}
return retval;

View File

@ -379,17 +379,20 @@ void expand_env_esc(char_u *srcp, char_u *dst, int dstlen, bool esc, bool one,
/// @param vimdir directory to test
static char *vim_version_dir(const char *vimdir)
{
char_u *p;
char *p;
if (vimdir == NULL || *vimdir == NUL)
if (vimdir == NULL || *vimdir == NUL) {
return NULL;
p = concat_fnames((char_u *)vimdir, (char_u *)VIM_VERSION_NODOT, true);
if (os_isdir(p))
return (char *)p;
}
p = concat_fnames(vimdir, VIM_VERSION_NODOT, true);
if (os_isdir((char_u *)p)) {
return p;
}
xfree(p);
p = concat_fnames((char_u *)vimdir, (char_u *)RUNTIME_DIRNAME, true);
if (os_isdir(p))
return (char *)p;
p = concat_fnames(vimdir, RUNTIME_DIRNAME, true);
if (os_isdir((char_u *)p)) {
return p;
}
xfree(p);
return NULL;
}

View File

@ -329,20 +329,25 @@ int vim_fnamencmp(char_u *x, char_u *y, size_t len)
#endif
}
/*
* Concatenate file names fname1 and fname2 into allocated memory.
* Only add a '/' or '\\' when 'sep' is TRUE and it is necessary.
*/
char_u *concat_fnames(char_u *fname1, char_u *fname2, int sep)
FUNC_ATTR_NONNULL_RET
/// Concatenate file names fname1 and fname2 into allocated memory.
///
/// Only add a '/' or '\\' when 'sep' is true and it is necessary.
///
/// @param fname1 is the first part of the path or filename
/// @param fname2 is the second half of the path or filename
/// @param sep is a flag to indicate a path separator should be added
/// if necessary
/// @return [allocated] Concatenation of fname1 and fname2.
char *concat_fnames(const char *fname1, const char *fname2, bool sep)
FUNC_ATTR_NONNULL_ARG(1, 2) FUNC_ATTR_NONNULL_RET
{
char_u *dest = xmalloc(STRLEN(fname1) + STRLEN(fname2) + 3);
char *dest = xmalloc(strlen(fname1) + strlen(fname2) + 3);
STRCPY(dest, fname1);
strcpy(dest, fname1);
if (sep) {
add_pathsep((char *)dest);
add_pathsep(dest);
}
STRCAT(dest, fname2);
strcat(dest, fname2);
return dest;
}

View File

@ -1085,7 +1085,7 @@ static int qf_get_fnum(char_u *directory, char_u *fname)
slash_adjust(fname);
#endif
if (directory != NULL && !vim_isAbsName(fname)) {
ptr = concat_fnames(directory, fname, TRUE);
ptr = (char_u *)concat_fnames((char *)directory, (char *)fname, TRUE);
/*
* Here we check if the file really exists.
* This should normally be true, but if make works without
@ -1096,7 +1096,7 @@ static int qf_get_fnum(char_u *directory, char_u *fname)
xfree(ptr);
directory = qf_guess_filepath(fname);
if (directory)
ptr = concat_fnames(directory, fname, TRUE);
ptr = (char_u *)concat_fnames((char *)directory, (char *)fname, TRUE);
else
ptr = vim_strsave(fname);
}
@ -1137,8 +1137,8 @@ static char_u *qf_push_dir(char_u *dirbuf, struct dir_stack_T **stackptr)
(*stackptr)->dirname = NULL;
while (ds_new) {
xfree((*stackptr)->dirname);
(*stackptr)->dirname = concat_fnames(ds_new->dirname, dirbuf,
TRUE);
(*stackptr)->dirname = (char_u *)concat_fnames((char *)ds_new->dirname,
(char *)dirbuf, TRUE);
if (os_isdir((*stackptr)->dirname))
break;
@ -1242,7 +1242,7 @@ static char_u *qf_guess_filepath(char_u *filename)
fullname = NULL;
while (ds_ptr) {
xfree(fullname);
fullname = concat_fnames(ds_ptr->dirname, filename, TRUE);
fullname = (char_u *)concat_fnames((char *)ds_ptr->dirname, (char *)filename, TRUE);
if (os_file_exists(fullname))
break;

View File

@ -677,7 +677,7 @@ char_u *u_get_undo_file_name(char_u *buf_ffname, int reading)
if (vim_ispathsep(*p))
*p = '%';
}
undo_file_name = concat_fnames(dir_name, munged_name, TRUE);
undo_file_name = (char_u *)concat_fnames((char *)dir_name, (char *)munged_name, TRUE);
}
}