mirror of
https://github.com/neovim/neovim.git
synced 2025-09-05 19:08:15 +00:00
refactor: remove redundant casts
(cherry picked from commit 347c8bbbd6
)
This commit is contained in:

committed by
github-actions[bot]
![github-actions[bot]](/assets/img/avatar_default.png)
parent
e2ab8f78c4
commit
67dc341aa0
@@ -2499,7 +2499,7 @@ bool aupat_is_buflocal(char *pat, int patlen)
|
||||
|
||||
int aupat_get_buflocal_nr(char *pat, int patlen)
|
||||
{
|
||||
assert(aupat_is_buflocal((char *)pat, patlen));
|
||||
assert(aupat_is_buflocal(pat, patlen));
|
||||
|
||||
// "<buffer>"
|
||||
if (patlen == 8) {
|
||||
|
@@ -1311,7 +1311,7 @@ int open_line(int dir, int flags, int second_line_indent, bool *did_do_comment)
|
||||
}
|
||||
|
||||
// find start of middle part
|
||||
(void)copy_option_part(&p, (char *)lead_middle, COM_MAX_LEN, ",");
|
||||
(void)copy_option_part(&p, lead_middle, COM_MAX_LEN, ",");
|
||||
require_blank = false;
|
||||
}
|
||||
|
||||
@@ -1322,7 +1322,7 @@ int open_line(int dir, int flags, int second_line_indent, bool *did_do_comment)
|
||||
}
|
||||
p++;
|
||||
}
|
||||
(void)copy_option_part(&p, (char *)lead_middle, COM_MAX_LEN, ",");
|
||||
(void)copy_option_part(&p, lead_middle, COM_MAX_LEN, ",");
|
||||
|
||||
while (*p && p[-1] != ':') { // find end of end flags
|
||||
// Check whether we allow automatic ending of comments
|
||||
@@ -1331,7 +1331,7 @@ int open_line(int dir, int flags, int second_line_indent, bool *did_do_comment)
|
||||
}
|
||||
p++;
|
||||
}
|
||||
size_t n = copy_option_part(&p, (char *)lead_end, COM_MAX_LEN, ",");
|
||||
size_t n = copy_option_part(&p, lead_end, COM_MAX_LEN, ",");
|
||||
|
||||
if (end_comment_pending == -1) { // we can set it now
|
||||
end_comment_pending = (unsigned char)lead_end[n - 1];
|
||||
@@ -1352,7 +1352,7 @@ int open_line(int dir, int flags, int second_line_indent, bool *did_do_comment)
|
||||
// Doing "o" on a start of comment inserts the middle leader.
|
||||
if (lead_len > 0) {
|
||||
if (current_flag == COM_START) {
|
||||
lead_repl = (char *)lead_middle;
|
||||
lead_repl = lead_middle;
|
||||
lead_repl_len = (int)strlen(lead_middle);
|
||||
}
|
||||
|
||||
|
@@ -396,11 +396,11 @@ void eval_init(void)
|
||||
|
||||
// add to v: scope dict, unless the value is not always available
|
||||
if (p->vv_type != VAR_UNKNOWN) {
|
||||
hash_add(&vimvarht, (char *)p->vv_di.di_key);
|
||||
hash_add(&vimvarht, p->vv_di.di_key);
|
||||
}
|
||||
if (p->vv_flags & VV_COMPAT) {
|
||||
// add to compat scope dict
|
||||
hash_add(&compat_hashtab, (char *)p->vv_di.di_key);
|
||||
hash_add(&compat_hashtab, p->vv_di.di_key);
|
||||
}
|
||||
}
|
||||
vimvars[VV_VERSION].vv_nr = VIM_VERSION_100;
|
||||
@@ -3035,7 +3035,7 @@ static int eval7_leader(typval_T *const rettv, const bool numeric_only,
|
||||
const char *const start_leader, const char **const end_leaderp)
|
||||
FUNC_ATTR_NONNULL_ALL
|
||||
{
|
||||
const char *end_leader = (char *)(*end_leaderp);
|
||||
const char *end_leader = *end_leaderp;
|
||||
int ret = OK;
|
||||
bool error = false;
|
||||
varnumber_T val = 0;
|
||||
@@ -3263,7 +3263,7 @@ static int eval_index(char **arg, typval_T *rettv, int evaluate, int verbose)
|
||||
bool empty2 = false;
|
||||
ptrdiff_t len = -1;
|
||||
int range = false;
|
||||
char *key = NULL;
|
||||
const char *key = NULL;
|
||||
|
||||
switch (rettv->v_type) {
|
||||
case VAR_FUNC:
|
||||
@@ -3512,7 +3512,7 @@ static int eval_index(char **arg, typval_T *rettv, int evaluate, int verbose)
|
||||
}
|
||||
|
||||
if (len == -1) {
|
||||
key = (char *)tv_get_string_chk(&var1);
|
||||
key = tv_get_string_chk(&var1);
|
||||
if (key == NULL) {
|
||||
tv_clear(&var1);
|
||||
return FAIL;
|
||||
@@ -7607,7 +7607,7 @@ const void *var_shada_iter(const void *const iter, const char **const name, typv
|
||||
} else {
|
||||
hi = (const hashitem_T *)iter;
|
||||
}
|
||||
*name = (char *)TV_DICT_HI2DI(hi)->di_key;
|
||||
*name = TV_DICT_HI2DI(hi)->di_key;
|
||||
tv_copy(&TV_DICT_HI2DI(hi)->di_tv, rettv);
|
||||
while ((size_t)(++hi - hifirst) < hinum) {
|
||||
if (!HASHITEM_EMPTY(hi) && (var_flavour(hi->hi_key) & flavour)) {
|
||||
@@ -7944,7 +7944,7 @@ repeat:
|
||||
// "path/to/this.file.ext" :r:r:r
|
||||
// ^ ^------------- tail
|
||||
// +--------------------- *fnamep
|
||||
if (s > MAX(tail, (char *)(*fnamep))) {
|
||||
if (s > MAX(tail, *fnamep)) {
|
||||
*fnamelen = (size_t)(s - *fnamep);
|
||||
}
|
||||
}
|
||||
|
@@ -9093,14 +9093,14 @@ static void f_trim(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|
||||
if (dir == 0 || dir == 1) {
|
||||
// Trim leading characters
|
||||
while (*head != NUL) {
|
||||
c1 = utf_ptr2char((char *)head);
|
||||
c1 = utf_ptr2char(head);
|
||||
if (mask == NULL) {
|
||||
if (c1 > ' ' && c1 != 0xa0) {
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
for (p = mask; *p != NUL; MB_PTR_ADV(p)) {
|
||||
if (c1 == utf_ptr2char((char *)p)) {
|
||||
if (c1 == utf_ptr2char(p)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -9118,14 +9118,14 @@ static void f_trim(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|
||||
for (; tail > head; tail = prev) {
|
||||
prev = tail;
|
||||
MB_PTR_BACK(head, prev);
|
||||
c1 = utf_ptr2char((char *)prev);
|
||||
c1 = utf_ptr2char(prev);
|
||||
if (mask == NULL) {
|
||||
if (c1 > ' ' && c1 != 0xa0) {
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
for (p = mask; *p != NUL; MB_PTR_ADV(p)) {
|
||||
if (c1 == utf_ptr2char((char *)p)) {
|
||||
if (c1 == utf_ptr2char(p)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@@ -898,7 +898,7 @@ void f_list2str(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|
||||
|
||||
TV_LIST_ITER_CONST(l, li, {
|
||||
buf[utf_char2bytes((int)tv_get_number(TV_LIST_ITEM_TV(li)), (char *)buf)] = NUL;
|
||||
ga_concat(&ga, (char *)buf);
|
||||
ga_concat(&ga, buf);
|
||||
});
|
||||
ga_append(&ga, NUL);
|
||||
|
||||
|
@@ -611,7 +611,7 @@ static void add_nr_var(dict_T *dp, dictitem_T *v, char *name, varnumber_T nr)
|
||||
STRCPY(v->di_key, name);
|
||||
#endif
|
||||
v->di_flags = DI_FLAGS_RO | DI_FLAGS_FIX;
|
||||
hash_add(&dp->dv_hashtab, (char *)v->di_key);
|
||||
hash_add(&dp->dv_hashtab, v->di_key);
|
||||
v->di_tv.v_type = VAR_NUMBER;
|
||||
v->di_tv.v_lock = VAR_FIXED;
|
||||
v->di_tv.vval.v_number = nr;
|
||||
@@ -2612,7 +2612,7 @@ void ex_function(exarg_T *eap)
|
||||
set_ufunc_name(fp, name);
|
||||
if (overwrite) {
|
||||
hi = hash_find(&func_hashtab, name);
|
||||
hi->hi_key = (char *)UF2HIKEY(fp);
|
||||
hi->hi_key = UF2HIKEY(fp);
|
||||
} else if (hash_add(&func_hashtab, UF2HIKEY(fp)) == FAIL) {
|
||||
xfree(fp);
|
||||
goto erret;
|
||||
@@ -2681,7 +2681,7 @@ int eval_fname_script(const char *const p)
|
||||
bool translated_function_exists(const char *name)
|
||||
{
|
||||
if (builtin_function(name, -1)) {
|
||||
return find_internal_func((char *)name) != NULL;
|
||||
return find_internal_func(name) != NULL;
|
||||
}
|
||||
return find_func(name) != NULL;
|
||||
}
|
||||
|
@@ -197,10 +197,10 @@ static void ex_let_const(exarg_T *eap, const bool is_const)
|
||||
int var_count = 0;
|
||||
int semicolon = 0;
|
||||
char op[2];
|
||||
char *argend;
|
||||
const char *argend;
|
||||
int first = true;
|
||||
|
||||
argend = (char *)skip_var_list(arg, &var_count, &semicolon);
|
||||
argend = skip_var_list(arg, &var_count, &semicolon);
|
||||
if (argend == NULL) {
|
||||
return;
|
||||
}
|
||||
@@ -235,8 +235,7 @@ static void ex_let_const(exarg_T *eap, const bool is_const)
|
||||
if (!eap->skip) {
|
||||
op[0] = '=';
|
||||
op[1] = NUL;
|
||||
(void)ex_let_vars(eap->arg, &rettv, false, semicolon, var_count,
|
||||
is_const, (char *)op);
|
||||
(void)ex_let_vars(eap->arg, &rettv, false, semicolon, var_count, is_const, op);
|
||||
}
|
||||
tv_clear(&rettv);
|
||||
}
|
||||
@@ -267,8 +266,7 @@ static void ex_let_const(exarg_T *eap, const bool is_const)
|
||||
}
|
||||
emsg_skip--;
|
||||
} else if (i != FAIL) {
|
||||
(void)ex_let_vars(eap->arg, &rettv, false, semicolon, var_count,
|
||||
is_const, (char *)op);
|
||||
(void)ex_let_vars(eap->arg, &rettv, false, semicolon, var_count, is_const, op);
|
||||
tv_clear(&rettv);
|
||||
}
|
||||
}
|
||||
@@ -375,7 +373,7 @@ const char *skip_var_list(const char *arg, int *var_count, int *semicolon)
|
||||
const char *p = arg;
|
||||
for (;;) {
|
||||
p = skipwhite(p + 1); // skip whites after '[', ';' or ','
|
||||
s = skip_var_one((char *)p);
|
||||
s = skip_var_one(p);
|
||||
if (s == p) {
|
||||
semsg(_(e_invarg2), p);
|
||||
return NULL;
|
||||
@@ -398,7 +396,7 @@ const char *skip_var_list(const char *arg, int *var_count, int *semicolon)
|
||||
}
|
||||
return p + 1;
|
||||
}
|
||||
return skip_var_one((char *)arg);
|
||||
return skip_var_one(arg);
|
||||
}
|
||||
|
||||
/// Skip one (assignable) variable name, including @r, $VAR, &option, d.key,
|
||||
@@ -430,7 +428,7 @@ void list_hashtable_vars(hashtab_T *ht, const char *prefix, int empty, int *firs
|
||||
|
||||
// apply :filter /pat/ to variable name
|
||||
xstrlcpy(buf, prefix, IOSIZE);
|
||||
xstrlcat(buf, (char *)di->di_key, IOSIZE);
|
||||
xstrlcat(buf, di->di_key, IOSIZE);
|
||||
if (message_filtered(buf)) {
|
||||
continue;
|
||||
}
|
||||
@@ -915,7 +913,7 @@ static int do_unlet_var(lval_T *lp, char *name_end, exarg_T *eap, int deep FUNC_
|
||||
if (watched) {
|
||||
tv_copy(&di->di_tv, &oldtv);
|
||||
// need to save key because dictitem_remove will free it
|
||||
key = xstrdup((char *)di->di_key);
|
||||
key = xstrdup(di->di_key);
|
||||
}
|
||||
|
||||
tv_dict_item_remove(d, di);
|
||||
@@ -1169,7 +1167,7 @@ void delete_var(hashtab_T *ht, hashitem_T *hi)
|
||||
static void list_one_var(dictitem_T *v, const char *prefix, int *first)
|
||||
{
|
||||
char *const s = encode_tv2echo(&v->di_tv, NULL);
|
||||
list_one_var_a(prefix, v->di_key, (ptrdiff_t)strlen((char *)v->di_key),
|
||||
list_one_var_a(prefix, v->di_key, (ptrdiff_t)strlen(v->di_key),
|
||||
v->di_tv.v_type, (s == NULL ? "" : s), first);
|
||||
xfree(s);
|
||||
}
|
||||
@@ -1343,7 +1341,7 @@ void set_var_const(const char *name, const size_t name_len, typval_T *const tv,
|
||||
|
||||
v = xmalloc(offsetof(dictitem_T, di_key) + strlen(varname) + 1);
|
||||
STRCPY(v->di_key, varname);
|
||||
if (hash_add(ht, (char *)v->di_key) == FAIL) {
|
||||
if (hash_add(ht, v->di_key) == FAIL) {
|
||||
xfree(v);
|
||||
return;
|
||||
}
|
||||
@@ -1362,7 +1360,7 @@ void set_var_const(const char *name, const size_t name_len, typval_T *const tv,
|
||||
}
|
||||
|
||||
if (watched) {
|
||||
tv_dict_watcher_notify(dict, (char *)v->di_key, &v->di_tv, &oldtv);
|
||||
tv_dict_watcher_notify(dict, v->di_key, &v->di_tv, &oldtv);
|
||||
tv_clear(&oldtv);
|
||||
}
|
||||
|
||||
|
@@ -4228,7 +4228,7 @@ void shorten_fnames(int force)
|
||||
|
||||
os_dirname(dirname, MAXPATHL);
|
||||
FOR_ALL_BUFFERS(buf) {
|
||||
shorten_buf_fname(buf, (char *)dirname, force);
|
||||
shorten_buf_fname(buf, dirname, force);
|
||||
|
||||
// Always make the swap file name a full path, a "nofile" buffer may
|
||||
// also have a swap file.
|
||||
@@ -4362,7 +4362,7 @@ bool vim_fgets(char *buf, int size, FILE *fp)
|
||||
do {
|
||||
tbuf[sizeof(tbuf) - 2] = NUL;
|
||||
errno = 0;
|
||||
retval = fgets((char *)tbuf, sizeof(tbuf), fp);
|
||||
retval = fgets(tbuf, sizeof(tbuf), fp);
|
||||
if (retval == NULL && (feof(fp) || errno != EINTR)) {
|
||||
break;
|
||||
}
|
||||
@@ -4544,8 +4544,7 @@ int vim_rename(const char *from, const char *to)
|
||||
// to the same file (ignoring case and slash/backslash differences) but
|
||||
// the file name differs we need to go through a temp file.
|
||||
if (path_fnamecmp(from, to) == 0) {
|
||||
if (p_fic && (strcmp(path_tail((char *)from), path_tail((char *)to))
|
||||
!= 0)) {
|
||||
if (p_fic && (strcmp(path_tail(from), path_tail(to)) != 0)) {
|
||||
use_tmp_file = true;
|
||||
} else {
|
||||
return 0;
|
||||
@@ -4554,7 +4553,7 @@ int vim_rename(const char *from, const char *to)
|
||||
|
||||
// Fail if the "from" file doesn't exist. Avoids that "to" is deleted.
|
||||
FileInfo from_info;
|
||||
if (!os_fileinfo((char *)from, &from_info)) {
|
||||
if (!os_fileinfo(from, &from_info)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -4562,8 +4561,7 @@ int vim_rename(const char *from, const char *to)
|
||||
// This happens when "from" and "to" differ in case and are on a FAT32
|
||||
// filesystem. In that case go through a temp file name.
|
||||
FileInfo to_info;
|
||||
if (os_fileinfo((char *)to, &to_info)
|
||||
&& os_fileinfo_id_equal(&from_info, &to_info)) {
|
||||
if (os_fileinfo(to, &to_info) && os_fileinfo_id_equal(&from_info, &to_info)) {
|
||||
use_tmp_file = true;
|
||||
}
|
||||
|
||||
@@ -4575,7 +4573,7 @@ int vim_rename(const char *from, const char *to)
|
||||
// os_rename() work, on other systems it makes sure that we don't have
|
||||
// two files when the os_rename() fails.
|
||||
|
||||
os_remove((char *)to);
|
||||
os_remove(to);
|
||||
|
||||
// First try a normal rename, return if it works.
|
||||
if (os_rename(from, to) == OK) {
|
||||
@@ -4586,14 +4584,14 @@ int vim_rename(const char *from, const char *to)
|
||||
long perm = os_getperm(from);
|
||||
// For systems that support ACL: get the ACL from the original file.
|
||||
vim_acl_T acl = os_get_acl(from);
|
||||
int fd_in = os_open((char *)from, O_RDONLY, 0);
|
||||
int fd_in = os_open(from, O_RDONLY, 0);
|
||||
if (fd_in < 0) {
|
||||
os_free_acl(acl);
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Create the new file with same permissions as the original.
|
||||
int fd_out = os_open((char *)to, O_CREAT|O_EXCL|O_WRONLY|O_NOFOLLOW, (int)perm);
|
||||
int fd_out = os_open(to, O_CREAT|O_EXCL|O_WRONLY|O_NOFOLLOW, (int)perm);
|
||||
if (fd_out < 0) {
|
||||
close(fd_in);
|
||||
os_free_acl(acl);
|
||||
@@ -4636,7 +4634,7 @@ int vim_rename(const char *from, const char *to)
|
||||
semsg(errmsg, to);
|
||||
return -1;
|
||||
}
|
||||
os_remove((char *)from);
|
||||
os_remove(from);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@@ -1788,7 +1788,7 @@ void f_getcharstr(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|
||||
int i = 0;
|
||||
|
||||
if (n != 0) {
|
||||
i += utf_char2bytes((int)n, (char *)temp);
|
||||
i += utf_char2bytes((int)n, temp);
|
||||
}
|
||||
assert(i < 7);
|
||||
temp[i++] = NUL;
|
||||
|
@@ -3002,7 +3002,7 @@ RgbValue name_to_color(const char *name, int *idx)
|
||||
&& isxdigit((uint8_t)name[6]) && name[7] == NUL) {
|
||||
// rgb hex string
|
||||
*idx = kColorIdxHex;
|
||||
return (RgbValue)strtol((char *)(name + 1), NULL, 16);
|
||||
return (RgbValue)strtol(name + 1, NULL, 16);
|
||||
} else if (!STRICMP(name, "bg") || !STRICMP(name, "background")) {
|
||||
*idx = kColorIdxBg;
|
||||
return normal_bg;
|
||||
|
@@ -427,7 +427,7 @@ int get_indent_str_vtab(const char *ptr, long ts, long *vts, bool list)
|
||||
} else {
|
||||
// In list mode, when tab is not set, count screen char width
|
||||
// for Tab, displays: ^I
|
||||
count += ptr2cells((char *)ptr);
|
||||
count += ptr2cells(ptr);
|
||||
}
|
||||
} else if (*ptr == ' ') {
|
||||
count++; // count a space for one
|
||||
|
@@ -1750,7 +1750,7 @@ void ins_compl_addleader(int c)
|
||||
if ((cc = utf_char2len(c)) > 1) {
|
||||
char buf[MB_MAXBYTES + 1];
|
||||
|
||||
utf_char2bytes(c, (char *)buf);
|
||||
utf_char2bytes(c, buf);
|
||||
buf[cc] = NUL;
|
||||
ins_char_bytes(buf, (size_t)cc);
|
||||
} else {
|
||||
|
@@ -2122,7 +2122,7 @@ static int execute_env(char *env)
|
||||
current_sctx.sc_sid = SID_ENV;
|
||||
current_sctx.sc_seq = 0;
|
||||
current_sctx.sc_lnum = 0;
|
||||
do_cmdline_cmd((char *)initstr);
|
||||
do_cmdline_cmd(initstr);
|
||||
|
||||
estack_pop();
|
||||
current_sctx = save_current_sctx;
|
||||
|
@@ -596,13 +596,13 @@ static int buf_do_map(int maptype, MapArguments *args, int mode, bool is_abbrev,
|
||||
int last = first;
|
||||
p = (char *)lhs + utfc_ptr2len((char *)lhs);
|
||||
n = 1;
|
||||
while (p < (char *)lhs + len) {
|
||||
while (p < lhs + len) {
|
||||
n++; // nr of (multi-byte) chars
|
||||
last = vim_iswordp(p); // type of last char
|
||||
if (same == -1 && last != first) {
|
||||
same = n - 1; // count of same char type
|
||||
}
|
||||
p += utfc_ptr2len((char *)p);
|
||||
p += utfc_ptr2len(p);
|
||||
}
|
||||
if (last && n > 2 && same >= 0 && same < n - 1) {
|
||||
retval = 1;
|
||||
|
@@ -367,7 +367,7 @@ static int enc_canon_search(const char *name)
|
||||
int enc_canon_props(const char *name)
|
||||
FUNC_ATTR_PURE
|
||||
{
|
||||
int i = enc_canon_search((char *)name);
|
||||
int i = enc_canon_search(name);
|
||||
if (i >= 0) {
|
||||
return enc_canon_table[i].prop;
|
||||
} else if (strncmp(name, "2byte-", 6) == 0) {
|
||||
@@ -538,9 +538,9 @@ int utf_ptr2cells_len(const char *p, int size)
|
||||
if (utf_ptr2len_len(p, size) < utf8len_tab[(uint8_t)(*p)]) {
|
||||
return 1; // truncated
|
||||
}
|
||||
int c = utf_ptr2char((char *)p);
|
||||
int c = utf_ptr2char(p);
|
||||
// An illegal byte is displayed as <xx>.
|
||||
if (utf_ptr2len((char *)p) == 1 || c == NUL) {
|
||||
if (utf_ptr2len(p) == 1 || c == NUL) {
|
||||
return 4;
|
||||
}
|
||||
// If the char is ASCII it must be an overlong sequence.
|
||||
@@ -719,7 +719,7 @@ bool utf_composinglike(const char *p1, const char *p2)
|
||||
{
|
||||
int c2;
|
||||
|
||||
c2 = utf_ptr2char((char *)p2);
|
||||
c2 = utf_ptr2char(p2);
|
||||
if (utf_iscomposing(c2)) {
|
||||
return true;
|
||||
}
|
||||
|
@@ -3988,7 +3988,7 @@ int inc(pos_T *lp)
|
||||
if (lp->col != MAXCOL) {
|
||||
const char *const p = ml_get_pos(lp);
|
||||
if (*p != NUL) { // still within line, move to next char (may be NUL)
|
||||
const int l = utfc_ptr2len((char *)p);
|
||||
const int l = utfc_ptr2len(p);
|
||||
|
||||
lp->col += l;
|
||||
return ((p[l] != NUL) ? 0 : 2);
|
||||
|
@@ -1343,7 +1343,7 @@ static char *menu_text(const char *str, int *mnemonic, char **actext)
|
||||
bool menu_is_menubar(const char *const name)
|
||||
FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL
|
||||
{
|
||||
return !menu_is_popup((char *)name)
|
||||
return !menu_is_popup(name)
|
||||
&& !menu_is_toolbar(name)
|
||||
&& !menu_is_winbar(name)
|
||||
&& *name != MNU_HIDDEN_CHAR;
|
||||
|
@@ -2002,7 +2002,7 @@ static const char *set_bool_option(const int opt_idx, char *const varp, const in
|
||||
// Disallow changing some options from secure mode
|
||||
if ((secure || sandbox != 0)
|
||||
&& (options[opt_idx].flags & P_SECURE)) {
|
||||
return (char *)e_secure;
|
||||
return e_secure;
|
||||
}
|
||||
|
||||
// Save the global value before changing anything. This is needed as for
|
||||
|
@@ -656,7 +656,7 @@ static size_t do_path_expand(garray_T *gap, const char *path, size_t wildoff, in
|
||||
)) { // NOLINT(whitespace/parens)
|
||||
e = p;
|
||||
}
|
||||
len = (size_t)(utfc_ptr2len((char *)path_end));
|
||||
len = (size_t)(utfc_ptr2len(path_end));
|
||||
memcpy(p, path_end, len);
|
||||
p += len;
|
||||
path_end += len;
|
||||
@@ -973,7 +973,7 @@ static void uniquefy_paths(garray_T *gap, char *pattern)
|
||||
for (int i = 0; i < gap->ga_len && !got_int; i++) {
|
||||
char *path = fnames[i];
|
||||
int is_in_curdir;
|
||||
char *dir_end = (char *)gettail_dir(path);
|
||||
const char *dir_end = gettail_dir(path);
|
||||
char *pathsep_p;
|
||||
char *path_cutoff;
|
||||
|
||||
@@ -1911,8 +1911,8 @@ void path_fix_case(char *name)
|
||||
return;
|
||||
}
|
||||
|
||||
char *entry;
|
||||
while ((entry = (char *)os_scandir_next(&dir))) {
|
||||
const char *entry;
|
||||
while ((entry = os_scandir_next(&dir))) {
|
||||
// Only accept names that differ in case and are the same byte
|
||||
// length. TODO: accept different length name.
|
||||
if (STRICMP(tail, entry) == 0 && strlen(tail) == strlen(entry)) {
|
||||
@@ -2021,7 +2021,7 @@ int pathcmp(const char *p, const char *q, int maxlen)
|
||||
// ignore a trailing slash, but not "//" or ":/"
|
||||
if (c2 == NUL
|
||||
&& i > 0
|
||||
&& !after_pathsep((char *)s, (char *)s + i)
|
||||
&& !after_pathsep(s, s + i)
|
||||
#ifdef BACKSLASH_IN_FILENAME
|
||||
&& (c1 == '/' || c1 == '\\')
|
||||
#else
|
||||
@@ -2354,11 +2354,11 @@ int append_path(char *path, const char *to_append, size_t max_len)
|
||||
/// @return FAIL for failure, OK for success.
|
||||
static int path_to_absolute(const char *fname, char *buf, size_t len, int force)
|
||||
{
|
||||
char *p;
|
||||
const char *p;
|
||||
*buf = NUL;
|
||||
|
||||
char *relative_directory = xmalloc(len);
|
||||
char *end_of_path = (char *)fname;
|
||||
const char *end_of_path = fname;
|
||||
|
||||
// expand it if forced or not an absolute path
|
||||
if (force || !path_is_absolute(fname)) {
|
||||
|
@@ -374,8 +374,8 @@ int qf_init(win_T *wp, const char *restrict efile, char *restrict errorformat, i
|
||||
qi = ll_get_or_alloc_list(wp);
|
||||
}
|
||||
|
||||
return qf_init_ext(qi, qi->qf_curlist, (char *)efile, curbuf, NULL, errorformat,
|
||||
newlist, (linenr_T)0, (linenr_T)0, (char *)qf_title, enc);
|
||||
return qf_init_ext(qi, qi->qf_curlist, efile, curbuf, NULL, errorformat,
|
||||
newlist, (linenr_T)0, (linenr_T)0, qf_title, enc);
|
||||
}
|
||||
|
||||
// Maximum number of bytes allowed per line while reading an errorfile.
|
||||
@@ -3228,7 +3228,7 @@ void qf_list(exarg_T *eap)
|
||||
static void qf_fmt_text(garray_T *gap, const char *restrict text)
|
||||
FUNC_ATTR_NONNULL_ALL
|
||||
{
|
||||
const char *p = (char *)text;
|
||||
const char *p = text;
|
||||
|
||||
while (*p != NUL) {
|
||||
if (*p == '\n') {
|
||||
@@ -4286,11 +4286,11 @@ static char *make_get_fullcmd(const char *makecmd, const char *fname)
|
||||
len += strlen(p_sp) + strlen(fname) + 3;
|
||||
}
|
||||
char *const cmd = xmalloc(len);
|
||||
snprintf(cmd, len, "%s%s%s", p_shq, (char *)makecmd, p_shq);
|
||||
snprintf(cmd, len, "%s%s%s", p_shq, makecmd, p_shq);
|
||||
|
||||
// If 'shellpipe' empty: don't redirect to 'errorfile'.
|
||||
if (*p_sp != NUL) {
|
||||
append_redir(cmd, len, p_sp, (char *)fname);
|
||||
append_redir(cmd, len, p_sp, fname);
|
||||
}
|
||||
|
||||
// Display the fully formed command. Output a newline if there's something
|
||||
@@ -7112,7 +7112,7 @@ static void hgr_search_in_rtp(qf_list_T *qfl, regmatch_T *p_regmatch, const char
|
||||
while (*p != NUL && !got_int) {
|
||||
copy_option_part(&p, NameBuff, MAXPATHL, ",");
|
||||
|
||||
hgr_search_files_in_dir(qfl, NameBuff, p_regmatch, (char *)lang);
|
||||
hgr_search_files_in_dir(qfl, NameBuff, p_regmatch, lang);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -1832,7 +1832,7 @@ static char *get_str_line(int c, void *cookie, int indent, bool do_concat)
|
||||
if (!concat_continued_line(&ga, 400, line, (size_t)(next_eol - line))) {
|
||||
break;
|
||||
}
|
||||
eol = (char *)next_eol;
|
||||
eol = next_eol;
|
||||
}
|
||||
}
|
||||
ga_append(&ga, NUL);
|
||||
|
@@ -3036,8 +3036,8 @@ static int fuzzy_match_recursive(const char *fuzpat, const char *str, uint32_t s
|
||||
// Loop through fuzpat and str looking for a match
|
||||
bool first_match = true;
|
||||
while (*fuzpat != NUL && *str != NUL) {
|
||||
const int c1 = utf_ptr2char((char *)fuzpat);
|
||||
const int c2 = utf_ptr2char((char *)str);
|
||||
const int c1 = utf_ptr2char(fuzpat);
|
||||
const int c2 = utf_ptr2char(str);
|
||||
|
||||
// Found match
|
||||
if (mb_tolower(c1) == mb_tolower(c2)) {
|
||||
@@ -3257,7 +3257,7 @@ static void fuzzy_match_in_list(list_T *const l, char *const str, const bool mat
|
||||
if (retmatchpos) {
|
||||
items[match_count].lmatchpos = tv_list_alloc(kListLenMayKnow);
|
||||
int j = 0;
|
||||
const char *p = (char *)str;
|
||||
const char *p = str;
|
||||
while (*p != NUL) {
|
||||
if (!ascii_iswhite(utf_ptr2char(p)) || matchseq) {
|
||||
tv_list_append_number(items[match_count].lmatchpos, matches[j]);
|
||||
|
@@ -1085,23 +1085,17 @@ static int sign_place(int *sign_id, const char *sign_group, const char *sign_nam
|
||||
return FAIL;
|
||||
}
|
||||
if (*sign_id == 0) {
|
||||
*sign_id = sign_group_get_next_signid(buf, (char *)sign_group);
|
||||
*sign_id = sign_group_get_next_signid(buf, sign_group);
|
||||
}
|
||||
|
||||
if (lnum > 0) {
|
||||
// ":sign place {id} line={lnum} name={name} file={fname}":
|
||||
// place a sign
|
||||
bool has_text_or_icon = sp->sn_text != NULL || sp->sn_icon != NULL;
|
||||
buf_addsign(buf,
|
||||
*sign_id,
|
||||
(char *)sign_group,
|
||||
prio,
|
||||
lnum,
|
||||
sp->sn_typenr,
|
||||
has_text_or_icon);
|
||||
buf_addsign(buf, *sign_id, sign_group, prio, lnum, sp->sn_typenr, has_text_or_icon);
|
||||
} else {
|
||||
// ":sign place {id} file={fname}": change sign type and/or priority
|
||||
lnum = buf_change_sign_type(buf, *sign_id, (char *)sign_group, sp->sn_typenr, prio);
|
||||
lnum = buf_change_sign_type(buf, *sign_id, sign_group, sp->sn_typenr, prio);
|
||||
}
|
||||
if (lnum > 0) {
|
||||
redraw_buf_line_later(buf, lnum, false);
|
||||
@@ -1585,7 +1579,7 @@ static void sign_getlist(const char *name, list_T *retlist)
|
||||
sign_T *sp = first_sign;
|
||||
|
||||
if (name != NULL) {
|
||||
sp = sign_find((char *)name, NULL);
|
||||
sp = sign_find(name, NULL);
|
||||
if (sp == NULL) {
|
||||
return;
|
||||
}
|
||||
@@ -1633,7 +1627,7 @@ static void sign_get_placed_in_buf(buf_T *buf, linenr_T lnum, int sign_id, const
|
||||
tv_dict_add_list(d, S_LEN("signs"), l);
|
||||
|
||||
FOR_ALL_SIGNS_IN_BUF(buf, sign) {
|
||||
if (!sign_in_group(sign, (char *)sign_group)) {
|
||||
if (!sign_in_group(sign, sign_group)) {
|
||||
continue;
|
||||
}
|
||||
if ((lnum == 0 && sign_id == 0)
|
||||
|
@@ -2845,7 +2845,7 @@ static void spell_soundfold_wsal(slang_T *slang, const char *inword, char *res)
|
||||
// Remove accents, if wanted. We actually remove all non-word characters.
|
||||
// But keep white space.
|
||||
int wordlen = 0;
|
||||
for (const char *s = (char *)inword; *s != NUL;) {
|
||||
for (const char *s = inword; *s != NUL;) {
|
||||
const char *t = s;
|
||||
int c = mb_cptr2char_adv(&s);
|
||||
if (slang->sl_rem_accents) {
|
||||
|
@@ -2137,7 +2137,7 @@ static afffile_T *spell_read_aff(spellinfo_T *spin, char *fname)
|
||||
if (itemcnt > 0) {
|
||||
if (is_aff_rule(items, itemcnt, "SET", 2) && aff->af_enc == NULL) {
|
||||
// Setup for conversion from "ENC" to 'encoding'.
|
||||
aff->af_enc = enc_canonize((char *)items[1]);
|
||||
aff->af_enc = enc_canonize(items[1]);
|
||||
if (!spin->si_ascii
|
||||
&& convert_setup(&spin->si_conv, aff->af_enc, p_enc) == FAIL) {
|
||||
smsg(_("Conversion in %s not supported: from %s to %s"),
|
||||
@@ -2240,13 +2240,13 @@ static afffile_T *spell_read_aff(spellinfo_T *spin, char *fname)
|
||||
} else if (is_aff_rule(items, itemcnt, "COMPOUNDRULES", 2)) {
|
||||
// We don't use the count, but do check that it's a number and
|
||||
// not COMPOUNDRULE mistyped.
|
||||
if (atoi((char *)items[1]) == 0) {
|
||||
if (atoi(items[1]) == 0) {
|
||||
smsg(_("Wrong COMPOUNDRULES value in %s line %d: %s"),
|
||||
fname, lnum, items[1]);
|
||||
}
|
||||
} else if (is_aff_rule(items, itemcnt, "COMPOUNDRULE", 2)) {
|
||||
// Don't use the first rule if it is a number.
|
||||
if (compflags != NULL || *skipdigits((char *)items[1]) != NUL) {
|
||||
if (compflags != NULL || *skipdigits(items[1]) != NUL) {
|
||||
// Concatenate this string to previously defined ones,
|
||||
// using a slash to separate them.
|
||||
l = (int)strlen(items[1]) + 1;
|
||||
@@ -2263,21 +2263,21 @@ static afffile_T *spell_read_aff(spellinfo_T *spin, char *fname)
|
||||
}
|
||||
} else if (is_aff_rule(items, itemcnt, "COMPOUNDWORDMAX", 2)
|
||||
&& compmax == 0) {
|
||||
compmax = atoi((char *)items[1]);
|
||||
compmax = atoi(items[1]);
|
||||
if (compmax == 0) {
|
||||
smsg(_("Wrong COMPOUNDWORDMAX value in %s line %d: %s"),
|
||||
fname, lnum, items[1]);
|
||||
}
|
||||
} else if (is_aff_rule(items, itemcnt, "COMPOUNDMIN", 2)
|
||||
&& compminlen == 0) {
|
||||
compminlen = atoi((char *)items[1]);
|
||||
compminlen = atoi(items[1]);
|
||||
if (compminlen == 0) {
|
||||
smsg(_("Wrong COMPOUNDMIN value in %s line %d: %s"),
|
||||
fname, lnum, items[1]);
|
||||
}
|
||||
} else if (is_aff_rule(items, itemcnt, "COMPOUNDSYLMAX", 2)
|
||||
&& compsylmax == 0) {
|
||||
compsylmax = atoi((char *)items[1]);
|
||||
compsylmax = atoi(items[1]);
|
||||
if (compsylmax == 0) {
|
||||
smsg(_("Wrong COMPOUNDSYLMAX value in %s line %d: %s"),
|
||||
fname, lnum, items[1]);
|
||||
@@ -2291,7 +2291,7 @@ static afffile_T *spell_read_aff(spellinfo_T *spin, char *fname)
|
||||
} else if (is_aff_rule(items, itemcnt, "CHECKCOMPOUNDTRIPLE", 1)) {
|
||||
compoptions |= COMP_CHECKTRIPLE;
|
||||
} else if (is_aff_rule(items, itemcnt, "CHECKCOMPOUNDPATTERN", 2)) {
|
||||
if (atoi((char *)items[1]) == 0) {
|
||||
if (atoi(items[1]) == 0) {
|
||||
smsg(_("Wrong CHECKCOMPOUNDPATTERN value in %s line %d: %s"),
|
||||
fname, lnum, items[1]);
|
||||
}
|
||||
@@ -2344,7 +2344,7 @@ static afffile_T *spell_read_aff(spellinfo_T *spin, char *fname)
|
||||
// "S" flag on all but the last block, thus we check for that
|
||||
// and store it in ah_follows.
|
||||
xstrlcpy(key, items[1], AH_KEY_LEN);
|
||||
hi = hash_find(tp, (char *)key);
|
||||
hi = hash_find(tp, key);
|
||||
if (!HASHITEM_EMPTY(hi)) {
|
||||
cur_aff = HI2AH(hi);
|
||||
if (cur_aff->ah_combine != (*items[2] == 'Y')) {
|
||||
@@ -2421,7 +2421,7 @@ static afffile_T *spell_read_aff(spellinfo_T *spin, char *fname)
|
||||
}
|
||||
}
|
||||
|
||||
aff_todo = atoi((char *)items[3]);
|
||||
aff_todo = atoi(items[3]);
|
||||
} else if ((strcmp(items[0], "PFX") == 0
|
||||
|| strcmp(items[0], "SFX") == 0)
|
||||
&& aff_todo > 0
|
||||
@@ -2640,7 +2640,7 @@ static afffile_T *spell_read_aff(spellinfo_T *spin, char *fname)
|
||||
|
||||
// We simply concatenate all the MAP strings, separated by
|
||||
// slashes.
|
||||
ga_concat(&spin->si_map, (char *)items[1]);
|
||||
ga_concat(&spin->si_map, items[1]);
|
||||
ga_append(&spin->si_map, '/');
|
||||
}
|
||||
}
|
||||
@@ -2670,7 +2670,7 @@ static afffile_T *spell_read_aff(spellinfo_T *spin, char *fname)
|
||||
sofoto = getroom_save(spin, items[1]);
|
||||
} else if (strcmp(items[0], "COMMON") == 0) {
|
||||
for (int i = 1; i < itemcnt; i++) {
|
||||
if (HASHITEM_EMPTY(hash_find(&spin->si_commonwords, (char *)items[i]))) {
|
||||
if (HASHITEM_EMPTY(hash_find(&spin->si_commonwords, items[i]))) {
|
||||
p = xstrdup(items[i]);
|
||||
hash_add(&spin->si_commonwords, p);
|
||||
}
|
||||
@@ -2906,7 +2906,7 @@ static void process_compflags(spellinfo_T *spin, afffile_T *aff, char *compflags
|
||||
// Find the flag in the hashtable. If it was used before, use
|
||||
// the existing ID. Otherwise add a new entry.
|
||||
xstrlcpy(key, prevp, (size_t)(p - prevp) + 1);
|
||||
hi = hash_find(&aff->af_comp, (char *)key);
|
||||
hi = hash_find(&aff->af_comp, key);
|
||||
if (!HASHITEM_EMPTY(hi)) {
|
||||
id = HI2CI(hi)->ci_newID;
|
||||
} else {
|
||||
@@ -3111,14 +3111,14 @@ static int spell_read_dic(spellinfo_T *spin, char *fname, afffile_T *affile)
|
||||
spin->si_msg_count = 999999;
|
||||
|
||||
// Read and ignore the first line: word count.
|
||||
if (vim_fgets((char *)line, MAXLINELEN, fd) || !ascii_isdigit(*skipwhite((char *)line))) {
|
||||
if (vim_fgets(line, MAXLINELEN, fd) || !ascii_isdigit(*skipwhite(line))) {
|
||||
semsg(_("E760: No word count in %s"), fname);
|
||||
}
|
||||
|
||||
// Read all the lines in the file one by one.
|
||||
// The words are converted to 'encoding' here, before being added to
|
||||
// the hashtable.
|
||||
while (!vim_fgets((char *)line, MAXLINELEN, fd) && !got_int) {
|
||||
while (!vim_fgets(line, MAXLINELEN, fd) && !got_int) {
|
||||
line_breakcheck();
|
||||
lnum++;
|
||||
if (line[0] == '#' || line[0] == '/') {
|
||||
@@ -3137,7 +3137,7 @@ static int spell_read_dic(spellinfo_T *spin, char *fname, afffile_T *affile)
|
||||
|
||||
// Convert from "SET" to 'encoding' when needed.
|
||||
if (spin->si_conv.vc_type != CONV_NONE) {
|
||||
pc = string_convert(&spin->si_conv, (char *)line, NULL);
|
||||
pc = string_convert(&spin->si_conv, line, NULL);
|
||||
if (pc == NULL) {
|
||||
smsg(_("Conversion failure for word in %s line %d: %s"),
|
||||
fname, lnum, line);
|
||||
@@ -3329,7 +3329,7 @@ static int get_pfxlist(afffile_T *affile, char *afflist, char *store_afflist)
|
||||
// A flag is a postponed prefix flag if it appears in "af_pref"
|
||||
// and its ID is not zero.
|
||||
xstrlcpy(key, prevp, (size_t)(p - prevp) + 1);
|
||||
hi = hash_find(&affile->af_pref, (char *)key);
|
||||
hi = hash_find(&affile->af_pref, key);
|
||||
if (!HASHITEM_EMPTY(hi)) {
|
||||
id = HI2AH(hi)->ah_newID;
|
||||
if (id != 0) {
|
||||
@@ -3360,7 +3360,7 @@ static void get_compflags(afffile_T *affile, char *afflist, char *store_afflist)
|
||||
if (get_affitem(affile->af_flagtype, &p) != 0) {
|
||||
// A flag is a compound flag if it appears in "af_comp".
|
||||
xstrlcpy(key, prevp, (size_t)(p - prevp) + 1);
|
||||
hi = hash_find(&affile->af_comp, (char *)key);
|
||||
hi = hash_find(&affile->af_comp, key);
|
||||
if (!HASHITEM_EMPTY(hi)) {
|
||||
store_afflist[cnt++] = (char)(uint8_t)HI2CI(hi)->ci_newID;
|
||||
}
|
||||
@@ -4393,7 +4393,7 @@ static int write_vim_spell(spellinfo_T *spin, char *fname)
|
||||
// Form the <folchars> string first, we need to know its length.
|
||||
size_t l = 0;
|
||||
for (size_t i = 128; i < 256; i++) {
|
||||
l += (size_t)utf_char2bytes(spelltab.st_fold[i], (char *)folchars + l);
|
||||
l += (size_t)utf_char2bytes(spelltab.st_fold[i], folchars + l);
|
||||
}
|
||||
put_bytes(fd, 1 + 128 + 2 + l, 4); // <sectionlen>
|
||||
|
||||
@@ -5561,7 +5561,7 @@ void spell_add_word(char *word, int len, SpellAddType what, int idx, bool undo)
|
||||
// since its flags sort before the one with WF_BANNED.
|
||||
fd = os_fopen(fname, "r");
|
||||
if (fd != NULL) {
|
||||
while (!vim_fgets((char *)line, MAXWLEN * 2, fd)) {
|
||||
while (!vim_fgets(line, MAXWLEN * 2, fd)) {
|
||||
fpos = fpos_next;
|
||||
fpos_next = ftell(fd);
|
||||
if (fpos_next < 0) {
|
||||
|
@@ -1468,7 +1468,7 @@ char *reverse_text(char *s)
|
||||
/// @return [allocated] Copy of the string.
|
||||
char *strrep(const char *src, const char *what, const char *rep)
|
||||
{
|
||||
char *pos = (char *)src;
|
||||
const char *pos = src;
|
||||
size_t whatlen = strlen(what);
|
||||
|
||||
// Count occurrences
|
||||
|
@@ -3763,7 +3763,7 @@ static void add_keyword(char *const name, const int id, const int flags,
|
||||
} else {
|
||||
// keyword already exists, prepend to list
|
||||
kp->ke_next = HI2KE(hi);
|
||||
hi->hi_key = (char *)KE2HIKEY(kp);
|
||||
hi->hi_key = KE2HIKEY(kp);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -1303,7 +1303,7 @@ static int find_tagfunc_tags(char *pat, garray_T *ga, int *match_count, int flag
|
||||
res_kind = NULL;
|
||||
|
||||
TV_DICT_ITER(TV_LIST_ITEM_TV(li)->vval.v_dict, di, {
|
||||
const char *dict_key = (char *)di->di_key;
|
||||
const char *dict_key = di->di_key;
|
||||
typval_T *tv = &di->di_tv;
|
||||
|
||||
if (tv->v_type != VAR_STRING || tv->vval.v_string == NULL) {
|
||||
@@ -1372,7 +1372,7 @@ static int find_tagfunc_tags(char *pat, garray_T *ga, int *match_count, int flag
|
||||
}
|
||||
|
||||
TV_DICT_ITER(TV_LIST_ITEM_TV(li)->vval.v_dict, di, {
|
||||
const char *dict_key = (char *)di->di_key;
|
||||
const char *dict_key = di->di_key;
|
||||
typval_T *tv = &di->di_tv;
|
||||
if (tv->v_type != VAR_STRING || tv->vval.v_string == NULL) {
|
||||
continue;
|
||||
@@ -2530,7 +2530,7 @@ int get_tagfname(tagname_T *tnp, int first, char *buf)
|
||||
}
|
||||
tnp->tn_hf_idx++;
|
||||
STRCPY(buf, p_hf);
|
||||
STRCPY(path_tail((char *)buf), "tags");
|
||||
STRCPY(path_tail(buf), "tags");
|
||||
#ifdef BACKSLASH_IN_FILENAME
|
||||
slash_adjust(buf);
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user