aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/buffer.c
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/nvim/buffer.c
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/nvim/buffer.c')
-rw-r--r--src/nvim/buffer.c62
1 files changed, 29 insertions, 33 deletions
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 == ',')