mirror of
https://github.com/neovim/neovim.git
synced 2025-09-15 15:58:17 +00:00
Remove char_u: concat_fnames()
This commit is contained in:
@@ -2054,7 +2054,7 @@ static char *cs_resolve_file(int i, char *name)
|
|||||||
} else if (csdir != NULL && csinfo[i].fname != NULL && *csdir != NUL) {
|
} else if (csdir != NULL && csinfo[i].fname != NULL && *csdir != NUL) {
|
||||||
/* Check for csdir to be non empty to avoid empty path concatenated to
|
/* Check for csdir to be non empty to avoid empty path concatenated to
|
||||||
* cscope output. */
|
* cscope output. */
|
||||||
fullname = (char *)concat_fnames(csdir, (char_u *)name, TRUE);
|
fullname = concat_fnames((char *)csdir, name, TRUE);
|
||||||
} else {
|
} else {
|
||||||
fullname = xstrdup(name);
|
fullname = xstrdup(name);
|
||||||
}
|
}
|
||||||
|
@@ -1282,7 +1282,7 @@ scripterror:
|
|||||||
&& !os_isdir(alist_name(&GARGLIST[0]))) {
|
&& !os_isdir(alist_name(&GARGLIST[0]))) {
|
||||||
char_u *r;
|
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);
|
xfree(p);
|
||||||
p = r;
|
p = r;
|
||||||
}
|
}
|
||||||
|
@@ -1332,11 +1332,11 @@ recover_names (
|
|||||||
num_names = recov_file_names(names, fname_res, TRUE);
|
num_names = recov_file_names(names, fname_res, TRUE);
|
||||||
} else { /* check directory dir_name */
|
} else { /* check directory dir_name */
|
||||||
if (fname == NULL) {
|
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
|
/* For Unix names starting with a dot are special. MS-Windows
|
||||||
* supports this too, on some file systems. */
|
* supports this too, on some file systems. */
|
||||||
names[1] = concat_fnames(dir_name, (char_u *)".*.sw?", TRUE);
|
names[1] = (char_u *)concat_fnames((char *)dir_name, ".*.sw?", TRUE);
|
||||||
names[2] = concat_fnames(dir_name, (char_u *)".sw?", TRUE);
|
names[2] = (char_u *)concat_fnames((char *)dir_name, ".sw?", TRUE);
|
||||||
num_names = 3;
|
num_names = 3;
|
||||||
} else {
|
} else {
|
||||||
p = dir_name + STRLEN(dir_name);
|
p = dir_name + STRLEN(dir_name);
|
||||||
@@ -1345,7 +1345,7 @@ recover_names (
|
|||||||
tail = (char_u *)make_percent_swname((char *)dir_name, (char *)fname_res);
|
tail = (char_u *)make_percent_swname((char *)dir_name, (char *)fname_res);
|
||||||
} else {
|
} else {
|
||||||
tail = path_tail(fname_res);
|
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);
|
num_names = recov_file_names(names, tail, FALSE);
|
||||||
xfree(tail);
|
xfree(tail);
|
||||||
@@ -1453,7 +1453,7 @@ static char *make_percent_swname(const char *dir, char *name)
|
|||||||
*d = '%';
|
*d = '%';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
d = (char *)concat_fnames((char_u *)dir, (char_u *)s, TRUE);
|
d = concat_fnames(dir, s, TRUE);
|
||||||
xfree(s);
|
xfree(s);
|
||||||
xfree(f);
|
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?".
|
// 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 */
|
if (num_names >= 1) { /* check if we have the same name twice */
|
||||||
char_u *p = names[num_names - 1];
|
char_u *p = names[num_names - 1];
|
||||||
int i = (int)STRLEN(names[num_names - 1]) - (int)STRLEN(names[num_names]);
|
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);
|
retval = vim_strsave(fname);
|
||||||
else if (dname[0] == '.' && vim_ispathsep(dname[1])) {
|
else if (dname[0] == '.' && vim_ispathsep(dname[1])) {
|
||||||
if (tail == fname) /* no path before file name */
|
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 {
|
else {
|
||||||
save_char = *tail;
|
save_char = *tail;
|
||||||
*tail = NUL;
|
*tail = NUL;
|
||||||
t = concat_fnames(fname, dname + 2, TRUE);
|
t = (char_u *)concat_fnames((char *)fname, (char *)dname + 2, TRUE);
|
||||||
*tail = save_char;
|
*tail = save_char;
|
||||||
retval = concat_fnames(t, tail, TRUE);
|
retval = (char_u *)concat_fnames((char *)t, (char *)tail, TRUE);
|
||||||
xfree(t);
|
xfree(t);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
retval = concat_fnames(dname, tail, TRUE);
|
retval = (char_u *)concat_fnames((char *)dname, (char *)tail, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
|
@@ -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
|
/// @param vimdir directory to test
|
||||||
static char *vim_version_dir(const char *vimdir)
|
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;
|
return NULL;
|
||||||
p = concat_fnames((char_u *)vimdir, (char_u *)VIM_VERSION_NODOT, true);
|
}
|
||||||
if (os_isdir(p))
|
p = concat_fnames(vimdir, VIM_VERSION_NODOT, true);
|
||||||
return (char *)p;
|
if (os_isdir((char_u *)p)) {
|
||||||
|
return p;
|
||||||
|
}
|
||||||
xfree(p);
|
xfree(p);
|
||||||
p = concat_fnames((char_u *)vimdir, (char_u *)RUNTIME_DIRNAME, true);
|
p = concat_fnames(vimdir, RUNTIME_DIRNAME, true);
|
||||||
if (os_isdir(p))
|
if (os_isdir((char_u *)p)) {
|
||||||
return (char *)p;
|
return p;
|
||||||
|
}
|
||||||
xfree(p);
|
xfree(p);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@@ -329,20 +329,25 @@ int vim_fnamencmp(char_u *x, char_u *y, size_t len)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/// Concatenate file names fname1 and fname2 into allocated memory.
|
||||||
* Concatenate file names fname1 and fname2 into allocated memory.
|
///
|
||||||
* Only add a '/' or '\\' when 'sep' is TRUE and it is necessary.
|
/// Only add a '/' or '\\' when 'sep' is true and it is necessary.
|
||||||
*/
|
///
|
||||||
char_u *concat_fnames(char_u *fname1, char_u *fname2, int sep)
|
/// @param fname1 is the first part of the path or filename
|
||||||
FUNC_ATTR_NONNULL_RET
|
/// @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) {
|
if (sep) {
|
||||||
add_pathsep((char *)dest);
|
add_pathsep(dest);
|
||||||
}
|
}
|
||||||
STRCAT(dest, fname2);
|
strcat(dest, fname2);
|
||||||
|
|
||||||
return dest;
|
return dest;
|
||||||
}
|
}
|
||||||
|
@@ -1085,7 +1085,7 @@ static int qf_get_fnum(char_u *directory, char_u *fname)
|
|||||||
slash_adjust(fname);
|
slash_adjust(fname);
|
||||||
#endif
|
#endif
|
||||||
if (directory != NULL && !vim_isAbsName(fname)) {
|
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.
|
* Here we check if the file really exists.
|
||||||
* This should normally be true, but if make works without
|
* 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);
|
xfree(ptr);
|
||||||
directory = qf_guess_filepath(fname);
|
directory = qf_guess_filepath(fname);
|
||||||
if (directory)
|
if (directory)
|
||||||
ptr = concat_fnames(directory, fname, TRUE);
|
ptr = (char_u *)concat_fnames((char *)directory, (char *)fname, TRUE);
|
||||||
else
|
else
|
||||||
ptr = vim_strsave(fname);
|
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;
|
(*stackptr)->dirname = NULL;
|
||||||
while (ds_new) {
|
while (ds_new) {
|
||||||
xfree((*stackptr)->dirname);
|
xfree((*stackptr)->dirname);
|
||||||
(*stackptr)->dirname = concat_fnames(ds_new->dirname, dirbuf,
|
(*stackptr)->dirname = (char_u *)concat_fnames((char *)ds_new->dirname,
|
||||||
TRUE);
|
(char *)dirbuf, TRUE);
|
||||||
if (os_isdir((*stackptr)->dirname))
|
if (os_isdir((*stackptr)->dirname))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -1242,7 +1242,7 @@ static char_u *qf_guess_filepath(char_u *filename)
|
|||||||
fullname = NULL;
|
fullname = NULL;
|
||||||
while (ds_ptr) {
|
while (ds_ptr) {
|
||||||
xfree(fullname);
|
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))
|
if (os_file_exists(fullname))
|
||||||
break;
|
break;
|
||||||
|
@@ -677,7 +677,7 @@ char_u *u_get_undo_file_name(char_u *buf_ffname, int reading)
|
|||||||
if (vim_ispathsep(*p))
|
if (vim_ispathsep(*p))
|
||||||
*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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user