aboutsummaryrefslogtreecommitdiff
path: root/src/nvim
diff options
context:
space:
mode:
authorEliseo Martínez <eliseomarmol@gmail.com>2015-05-07 08:08:31 +0200
committerEliseo Martínez <eliseomarmol@gmail.com>2015-05-07 08:08:31 +0200
commitf88cec802169d94ad0a19d45746feac5fe2ea0fa (patch)
treec87107941de9eab120e21df65e46432921c7aebe /src/nvim
parenta2cf628603bf5948f96ceb90b653d2879a9d2f9e (diff)
parent2f60a69bafc4b5130fb213df206179701ec0d74a (diff)
downloadrneovim-f88cec802169d94ad0a19d45746feac5fe2ea0fa.tar.gz
rneovim-f88cec802169d94ad0a19d45746feac5fe2ea0fa.tar.bz2
rneovim-f88cec802169d94ad0a19d45746feac5fe2ea0fa.zip
Merge #2470: Remove char_u (5)
Reviewed-by: Scott Prager <splinterofchaos@gmail.com> Reviewed-by: Michael Reed <m.reed@mykolab.com> Reviewed-by: Eliseo Martínez <eliseomarmol@gmail.com>
Diffstat (limited to 'src/nvim')
-rw-r--r--src/nvim/buffer.c4
-rw-r--r--src/nvim/diff.c2
-rw-r--r--src/nvim/eval.c12
-rw-r--r--src/nvim/ex_cmds.c12
-rw-r--r--src/nvim/ex_cmds2.c10
-rw-r--r--src/nvim/ex_docmd.c8
-rw-r--r--src/nvim/ex_getln.c4
-rw-r--r--src/nvim/file_search.c28
-rw-r--r--src/nvim/fileio.c146
-rw-r--r--src/nvim/hardcopy.c2
-rw-r--r--src/nvim/if_cscope.c2
-rw-r--r--src/nvim/macros.h8
-rw-r--r--src/nvim/main.c2
-rw-r--r--src/nvim/memfile.c2
-rw-r--r--src/nvim/memline.c53
-rw-r--r--src/nvim/option.c2
-rw-r--r--src/nvim/os/env.c19
-rw-r--r--src/nvim/os_unix.c2
-rw-r--r--src/nvim/path.c181
-rw-r--r--src/nvim/quickfix.c12
-rw-r--r--src/nvim/tag.c2
-rw-r--r--src/nvim/tempfile.c10
-rw-r--r--src/nvim/undo.c2
-rw-r--r--src/nvim/window.c4
24 files changed, 263 insertions, 266 deletions
diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c
index 395b20b219..094e80086c 100644
--- a/src/nvim/buffer.c
+++ b/src/nvim/buffer.c
@@ -1661,7 +1661,7 @@ buf_T *buflist_findname_exp(char_u *fname)
buf_T *buf = NULL;
/* First make the name into a full path name */
- ffname = FullName_save(fname,
+ ffname = (char_u *)FullName_save((char *)fname,
#ifdef UNIX
TRUE /* force expansion, get rid of symbolic links */
#else
@@ -3569,7 +3569,7 @@ void fname_expand(buf_T *buf, char_u **ffname, char_u **sfname)
return;
if (*sfname == NULL) /* if no short file name given, use ffname */
*sfname = *ffname;
- *ffname = fix_fname(*ffname); /* expand to full path */
+ *ffname = (char_u *)fix_fname((char *)*ffname); /* expand to full path */
#ifdef FEAT_SHORTCUT
if (!buf->b_p_bin) {
diff --git a/src/nvim/diff.c b/src/nvim/diff.c
index d4fbb290c1..b21bc1f2f4 100644
--- a/src/nvim/diff.c
+++ b/src/nvim/diff.c
@@ -867,7 +867,7 @@ void ex_diffpatch(exarg_T *eap)
#ifdef UNIX
// Get the absolute path of the patchfile, changing directory below.
- fullname = FullName_save(eap->arg, FALSE);
+ fullname = (char_u *)FullName_save((char *)eap->arg, FALSE);
#endif // ifdef UNIX
#ifdef UNIX
diff --git a/src/nvim/eval.c b/src/nvim/eval.c
index c4c2821b80..8a98eae21f 100644
--- a/src/nvim/eval.c
+++ b/src/nvim/eval.c
@@ -7347,7 +7347,7 @@ static buf_T *find_buffer(typval_T *avar)
* buffer, these don't use the full path. */
FOR_ALL_BUFFERS(bp) {
if (bp->b_fname != NULL
- && (path_with_url(bp->b_fname)
+ && (path_with_url((char *)bp->b_fname)
|| bt_nofile(bp)
)
&& STRCMP(bp->b_fname, avar->vval.v_string) == 0) {
@@ -12484,7 +12484,7 @@ static void f_resolve(typval_T *argvars, typval_T *rettv)
/* Ensure that the result will have a trailing path separator
* if the argument has one. */
if (remain == NULL && has_trailing_pathsep)
- add_pathsep(buf);
+ add_pathsep((char *)buf);
/* Separate the first path component in the link value and
* concatenate the remainders. */
@@ -15490,7 +15490,7 @@ static void f_undofile(typval_T *argvars, typval_T *rettv)
/* If there is no file name there will be no undo file. */
rettv->vval.v_string = NULL;
} else {
- char_u *ffname = FullName_save(fname, FALSE);
+ char_u *ffname = (char_u *)FullName_save((char *)fname, FALSE);
if (ffname != NULL)
rettv->vval.v_string = u_get_undo_file_name(ffname, FALSE);
@@ -19912,7 +19912,7 @@ repeat:
/* FullName_save() is slow, don't use it when not needed. */
if (*p != NUL || !vim_isAbsName(*fnamep)) {
- *fnamep = FullName_save(*fnamep, *p != NUL);
+ *fnamep = (char_u *)FullName_save((char *)*fnamep, *p != NUL);
xfree(*bufp); /* free any allocated file name */
*bufp = *fnamep;
if (*fnamep == NULL)
@@ -19927,7 +19927,7 @@ repeat:
*bufp = *fnamep;
if (*fnamep == NULL)
return -1;
- add_pathsep(*fnamep);
+ add_pathsep((char *)*fnamep);
}
}
@@ -19946,7 +19946,7 @@ repeat:
if (c == '.' && **fnamep == '~')
p = pbuf = expand_env_save(*fnamep);
else
- p = pbuf = FullName_save(*fnamep, FALSE);
+ p = pbuf = (char_u *)FullName_save((char *)*fnamep, FALSE);
} else
p = *fnamep;
diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c
index 78200e4689..62c2d4ac98 100644
--- a/src/nvim/ex_cmds.c
+++ b/src/nvim/ex_cmds.c
@@ -1530,7 +1530,7 @@ void write_viminfo(char_u *file, int forceit)
#endif
// Make tempname
- tempname = modname(fname, (char_u *)".tmp", FALSE);
+ tempname = (char_u *)modname((char *)fname, ".tmp", FALSE);
if (tempname != NULL) {
/*
* Check if tempfile already exists. Never overwrite an
@@ -2080,7 +2080,7 @@ int do_write(exarg_T *eap)
other = FALSE;
} else {
fname = ffname;
- free_fname = fix_fname(ffname);
+ free_fname = (char_u *)fix_fname((char *)ffname);
/*
* When out-of-memory, keep unexpanded file name, because we MUST be
* able to write the file in this situation.
@@ -2579,7 +2579,7 @@ do_ecmd (
ffname = curbuf->b_ffname;
sfname = curbuf->b_fname;
}
- free_fname = fix_fname(ffname); /* may expand to full path name */
+ free_fname = (char_u *)fix_fname((char *)ffname); /* may expand to full path name */
if (free_fname != NULL)
ffname = free_fname;
other_file = otherfile(ffname);
@@ -5126,7 +5126,7 @@ void fix_help_buffer(void)
char_u *cp;
/* Find all "doc/ *.txt" files in this directory. */
- add_pathsep(NameBuff);
+ add_pathsep((char *)NameBuff);
STRCAT(NameBuff, "doc/*.??[tx]");
// Note: We cannot just do `&NameBuff` because it is a statically sized array
@@ -5297,7 +5297,7 @@ void ex_helptags(exarg_T *eap)
/* Get a list of all files in the help directory and in subdirectories. */
STRCPY(NameBuff, dirname);
- add_pathsep(NameBuff);
+ add_pathsep((char *)NameBuff);
STRCAT(NameBuff, "**");
// Note: We cannot just do `&NameBuff` because it is a statically sized array
@@ -5419,7 +5419,7 @@ helptags_one (
* Do this before scanning through all the files.
*/
STRCPY(NameBuff, dir);
- add_pathsep(NameBuff);
+ add_pathsep((char *)NameBuff);
STRCAT(NameBuff, tagfname);
fd_tags = mch_fopen((char *)NameBuff, "w");
if (fd_tags == NULL) {
diff --git a/src/nvim/ex_cmds2.c b/src/nvim/ex_cmds2.c
index b79d09885c..08d84c2440 100644
--- a/src/nvim/ex_cmds2.c
+++ b/src/nvim/ex_cmds2.c
@@ -495,7 +495,7 @@ dbg_parsearg (
if (p == NULL)
return FAIL;
if (*p != '*') {
- bp->dbg_name = fix_fname(p);
+ bp->dbg_name = (char_u *)fix_fname((char *)p);
xfree(p);
} else
bp->dbg_name = p;
@@ -1692,7 +1692,7 @@ void do_argfile(exarg_T *eap, int argn)
*/
other = TRUE;
if (P_HID(curbuf)) {
- p = fix_fname(alist_name(&ARGLIST[argn]));
+ p = (char_u *)fix_fname((char *)alist_name(&ARGLIST[argn]));
other = otherfile(p);
xfree(p);
}
@@ -2144,7 +2144,7 @@ int do_in_runtimepath(char_u *name, int all, DoInRuntimepathCB callback,
if (!did_one)
did_one = (cookie == NULL);
} else if (STRLEN(buf) + STRLEN(name) + 2 < MAXPATHL) {
- add_pathsep(buf);
+ add_pathsep((char *)buf);
tail = buf + STRLEN(buf);
/* Loop over all patterns in "name" */
@@ -2313,7 +2313,7 @@ do_source (
p = expand_env_save(fname);
if (p == NULL)
return retval;
- fname_exp = fix_fname(p);
+ fname_exp = (char_u *)fix_fname((char *)p);
xfree(p);
if (fname_exp == NULL)
return retval;
@@ -3305,7 +3305,7 @@ static void script_host_execute(char *name, exarg_T *eap)
static void script_host_execute_file(char *name, exarg_T *eap)
{
uint8_t buffer[MAXPATHL];
- vim_FullName(eap->arg, buffer, sizeof(buffer), false);
+ vim_FullName((char *)eap->arg, (char *)buffer, sizeof(buffer), false);
list_T *args = list_alloc();
// filename
diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c
index 9ff19521b6..289bb85f4d 100644
--- a/src/nvim/ex_docmd.c
+++ b/src/nvim/ex_docmd.c
@@ -7544,7 +7544,7 @@ static void ex_mkrc(exarg_T *eap)
char_u *tbuf;
tbuf = xmalloc(MAXPATHL);
- if (vim_FullName(fname, tbuf, MAXPATHL, FALSE) == OK)
+ if (vim_FullName((char *)fname, (char *)tbuf, MAXPATHL, FALSE) == OK)
set_vim_var_string(VV_THIS_SESSION, tbuf, -1);
xfree(tbuf);
}
@@ -8155,7 +8155,7 @@ eval_vars (
/* Still need to turn the fname into a full path. It is
* postponed to avoid a delay when <afile> is not used. */
autocmd_fname_full = TRUE;
- result = FullName_save(autocmd_fname, FALSE);
+ result = (char_u *)FullName_save((char *)autocmd_fname, FALSE);
xfree(autocmd_fname);
autocmd_fname = result;
}
@@ -8975,7 +8975,7 @@ ses_arglist (
if (s != NULL) {
if (fullname) {
buf = xmalloc(MAXPATHL);
- (void)vim_FullName(s, buf, MAXPATHL, FALSE);
+ (void)vim_FullName((char *)s, (char *)buf, MAXPATHL, FALSE);
s = buf;
}
if (fputs("argadd ", fd) < 0 || ses_put_fname(fd, s, flagp) == FAIL
@@ -9089,7 +9089,7 @@ static char_u *get_view_file(int c)
++len;
retval = xmalloc(STRLEN(sname) + len + STRLEN(p_vdir) + 9);
STRCPY(retval, p_vdir);
- add_pathsep(retval);
+ add_pathsep((char *)retval);
s = retval + STRLEN(retval);
for (p = sname; *p; ++p) {
if (*p == '=') {
diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c
index 1a04f1bd91..3af035a6e3 100644
--- a/src/nvim/ex_getln.c
+++ b/src/nvim/ex_getln.c
@@ -3890,7 +3890,7 @@ static void expand_shellcmd(char_u *filepat, int *num_file, char_u ***file,
if (l > MAXPATHL - 5)
break;
STRLCPY(buf, s, l + 1);
- add_pathsep(buf);
+ add_pathsep((char *)buf);
l = STRLEN(buf);
STRLCPY(buf + l, pat, MAXPATHL - l);
@@ -4107,7 +4107,7 @@ void globpath(char_u *path, char_u *file, garray_T *ga, int expand_options)
// Copy one item of the path to buf[] and concatenate the file name.
copy_option_part(&path, buf, MAXPATHL, ",");
if (STRLEN(buf) + STRLEN(file) + 2 < MAXPATHL) {
- add_pathsep(buf);
+ add_pathsep((char *)buf);
STRCAT(buf, file); // NOLINT
char_u **p;
diff --git a/src/nvim/file_search.c b/src/nvim/file_search.c
index 2777271377..855de6595f 100644
--- a/src/nvim/file_search.c
+++ b/src/nvim/file_search.c
@@ -313,7 +313,7 @@ vim_findfile_init (
if (!vim_isAbsName(rel_fname) && len + 1 < MAXPATHL) {
/* Make the start dir an absolute path name. */
STRLCPY(ff_expand_buffer, rel_fname, len + 1);
- search_ctx->ffsc_start_dir = FullName_save(ff_expand_buffer, FALSE);
+ search_ctx->ffsc_start_dir = (char_u *)FullName_save((char *)ff_expand_buffer, FALSE);
} else
search_ctx->ffsc_start_dir = vim_strnsave(rel_fname, len);
if (*++path != NUL)
@@ -465,7 +465,7 @@ vim_findfile_init (
goto error_return;
}
STRCPY(ff_expand_buffer, search_ctx->ffsc_start_dir);
- add_pathsep(ff_expand_buffer);
+ add_pathsep((char *)ff_expand_buffer);
{
size_t eb_len = STRLEN(ff_expand_buffer);
char_u *buf = xmalloc(eb_len + STRLEN(search_ctx->ffsc_fix_path) + 1);
@@ -474,7 +474,7 @@ vim_findfile_init (
STRCPY(buf + eb_len, search_ctx->ffsc_fix_path);
if (os_isdir(buf)) {
STRCAT(ff_expand_buffer, search_ctx->ffsc_fix_path);
- add_pathsep(ff_expand_buffer);
+ add_pathsep((char *)ff_expand_buffer);
} else {
char_u *p = path_tail(search_ctx->ffsc_fix_path);
char_u *wc_path = NULL;
@@ -484,7 +484,7 @@ vim_findfile_init (
if (p > search_ctx->ffsc_fix_path) {
len = (int)(p - search_ctx->ffsc_fix_path) - 1;
STRNCAT(ff_expand_buffer, search_ctx->ffsc_fix_path, len);
- add_pathsep(ff_expand_buffer);
+ add_pathsep((char *)ff_expand_buffer);
} else
len = (int)STRLEN(search_ctx->ffsc_fix_path);
@@ -695,12 +695,12 @@ char_u *vim_findfile(void *search_ctx_arg)
if (!vim_isAbsName(stackp->ffs_fix_path)
&& search_ctx->ffsc_start_dir) {
STRCPY(file_path, search_ctx->ffsc_start_dir);
- add_pathsep(file_path);
+ add_pathsep((char *)file_path);
}
/* append the fix part of the search path */
STRCAT(file_path, stackp->ffs_fix_path);
- add_pathsep(file_path);
+ add_pathsep((char *)file_path);
rest_of_wildcards = stackp->ffs_wc_path;
if (*rest_of_wildcards != NUL) {
@@ -749,7 +749,7 @@ char_u *vim_findfile(void *search_ctx_arg)
* Expand wildcards like "*" and "$VAR".
* If the path is a URL don't try this.
*/
- if (path_with_url(dirptrs[0])) {
+ if (path_with_url((char *)dirptrs[0])) {
stackp->ffs_filearray = (char_u **)xmalloc(sizeof(char *));
stackp->ffs_filearray[0] = vim_strsave(dirptrs[0]);
stackp->ffs_filearray_size = 1;
@@ -777,14 +777,14 @@ char_u *vim_findfile(void *search_ctx_arg)
*/
for (int i = stackp->ffs_filearray_cur;
i < stackp->ffs_filearray_size; ++i) {
- if (!path_with_url(stackp->ffs_filearray[i])
+ if (!path_with_url((char *)stackp->ffs_filearray[i])
&& !os_isdir(stackp->ffs_filearray[i]))
continue; /* not a directory */
/* prepare the filename to be checked for existence
* below */
STRCPY(file_path, stackp->ffs_filearray[i]);
- add_pathsep(file_path);
+ add_pathsep((char *)file_path);
STRCAT(file_path, search_ctx->ffsc_file_to_search);
/*
@@ -798,7 +798,7 @@ char_u *vim_findfile(void *search_ctx_arg)
suf = curbuf->b_p_sua;
for (;; ) {
/* if file exists and we didn't already find it */
- if ((path_with_url(file_path)
+ if ((path_with_url((char *)file_path)
|| (os_file_exists(file_path)
&& (search_ctx->ffsc_find_what
== FINDFILE_BOTH
@@ -836,7 +836,7 @@ char_u *vim_findfile(void *search_ctx_arg)
stackp->ffs_filearray_cur = (char_u)(i + 1);
ff_push(search_ctx, stackp);
- if (!path_with_url(file_path))
+ if (!path_with_url((char *)file_path))
simplify_filename(file_path);
if (os_dirname(ff_expand_buffer, MAXPATHL)
== OK) {
@@ -936,7 +936,7 @@ char_u *vim_findfile(void *search_ctx_arg)
break;
STRCPY(file_path, search_ctx->ffsc_start_dir);
- add_pathsep(file_path);
+ add_pathsep((char *)file_path);
STRCAT(file_path, search_ctx->ffsc_fix_path);
/* create a new stack entry */
@@ -1097,7 +1097,7 @@ static int ff_check_visited(ff_visited_T **visited_list, char_u *fname, char_u *
FileID file_id;
// For an URL we only compare the name, otherwise we compare the
// device/inode.
- if (path_with_url(fname)) {
+ if (path_with_url((char *)fname)) {
STRLCPY(ff_expand_buffer, fname, MAXPATHL);
url = true;
} else {
@@ -1404,7 +1404,7 @@ find_file_in_path_option (
* filename on the first call.
*/
if (first == TRUE) {
- if (path_with_url(ff_file_to_find)) {
+ if (path_with_url((char *)ff_file_to_find)) {
file_name = vim_strsave(ff_file_to_find);
goto theend;
}
diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c
index 98a2cb4076..f5cf226da4 100644
--- a/src/nvim/fileio.c
+++ b/src/nvim/fileio.c
@@ -2814,7 +2814,7 @@ buf_write (
/*
* Make backup file name.
*/
- backup = modname(rootname, backup_ext, FALSE);
+ backup = (char_u *)modname((char *)rootname, (char *)backup_ext, FALSE);
if (backup == NULL) {
xfree(rootname);
some_error = TRUE; /* out of memory */
@@ -2985,7 +2985,7 @@ nobackup:
if (rootname == NULL)
backup = NULL;
else {
- backup = modname(rootname, backup_ext, FALSE);
+ backup = (char_u *)modname((char *)rootname, (char *)backup_ext, FALSE);
xfree(rootname);
}
@@ -3595,7 +3595,7 @@ restore_backup:
* the backup file our 'original' file.
*/
if (*p_pm && dobackup) {
- char *org = (char *)modname(fname, p_pm, FALSE);
+ char *org = modname((char *)fname, (char *)p_pm, FALSE);
if (backup != NULL) {
/*
@@ -4310,7 +4310,7 @@ void shorten_fnames(int force)
FOR_ALL_BUFFERS(buf) {
if (buf->b_fname != NULL
&& !bt_nofile(buf)
- && !path_with_url(buf->b_fname)
+ && !path_with_url((char *)buf->b_fname)
&& (force
|| buf->b_sfname == NULL
|| path_is_absolute_path(buf->b_sfname))) {
@@ -4333,108 +4333,108 @@ void shorten_fnames(int force)
redraw_tabline = TRUE;
}
-/*
- * add extension to file name - change path/fo.o.h to path/fo.o.h.ext
- *
- * Assumed that fname is a valid name found in the filesystem we assure that
- * the return value is a different name and ends in 'ext'.
- * "ext" MUST be at most 4 characters long if it starts with a dot, 3
- * characters otherwise.
- * Space for the returned name is allocated, must be freed later.
- * Returns NULL when out of memory.
- */
-char_u *
-modname (
- char_u *fname,
- char_u *ext,
- int prepend_dot /* may prepend a '.' to file name */
-)
+/// Get new filename ended by given extension.
+///
+/// @param fname The original filename.
+/// If NULL, use current directory name and ext to
+/// compute new filename.
+/// @param ext The extension to add to the filename.
+/// 4 chars max if prefixed with a dot, 3 otherwise.
+/// @param prepend_dot If true, prefix ext with a dot.
+/// Does nothing if ext already starts with a dot, or
+/// if fname is NULL.
+///
+/// @return [allocated] - A new filename, made up from:
+/// * fname + ext, if fname not NULL.
+/// * current dir + ext, if fname is NULL.
+/// On Windows, and if ext starts with ".", a "_" is
+/// preprended to ext (for filename to be valid).
+/// Result is guaranteed to:
+/// * be ended by <ext>.
+/// * have a basename with at most BASENAMELEN chars:
+/// original basename is truncated if necessary.
+/// * be different than original: basename chars are
+/// replaced by "_" if necessary. If that can't be done
+/// because truncated value of original filename was
+/// made of all underscores, replace first "_" by "v".
+/// - NULL, if fname is NULL and there was a problem trying
+/// to get current directory.
+char *modname(const char *fname, const char *ext, bool prepend_dot)
+ FUNC_ATTR_NONNULL_ARG(2)
{
- char_u *retval;
- char_u *s;
- char_u *e;
- char_u *ptr;
- int fnamelen, extlen;
-
- extlen = (int)STRLEN(ext);
+ char *retval;
+ size_t fnamelen;
+ size_t extlen = strlen(ext);
- /*
- * If there is no file name we must get the name of the current directory
- * (we need the full path in case :cd is used).
- */
+ // If there is no file name we must get the name of the current directory
+ // (we need the full path in case :cd is used).
if (fname == NULL || *fname == NUL) {
- retval = xmalloc(MAXPATHL + extlen + 3);
- if (os_dirname(retval, MAXPATHL) == FAIL ||
- (fnamelen = (int)STRLEN(retval)) == 0) {
+ retval = xmalloc(MAXPATHL + extlen + 3); // +3 for PATHSEP, "_" (Win), NUL
+ if (os_dirname((char_u *)retval, MAXPATHL) == FAIL ||
+ (fnamelen = strlen(retval)) == 0) {
xfree(retval);
return NULL;
}
- if (!after_pathsep((char *)retval, (char *)retval + fnamelen)) {
- retval[fnamelen++] = PATHSEP;
- retval[fnamelen] = NUL;
- }
- prepend_dot = FALSE; /* nothing to prepend a dot to */
+ add_pathsep(retval);
+ fnamelen = strlen(retval);
+ prepend_dot = FALSE; // nothing to prepend a dot to
} else {
- fnamelen = (int)STRLEN(fname);
+ fnamelen = strlen(fname);
retval = xmalloc(fnamelen + extlen + 3);
- STRCPY(retval, fname);
+ strcpy(retval, fname);
}
- /*
- * search backwards until we hit a '/', '\' or ':'.
- * Then truncate what is after the '/', '\' or ':' to BASENAMELEN characters.
- */
+ // Search backwards until we hit a '/', '\' or ':'.
+ // Then truncate what is after the '/', '\' or ':' to BASENAMELEN characters.
+ char *ptr = NULL;
for (ptr = retval + fnamelen; ptr > retval; mb_ptr_back(retval, ptr)) {
if (vim_ispathsep(*ptr)) {
- ++ptr;
+ ptr++;
break;
}
}
- /* the file name has at most BASENAMELEN characters. */
- if (STRLEN(ptr) > BASENAMELEN)
+ // the file name has at most BASENAMELEN characters.
+ if (strlen(ptr) > BASENAMELEN) {
ptr[BASENAMELEN] = '\0';
+ }
- s = ptr + STRLEN(ptr);
+ char *s;
+ s = ptr + strlen(ptr);
#if defined(WIN3264)
- /*
- * If there is no file name, and the extension starts with '.', put a
- * '_' before the dot, because just ".ext" may be invalid if it's on a
- * FAT partition, and on HPFS it doesn't matter.
- */
- else if ((fname == NULL || *fname == NUL) && *ext == '.')
+ // If there is no file name, and the extension starts with '.', put a
+ // '_' before the dot, because just ".ext" may be invalid if it's on a
+ // FAT partition, and on HPFS it doesn't matter.
+ else if ((fname == NULL || *fname == NUL) && *ext == '.') {
*s++ = '_';
+ }
#endif
- /*
- * Append the extension.
- * ext can start with '.' and cannot exceed 3 more characters.
- */
- STRCPY(s, ext);
+ // Append the extension.
+ // ext can start with '.' and cannot exceed 3 more characters.
+ strcpy(s, ext);
- /*
- * Prepend the dot.
- */
- if (prepend_dot && *(e = path_tail(retval)) != '.') {
+ char *e;
+ // Prepend the dot if needed.
+ if (prepend_dot && *(e = (char *)path_tail((char_u *)retval)) != '.') {
STRMOVE(e + 1, e);
*e = '.';
}
- /*
- * Check that, after appending the extension, the file name is really
- * different.
- */
- if (fname != NULL && STRCMP(fname, retval) == 0) {
- /* we search for a character that can be replaced by '_' */
+ // Check that, after appending the extension, the file name is really
+ // different.
+ if (fname != NULL && strcmp(fname, retval) == 0) {
+ // we search for a character that can be replaced by '_'
while (--s >= ptr) {
if (*s != '_') {
*s = '_';
break;
}
}
- if (s < ptr) /* fname was "________.<ext>", how tricky! */
+ if (s < ptr) { // fname was "________.<ext>", how tricky!
*ptr = 'v';
+ }
}
return retval;
}
@@ -6597,7 +6597,7 @@ apply_autocmds_group (
|| event == EVENT_TABCLOSED)
fname = vim_strsave(fname);
else
- fname = FullName_save(fname, FALSE);
+ fname = (char_u *)FullName_save((char *)fname, FALSE);
}
if (fname == NULL) { /* out of memory */
xfree(sfname);
@@ -6923,7 +6923,7 @@ int has_autocmd(event_T event, char_u *sfname, buf_T *buf)
char_u *tail = path_tail(sfname);
int retval = FALSE;
- fname = FullName_save(sfname, FALSE);
+ fname = (char_u *)FullName_save((char *)sfname, FALSE);
if (fname == NULL)
return FALSE;
diff --git a/src/nvim/hardcopy.c b/src/nvim/hardcopy.c
index cf33703fdb..819015a85d 100644
--- a/src/nvim/hardcopy.c
+++ b/src/nvim/hardcopy.c
@@ -1532,7 +1532,7 @@ static int prt_find_resource(char *name, struct prt_ps_resource_S *resource)
STRLCPY(resource->name, name, 64);
/* Look for named resource file in runtimepath */
STRCPY(buffer, "print");
- add_pathsep(buffer);
+ add_pathsep((char *)buffer);
vim_strcat(buffer, (char_u *)name, MAXPATHL);
vim_strcat(buffer, (char_u *)".ps", MAXPATHL);
resource->filename[0] = NUL;
diff --git a/src/nvim/if_cscope.c b/src/nvim/if_cscope.c
index a7052149e0..b5751f0a6e 100644
--- a/src/nvim/if_cscope.c
+++ b/src/nvim/if_cscope.c
@@ -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);
}
diff --git a/src/nvim/macros.h b/src/nvim/macros.h
index 46f591eb33..51542bd3a7 100644
--- a/src/nvim/macros.h
+++ b/src/nvim/macros.h
@@ -128,12 +128,12 @@
/* Get the length of the character p points to */
# define MB_PTR2LEN(p) (has_mbyte ? (*mb_ptr2len)(p) : 1)
/* Advance multi-byte pointer, skip over composing chars. */
-# define mb_ptr_adv(p) p += has_mbyte ? (*mb_ptr2len)(p) : 1
+# define mb_ptr_adv(p) (p += has_mbyte ? (*mb_ptr2len)((char_u *)p) : 1)
/* Advance multi-byte pointer, do not skip over composing chars. */
-# define mb_cptr_adv(p) p += \
- enc_utf8 ? utf_ptr2len(p) : has_mbyte ? (*mb_ptr2len)(p) : 1
+# define mb_cptr_adv(p) (p += \
+ enc_utf8 ? utf_ptr2len(p) : has_mbyte ? (*mb_ptr2len)(p) : 1)
/* Backup multi-byte pointer. Only use with "p" > "s" ! */
-# define mb_ptr_back(s, p) p -= has_mbyte ? ((*mb_head_off)(s, p - 1) + 1) : 1
+# define mb_ptr_back(s, p) (p -= has_mbyte ? ((*mb_head_off)((char_u *)s, (char_u *)p - 1) + 1) : 1)
/* get length of multi-byte char, not including composing chars */
# define mb_cptr2len(p) (enc_utf8 ? utf_ptr2len(p) : (*mb_ptr2len)(p))
diff --git a/src/nvim/main.c b/src/nvim/main.c
index e1d53183aa..c1270c6181 100644
--- a/src/nvim/main.c
+++ b/src/nvim/main.c
@@ -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;
}
diff --git a/src/nvim/memfile.c b/src/nvim/memfile.c
index bbe2e62021..b6a341d5e8 100644
--- a/src/nvim/memfile.c
+++ b/src/nvim/memfile.c
@@ -893,7 +893,7 @@ blocknr_T mf_trans_del(memfile_T *mfp, blocknr_T old_nr)
/// name so we must work out the full path name.
void mf_set_ffname(memfile_T *mfp)
{
- mfp->mf_ffname = FullName_save(mfp->mf_fname, false);
+ mfp->mf_ffname = (char_u *)FullName_save((char *)mfp->mf_fname, false);
}
/// Make name of memfile's swapfile a full path.
diff --git a/src/nvim/memline.c b/src/nvim/memline.c
index 8e87bef244..29263144a4 100644
--- a/src/nvim/memline.c
+++ b/src/nvim/memline.c
@@ -1332,20 +1332,20 @@ 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);
if (after_pathsep((char *)dir_name, (char *)p) && p[-1] == p[-2]) {
/* Ends with '//', Use Full path for swap name */
- tail = make_percent_swname(dir_name, fname_res);
+ 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);
@@ -1364,7 +1364,7 @@ recover_names (
* Try finding a swap file by simply adding ".swp" to the file name.
*/
if (*dirp == NUL && file_count + num_files == 0 && fname != NULL) {
- char_u *swapname = modname(fname_res, (char_u *)".swp", TRUE);
+ char_u *swapname = (char_u *)modname((char *)fname_res, ".swp", TRUE);
if (swapname != NULL) {
if (os_file_exists(swapname)) {
files = (char_u **)xmalloc(sizeof(char_u *));
@@ -1441,17 +1441,18 @@ recover_names (
* Append the full path to name with path separators made into percent
* signs, to dir. An unnamed buffer is handled as "" (<currentdir>/"")
*/
-static char_u *make_percent_swname(char_u *dir, char_u *name)
+static char *make_percent_swname(const char *dir, char *name)
+ FUNC_ATTR_NONNULL_ARG(1)
{
- char_u *d, *s, *f;
-
- f = fix_fname(name != NULL ? name : (char_u *) "");
- d = NULL;
+ char *d = NULL;
+ char *f = fix_fname(name != NULL ? name : "");
if (f != NULL) {
- s = (char_u *)xstrdup((char *)f);
- for (d = s; *d != NUL; mb_ptr_adv(d))