aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDundar Göc <gocdundar@gmail.com>2022-08-26 23:11:25 +0200
committerdundargoc <gocdundar@gmail.com>2022-09-10 11:17:40 +0200
commit684bc749efef0fa31395d349f4495d79ec5f3fd5 (patch)
tree2f20ecdf42e443e48ac981d204c316449aa87821 /src
parent82d93429e78b661027c05f3fbc862aa0e0c6cd95 (diff)
downloadrneovim-684bc749efef0fa31395d349f4495d79ec5f3fd5.tar.gz
rneovim-684bc749efef0fa31395d349f4495d79ec5f3fd5.tar.bz2
rneovim-684bc749efef0fa31395d349f4495d79ec5f3fd5.zip
refactor: replace char_u with char
Work on https://github.com/neovim/neovim/issues/459
Diffstat (limited to 'src')
-rw-r--r--src/nvim/arglist.c2
-rw-r--r--src/nvim/autocmd.c6
-rw-r--r--src/nvim/buffer.c4
-rw-r--r--src/nvim/cmdexpand.c2
-rw-r--r--src/nvim/eval.c10
-rw-r--r--src/nvim/eval/funcs.c22
-rw-r--r--src/nvim/eval/userfunc.c4
-rw-r--r--src/nvim/ex_cmds.c6
-rw-r--r--src/nvim/ex_docmd.c4
-rw-r--r--src/nvim/ex_getln.c2
-rw-r--r--src/nvim/file_search.c25
-rw-r--r--src/nvim/fileio.c80
-rw-r--r--src/nvim/garray.c2
-rw-r--r--src/nvim/globals.h2
-rw-r--r--src/nvim/hardcopy.c14
-rw-r--r--src/nvim/help.c44
-rw-r--r--src/nvim/indent.c2
-rw-r--r--src/nvim/insexpand.c12
-rw-r--r--src/nvim/lua/stdlib.c4
-rw-r--r--src/nvim/mark.c12
-rw-r--r--src/nvim/memline.c16
-rw-r--r--src/nvim/option.c34
-rw-r--r--src/nvim/os/env.c6
-rw-r--r--src/nvim/path.c88
-rw-r--r--src/nvim/profile.c2
-rw-r--r--src/nvim/quickfix.c48
-rw-r--r--src/nvim/regexp.c12
-rw-r--r--src/nvim/regexp_bt.c4
-rw-r--r--src/nvim/regexp_defs.h4
-rw-r--r--src/nvim/regexp_nfa.c4
-rw-r--r--src/nvim/runtime.c4
-rw-r--r--src/nvim/search.c16
-rw-r--r--src/nvim/shada.c4
-rw-r--r--src/nvim/spell.c8
-rw-r--r--src/nvim/spellfile.c2
-rw-r--r--src/nvim/spellsuggest.c4
-rw-r--r--src/nvim/tag.c2
-rw-r--r--src/nvim/undo.c2
-rw-r--r--src/nvim/vim.h18
39 files changed, 262 insertions, 275 deletions
diff --git a/src/nvim/arglist.c b/src/nvim/arglist.c
index 0000636417..02e3a99aab 100644
--- a/src/nvim/arglist.c
+++ b/src/nvim/arglist.c
@@ -633,7 +633,7 @@ void ex_argdedupe(exarg_T *eap FUNC_ATTR_UNUSED)
{
for (int i = 0; i < ARGCOUNT; i++) {
for (int j = i + 1; j < ARGCOUNT; j++) {
- if (FNAMECMP(ARGLIST[i].ae_fname, ARGLIST[j].ae_fname) == 0) {
+ if (path_fnamecmp(ARGLIST[i].ae_fname, ARGLIST[j].ae_fname) == 0) {
xfree(ARGLIST[j].ae_fname);
memmove(ARGLIST + j, ARGLIST + j + 1,
(size_t)(ARGCOUNT - j - 1) * sizeof(aentry_T));
diff --git a/src/nvim/autocmd.c b/src/nvim/autocmd.c
index 635875b16f..9d37647a4e 100644
--- a/src/nvim/autocmd.c
+++ b/src/nvim/autocmd.c
@@ -2396,7 +2396,7 @@ bool au_exists(const char *const arg) FUNC_ATTR_WARN_UNUSED_RESULT
}
// if pattern is "<buffer>", special handling is needed which uses curbuf
- // for pattern "<buffer=N>, FNAMECMP() will work fine
+ // for pattern "<buffer=N>, path_fnamecmp() will work fine
if (pattern != NULL && STRICMP(pattern, "<buffer>") == 0) {
buflocal_buf = curbuf;
}
@@ -2404,12 +2404,12 @@ bool au_exists(const char *const arg) FUNC_ATTR_WARN_UNUSED_RESULT
// Check if there is an autocommand with the given pattern.
for (; ap != NULL; ap = ap->next) {
// only use a pattern when it has not been removed and has commands.
- // For buffer-local autocommands, FNAMECMP() works fine.
+ // For buffer-local autocommands, path_fnamecmp() works fine.
if (ap->pat != NULL && ap->cmds != NULL
&& (group == AUGROUP_ALL || ap->group == group)
&& (pattern == NULL
|| (buflocal_buf == NULL
- ? FNAMECMP(ap->pat, pattern) == 0
+ ? path_fnamecmp(ap->pat, pattern) == 0
: ap->buflocal_nr == buflocal_buf->b_fnum))) {
retval = true;
break;
diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c
index 658d372cee..1cc68c9cee 100644
--- a/src/nvim/buffer.c
+++ b/src/nvim/buffer.c
@@ -2733,7 +2733,7 @@ void buflist_list(exarg_T *eap)
IObuff[len++] = ' ';
} while (--i > 0 && len < IOSIZE - 18);
if (vim_strchr(eap->arg, 't') && buf->b_last_used) {
- undo_fmt_time(IObuff + len, (size_t)(IOSIZE - len), buf->b_last_used);
+ undo_fmt_time((char_u *)IObuff + len, (size_t)(IOSIZE - len), buf->b_last_used);
} else {
vim_snprintf((char *)IObuff + len, (size_t)(IOSIZE - len), _("line %" PRId64),
buf == curbuf ? (int64_t)curwin->w_cursor.lnum : (int64_t)buflist_findlnum(buf));
@@ -2965,7 +2965,7 @@ static bool otherfile_buf(buf_T *buf, char *ffname, FileID *file_id_p, bool file
if (ffname == NULL || *ffname == NUL || buf->b_ffname == NULL) {
return true;
}
- if (FNAMECMP(ffname, buf->b_ffname) == 0) {
+ if (path_fnamecmp(ffname, buf->b_ffname) == 0) {
return false;
}
{
diff --git a/src/nvim/cmdexpand.c b/src/nvim/cmdexpand.c
index d2cfb25bf9..3e9edea372 100644
--- a/src/nvim/cmdexpand.c
+++ b/src/nvim/cmdexpand.c
@@ -361,7 +361,7 @@ static char *ExpandOne_start(int mode, expand_T *xp, char *str, int options)
// expand_wildcards, only need to check the first two.
non_suf_match = 0;
for (int i = 0; i < 2; i++) {
- if (match_suffix((char_u *)xp->xp_files[i])) {
+ if (match_suffix(xp->xp_files[i])) {
non_suf_match++;
}
}
diff --git a/src/nvim/eval.c b/src/nvim/eval.c
index 0f2547120d..ead01fcbad 100644
--- a/src/nvim/eval.c
+++ b/src/nvim/eval.c
@@ -8117,7 +8117,7 @@ repeat:
// Do not call shorten_fname() here since it removes the prefix
// even though the path does not have a prefix.
- if (FNAMENCMP(p, dirname, namelen) == 0) {
+ if (path_fnamencmp(p, dirname, namelen) == 0) {
p += namelen;
if (vim_ispathsep(*p)) {
while (*p && vim_ispathsep(*p)) {
@@ -8329,7 +8329,7 @@ char *do_string_sub(char *str, char *pat, char *sub, typval_T *expr, char *flags
while (vim_regexec_nl(&regmatch, (char_u *)str, (colnr_T)(tail - str))) {
// Skip empty match except for first match.
if (regmatch.startp[0] == regmatch.endp[0]) {
- if ((char_u *)zero_width == regmatch.startp[0]) {
+ if (zero_width == regmatch.startp[0]) {
// avoid getting stuck on a match with an empty string
int i = utfc_ptr2len(tail);
memmove((char_u *)ga.ga_data + ga.ga_len, tail, (size_t)i);
@@ -8337,7 +8337,7 @@ char *do_string_sub(char *str, char *pat, char *sub, typval_T *expr, char *flags
tail += i;
continue;
}
- zero_width = (char *)regmatch.startp[0];
+ zero_width = regmatch.startp[0];
}
// Get some space for a temporary buffer to do the substitution
@@ -8350,14 +8350,14 @@ char *do_string_sub(char *str, char *pat, char *sub, typval_T *expr, char *flags
(regmatch.endp[0] - regmatch.startp[0])));
// copy the text up to where the match is
- int i = (int)(regmatch.startp[0] - (char_u *)tail);
+ int i = (int)(regmatch.startp[0] - tail);
memmove((char_u *)ga.ga_data + ga.ga_len, tail, (size_t)i);
// add the substituted text
(void)vim_regsub(&regmatch, (char_u *)sub, expr,
(char_u *)ga.ga_data + ga.ga_len + i, sublen,
REGSUB_COPY | REGSUB_MAGIC);
ga.ga_len += i + sublen - 1;
- tail = (char *)regmatch.endp[0];
+ tail = regmatch.endp[0];
if (*tail == NUL) {
break;
}
diff --git a/src/nvim/eval/funcs.c b/src/nvim/eval/funcs.c
index fa48f227e3..b59caab34f 100644
--- a/src/nvim/eval/funcs.c
+++ b/src/nvim/eval/funcs.c
@@ -4984,9 +4984,9 @@ static void find_some_match(typval_T *const argvars, typval_T *const rettv,
li = TV_LIST_ITEM_NEXT(l, li);
idx++;
} else {
- startcol = (colnr_T)(regmatch.startp[0]
- + utfc_ptr2len((char *)regmatch.startp[0]) - str);
- if (startcol > (colnr_T)len || str + startcol <= regmatch.startp[0]) {
+ startcol = (colnr_T)((char_u *)regmatch.startp[0]
+ + utfc_ptr2len(regmatch.startp[0]) - str);
+ if (startcol > (colnr_T)len || str + startcol <= (char_u *)regmatch.startp[0]) {
match = false;
break;
}
@@ -5005,8 +5005,8 @@ static void find_some_match(typval_T *const argvars, typval_T *const rettv,
const size_t rd = (size_t)(regmatch.endp[0] - regmatch.startp[0]);
TV_LIST_ITEM_TV(li1)->vval.v_string = xmemdupz((const char *)regmatch.startp[0], rd);
- TV_LIST_ITEM_TV(li3)->vval.v_number = (varnumber_T)(regmatch.startp[0] - expr);
- TV_LIST_ITEM_TV(li4)->vval.v_number = (varnumber_T)(regmatch.endp[0] - expr);
+ TV_LIST_ITEM_TV(li3)->vval.v_number = (varnumber_T)((char_u *)regmatch.startp[0] - expr);
+ TV_LIST_ITEM_TV(li4)->vval.v_number = (varnumber_T)(regmatch.endp[0] - (char *)expr);
if (l != NULL) {
TV_LIST_ITEM_TV(li2)->vval.v_number = (varnumber_T)idx;
}
@@ -5041,10 +5041,10 @@ static void find_some_match(typval_T *const argvars, typval_T *const rettv,
} else {
if (type == kSomeMatch) {
rettv->vval.v_number =
- (varnumber_T)(regmatch.startp[0] - str);
+ (varnumber_T)((char_u *)regmatch.startp[0] - str);
} else {
rettv->vval.v_number =
- (varnumber_T)(regmatch.endp[0] - str);
+ (varnumber_T)(regmatch.endp[0] - (char *)str);
}
rettv->vval.v_number += (varnumber_T)(str - expr);
}
@@ -6225,8 +6225,8 @@ static void f_rename(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
rettv->vval.v_number = -1;
} else {
char buf[NUMBUFLEN];
- rettv->vval.v_number = vim_rename((const char_u *)tv_get_string(&argvars[0]),
- (const char_u *)tv_get_string_buf(&argvars[1], buf));
+ rettv->vval.v_number = vim_rename(tv_get_string(&argvars[0]),
+ tv_get_string_buf(&argvars[1], buf));
}
}
@@ -8193,11 +8193,11 @@ static void f_split(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
break;
}
// Advance to just after the match.
- if (regmatch.endp[0] > (char_u *)str) {
+ if (regmatch.endp[0] > str) {
col = 0;
} else {
// Don't get stuck at the same match.
- col = utfc_ptr2len((char *)regmatch.endp[0]);
+ col = utfc_ptr2len(regmatch.endp[0]);
}
str = (const char *)regmatch.endp[0];
}
diff --git a/src/nvim/eval/userfunc.c b/src/nvim/eval/userfunc.c
index a1c4b8b893..70c9e02d5c 100644
--- a/src/nvim/eval/userfunc.c
+++ b/src/nvim/eval/userfunc.c
@@ -2462,7 +2462,7 @@ void ex_function(exarg_T *eap)
p = vim_strchr((char *)scriptname, '/');
plen = (int)STRLEN(p);
slen = (int)STRLEN(SOURCING_NAME);
- if (slen > plen && FNAMECMP(p, SOURCING_NAME + slen - plen) == 0) {
+ if (slen > plen && path_fnamecmp(p, SOURCING_NAME + slen - plen) == 0) {
j = OK;
}
xfree(scriptname);
@@ -2632,7 +2632,7 @@ char *get_user_func_name(expand_T *xp, int idx)
return (char *)fp->uf_name; // Prevent overflow.
}
- cat_func_name(IObuff, fp);
+ cat_func_name((char_u *)IObuff, fp);
if (xp->xp_context != EXPAND_USER_FUNC) {
STRCAT(IObuff, "(");
if (!fp->uf_varargs && GA_EMPTY(&fp->uf_args)) {
diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c
index 4f33a2d883..96bef4902c 100644
--- a/src/nvim/ex_cmds.c
+++ b/src/nvim/ex_cmds.c
@@ -559,10 +559,10 @@ void ex_sort(exarg_T *eap)
end_col = len;
if (regmatch.regprog != NULL && vim_regexec(&regmatch, s, 0)) {
if (sort_rx) {
- start_col = (colnr_T)(regmatch.startp[0] - (char_u *)s);
- end_col = (colnr_T)(regmatch.endp[0] - (char_u *)s);
+ start_col = (colnr_T)(regmatch.startp[0] - s);
+ end_col = (colnr_T)(regmatch.endp[0] - s);
} else {
- start_col = (colnr_T)(regmatch.endp[0] - (char_u *)s);
+ start_col = (colnr_T)(regmatch.endp[0] - s);
}
} else if (regmatch.regprog != NULL) {
end_col = 0;
diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c
index 2a378f6f02..5defabc05a 100644
--- a/src/nvim/ex_docmd.c
+++ b/src/nvim/ex_docmd.c
@@ -2836,12 +2836,12 @@ static void append_command(char *cmd)
}
STRCAT(IObuff, ": ");
d = (char *)IObuff + STRLEN(IObuff);
- while (*s != NUL && (char_u *)d - IObuff + 5 < IOSIZE) {
+ while (*s != NUL && d - IObuff + 5 < IOSIZE) {
if ((char_u)s[0] == 0xc2 && (char_u)s[1] == 0xa0) {
s += 2;
STRCPY(d, "<a0>");
d += 4;
- } else if ((char_u *)d - IObuff + utfc_ptr2len(s) + 1 >= IOSIZE) {
+ } else if (d - IObuff + utfc_ptr2len(s) + 1 >= IOSIZE) {
break;
} else {
mb_copy_char((const char **)&s, &d);
diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c
index 60c89f61a8..2b7797ddc8 100644
--- a/src/nvim/ex_getln.c
+++ b/src/nvim/ex_getln.c
@@ -2005,7 +2005,7 @@ static int command_line_handle_key(CommandLineState *s)
} else {
int j = utf_char2bytes(s->c, (char *)IObuff);
IObuff[j] = NUL; // exclude composing chars
- put_on_cmdline(IObuff, j, true);
+ put_on_cmdline((char_u *)IObuff, j, true);
}
return command_line_changed(s);
}
diff --git a/src/nvim/file_search.c b/src/nvim/file_search.c
index 5416be651d..b3491e98c2 100644
--- a/src/nvim/file_search.c
+++ b/src/nvim/file_search.c
@@ -112,7 +112,7 @@ typedef struct ff_visited {
FileID file_id;
// The memory for this struct is allocated according to the length of
// ffv_fname.
- char_u ffv_fname[1]; // actually longer
+ char ffv_fname[1]; // actually longer
} ff_visited_T;
// We might have to manage several visited lists during a search.
@@ -463,7 +463,7 @@ void *vim_findfile_init(char *path, char *filename, char *stopdirs, int level, i
xfree(buf);
goto error_return;
}
- STRLCAT(ff_expand_buffer, search_ctx->ffsc_fix_path, eb_len + (size_t)len + 1);
+ xstrlcat(ff_expand_buffer, search_ctx->ffsc_fix_path, eb_len + (size_t)len + 1);
add_pathsep(ff_expand_buffer);
} else {
len = (int)STRLEN(search_ctx->ffsc_fix_path);
@@ -813,8 +813,7 @@ char_u *vim_findfile(void *search_ctx_arg)
}
if (os_dirname((char_u *)ff_expand_buffer, MAXPATHL)
== OK) {
- p = path_shorten_fname(file_path,
- (char_u *)ff_expand_buffer);
+ p = (char_u *)path_shorten_fname((char *)file_path, ff_expand_buffer);
if (p != NULL) {
STRMOVE(file_path, p);
}
@@ -859,8 +858,8 @@ char_u *vim_findfile(void *search_ctx_arg)
if (STRNCMP(stackp->ffs_wc_path, "**", 2) == 0) {
for (int i = stackp->ffs_filearray_cur;
i < stackp->ffs_filearray_size; i++) {
- if (FNAMECMP(stackp->ffs_filearray[i],
- stackp->ffs_fix_path) == 0) {
+ if (path_fnamecmp(stackp->ffs_filearray[i],
+ (char *)stackp->ffs_fix_path) == 0) {
continue; // don't repush same directory
}
if (!os_isdir(stackp->ffs_filearray[i])) {
@@ -883,9 +882,9 @@ char_u *vim_findfile(void *search_ctx_arg)
ff_stack_T *sptr;
// is the last starting directory in the stop list?
- if (ff_path_in_stoplist((char_u *)search_ctx->ffsc_start_dir,
+ if (ff_path_in_stoplist(search_ctx->ffsc_start_dir,
(int)(path_end - (char_u *)search_ctx->ffsc_start_dir),
- (char_u **)search_ctx->ffsc_stopdirs_v) == true) {
+ search_ctx->ffsc_stopdirs_v) == true) {
break;
}
@@ -981,7 +980,7 @@ static ff_visited_list_hdr_T *ff_get_visited_list(char *filename,
if (*list_headp != NULL) {
retptr = *list_headp;
while (retptr != NULL) {
- if (FNAMECMP(filename, retptr->ffvl_filename) == 0) {
+ if (path_fnamecmp(filename, retptr->ffvl_filename) == 0) {
#ifdef FF_VERBOSE
if (p_verbose >= 5) {
verbose_enter_scroll();
@@ -1080,7 +1079,7 @@ static int ff_check_visited(ff_visited_T **visited_list, char *fname, char *wc_p
// check against list of already visited files
for (vp = *visited_list; vp != NULL; vp = vp->ffv_next) {
- if ((url && FNAMECMP(vp->ffv_fname, ff_expand_buffer) == 0)
+ if ((url && path_fnamecmp(vp->ffv_fname, ff_expand_buffer) == 0)
|| (!url && vp->file_id_valid
&& os_fileid_equal(&(vp->file_id), &file_id))) {
// are the wildcard parts equal
@@ -1224,7 +1223,7 @@ static void ff_clear(ff_search_ctx_T *search_ctx)
/// check if the given path is in the stopdirs
///
/// @return true if yes else false
-static int ff_path_in_stoplist(char_u *path, int path_len, char_u **stopdirs_v)
+static int ff_path_in_stoplist(char *path, int path_len, char **stopdirs_v)
{
int i = 0;
@@ -1243,12 +1242,12 @@ static int ff_path_in_stoplist(char_u *path, int path_len, char_u **stopdirs_v)
// match for parent directory. So '/home' also matches
// '/home/rks'. Check for PATHSEP in stopdirs_v[i], else
// '/home/r' would also match '/home/rks'
- if (FNAMENCMP(stopdirs_v[i], path, path_len) == 0
+ if (path_fnamencmp(stopdirs_v[i], path, (size_t)path_len) == 0
&& vim_ispathsep(stopdirs_v[i][path_len])) {
return true;
}
} else {
- if (FNAMECMP(stopdirs_v[i], path) == 0) {
+ if (path_fnamecmp(stopdirs_v[i], path) == 0) {
return true;
}
}
diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c
index 7b117aa6e3..0bc7f736bc 100644
--- a/src/nvim/fileio.c
+++ b/src/nvim/fileio.c
@@ -117,7 +117,7 @@ struct bw_info {
static char *e_auchangedbuf = N_("E812: Autocommands changed buffer or buffer name");
-void filemess(buf_T *buf, char_u *name, char_u *s, int attr)
+void filemess(buf_T *buf, char *name, char *s, int attr)
{
int msg_scroll_save;
@@ -126,7 +126,7 @@ void filemess(buf_T *buf, char_u *name, char_u *s, int attr)
}
add_quoted_fname((char *)IObuff, IOSIZE - 100, buf, (const char *)name);
// Avoid an over-long translation to cause trouble.
- STRLCAT(IObuff, s, IOSIZE);
+ xstrlcat(IObuff, s, IOSIZE);
// For the first message may have to start a new line.
// For further ones overwrite the previous one, reset msg_scroll before
// calling filemess().
@@ -350,7 +350,7 @@ int readfile(char *fname, char *sfname, linenr_T from, linenr_T lines_to_skip,
// If the name is too long we might crash further on, quit here.
if (namelen >= MAXPATHL) {
- filemess(curbuf, (char_u *)fname, (char_u *)_("Illegal file name"), 0);
+ filemess(curbuf, fname, _("Illegal file name"), 0);
msg_end();
msg_scroll = msg_save;
return FAIL;
@@ -361,7 +361,7 @@ int readfile(char *fname, char *sfname, linenr_T from, linenr_T lines_to_skip,
// swap file may destroy it! Reported on MS-DOS and Win 95.
if (after_pathsep(fname, fname + namelen)) {
if (!silent) {
- filemess(curbuf, (char_u *)fname, (char_u *)_(msg_is_a_directory), 0);
+ filemess(curbuf, fname, _(msg_is_a_directory), 0);
}
msg_end();
msg_scroll = msg_save;
@@ -383,10 +383,10 @@ int readfile(char *fname, char *sfname, linenr_T from, linenr_T lines_to_skip,
) {
if (S_ISDIR(perm)) {
if (!silent) {
- filemess(curbuf, (char_u *)fname, (char_u *)_(msg_is_a_directory), 0);
+ filemess(curbuf, fname, _(msg_is_a_directory), 0);
}
} else {
- filemess(curbuf, (char_u *)fname, (char_u *)_("is not a file"), 0);
+ filemess(curbuf, fname, _("is not a file"), 0);
}
msg_end();
msg_scroll = msg_save;
@@ -475,9 +475,9 @@ int readfile(char *fname, char *sfname, linenr_T from, linenr_T lines_to_skip,
}
if (!silent) {
if (dir_of_file_exists((char_u *)fname)) {
- filemess(curbuf, (char_u *)sfname, (char_u *)new_file_message(), 0);
+ filemess(curbuf, sfname, new_file_message(), 0);
} else {
- filemess(curbuf, (char_u *)sfname, (char_u *)_("[New DIRECTORY]"), 0);
+ filemess(curbuf, sfname, _("[New DIRECTORY]"), 0);
}
}
// Even though this is a new file, it might have been
@@ -497,15 +497,15 @@ int readfile(char *fname, char *sfname, linenr_T from, linenr_T lines_to_skip,
}
return OK; // a new file is not an error
} else {
- filemess(curbuf, (char_u *)sfname, (char_u *)((fd == UV_EFBIG) ? _("[File too big]") :
+ filemess(curbuf, sfname, ((fd == UV_EFBIG) ? _("[File too big]") :
#if defined(UNIX) && defined(EOVERFLOW)
- // libuv only returns -errno
- // in Unix and in Windows
- // open() does not set
- // EOVERFLOW
- (fd == -EOVERFLOW) ? _("[File too big]") :
+ // libuv only returns -errno
+ // in Unix and in Windows
+ // open() does not set
+ // EOVERFLOW
+ (fd == -EOVERFLOW) ? _("[File too big]") :
#endif
- _("[Permission Denied]")), 0);
+ _("[Permission Denied]")), 0);
curbuf->b_p_ro = true; // must use "w!" now
}
@@ -661,7 +661,7 @@ int readfile(char *fname, char *sfname, linenr_T from, linenr_T lines_to_skip,
if (!recoverymode && !filtering && !(flags & READ_DUMMY) && !silent) {
if (!read_stdin && !read_buffer) {
- filemess(curbuf, (char_u *)sfname, (char_u *)"", 0);
+ filemess(curbuf, sfname, "", 0);
}
}
@@ -1728,7 +1728,7 @@ failed:
if (got_int) {
if (!(flags & READ_DUMMY)) {
- filemess(curbuf, (char_u *)sfname, (char_u *)_(e_interr), 0);
+ filemess(curbuf, sfname, _(e_interr), 0);
if (newfile) {
curbuf->b_p_ro = true; // must use "w!" now
}
@@ -2253,7 +2253,7 @@ int buf_write(buf_T *buf, char *fname, char *sfname, linenr_T start, linenr_T en
fname = sfname;
#endif
- if (buf->b_ffname != NULL && FNAMECMP(ffname, buf->b_ffname) == 0) {
+ if (buf->b_ffname != NULL && path_fnamecmp(ffname, buf->b_ffname) == 0) {
overwriting = true;
} else {
overwriting = false;
@@ -2455,9 +2455,9 @@ int buf_write(buf_T *buf, char *fname, char *sfname, linenr_T start, linenr_T en
#ifndef UNIX
(char_u *)sfname,
#else
- (char_u *)fname,
+ fname,
#endif
- (char_u *)"", 0); // show that we are busy
+ "", 0); // show that we are busy
}
msg_scroll = false; // always overwrite the file message now
@@ -2596,7 +2596,7 @@ int buf_write(buf_T *buf, char *fname, char *sfname, linenr_T start, linenr_T en
STRCPY(IObuff, fname);
for (i = 4913;; i += 123) {
char *tail = path_tail((char *)IObuff);
- size_t size = (size_t)((char_u *)tail - IObuff);
+ size_t size = (size_t)(tail - IObuff);
snprintf(tail, IOSIZE - size, "%d", i);
if (!os_fileinfo_link((char *)IObuff, &file_info)) {
break;
@@ -2884,7 +2884,7 @@ nobackup:
// If the renaming of the original file to the backup file
// works, quit here.
///
- if (vim_rename((char_u *)fname, (char_u *)backup) == 0) {
+ if (vim_rename(fname, backup) == 0) {
break;
}
@@ -3100,7 +3100,7 @@ restore_backup:
// In that case we leave the copy around.
// If file does not exist, put the copy in its place
if (!os_path_exists(fname)) {
- vim_rename((char_u *)backup, (char_u *)fname);
+ vim_rename(backup, fname);
}
// if original file does exist throw away the copy
if (os_path_exists(fname)) {
@@ -3108,7 +3108,7 @@ restore_backup:
}
} else {
// try to put the original file back
- vim_rename((char_u *)backup, (char_u *)fname);
+ vim_rename(backup, fname);
}
}
@@ -3375,7 +3375,7 @@ restore_backup:
end = 1; // success
}
} else {
- if (vim_rename((char_u *)backup, (char_u *)fname) == 0) {
+ if (vim_rename(backup, fname) == 0) {
end = 1;
}
}
@@ -3471,7 +3471,7 @@ restore_backup:
if (org == NULL) {
emsg(_("E205: Patchmode: can't save original file"));
} else if (!os_path_exists(org)) {
- vim_rename((char_u *)backup, (char_u *)org);
+ vim_rename(backup, org);
XFREE_CLEAR(backup); // don't delete the file
#ifdef UNIX
os_file_settime(org,
@@ -3716,20 +3716,20 @@ void msg_add_lines(int insert_space, long lnum, off_T nchars)
{
char_u *p;
- p = IObuff + STRLEN(IObuff);
+ p = (char_u *)IObuff + STRLEN(IObuff);
if (insert_space) {
*p++ = ' ';
}
if (shortmess(SHM_LINES)) {
- vim_snprintf((char *)p, (size_t)(IOSIZE - (p - IObuff)), "%" PRId64 "L, %" PRId64 "B",
+ vim_snprintf((char *)p, (size_t)(IOSIZE - (p - (char_u *)IObuff)), "%" PRId64 "L, %" PRId64 "B",
(int64_t)lnum, (int64_t)nchars);
} else {
- vim_snprintf((char *)p, (size_t)(IOSIZE - (p - IObuff)),
+ vim_snprintf((char *)p, (size_t)(IOSIZE - (p - (char_u *)IObuff)),
NGETTEXT("%" PRId64 " line, ", "%" PRId64 " lines, ", lnum),
(int64_t)lnum);
p += STRLEN(p);
- vim_snprintf((char *)p, (size_t)(IOSIZE - (p - IObuff)),
+ vim_snprintf((char *)p, (size_t)(IOSIZE - (p - (char_u *)IObuff)),
NGETTEXT("%" PRId64 " byte", "%" PRId64 " bytes", nchars),
(int64_t)nchars);
}
@@ -4189,7 +4189,7 @@ void shorten_buf_fname(buf_T *buf, char_u *dirname, int force)
if (buf->b_sfname != buf->b_ffname) {
XFREE_CLEAR(buf->b_sfname);
}
- p = (char *)path_shorten_fname((char_u *)buf->b_ffname, dirname);
+ p = path_shorten_fname(buf->b_ffname, (char *)dirname);
if (p != NULL) {
buf->b_sfname = xstrdup(p);
buf->b_fname = buf->b_sfname;
@@ -4481,7 +4481,7 @@ int put_time(FILE *fd, time_t time_)
/// function will (attempts to?) copy the file across if rename fails -- webb
///
/// @return -1 for failure, 0 for success
-int vim_rename(const char_u *from, const char_u *to)
+int vim_rename(const char *from, const char *to)
FUNC_ATTR_NONNULL_ALL
{
int fd_in;
@@ -4498,7 +4498,7 @@ int vim_rename(const char_u *from, const char_u *to)
// When the names are identical, there is nothing to do. When they refer
// to the same file (ignoring case and slash/backslash differences) but
// the file name differs we need to go through a temp file.
- if (FNAMECMP(from, to) == 0) {
+ if (path_fnamecmp(from, to) == 0) {
if (p_fic && (strcmp(path_tail((char *)from), path_tail((char *)to))
!= 0)) {
use_tmp_file = true;
@@ -4536,13 +4536,13 @@ int vim_rename(const char_u *from, const char_u *to)
snprintf(tail, (size_t)((MAXPATHL + 1) - (tail - (char *)tempname - 1)), "%d", n);
if (!os_path_exists((char *)tempname)) {
- if (os_rename(from, tempname) == OK) {
- if (os_rename(tempname, to) == OK) {
+ if (os_rename((char_u *)from, tempname) == OK) {
+ if (os_rename(tempname, (char_u *)to) == OK) {
return 0;
}
// Strange, the second step failed. Try mov