aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordundargoc <33953936+dundargoc@users.noreply.github.com>2021-11-16 20:27:59 +0100
committerGitHub <noreply@github.com>2021-11-16 20:27:59 +0100
commiteba317d7a907a76e6e265c0fe0b97a87f17cf943 (patch)
tree21edca825d0de28a4024c969e26ecfe75f6dc298 /src
parent99211b008c10561560e84eabfaa22e1577ac179a (diff)
downloadrneovim-eba317d7a907a76e6e265c0fe0b97a87f17cf943.tar.gz
rneovim-eba317d7a907a76e6e265c0fe0b97a87f17cf943.tar.bz2
rneovim-eba317d7a907a76e6e265c0fe0b97a87f17cf943.zip
refactor: reduce number of explicit char casts (#16077)
* refactor: reduce number of explicit char casts
Diffstat (limited to 'src')
-rw-r--r--src/nvim/api/vim.c2
-rw-r--r--src/nvim/buffer.c62
-rw-r--r--src/nvim/edit.c30
-rw-r--r--src/nvim/eval/encode.c10
-rw-r--r--src/nvim/eval/funcs.c6
-rw-r--r--src/nvim/eval/userfunc.c2
-rw-r--r--src/nvim/ex_cmds.c6
-rw-r--r--src/nvim/ex_docmd.c4
-rw-r--r--src/nvim/ex_eval.c2
-rw-r--r--src/nvim/ex_getln.c10
-rw-r--r--src/nvim/fileio.c6
-rw-r--r--src/nvim/hardcopy.c106
-rw-r--r--src/nvim/if_cscope.c6
-rw-r--r--src/nvim/lua/executor.c2
-rw-r--r--src/nvim/macros.h2
-rw-r--r--src/nvim/memline.c2
-rw-r--r--src/nvim/message.c10
-rw-r--r--src/nvim/misc1.c2
-rw-r--r--src/nvim/option.c2
-rw-r--r--src/nvim/os/env.c2
-rw-r--r--src/nvim/path.c8
-rw-r--r--src/nvim/quickfix.c8
-rw-r--r--src/nvim/runtime.c2
-rw-r--r--src/nvim/screen.c2
-rw-r--r--src/nvim/syntax.c20
-rw-r--r--src/nvim/terminal.c2
-rw-r--r--src/nvim/window.c2
27 files changed, 151 insertions, 167 deletions
diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c
index c1374ff00e..3103905819 100644
--- a/src/nvim/api/vim.c
+++ b/src/nvim/api/vim.c
@@ -71,7 +71,7 @@ Dictionary nvim_get_hl_by_name(String name, Boolean rgb, Error *err)
FUNC_API_SINCE(3)
{
Dictionary result = ARRAY_DICT_INIT;
- int id = syn_name2id((const char_u *)name.data);
+ int id = syn_name2id(name.data);
if (id == 0) {
api_set_error(err, kErrorTypeException, "Invalid highlight name: %s",
diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c
index e9d89c2f91..88938d5099 100644
--- a/src/nvim/buffer.c
+++ b/src/nvim/buffer.c
@@ -3130,7 +3130,7 @@ void fileinfo(int fullname, int shorthelp, int dont_truncate)
// before redrawing).
// - When the screen was scrolled but there is no wait-return
// prompt.
- set_keep_msg((char_u *)p, 0);
+ set_keep_msg(p, 0);
}
}
@@ -3429,7 +3429,7 @@ int build_stl_str_hl(win_T *wp, char_u *out, size_t outlen, char_u *fmt, int use
static int *stl_separator_locations = NULL;
#define TMPLEN 70
- char_u buf_tmp[TMPLEN];
+ char buf_tmp[TMPLEN];
char_u win_tmp[TMPLEN];
char_u *usefmt = fmt;
const int save_must_redraw = must_redraw;
@@ -3856,7 +3856,7 @@ int build_stl_str_hl(win_T *wp, char_u *out, size_t outlen, char_u *fmt, int use
bool itemisflag = false;
bool fillable = true;
long num = -1;
- char_u *str = NULL;
+ char *str = NULL;
switch (opt) {
case STL_FILEPATH:
case STL_FULLPATH:
@@ -3873,9 +3873,9 @@ int build_stl_str_hl(win_T *wp, char_u *out, size_t outlen, char_u *fmt, int use
}
trans_characters(NameBuff, MAXPATHL);
if (opt != STL_FILENAME) {
- str = NameBuff;
+ str = (char *)NameBuff;
} else {
- str = path_tail(NameBuff);
+ str = (char *)path_tail(NameBuff);
}
break;
case STL_VIM_EXPR: // '{'
@@ -3912,8 +3912,8 @@ int build_stl_str_hl(win_T *wp, char_u *out, size_t outlen, char_u *fmt, int use
// { Evaluate the expression
// Store the current buffer number as a string variable
- vim_snprintf((char *)buf_tmp, sizeof(buf_tmp), "%d", curbuf->b_fnum);
- set_internal_string_var("g:actual_curbuf", buf_tmp);
+ vim_snprintf(buf_tmp, sizeof(buf_tmp), "%d", curbuf->b_fnum);
+ set_internal_string_var("g:actual_curbuf", (char_u *)buf_tmp);
vim_snprintf((char *)win_tmp, sizeof(win_tmp), "%d", curwin->handle);
set_internal_string_var("g:actual_curwin", win_tmp);
@@ -3928,7 +3928,7 @@ int build_stl_str_hl(win_T *wp, char_u *out, size_t outlen, char_u *fmt, int use
}
// Note: The result stored in `t` is unused.
- str = eval_to_string_safe(out_p, &t, use_sandbox);
+ str = (char *)eval_to_string_safe(out_p, &t, use_sandbox);
curwin = save_curwin;
curbuf = save_curbuf;
@@ -3943,8 +3943,8 @@ int build_stl_str_hl(win_T *wp, char_u *out, size_t outlen, char_u *fmt, int use
// Check if the evaluated result is a number.
// If so, convert the number to an int and free the string.
if (str != NULL && *str != 0) {
- if (*skipdigits(str) == NUL) {
- num = atoi((char *)str);
+ if (*skipdigits((char_u *)str) == NUL) {
+ num = atoi(str);
XFREE_CLEAR(str);
itemisflag = false;
}
@@ -3957,8 +3957,8 @@ int build_stl_str_hl(win_T *wp, char_u *out, size_t outlen, char_u *fmt, int use
&& strchr((const char *)str, '%') != NULL
&& evaldepth < MAX_STL_EVAL_DEPTH) {
size_t parsed_usefmt = (size_t)(block_start - usefmt);
- size_t str_length = strlen((const char *)str);
- size_t fmt_length = strlen((const char *)fmt_p);
+ size_t str_length = STRLEN(str);
+ size_t fmt_length = STRLEN(fmt_p);
size_t new_fmt_len = parsed_usefmt
+ str_length + fmt_length + 3;
char_u *new_fmt = (char_u *)xmalloc(new_fmt_len * sizeof(char_u));
@@ -4029,7 +4029,7 @@ int build_stl_str_hl(win_T *wp, char_u *out, size_t outlen, char_u *fmt, int use
// Store the position percentage in our temporary buffer.
// Note: We cannot store the value in `num` because
// `get_rel_pos` can return a named position. Ex: "Top"
- get_rel_pos(wp, buf_tmp, TMPLEN);
+ get_rel_pos(wp, (char_u *)buf_tmp, TMPLEN);
str = buf_tmp;
break;
@@ -4044,14 +4044,14 @@ int build_stl_str_hl(win_T *wp, char_u *out, size_t outlen, char_u *fmt, int use
// Note: The call will only return true if it actually
// appended data to the `buf_tmp` buffer.
- if (append_arg_number(wp, buf_tmp, (int)sizeof(buf_tmp), false)) {
+ if (append_arg_number(wp, (char_u *)buf_tmp, (int)sizeof(buf_tmp), false)) {
str = buf_tmp;
}
break;
case STL_KEYMAP:
fillable = false;
- if (get_keymap_str(wp, (char_u *)"<%s>", buf_tmp, TMPLEN)) {
+ if (get_keymap_str(wp, (char_u *)"<%s>", (char_u *)buf_tmp, TMPLEN)) {
str = buf_tmp;
}
break;
@@ -4090,7 +4090,7 @@ int build_stl_str_hl(win_T *wp, char_u *out, size_t outlen, char_u *fmt, int use
case STL_ROFLAG_ALT:
itemisflag = true;
if (wp->w_buffer->b_p_ro) {
- str = (char_u *)((opt == STL_ROFLAG_ALT) ? ",RO" : _("[RO]"));
+ str = (opt == STL_ROFLAG_ALT) ? ",RO" : _("[RO]");
}
break;
@@ -4098,8 +4098,7 @@ int build_stl_str_hl(win_T *wp, char_u *out, size_t outlen, char_u *fmt, int use
case STL_HELPFLAG_ALT:
itemisflag = true;
if (wp->w_buffer->b_help) {
- str = (char_u *)((opt == STL_HELPFLAG_ALT) ? ",HLP"
- : _("[Help]"));
+ str = (opt == STL_HELPFLAG_ALT) ? ",HLP" : _("[Help]");
}
break;
@@ -4109,7 +4108,7 @@ int build_stl_str_hl(win_T *wp, char_u *out, size_t outlen, char_u *fmt, int use
// (including the brackets and null terminating character)
if (*wp->w_buffer->b_p_ft != NUL
&& STRLEN(wp->w_buffer->b_p_ft) < TMPLEN - 3) {
- vim_snprintf((char *)buf_tmp, sizeof(buf_tmp), "[%s]",
+ vim_snprintf(buf_tmp, sizeof(buf_tmp), "[%s]",
wp->w_buffer->b_p_ft);
str = buf_tmp;
}
@@ -4122,10 +4121,10 @@ int build_stl_str_hl(win_T *wp, char_u *out, size_t outlen, char_u *fmt, int use
// (including the comma and null terminating character)
if (*wp->w_buffer->b_p_ft != NUL
&& STRLEN(wp->w_buffer->b_p_ft) < TMPLEN - 2) {
- vim_snprintf((char *)buf_tmp, sizeof(buf_tmp), ",%s",
+ vim_snprintf(buf_tmp, sizeof(buf_tmp), ",%s",
wp->w_buffer->b_p_ft);
// Uppercase the file extension
- for (char_u *t = buf_tmp; *t != 0; t++) {
+ for (char_u *t = (char_u *)buf_tmp; *t != 0; t++) {
*t = (char_u)TOUPPER_LOC(*t);
}
str = buf_tmp;
@@ -4135,16 +4134,13 @@ int build_stl_str_hl(win_T *wp, char_u *out, size_t outlen, char_u *fmt, int use
case STL_PREVIEWFLAG_ALT:
itemisflag = true;
if (wp->w_p_pvw) {
- str = (char_u *)((opt == STL_PREVIEWFLAG_ALT) ? ",PRV"
- : _("[Preview]"));
+ str = (opt == STL_PREVIEWFLAG_ALT) ? ",PRV" : _("[Preview]");
}
break;
case STL_QUICKFIX:
if (bt_quickfix(wp->w_buffer)) {
- str = (char_u *)(wp->w_llist_ref
- ? _(msg_loclist)
- : _(msg_qflist));
+ str = wp->w_llist_ref ? _(msg_loclist) : _(msg_qflist);
}
break;
@@ -4155,17 +4151,17 @@ int build_stl_str_hl(win_T *wp, char_u *out, size_t outlen, char_u *fmt, int use
+ bufIsChanged(wp->w_buffer) * 2
+ (!MODIFIABLE(wp->w_buffer)) * 4) {
case 2:
- str = (char_u *)"[+]"; break;
+ str = "[+]"; break;
case 3:
- str = (char_u *)",+"; break;
+ str = ",+"; break;
case 4:
- str = (char_u *)"[-]"; break;
+ str = "[-]"; break;
case 5:
- str = (char_u *)",-"; break;
+ str = ",-"; break;
case 6:
- str = (char_u *)"[+-]"; break;
+ str = "[+-]"; break;
case 7:
- str = (char_u *)",+-"; break;
+ str = ",+-"; break;
}
break;
@@ -4199,7 +4195,7 @@ int build_stl_str_hl(win_T *wp, char_u *out, size_t outlen, char_u *fmt, int use
if (str != NULL && *str) {
// { Skip the leading `,` or ` ` if the item is a flag
// and the proper conditions are met
- char_u *t = str;
+ char_u *t = (char_u *)str;
if (itemisflag) {
if ((t[0] && t[1])
&& ((!prevchar_isitem && *t == ',')
diff --git a/src/nvim/edit.c b/src/nvim/edit.c
index ca903fdcf7..7a24ee1b32 100644
--- a/src/nvim/edit.c
+++ b/src/nvim/edit.c
@@ -3292,16 +3292,11 @@ void get_complete_info(list_T *what_list, dict_T *retdict)
dict_T *di = tv_dict_alloc();
tv_list_append_dict(li, di);
- tv_dict_add_str(di, S_LEN("word"),
- (char *)EMPTY_IF_NULL(match->cp_str));
- tv_dict_add_str(di, S_LEN("abbr"),
- (char *)EMPTY_IF_NULL(match->cp_text[CPT_ABBR]));
- tv_dict_add_str(di, S_LEN("menu"),
- (char *)EMPTY_IF_NULL(match->cp_text[CPT_MENU]));
- tv_dict_add_str(di, S_LEN("kind"),
- (char *)EMPTY_IF_NULL(match->cp_text[CPT_KIND]));
- tv_dict_add_str(di, S_LEN("info"),
- (char *)EMPTY_IF_NULL(match->cp_text[CPT_INFO]));
+ tv_dict_add_str(di, S_LEN("word"), EMPTY_IF_NULL(match->cp_str));
+ tv_dict_add_str(di, S_LEN("abbr"), EMPTY_IF_NULL(match->cp_text[CPT_ABBR]));
+ tv_dict_add_str(di, S_LEN("menu"), EMPTY_IF_NULL(match->cp_text[CPT_MENU]));
+ tv_dict_add_str(di, S_LEN("kind"), EMPTY_IF_NULL(match->cp_text[CPT_KIND]));
+ tv_dict_add_str(di, S_LEN("info"), EMPTY_IF_NULL(match->cp_text[CPT_INFO]));
if (match->cp_user_data.v_type == VAR_UNKNOWN) {
tv_dict_add_str(di, S_LEN("user_data"), "");
} else {
@@ -4635,16 +4630,11 @@ static dict_T *ins_compl_dict_alloc(compl_T *match)
{
// { word, abbr, menu, kind, info }
dict_T *dict = tv_dict_alloc_lock(VAR_FIXED);
- tv_dict_add_str(dict, S_LEN("word"),
- (const char *)EMPTY_IF_NULL(match->cp_str));
- tv_dict_add_str(dict, S_LEN("abbr"),
- (const char *)EMPTY_IF_NULL(match->cp_text[CPT_ABBR]));
- tv_dict_add_str(dict, S_LEN("menu"),
- (const char *)EMPTY_IF_NULL(match->cp_text[CPT_MENU]));
- tv_dict_add_str(dict, S_LEN("kind"),
- (const char *)EMPTY_IF_NULL(match->cp_text[CPT_KIND]));
- tv_dict_add_str(dict, S_LEN("info"),
- (const char *)EMPTY_IF_NULL(match->cp_text[CPT_INFO]));
+ tv_dict_add_str(dict, S_LEN("word"), EMPTY_IF_NULL(match->cp_str));
+ tv_dict_add_str(dict, S_LEN("abbr"), EMPTY_IF_NULL(match->cp_text[CPT_ABBR]));
+ tv_dict_add_str(dict, S_LEN("menu"), EMPTY_IF_NULL(match->cp_text[CPT_MENU]));
+ tv_dict_add_str(dict, S_LEN("kind"), EMPTY_IF_NULL(match->cp_text[CPT_KIND]));
+ tv_dict_add_str(dict, S_LEN("info"), EMPTY_IF_NULL(match->cp_text[CPT_INFO]));
if (match->cp_user_data.v_type == VAR_UNKNOWN) {
tv_dict_add_str(dict, S_LEN("user_data"), "");
} else {
diff --git a/src/nvim/eval/encode.c b/src/nvim/eval/encode.c
index b457353838..d694b8a374 100644
--- a/src/nvim/eval/encode.c
+++ b/src/nvim/eval/encode.c
@@ -29,8 +29,6 @@
#include "nvim/message.h"
#include "nvim/vim.h" // For _()
-#define utf_ptr2char(b) utf_ptr2char((char_u *)b)
-#define utf_ptr2len(b) ((size_t)utf_ptr2len((char_u *)b))
#define utf_char2len(b) ((size_t)utf_char2len(b))
const char *const encode_bool_var_names[] = {
@@ -614,8 +612,8 @@ static inline int convert_to_json_string(garray_T *const gap, const char *const
#define ENCODE_RAW(ch) \
(ch >= 0x20 && utf_printable(ch))
for (size_t i = 0; i < utf_len;) {
- const int ch = utf_ptr2char(utf_buf + i);
- const size_t shift = (ch == 0? 1: utf_ptr2len(utf_buf + i));
+ const int ch = utf_ptr2char((char_u *)utf_buf + i);
+ const size_t shift = (ch == 0 ? 1 : ((size_t)utf_ptr2len((char_u *)utf_buf + i)));
assert(shift > 0);
i += shift;
switch (ch) {
@@ -654,11 +652,11 @@ static inline int convert_to_json_string(garray_T *const gap, const char *const
ga_append(gap, '"');
ga_grow(gap, (int)str_len);
for (size_t i = 0; i < utf_len;) {
- const int ch = utf_ptr2char(utf_buf + i);
+ const int ch = utf_ptr2char((char_u *)utf_buf + i);
const size_t shift = (ch == 0? 1: utf_char2len(ch));
assert(shift > 0);
// Is false on invalid unicode, but this should already be handled.
- assert(ch == 0 || shift == utf_ptr2len(utf_buf + i));
+ assert(ch == 0 || shift == ((size_t)utf_ptr2len((char_u *)utf_buf + i)));
switch (ch) {
case BS:
case TAB:
diff --git a/src/nvim/eval/funcs.c b/src/nvim/eval/funcs.c
index 1d9ebdb596..7549ec7ac8 100644
--- a/src/nvim/eval/funcs.c
+++ b/src/nvim/eval/funcs.c
@@ -3544,7 +3544,7 @@ static void f_getcwd(typval_T *argvars, typval_T *rettv, FunPtr fptr)
}
if (from) {
- xstrlcpy((char *)cwd, (char *)from, MAXPATHL);
+ STRLCPY(cwd, from, MAXPATHL);
}
rettv->vval.v_string = vim_strsave(cwd);
@@ -4867,7 +4867,7 @@ static void f_histnr(typval_T *argvars, typval_T *rettv, FunPtr fptr)
*/
static void f_hlID(typval_T *argvars, typval_T *rettv, FunPtr fptr)
{
- rettv->vval.v_number = syn_name2id((const char_u *)tv_get_string(&argvars[0]));
+ rettv->vval.v_number = syn_name2id(tv_get_string(&argvars[0]));
}
/*
@@ -4875,7 +4875,7 @@ static void f_hlID(typval_T *argvars, typval_T *rettv, FunPtr fptr)
*/
static void f_hlexists(typval_T *argvars, typval_T *rettv, FunPtr fptr)
{
- rettv->vval.v_number = highlight_exists((const char_u *)tv_get_string(&argvars[0]));
+ rettv->vval.v_number = highlight_exists(tv_get_string(&argvars[0]));
}
/*
diff --git a/src/nvim/eval/userfunc.c b/src/nvim/eval/userfunc.c
index 6fe75e5e1f..80a22f6f9d 100644
--- a/src/nvim/eval/userfunc.c
+++ b/src/nvim/eval/userfunc.c
@@ -1818,7 +1818,7 @@ char_u *trans_function_name(char_u **pp, bool skip, int flags, funcdict_T *fdp,
if (name != NULL) {
name = vim_strsave(name);
*pp = (char_u *)end;
- if (strncmp((char *)name, "<SNR>", 5) == 0) {
+ if (STRNCMP(name, "<SNR>", 5) == 0) {
// Change "<SNR>" to the byte sequence.
name[0] = K_SPECIAL;
name[1] = KS_EXTRA;
diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c
index 145fe33284..66e30bdf2b 100644
--- a/src/nvim/ex_cmds.c
+++ b/src/nvim/ex_cmds.c
@@ -1440,7 +1440,7 @@ static void do_filter(linenr_T line1, linenr_T line2, exarg_T *eap, char_u *cmd,
_("%" PRId64 " lines filtered"), (int64_t)linecount);
if (msg(msg_buf) && !msg_scroll) {
// save message to display it after redraw
- set_keep_msg((char_u *)msg_buf, 0);
+ set_keep_msg(msg_buf, 0);
}
} else {
msgmore((long)linecount);
@@ -3280,7 +3280,7 @@ static bool sub_joining_lines(exarg_T *eap, char_u *pat, char_u *sub, char_u *cm
// TODO(vim): find a generic solution to make line-joining operations more
// efficient, avoid allocating a string that grows in size.
if (pat != NULL
- && strcmp((const char *)pat, "\\n") == 0
+ && STRCMP(pat, "\\n") == 0
&& *sub == NUL
&& (*cmd == NUL || (cmd[1] == NUL
&& (*cmd == 'g'
@@ -4468,7 +4468,7 @@ bool do_sub_msg(bool count_only)
(int64_t)sub_nsubs, (int64_t)sub_nlines);
if (msg(msg_buf)) {
// save message to display it after redraw
- set_keep_msg((char_u *)msg_buf, 0);
+ set_keep_msg(msg_buf, 0);
}
return true;
}
diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c
index 499c6ed4f9..e622a2a68f 100644
--- a/src/nvim/ex_docmd.c
+++ b/src/nvim/ex_docmd.c
@@ -2647,7 +2647,7 @@ static char_u *find_command(exarg_T *eap, int *full)
const int c2 = len == 1 ? NUL : eap->cmd[1];
if (command_count != CMD_SIZE) {
- iemsg((char *)_("E943: Command table needs to be updated, run 'make'"));
+ iemsg(_("E943: Command table needs to be updated, run 'make'"));
getout(1);
}
@@ -9130,7 +9130,7 @@ char_u *eval_vars(char_u *src, char_u *srcstart, size_t *usedlen, linenr_T *lnum
// postponed to avoid a delay when <afile> is not used.
result = (char_u *)FullName_save((char *)autocmd_fname, false);
// Copy into `autocmd_fname`, don't reassign it. #8165
- xstrlcpy((char *)autocmd_fname, (char *)result, MAXPATHL);
+ STRLCPY(autocmd_fname, result, MAXPATHL);
xfree(result);
}
result = autocmd_fname;
diff --git a/src/nvim/ex_eval.c b/src/nvim/ex_eval.c
index cfc8eb7316..348a26d723 100644
--- a/src/nvim/ex_eval.c
+++ b/src/nvim/ex_eval.c
@@ -566,7 +566,7 @@ static void discard_exception(except_T *excp, bool was_finished)
} else {
verbose_leave();
}
- xstrlcpy((char *)IObuff, (const char *)saved_IObuff, IOSIZE);
+ STRLCPY(IObuff, saved_IObuff, IOSIZE);
xfree(saved_IObuff);
}
if (excp->type != ET_INTERRUPT) {
diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c
index 9ccbdbaf58..0716b5445d 100644
--- a/src/nvim/ex_getln.c
+++ b/src/nvim/ex_getln.c
@@ -2697,7 +2697,7 @@ static void color_expr_cmdline(const CmdlineInfo *const colored_ccline,
.attr = 0,
}));
}
- const int id = syn_name2id((const char_u *)chunk.group);
+ const int id = syn_name2id(chunk.group);
const int attr = (id == 0 ? 0 : syn_id2attr(id));
kv_push(ret_ccline_colors->colors, ((CmdlineColorChunk) {
.start = (int)chunk.start.col,
@@ -2899,7 +2899,7 @@ static bool color_cmdline(CmdlineInfo *colored_ccline)
if (group == NULL) {
goto color_cmdline_error;
}
- const int id = syn_name2id((char_u *)group);
+ const int id = syn_name2id(group);
const int attr = (id == 0 ? 0 : syn_id2attr(id));
kv_push(ccline_colors->colors, ((CmdlineColorChunk) {
.start = (int)start,
@@ -4989,13 +4989,13 @@ static int ExpandFromContext(expand_T *xp, char_u *pat, int *num_file, char_u **
// When expanding a function name starting with s:, match the <SNR>nr_
// prefix.
- char_u *tofree = NULL;
+ char *tofree = NULL;
if (xp->xp_context == EXPAND_USER_FUNC && STRNCMP(pat, "^s:", 3) == 0) {
const size_t len = STRLEN(pat) + 20;
tofree = xmalloc(len);
- snprintf((char *)tofree, len, "^<SNR>\\d\\+_%s", pat + 3);
- pat = tofree;
+ snprintf(tofree, len, "^<SNR>\\d\\+_%s", pat + 3);
+ pat = (char_u *)tofree;
}
if (xp->xp_context == EXPAND_LUA) {
diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c
index cf4037308b..321d884d9c 100644
--- a/src/nvim/fileio.c
+++ b/src/nvim/fileio.c
@@ -125,7 +125,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.
- xstrlcat((char *)IObuff, (const char *)s, IOSIZE);
+ STRLCAT(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().
@@ -1857,7 +1857,7 @@ failed:
// - When restart_edit is set (otherwise there will be a delay before
// redrawing).
// - When the screen was scrolled but there is no wait-return prompt.
- set_keep_msg(p, 0);
+ set_keep_msg((char *)p, 0);
}
msg_scrolled_ign = false;
}
@@ -3536,7 +3536,7 @@ restore_backup:
}
}
- set_keep_msg((char_u *)msg_trunc_attr((char *)IObuff, FALSE, 0), 0);
+ set_keep_msg(msg_trunc_attr((char *)IObuff, false, 0), 0);
}
/* When written everything correctly: reset 'modified'. Unless not
diff --git a/src/nvim/hardcopy.c b/src/nvim/hardcopy.c
index 296c5cbdbf..ab3f63c93e 100644
--- a/src/nvim/hardcopy.c
+++ b/src/nvim/hardcopy.c
@@ -461,10 +461,10 @@ static void prt_line_number(prt_settings_T *const psettings, const int page_line
// Leave two spaces between the number and the text; depends on
// PRINT_NUMBER_WIDTH.
- char_u tbuf[20];
- snprintf((char *)tbuf, sizeof(tbuf), "%6ld", (long)lnum);
+ char tbuf[20];
+ snprintf(tbuf, sizeof(tbuf), "%6ld", (long)lnum);
for (int i = 0; i < 6; i++) {
- (void)mch_print_text_out(&tbuf[i], 1);
+ (void)mch_print_text_out((char_u *)(&tbuf[i]), 1);
}
if (psettings->do_syntax) {
@@ -669,7 +669,7 @@ void ex_hardcopy(exarg_T *eap)
// Syntax highlighting of line numbers.
if (prt_use_number() && settings.do_syntax) {
- int id = syn_name2id((char_u *)"LineNr");
+ int id = syn_name2id("LineNr");
if (id > 0) {
id = syn_get_final_id(id);
}
@@ -1310,7 +1310,7 @@ static int prt_collate;
/*
* Buffers used when generating PostScript output
*/
-static char_u prt_line_buffer[257];
+static char prt_line_buffer[257];
static garray_T prt_ps_buffer = GA_EMPTY_INIT_VALUE;
static int prt_do_conv;
@@ -1334,9 +1334,9 @@ static void prt_write_file_raw_len(char_u *buffer, size_t bytes)
}
}
-static void prt_write_file(char_u *buffer)
+static void prt_write_file(char *buffer)
{
- prt_write_file_len(buffer, STRLEN(buffer));
+ prt_write_file_len((char_u *)buffer, STRLEN(buffer));
}
static void prt_write_file_len(char_u *buffer, size_t bytes)
@@ -1349,7 +1349,7 @@ static void prt_write_file_len(char_u *buffer, size_t bytes)
*/
static void prt_write_string(char *s)
{
- vim_snprintf((char *)prt_line_buffer, sizeof(prt_line_buffer), "%s", s);
+ vim_snprintf(prt_line_buffer, sizeof(prt_line_buffer), "%s", s);
prt_write_file(prt_line_buffer);
}
@@ -1358,7 +1358,7 @@ static void prt_write_string(char *s)
*/
static void prt_write_int(int i)
{
- sprintf((char *)prt_line_buffer, "%d ", i);
+ snprintf(prt_line_buffer, sizeof(prt_line_buffer), "%d ", i);
prt_write_file(prt_line_buffer);
}
@@ -1367,7 +1367,7 @@ static void prt_write_int(int i)
*/
static void prt_write_boolean(int b)
{
- sprintf((char *)prt_line_buffer, "%s ", (b ? "T" : "F"));
+ snprintf(prt_line_buffer, sizeof(prt_line_buffer), "%s ", (b ? "T" : "F"));
prt_write_file(prt_line_buffer);
}
@@ -1376,14 +1376,14 @@ static void prt_write_boolean(int b)
*/
static void prt_def_font(char *new_name, char *encoding, int height, char *font)
{
- vim_snprintf((char *)prt_line_buffer, sizeof(prt_line_buffer),
+ vim_snprintf(prt_line_buffer, sizeof(prt_line_buffer),
"/_%s /VIM-%s /%s ref\n", new_name, encoding, font);
prt_write_file(prt_line_buffer);
if (prt_out_mbyte) {
- sprintf((char *)prt_line_buffer, "/%s %d %f /_%s sffs\n",
- new_name, height, 500./prt_ps_courier_font.wx, new_name);
+ snprintf(prt_line_buffer, sizeof(prt_line_buffer), "/%s %d %f /_%s sffs\n",
+ new_name, height, 500./prt_ps_courier_font.wx, new_name);
} else {
- vim_snprintf((char *)prt_line_buffer, sizeof(prt_line_buffer),
+ vim_snprintf(prt_line_buffer, sizeof(prt_line_buffer),
"/%s %d /_%s ffs\n", new_name, height, new_name);
}
prt_write_file(prt_line_buffer);
@@ -1394,10 +1394,10 @@ static void prt_def_font(char *new_name, char *encoding, int height, char *font)
*/
static void prt_def_cidfont(char *new_name, int height, char *cidfont)
{
- vim_snprintf((char *)prt_line_buffer, sizeof(prt_line_buffer),
+ vim_snprintf(prt_line_buffer, sizeof(prt_line_buffer),
"/_%s /%s[/%s] vim_composefont\n", new_name, prt_cmap, cidfont);
prt_write_file(prt_line_buffer);
- vim_snprintf((char *)prt_line_buffer, sizeof(prt_line_buffer),
+ vim_snprintf(prt_line_buffer, sizeof(prt_line_buffer),
"/%s %d /_%s ffs\n", new_name, height, new_name);
prt_write_file(prt_line_buffer);
}
@@ -1407,7 +1407,7 @@ static void prt_def_cidfont(char *new_name, int height, char *cidfont)
*/
static void prt_dup_cidfont(char *original_name, char *new_name)
{
- vim_snprintf((char *)prt_line_buffer, sizeof(prt_line_buffer),
+ vim_snprintf(prt_line_buffer, sizeof(prt_line_buffer),
"/%s %s d\n", new_name, original_name);
prt_write_file(prt_line_buffer);
}
@@ -1444,7 +1444,7 @@ static void prt_write_real(double val, int prec)
prt_real_bits(val, prec, &integer, &fraction);
// Emit integer part
- snprintf((char *)prt_line_buffer, sizeof(prt_line_buffer), "%d", integer);
+ snprintf(prt_line_buffer, sizeof(prt_line_buffer), "%d", integer);
prt_write_file(prt_line_buffer);
// Only emit fraction if necessary
if (fraction != 0) {
@@ -1454,11 +1454,11 @@ static void prt_write_real(double val, int prec)
fraction /= 10;
}
// Emit fraction left padded with zeros
- snprintf((char *)prt_line_buffer, sizeof(prt_line_buffer), ".%0*d",
+ snprintf(prt_line_buffer, sizeof(prt_line_buffer), ".%0*d",
prec, fraction);
prt_write_file(prt_line_buffer);
}
- sprintf((char *)prt_line_buffer, " ");
+ snprintf(prt_line_buffer, sizeof(prt_line_buffer), " ");
prt_write_file(prt_line_buffer);
}
@@ -1467,11 +1467,11 @@ static void prt_write_real(double val, int prec)
*/
static void prt_def_var(char *name, double value, int prec)
{
- vim_snprintf((char *)prt_line_buffer, sizeof(prt_line_buffer),
+ vim_snprintf(prt_line_buffer, sizeof(prt_line_buffer),
"/%s ", name);
prt_write_file(prt_line_buffer);
prt_write_real(value, prec);
- sprintf((char *)prt_line_buffer, "d\n");
+ snprintf(prt_line_buffer, sizeof(prt_line_buffer), "d\n");
prt_write_file(prt_line_buffer);
}
@@ -1569,8 +1569,8 @@ static int prt_find_resource(char *name, struct prt_ps_resource_S *resource)
// Look for named resource file in runtimepath
STRCPY(buffer, "print");
add_pathsep((char *)buffer);
- xstrlcat((char *)buffer, name, MAXPATHL);
- xstrlcat((char *)buffer, ".ps", MAXPATHL);
+ STRLCAT(buffer, name, MAXPATHL);
+ STRLCAT(buffer, ".ps", MAXPATHL);
resource->filename[0] = NUL;
retval = (do_in_runtimepath(buffer, 0, prt_resource_name, resource->filename)
&& resource->filename[0] != NUL);
@@ -1833,14 +1833,14 @@ static void prt_dsc_start(void)
static void prt_dsc_noarg(char *comment)
{
- vim_snprintf((char *)prt_line_buffer, sizeof(prt_line_buffer),
+ vim_snprintf(prt_line_buffer, sizeof(prt_line_buffer),
"%%%%%s\n", comment);
prt_write_file(prt_line_buffer);
}
static void prt_dsc_textline(char *comment, char *text)
{
- vim_snprintf((char *)prt_line_buffer, sizeof(prt_line_buffer),
+ vim_snprintf(prt_line_buffer, sizeof(prt_line_buffer),
"%%%%%s: %s\n", comment, text);
prt_write_file(prt_line_buffer);
}
@@ -1848,7 +1848,7 @@ static void prt_dsc_textline(char *comment, char *text)
static void prt_dsc_text(char *comment, char *text)
{
// TODO(vim): - should scan 'text' for any chars needing escaping!
- vim_snprintf((char *)prt_line_buffer, sizeof(prt_line_buffer),
+ vim_snprintf(prt_line_buffer, sizeof(prt_line_buffer),
"%%%%%s: (%s)\n", comment, text);
prt_write_file(prt_line_buffer);
}
@@ -1859,12 +1859,12 @@ static void prt_dsc_ints(char *comment, int count, int *ints)
{
int i;
- vim_snprintf((char *)prt_line_buffer, sizeof(prt_line_buffer),
+ vim_snprintf(prt_line_buffer, sizeof(prt_line_buffer),
"%%%%%s:", comment);
prt_write_file(prt_line_buffer);
for (i = 0; i < count; i++) {
- sprintf((char *)prt_line_buffer, " %d", ints[i]);
+ snprintf(prt_line_buffer, sizeof(prt_line_buffer), " %d", ints[i]);
prt_write_file(prt_line_buffer);
}
@@ -1876,15 +1876,15 @@ static void prt_dsc_resources(const char *comment, const char *type, const char
FUNC_ATTR_NONNULL_ARG(2, 3)
{
if (comment != NULL) {
- vim_snprintf((char *)prt_line_buffer, sizeof(prt_line_buffer),
+ vim_snprintf(prt_line_buffer, sizeof(prt_line_buffer),
"%%%%%s: %s", comment, type);
} else {
- vim_snprintf((char *)prt_line_buffer, sizeof(prt_line_buffer),
+ vim_snprintf(prt_line_buffer, sizeof(prt_line_buffer),
"%%%%+ %s", type);
}
prt_write_file(prt_line_buffer);
- vim_snprintf((char *)prt_line_buffer, sizeof(prt_line_buffer),
+ vim_snprintf(prt_line_buffer, sizeof(prt_line_buffer),
" %s\n", string);
prt_write_file(prt_line_buffer);
}
@@ -1910,7 +1910,7 @@ static void prt_dsc_requirements(int duplex, int tumble, int collate, int color,
return;
}
- sprintf((char *)prt_line_buffer, "%%%%Requirements:");
+ snprintf(prt_line_buffer, sizeof(prt_line_buffer), "%%%%Requirements:");
prt_write_file(prt_line_buffer);
if (duplex) {
@@ -1928,7 +1928,7 @@ static void prt_dsc_requirements(int duplex, int tumble, int collate, int color,
if (num_copies > 1) {
prt_write_string(" numcopies(");
// Note: no space wanted so don't use prt_write_int()
- snprintf((char *)prt_line_buffer, sizeof(prt_line_buffer), "%d",
+ snprintf(prt_line_buffer, sizeof