diff options
author | ii14 <59243201+ii14@users.noreply.github.com> | 2023-04-07 19:40:57 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-07 19:40:57 +0200 |
commit | 9408f2dcf7cade2631688300e9b58eed6bc5219a (patch) | |
tree | 152b8b6135f50619b1fb2a69719d71a180ea0792 | |
parent | 1d2a29f75ba7d094c8e7444c9b249a4a7211c93c (diff) | |
download | rneovim-9408f2dcf7cade2631688300e9b58eed6bc5219a.tar.gz rneovim-9408f2dcf7cade2631688300e9b58eed6bc5219a.tar.bz2 rneovim-9408f2dcf7cade2631688300e9b58eed6bc5219a.zip |
refactor: remove redundant const char * casts
56 files changed, 302 insertions, 350 deletions
diff --git a/src/nvim/api/private/converter.c b/src/nvim/api/private/converter.c index 58ff552ab7..7d04d883f5 100644 --- a/src/nvim/api/private/converter.c +++ b/src/nvim/api/private/converter.c @@ -49,7 +49,7 @@ typedef struct { #define TYPVAL_ENCODE_CONV_STRING(tv, str, len) \ do { \ const size_t len_ = (size_t)(len); \ - const char *const str_ = (const char *)(str); \ + const char *const str_ = (str); \ assert(len_ == 0 || str_ != NULL); \ kvi_push(edata->stack, STRING_OBJ(cbuf_to_string((len_?str_:""), len_))); \ } while (0) diff --git a/src/nvim/api/ui.c b/src/nvim/api/ui.c index 5dd858a6a9..edf13b073c 100644 --- a/src/nvim/api/ui.c +++ b/src/nvim/api/ui.c @@ -843,7 +843,7 @@ void remote_ui_raw_line(UI *ui, Integer grid, Integer row, Integer startcol, Int uint32_t csize = (repeat > 1) ? 3 : ((attrs[i] != last_hl) ? 2 : 1); nelem++; mpack_array(buf, csize); - mpack_str(buf, (const char *)chunk[i]); + mpack_str(buf, chunk[i]); if (csize >= 2) { mpack_uint(buf, (uint32_t)attrs[i]); if (csize >= 3) { @@ -873,7 +873,7 @@ void remote_ui_raw_line(UI *ui, Integer grid, Integer row, Integer startcol, Int for (int i = 0; i < endcol - startcol; i++) { remote_ui_cursor_goto(ui, row, startcol + i); remote_ui_highlight_set(ui, attrs[i]); - remote_ui_put(ui, (const char *)chunk[i]); + remote_ui_put(ui, chunk[i]); if (utf_ambiguous_width(utf_ptr2char((char *)chunk[i]))) { data->client_col = -1; // force cursor update } diff --git a/src/nvim/api/win_config.c b/src/nvim/api/win_config.c index 0ffeac1bff..23bd5d2f48 100644 --- a/src/nvim/api/win_config.c +++ b/src/nvim/api/win_config.c @@ -275,13 +275,13 @@ Dictionary nvim_win_get_config(Window window, Error *err) for (size_t i = 0; i < 8; i++) { Array tuple = ARRAY_DICT_INIT; - String s = cstrn_to_string((const char *)config->border_chars[i], sizeof(schar_T)); + String s = cstrn_to_string(config->border_chars[i], sizeof(schar_T)); int hi_id = config->border_hl_ids[i]; char *hi_name = syn_id2name(hi_id); if (hi_name[0]) { ADD(tuple, STRING_OBJ(s)); - ADD(tuple, STRING_OBJ(cstr_to_string((const char *)hi_name))); + ADD(tuple, STRING_OBJ(cstr_to_string(hi_name))); ADD(border, ARRAY_OBJ(tuple)); } else { ADD(border, STRING_OBJ(s)); @@ -293,10 +293,9 @@ Dictionary nvim_win_get_config(Window window, Error *err) VirtText title_datas = config->title_chunks; for (size_t i = 0; i < title_datas.size; i++) { Array tuple = ARRAY_DICT_INIT; - ADD(tuple, CSTR_TO_OBJ((const char *)title_datas.items[i].text)); + ADD(tuple, CSTR_TO_OBJ(title_datas.items[i].text)); if (title_datas.items[i].hl_id > 0) { - ADD(tuple, - STRING_OBJ(cstr_to_string((const char *)syn_id2name(title_datas.items[i].hl_id)))); + ADD(tuple, STRING_OBJ(cstr_to_string(syn_id2name(title_datas.items[i].hl_id)))); } ADD(titles, ARRAY_OBJ(tuple)); } diff --git a/src/nvim/arglist.c b/src/nvim/arglist.c index 537b56353e..6735371576 100644 --- a/src/nvim/arglist.c +++ b/src/nvim/arglist.c @@ -1230,8 +1230,7 @@ static void get_arglist_as_rettv(aentry_T *arglist, int argcount, typval_T *rett tv_list_alloc_ret(rettv, argcount); if (arglist != NULL) { for (int idx = 0; idx < argcount; idx++) { - tv_list_append_string(rettv->vval.v_list, - (const char *)alist_name(&arglist[idx]), -1); + tv_list_append_string(rettv->vval.v_list, alist_name(&arglist[idx]), -1); } } } @@ -1267,7 +1266,7 @@ void f_argv(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) rettv->vval.v_string = NULL; int idx = (int)tv_get_number_chk(&argvars[0], NULL); if (arglist != NULL && idx >= 0 && idx < argcount) { - rettv->vval.v_string = xstrdup((const char *)alist_name(&arglist[idx])); + rettv->vval.v_string = xstrdup(alist_name(&arglist[idx])); } else if (idx == -1) { get_arglist_as_rettv(arglist, argcount, rettv); } diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c index fb674774c6..d8282734d4 100644 --- a/src/nvim/buffer.c +++ b/src/nvim/buffer.c @@ -268,7 +268,7 @@ int open_buffer(int read_stdin, exarg_T *eap, int flags_arg) int save_bin = curbuf->b_p_bin; int perm; - perm = os_getperm((const char *)curbuf->b_ffname); + perm = os_getperm(curbuf->b_ffname); if (perm >= 0 && (0 || S_ISFIFO(perm) || S_ISSOCK(perm) # ifdef OPEN_CHR_FILES @@ -3309,8 +3309,7 @@ void maketitle(void) SPACE_FOR_FNAME + 1); buf_p += MIN(size, SPACE_FOR_FNAME); } else { - buf_p += transstr_buf((const char *)path_tail(curbuf->b_fname), - -1, buf_p, SPACE_FOR_FNAME + 1, true); + buf_p += transstr_buf(path_tail(curbuf->b_fname), -1, buf_p, SPACE_FOR_FNAME + 1, true); } switch (bufIsChanged(curbuf) @@ -3557,7 +3556,7 @@ void fname_expand(buf_T *buf, char **ffname, char **sfname) #ifdef MSWIN if (!buf->b_p_bin) { // If the file name is a shortcut file, use the file it links to. - char *rfname = os_resolve_shortcut((const char *)(*ffname)); + char *rfname = os_resolve_shortcut(*ffname); if (rfname != NULL) { xfree(*ffname); *ffname = rfname; diff --git a/src/nvim/channel.c b/src/nvim/channel.c index a7ec303a6c..820ce534e1 100644 --- a/src/nvim/channel.c +++ b/src/nvim/channel.c @@ -81,7 +81,7 @@ bool channel_close(uint64_t id, ChannelPart part, const char **error) // allow double close, even though we can't say what parts was valid. return true; } - *error = (const char *)e_invchan; + *error = e_invchan; return false; } @@ -91,19 +91,19 @@ bool channel_close(uint64_t id, ChannelPart part, const char **error) if (chan->is_rpc) { rpc_close(chan); } else if (part == kChannelPartRpc) { - *error = (const char *)e_invstream; + *error = e_invstream; return false; } } else if ((part == kChannelPartStdin || part == kChannelPartStdout) && chan->is_rpc) { - *error = (const char *)e_invstreamrpc; + *error = e_invstreamrpc; return false; } switch (chan->streamtype) { case kChannelStreamSocket: if (!close_main) { - *error = (const char *)e_invstream; + *error = e_invstream; return false; } stream_may_close(&chan->stream.socket); @@ -134,14 +134,14 @@ bool channel_close(uint64_t id, ChannelPart part, const char **error) stream_may_close(&chan->stream.stdio.out); } if (part == kChannelPartStderr) { - *error = (const char *)e_invstream; + *error = e_invstream; return false; } break; case kChannelStreamStderr: if (part != kChannelPartAll && part != kChannelPartStderr) { - *error = (const char *)e_invstream; + *error = e_invstream; return false; } if (!chan->stream.err.closed) { @@ -156,7 +156,7 @@ bool channel_close(uint64_t id, ChannelPart part, const char **error) case kChannelStreamInternal: if (!close_main) { - *error = (const char *)e_invstream; + *error = e_invstream; return false; } if (chan->term) { diff --git a/src/nvim/charset.c b/src/nvim/charset.c index 2be8ccc456..545002a197 100644 --- a/src/nvim/charset.c +++ b/src/nvim/charset.c @@ -389,7 +389,7 @@ size_t transstr_buf(const char *const s, const ssize_t slen, char *const buf, co } else if (*p == TAB && !untab) { *buf_p++ = *p++; } else { - const char *const tb = (const char *)transchar_byte((uint8_t)(*p++)); + const char *const tb = transchar_byte((uint8_t)(*p++)); const size_t tb_len = strlen(tb); if (buf_p + tb_len > buf_e) { break; // Exceeded `buf` size. diff --git a/src/nvim/cmdexpand.c b/src/nvim/cmdexpand.c index bce28fa449..774e16f73d 100644 --- a/src/nvim/cmdexpand.c +++ b/src/nvim/cmdexpand.c @@ -959,7 +959,7 @@ static void showmatches_oneline(expand_T *xp, char **matches, int numMatches, in msg_outtrans_attr(matches[j], HL_ATTR(HLF_D)); p = matches[j] + strlen(matches[j]) + 1; msg_advance(maxlen + 1); - msg_puts((const char *)p); + msg_puts(p); msg_advance(maxlen + 3); msg_outtrans_long_attr(p + 2, HL_ATTR(HLF_D)); break; @@ -1438,7 +1438,7 @@ static const char *set_cmd_index(const char *cmd, exarg_T *eap, expand_T *xp, in p = cmd + 1; } else if (cmd[0] >= 'A' && cmd[0] <= 'Z') { eap->cmd = (char *)cmd; - p = (const char *)find_ucmd(eap, (char *)p, NULL, xp, complp); + p = find_ucmd(eap, (char *)p, NULL, xp, complp); if (p == NULL) { eap->cmdidx = CMD_SIZE; // Ambiguous user command. } @@ -1464,7 +1464,7 @@ static void set_context_for_wildcard_arg(exarg_T *eap, const char *arg, bool use // Allow spaces within back-quotes to count as part of the argument // being expanded. xp->xp_pattern = skipwhite(arg); - const char *p = (const char *)xp->xp_pattern; + const char *p = xp->xp_pattern; while (*p != NUL) { int c = utf_ptr2char(p); if (c == '\\' && p[1] != NUL) { @@ -1517,7 +1517,7 @@ static void set_context_for_wildcard_arg(exarg_T *eap, const char *arg, bool use // Check for environment variable. if (*xp->xp_pattern == '$') { - for (p = (const char *)xp->xp_pattern + 1; *p != NUL; p++) { + for (p = xp->xp_pattern + 1; *p != NUL; p++) { if (!vim_isIDc((uint8_t)(*p))) { break; } @@ -1533,12 +1533,11 @@ static void set_context_for_wildcard_arg(exarg_T *eap, const char *arg, bool use } // Check for user names. if (*xp->xp_pattern == '~') { - for (p = (const char *)xp->xp_pattern + 1; *p != NUL && *p != '/'; p++) {} + for (p = xp->xp_pattern + 1; *p != NUL && *p != '/'; p++) {} // Complete ~user only if it partially matches a user name. // A full match ~user<Tab> will be replaced by user's home // directory i.e. something like ~user<Tab> -> /home/user/ - if (*p == NUL && p > (const char *)xp->xp_pattern + 1 - && match_user(xp->xp_pattern + 1) >= 1) { + if (*p == NUL && p > xp->xp_pattern + 1 && match_user(xp->xp_pattern + 1) >= 1) { xp->xp_context = EXPAND_USER; xp->xp_pattern++; } @@ -1550,13 +1549,13 @@ static void set_context_for_wildcard_arg(exarg_T *eap, const char *arg, bool use static const char *set_context_in_filter_cmd(expand_T *xp, const char *arg) { if (*arg != NUL) { - arg = (const char *)skip_vimgrep_pat((char *)arg, NULL, NULL); + arg = skip_vimgrep_pat((char *)arg, NULL, NULL); } if (arg == NULL || *arg == NUL) { xp->xp_context = EXPAND_NOTHING; return NULL; } - return (const char *)skipwhite(arg); + return skipwhite(arg); } /// Set the completion context for the :match command. Returns a pointer to the @@ -1566,13 +1565,13 @@ static const char *set_context_in_match_cmd(expand_T *xp, const char *arg) if (*arg == NUL || !ends_excmd(*arg)) { // also complete "None" set_context_in_echohl_cmd(xp, arg); - arg = (const char *)skipwhite(skiptowhite(arg)); + arg = skipwhite(skiptowhite(arg)); if (*arg != NUL) { xp->xp_context = EXPAND_NOTHING; - arg = (const char *)skip_regexp((char *)arg + 1, (uint8_t)(*arg), magic_isset()); + arg = skip_regexp((char *)arg + 1, (uint8_t)(*arg), magic_isset()); } } - return (const char *)find_nextcmd(arg); + return find_nextcmd(arg); } /// Returns a pointer to the next command after a :global or a :v command. @@ -1605,7 +1604,7 @@ static const char *find_cmd_after_substitute_cmd(const char *arg) if (delim) { // Skip "from" part. arg++; - arg = (const char *)skip_regexp((char *)arg, delim, magic_isset()); + arg = skip_regexp((char *)arg, delim, magic_isset()); if (arg[0] != NUL && arg[0] == delim) { // Skip "to" part. @@ -1637,7 +1636,7 @@ static const char *find_cmd_after_substitute_cmd(const char *arg) static const char *find_cmd_after_isearch_cmd(expand_T *xp, const char *arg) { // Skip count. - arg = (const char *)skipwhite(skipdigits(arg)); + arg = skipwhite(skipdigits(arg)); if (*arg != '/') { return NULL; } @@ -1649,7 +1648,7 @@ static const char *find_cmd_after_isearch_cmd(expand_T *xp, const char *arg) } } if (*arg) { - arg = (const char *)skipwhite(arg + 1); + arg = skipwhite(arg + 1); // Check for trailing illegal characters. if (*arg == NUL || strchr("|\"\n", *arg) == NULL) { @@ -1666,7 +1665,7 @@ static const char *find_cmd_after_isearch_cmd(expand_T *xp, const char *arg) static const char *set_context_in_unlet_cmd(expand_T *xp, const char *arg) { while ((xp->xp_pattern = strchr(arg, ' ')) != NULL) { - arg = (const char *)xp->xp_pattern + 1; + arg = xp->xp_pattern + 1; } xp->xp_context = EXPAND_USER_VARS; @@ -1683,7 +1682,7 @@ static const char *set_context_in_unlet_cmd(expand_T *xp, const char *arg) /// Set the completion context for the :language command. Always returns NULL. static const char *set_context_in_lang_cmd(expand_T *xp, const char *arg) { - const char *p = (const char *)skiptowhite(arg); + const char *p = skiptowhite(arg); if (*p == NUL) { xp->xp_context = EXPAND_LANGUAGE; xp->xp_pattern = (char *)arg; @@ -1876,11 +1875,11 @@ static const char *set_context_by_cmdname(const char *cmd, cmdidx_T cmdidx, expa case CMD_dsplit: return find_cmd_after_isearch_cmd(xp, arg); case CMD_autocmd: - return (const char *)set_context_in_autocmd(xp, (char *)arg, false); + return set_context_in_autocmd(xp, (char *)arg, false); case CMD_doautocmd: case CMD_doautoall: - return (const char *)set_context_in_autocmd(xp, (char *)arg, true); + return set_context_in_autocmd(xp, (char *)arg, true); case CMD_set: set_context_in_set_cmd(xp, (char *)arg, 0); break; @@ -1957,7 +1956,7 @@ static const char *set_context_by_cmdname(const char *cmd, cmdidx_T cmdidx, expa case CMD_bwipeout: case CMD_bunload: while ((xp->xp_pattern = strchr(arg, ' ')) != NULL) { - arg = (const char *)xp->xp_pattern + 1; + arg = xp->xp_pattern + 1; } FALLTHROUGH; case CMD_buffer: @@ -2063,7 +2062,7 @@ static const char *set_context_by_cmdname(const char *cmd, cmdidx_T cmdidx, expa case CMD_tunmenu: case CMD_popup: case CMD_emenu: - return (const char *)set_context_in_menu_cmd(xp, cmd, (char *)arg, forceit); + return set_context_in_menu_cmd(xp, cmd, (char *)arg, forceit); case CMD_colorscheme: xp->xp_context = EXPAND_COLORS; @@ -2126,7 +2125,7 @@ static const char *set_context_by_cmdname(const char *cmd, cmdidx_T cmdidx, expa case CMD_argdelete: while ((xp->xp_pattern = vim_strchr(arg, ' ')) != NULL) { - arg = (const char *)(xp->xp_pattern + 1); + arg = (xp->xp_pattern + 1); } xp->xp_context = EXPAND_ARGLIST; xp->xp_pattern = (char *)arg; @@ -2186,7 +2185,7 @@ static const char *set_one_cmd_context(expand_T *xp, const char *buff) } // 3. skip over a range specifier of the form: addr [,addr] [;addr] .. - cmd = (const char *)skip_range(cmd, &xp->xp_context); + cmd = skip_range(cmd, &xp->xp_context); xp->xp_pattern = (char *)cmd; if (*cmd == NUL) { return NULL; @@ -2218,7 +2217,7 @@ static const char *set_one_cmd_context(expand_T *xp, const char *buff) ea.argt = excmd_get_argt(ea.cmdidx); } - const char *arg = (const char *)skipwhite(p); + const char *arg = skipwhite(p); // Skip over ++argopt argument if ((ea.argt & EX_ARGOPT) && *arg != NUL && strncmp(arg, "++", 2) == 0) { @@ -2226,7 +2225,7 @@ static const char *set_one_cmd_context(expand_T *xp, const char *buff) while (*p && !ascii_isspace(*p)) { MB_PTR_ADV(p); } - arg = (const char *)skipwhite(p); + arg = skipwhite(p); } if (ea.cmdidx == CMD_write || ea.cmdidx == CMD_update) { @@ -2234,7 +2233,7 @@ static const char *set_one_cmd_context(expand_T *xp, const char *buff) if (*++arg == '>') { arg++; } - arg = (const char *)skipwhite(arg); + arg = skipwhite(arg); } else if (*arg == '!' && ea.cmdidx == CMD_write) { // :w !filter arg++; usefilter = true; @@ -2253,14 +2252,14 @@ static const char *set_one_cmd_context(expand_T *xp, const char *buff) while (*arg == *cmd) { // allow any number of '>' or '<' arg++; } - arg = (const char *)skipwhite(arg); + arg = skipwhite(arg); } // Does command allow "+command"? if ((ea.argt & EX_CMDARG) && !usefilter && *arg == '+') { // Check if we're in the +command p = arg + 1; - arg = (const char *)skip_cmd_arg((char *)arg, false); + arg = skip_cmd_arg((char *)arg, false); // Still touching the command after '+'? if (*arg == NUL) { @@ -2268,7 +2267,7 @@ static const char *set_one_cmd_context(expand_T *xp, const char *buff) } // Skip space(s) after +command to get to the real argument. - arg = (const char *)skipwhite(arg); + arg = skipwhite(arg); } // Check for '|' to separate commands and '"' to start comments. @@ -2344,7 +2343,7 @@ void set_cmd_context(expand_T *xp, char *str, int len, int col, int use_ccline) old_char = str[col]; } str[col] = NUL; - const char *nextcomm = (const char *)str; + const char *nextcomm = str; if (use_ccline && ccline->cmdfirstc == '=') { // pass CMD_SIZE because there is no real command @@ -2922,7 +2921,7 @@ static void expand_shellcmd_onedir(char *buf, char *s, size_t l, char *pat, char // Check if this name was already found. hash_T hash = hash_hash(name + l); hashitem_T *hi = - hash_lookup(ht, (const char *)(name + l), strlen(name + l), hash); + hash_lookup(ht, name + l, strlen(name + l), hash); if (HASHITEM_EMPTY(hi)) { // Remove the path that was prepended. STRMOVE(name, name + l); @@ -3166,7 +3165,7 @@ static int ExpandUserList(expand_T *xp, char ***matches, int *numMatches) continue; // Skip non-string items and empty strings. } - GA_APPEND(char *, &ga, xstrdup((const char *)TV_LIST_ITEM_TV(li)->vval.v_string)); + GA_APPEND(char *, &ga, xstrdup(TV_LIST_ITEM_TV(li)->vval.v_string)); }); tv_list_unref(retlist); @@ -3195,7 +3194,7 @@ static int ExpandUserLua(expand_T *xp, int *num_file, char ***file) continue; // Skip non-string items and empty strings. } - GA_APPEND(char *, &ga, xstrdup((const char *)TV_LIST_ITEM_TV(li)->vval.v_string)); + GA_APPEND(char *, &ga, xstrdup(TV_LIST_ITEM_TV(li)->vval.v_string)); }); tv_list_unref(retlist); @@ -3551,8 +3550,7 @@ theend: tv_list_alloc_ret(rettv, xpc.xp_numfiles); for (int i = 0; i < xpc.xp_numfiles; i++) { - tv_list_append_string(rettv->vval.v_list, (const char *)xpc.xp_files[i], - -1); + tv_list_append_string(rettv->vval.v_list, xpc.xp_files[i], -1); } xfree(pat); ExpandCleanup(&xpc); diff --git a/src/nvim/edit.c b/src/nvim/edit.c index c551ec2726..9e4457f793 100644 --- a/src/nvim/edit.c +++ b/src/nvim/edit.c @@ -2699,7 +2699,7 @@ int stuff_inserted(int c, long count, int no_esc) } do { - stuffReadbuff((const char *)ptr); + stuffReadbuff(ptr); // A trailing "0" is inserted as "<C-V>048", "^" as "<C-V>^". if (last) { stuffReadbuff(last == '0' ? "\026\060\064\070" : "\026^"); diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 16a2dfa39b..f875e4f06f 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -1234,9 +1234,8 @@ char *get_lval(char *const name, typval_T *const rettv, lval_T *const lp, const if (skip) { // When skipping just find the end of the name. - lp->ll_name = (const char *)name; - return (char *)find_name_end(name, NULL, NULL, - FNE_INCL_BR | fne_flags); + lp->ll_name = name; + return (char *)find_name_end(name, NULL, NULL, FNE_INCL_BR | fne_flags); } // Find the end of the name. @@ -1269,8 +1268,8 @@ char *get_lval(char *const name, typval_T *const rettv, lval_T *const lp, const lp->ll_name_len = strlen(lp->ll_name); } } else { - lp->ll_name = (const char *)name; - lp->ll_name_len = (size_t)((const char *)p - lp->ll_name); + lp->ll_name = name; + lp->ll_name_len = (size_t)(p - lp->ll_name); } // Without [idx] or .key we are done. @@ -1417,7 +1416,7 @@ char *get_lval(char *const name, typval_T *const rettv, lval_T *const lp, const } lp->ll_list = NULL; lp->ll_dict = lp->ll_tv->vval.v_dict; - lp->ll_di = tv_dict_find(lp->ll_dict, (const char *)key, len); + lp->ll_di = tv_dict_find(lp->ll_dict, key, len); // When assigning to a scope dictionary check that a function and // variable name is valid (only variable name unless it is l: or @@ -1434,8 +1433,8 @@ char *get_lval(char *const name, typval_T *const rettv, lval_T *const lp, const } wrong = ((lp->ll_dict->dv_scope == VAR_DEF_SCOPE && tv_is_func(*rettv) - && var_wrong_func_name((const char *)key, lp->ll_di == NULL)) - || !valid_varname((const char *)key)); + && var_wrong_func_name(key, lp->ll_di == NULL)) + || !valid_varname(key)); if (len != -1) { key[len] = prevval; } @@ -1728,7 +1727,7 @@ void set_var_lval(lval_T *lp, char *endp, typval_T *rettv, int copy, const bool } // Need to add an item to the Dictionary. - di = tv_dict_item_alloc((const char *)lp->ll_newkey); + di = tv_dict_item_alloc(lp->ll_newkey); if (tv_dict_add(lp->ll_tv->vval.v_dict, di) == FAIL) { xfree(di); return; @@ -2172,13 +2171,13 @@ static int eval_func(char **const arg, char *const name, const int name_len, typ int len = name_len; if (!evaluate) { - check_vars((const char *)s, (size_t)len); + check_vars(s, (size_t)len); } // If "s" is the name of a variable of type VAR_FUNC // use its contents. partial_T *partial; - s = deref_func_name((const char *)s, &len, &partial, !evaluate); + s = deref_func_name(s, &len, &partial, !evaluate); // Need to make a copy, in case evaluating the arguments makes // the name invalid. @@ -3000,9 +2999,9 @@ static int eval7(char **arg, typval_T *rettv, int evaluate, int want_string) if (**arg == '(') { // recursive! ret = eval_func(arg, s, len, rettv, evaluate, NULL); } else if (evaluate) { - ret = get_var_tv((const char *)s, len, rettv, NULL, true, false); + ret = get_var_tv(s, len, rettv, NULL, true, false); } else { - check_vars((const char *)s, (size_t)len); + check_vars(s, (size_t)len); ret = OK; } } @@ -3199,7 +3198,7 @@ static int eval_method(char **const arg, typval_T *const rettv, const bool evalu char *lua_funcname = NULL; if (strncmp(name, "v:lua.", 6) == 0) { lua_funcname = name + 6; - *arg = (char *)skip_luafunc_name((const char *)lua_funcname); + *arg = (char *)skip_luafunc_name(lua_funcname); *arg = skipwhite(*arg); // to detect trailing whitespace later len = (int)(*arg - lua_funcname); } else { @@ -3520,8 +3519,7 @@ static int eval_index(char **arg, typval_T *rettv, int evaluate, int verbose) } } - dictitem_T *const item = tv_dict_find(rettv->vval.v_dict, - (const char *)key, len); + dictitem_T *const item = tv_dict_find(rettv->vval.v_dict, key, len); if (item == NULL && verbose) { semsg(_(e_dictkey), key); @@ -4635,14 +4633,14 @@ static int eval_dict(char **arg, typval_T *rettv, int evaluate, bool literal) goto failret; } if (evaluate) { - dictitem_T *item = tv_dict_find(d, (const char *)key, -1); + dictitem_T *item = tv_dict_find(d, key, -1); if (item != NULL) { semsg(_("E721: Duplicate key in Dictionary: \"%s\""), key); tv_clear(&tvkey); tv_clear(&tv); goto failret; } - item = tv_dict_item_alloc((const char *)key); + item = tv_dict_item_alloc(key); item->di_tv = tv; item->di_tv.v_lock = VAR_UNLOCKED; if (tv_dict_add(d, item) == FAIL) { @@ -4755,8 +4753,7 @@ void assert_error(garray_T *gap) // Make sure v:errors is a list. set_vim_var_list(VV_ERRORS, tv_list_alloc(1)); } - tv_list_append_string(vimvars[VV_ERRORS].vv_list, - (const char *)gap->ga_data, (ptrdiff_t)gap->ga_len); + tv_list_append_string(vimvars[VV_ERRORS].vv_list, gap->ga_data, (ptrdiff_t)gap->ga_len); } /// Implementation of map() and filter(). @@ -4983,14 +4980,12 @@ void common_function(typval_T *argvars, typval_T *rettv, bool is_funcref) } if (s == NULL || *s == NUL || (use_string && ascii_isdigit(*s)) || (is_funcref && trans_name == NULL)) { - semsg(_(e_invarg2), (use_string - ? tv_get_string(&argvars[0]) - : (const char *)s)); + semsg(_(e_invarg2), (use_string ? tv_get_string(&argvars[0]) : s)); // Don't check an autoload name for existence here. } else if (trans_name != NULL && (is_funcref ? find_func(trans_name) == NULL - : !translated_function_exists((const char *)trans_name))) { + : !translated_function_exists(trans_name))) { semsg(_("E700: Unknown function: %s"), s); } else { int dict_idx = 0; @@ -6338,7 +6333,7 @@ int get_id_len(const char **const arg) } len = (int)(p - *arg); - *arg = (const char *)skipwhite(p); + *arg = skipwhite(p); return len; } @@ -6376,7 +6371,7 @@ int get_name_len(const char **const arg, char **alias, bool evaluate, bool verbo if (expr_start != NULL) { if (!evaluate) { len += (int)(p - *arg); - *arg = (const char *)skipwhite(p); + *arg = skipwhite(p); return len; } @@ -6387,7 +6382,7 @@ int get_name_len(const char **const arg, char **alias, bool evaluate, bool verbo return -1; } *alias = temp_string; - *arg = (const char *)skipwhite(p); + *arg = skipwhite(p); return (int)strlen(temp_string); } @@ -8165,7 +8160,7 @@ void script_host_eval(char *name, typval_T *argvars, typval_T *rettv) } list_T *args = tv_list_alloc(1); - tv_list_append_string(args, (const char *)argvars[0].vval.v_string, -1); + tv_list_append_string(args, argvars[0].vval.v_string, -1); *rettv = eval_call_provider(name, "eval", args, false); } diff --git a/src/nvim/eval/buffer.c b/src/nvim/eval/buffer.c index 2f37d1ba2e..d9cc18a402 100644 --- a/src/nvim/eval/buffer.c +++ b/src/nvim/eval/buffer.c @@ -487,8 +487,7 @@ static dict_T *get_buffer_info(buf_T *buf) dict_T *const dict = tv_dict_alloc(); tv_dict_add_nr(dict, S_LEN("bufnr"), buf->b_fnum); - tv_dict_add_str(dict, S_LEN("name"), - buf->b_ffname != NULL ? (const char *)buf->b_ffname : ""); + tv_dict_add_str(dict, S_LEN("name"), buf->b_ffname != NULL ? buf->b_ffname : ""); tv_dict_add_nr(dict, S_LEN("lnum"), buf == curbuf ? curwin->w_cursor.lnum : buflist_findlnum(buf)); tv_dict_add_nr(dict, S_LEN("linecount"), buf->b_ml.ml_line_count); @@ -496,8 +495,7 @@ static dict_T *get_buffer_info(buf_T *buf) tv_dict_add_nr(dict, S_LEN("listed"), buf->b_p_bl); tv_dict_add_nr(dict, S_LEN("changed"), bufIsChanged(buf)); tv_dict_add_nr(dict, S_LEN("changedtick"), buf_get_changedtick(buf)); - tv_dict_add_nr(dict, S_LEN("hidden"), - buf->b_ml.ml_mfp != NULL && buf->b_nwindows == 0); + tv_dict_add_nr(dict, S_LEN("hidden"), buf->b_ml.ml_mfp != NULL && buf->b_nwindows == 0); // Get a reference to buffer variables tv_dict_add_dict(dict, S_LEN("variables"), buf->b_vars); @@ -609,8 +607,7 @@ static void get_buffer_lines(buf_T *buf, linenr_T start, linenr_T end, int retli } tv_list_alloc_ret(rettv, end - start + 1); while (start <= end) { - tv_list_append_string(rettv->vval.v_list, - (const char *)ml_get_buf(buf, start++, false), -1); + tv_list_append_string(rettv->vval.v_list, ml_get_buf(buf, start++, false), -1); } } else { rettv->v_type = VAR_STRING; diff --git a/src/nvim/eval/decode.c b/src/nvim/eval/decode.c index 6ce9309677..acef37e0e8 100644 --- a/src/nvim/eval/decode.c +++ b/src/nvim/eval/decode.c @@ -148,7 +148,7 @@ static inline int json_decoder_pop(ValuesStackItem obj, ValuesStack *const stack assert(!(key.is_special_string || key.val.vval.v_string == NULL || *key.val.vval.v_string == NUL)); - dictitem_T *const obj_di = tv_dict_item_alloc((const char *)key.val.vval.v_string); + dictitem_T *const obj_di = tv_dict_item_alloc(key.val.vval.v_string); tv_clear(&key.val); if (tv_dict_add(last_container.container.vval.v_dict, obj_di) == FAIL) { @@ -179,8 +179,7 @@ static inline int json_decoder_pop(ValuesStackItem obj, ValuesStack *const stack && (obj.is_special_string || obj.val.vval.v_string == NULL || *obj.val.vval.v_string == NUL - || tv_dict_find(last_container.container.vval.v_dict, - (const char *)obj.val.vval.v_string, -1))) { + || tv_dict_find(last_container.container.vval.v_dict, obj.val.vval.v_string, -1))) { tv_clear(&obj.val); // Restart diff --git a/src/nvim/eval/encode.c b/src/nvim/eval/encode.c index c2f1eae8af..b056a1784c 100644 --- a/src/nvim/eval/encode.c +++ b/src/nvim/eval/encode.c @@ -298,7 +298,7 @@ int encode_read_from_list(ListReaderState *const state, char *const buf, const s #define TYPVAL_ENCODE_CONV_STRING(tv, buf, len) \ do { \ - const char *const buf_ = (const char *)(buf); \ + const char *const buf_ = (buf); \ if ((buf) == NULL) { \ ga_concat(gap, "''"); \ } else { \ @@ -376,7 +376,7 @@ int encode_read_from_list(ListReaderState *const state, char *const buf, const s #define TYPVAL_ENCODE_CONV_FUNC_START(tv, fun) \ do { \ - const char *const fun_ = (const char *)(fun); \ + const char *const fun_ = (fun); \ if (fun_ == NULL) { \ internal_error("string(): NULL function name"); \ ga_concat(gap, "function(NULL"); \ @@ -712,7 +712,7 @@ static inline int convert_to_json_string(garray_T *const gap, const char *const #undef TYPVAL_ENCODE_CONV_STRING #define TYPVAL_ENCODE_CONV_STRING(tv, buf, len) \ do { \ - if (convert_to_json_string(gap, (const char *)(buf), (len)) != OK) { \ + if (convert_to_json_string(gap, (buf), (len)) != OK) { \ return FAIL; \ } \ } while (0) diff --git a/src/nvim/eval/funcs.c b/src/nvim/eval/funcs.c index 03df0661c5..b7425b1ef3 100644 --- a/src/nvim/eval/funcs.c +++ b/src/nvim/eval/funcs.c @@ -319,7 +319,7 @@ static void api_wrapper(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) Object result = handler.fn(VIML_INTERNAL_CALL, args, &res_arena, &err); if (ERROR_SET(&err)) { - semsg_multiline((const char *)e_api_error, err.msg); + semsg_multiline(e_api_error, err.msg); goto end; } @@ -1546,7 +1546,7 @@ static void f_eval(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) { const char *s = tv_get_string_chk(&argvars[0]); if (s != NULL) { - s = (const char *)skipwhite(s); + s = skipwhite(s); } const char *const expr_start = s; @@ -1779,7 +1779,7 @@ static void f_expand(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) if (rettv->v_type == VAR_LIST) { tv_list_alloc_ret(rettv, (result != NULL)); if (result != NULL) { - tv_list_append_string(rettv->vval.v_list, (const char *)result, -1); + tv_list_append_string(rettv->vval.v_list, result, -1); } XFREE_CLEAR(result); } else { @@ -1805,8 +1805,7 @@ static void f_expand(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) ExpandOne(&xpc, (char *)s, NULL, options, WILD_ALL_KEEP); tv_list_alloc_ret(rettv, xpc.xp_numfiles); for (int i = 0; i < xpc.xp_numfiles; i++) { - tv_list_append_string(rettv->vval.v_list, - (const char *)xpc.xp_files[i], -1); + tv_list_append_string(rettv->vval.v_list, xpc.xp_files[i], -1); } ExpandCleanup(&xpc); } @@ -2134,7 +2133,7 @@ static void findfilendir(typval_T *argvars, typval_T *rettv, int find_what) first = false; if (fresult != NULL && rettv->v_type == VAR_LIST) { - tv_list_append_string(rettv->vval.v_list, (const char *)fresult, -1); + tv_list_append_string(rettv->vval.v_list, fresult, -1); } } while ((rettv->v_type == VAR_LIST || --count > 0) && fresult != NULL); } @@ -3008,8 +3007,7 @@ static void f_glob(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) WILD_ALL_KEEP); tv_list_alloc_ret(rettv, xpc.xp_numfiles); for (int i = 0; i < xpc.xp_numfiles; i++) { - tv_list_append_string(rettv->vval.v_list, (const char *)xpc.xp_files[i], - -1); + tv_list_append_string(rettv->vval.v_list, xpc.xp_files[i], -1); } ExpandCleanup(&xpc); } @@ -4050,7 +4048,7 @@ static dict_T *create_environment(const dictitem_T *job_env, const bool clear_en #ifdef MSWIN TV_DICT_ITER(job_env->di_tv.vval.v_dict, var, { // Always use upper-case keys for Windows so we detect duplicate keys - char *const key = strcase_save((const char *)var->di_key, true); + char *const key = strcase_save(var->di_key, true); size_t len = strlen(key); dictitem_T *dv = tv_dict_find(env, key, len); if (dv) { @@ -4735,8 +4733,7 @@ static void find_some_match(typval_T *const argvars, typval_T *const rettv, if (regmatch.endp[i] == NULL) { tv_list_append_string(rettv->vval.v_list, NULL, 0); } else { - tv_list_append_string(rettv->vval.v_list, - (const char *)regmatch.startp[i], + tv_list_append_string(rettv->vval.v_list, regmatch.startp[i], (regmatch.endp[i] - regmatch.startp[i])); } } @@ -4746,7 +4743,7 @@ static void find_some_match(typval_T *const argvars, typval_T *const rettv, if (l != NULL) { tv_copy(TV_LIST_ITEM_TV(li), rettv); } else { - rettv->vval.v_string = xmemdupz((const char *)regmatch.startp[0], + rettv->vval.v_string = xmemdupz(regmatch.startp[0], (size_t)(regmatch.endp[0] - regmatch.startp[0])); } @@ -7910,14 +7907,14 @@ static void f_split(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) } const char *end; if (match) { - end = (const char *)regmatch.startp[0]; + end = regmatch.startp[0]; } else { end = str + strlen(str); } if (keepempty || end > str || (tv_list_len(rettv->vval.v_list) > 0 && *str != NUL && match - && end < (const char *)regmatch.endp[0])) { + && end < regmatch.endp[0])) { tv_list_append_string(rettv->vval.v_list, str, end - str); } if (!match) { @@ -7930,7 +7927,7 @@ static void f_split(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) // Don't get stuck at the same match. col = utfc_ptr2len(regmatch.endp[0]); } - str = (const char *)regmatch.endp[0]; + str = regmatch.endp[0]; } vim_regfree(regmatch.regprog); diff --git a/src/nvim/eval/typval.c b/src/nvim/eval/typval.c index 8e5db64d6a..e027517108 100644 --- a/src/nvim/eval/typval.c +++ b/src/nvim/eval/typval.c @@ -1091,7 +1091,7 @@ static int item_compare2(const void *s1, const void *s2, bool keep_zero) if (partial == NULL) { func_name = sortinfo->item_compare_func; } else { - func_name = (const char *)partial_name(partial); + func_name = partial_name(partial); } // Copy the values. This is needed to be able to set v_lock to VAR_FIXED @@ -1189,7 +1189,7 @@ static void do_sort_uniq(typval_T *argvars, typval_T *rettv, bool sort) if (argvars[1].v_type != VAR_UNKNOWN) { // optional second argument: {func} if (argvars[1].v_type == VAR_FUNC) { - info.item_compare_func = (const char *)argvars[1].vval.v_string; + info.item_compare_func = argvars[1].vval.v_string; } else if (argvars[1].v_type == VAR_PARTIAL) { info.item_compare_partial = argvars[1].vval.v_partial; } else { @@ -1894,7 +1894,7 @@ void tv_dict_item_free(dictitem_T *const item) dictitem_T *tv_dict_item_copy(dictitem_T *const di) FUNC_ATTR_NONNULL_RET FUNC_ATTR_NONNULL_ALL FUNC_ATTR_WARN_UNUSED_RESULT { - dictitem_T *const new_di = tv_dict_item_alloc((const char *)di->di_key); + dictitem_T *const new_di = tv_dict_item_alloc(di->di_key); tv_copy(&di->di_tv, &new_di->di_tv); return new_di; } @@ -2240,7 +2240,7 @@ int tv_dict_wrong_func_name(dict_T *d, typval_T *tv, const char *name) int tv_dict_add(dict_T *const d, dictitem_T *const item) FUNC_ATTR_NONNULL_ALL { - if (tv_dict_wrong_func_name(d, &item->di_tv, (const char *)item->di_key)) { + if (tv_dict_wrong_func_name(d, &item->di_tv, item->di_key)) { return FAIL; } return hash_add(&d->dv_hashtab, (char *)item->di_key); @@ -2477,9 +2477,9 @@ void tv_dict_extend(dict_T *const d1, dict_T *const d2, const char *const action HASHTAB_ITER(&d2->dv_hashtab, hi2, { dictitem_T *const di2 = TV_DICT_HI2DI(hi2); - dictitem_T *const di1 = tv_dict_find(d1, (const char *)di2->di_key, -1); + dictitem_T *const di1 = tv_dict_find(d1, di2->di_key, -1); // Check the key to be valid when adding to any scope. - if (d1->dv_scope != VAR_NO_SCOPE && !valid_varname((const char *)di2->di_key)) { + if (d1->dv_scope != VAR_NO_SCOPE && !valid_varname(di2->di_key)) { break; } if (di1 == NULL) { @@ -2489,14 +2489,14 @@ void tv_dict_extend(dict_T *const d1, dict_T *const d2, const char *const action dictitem_T *const new_di = di2; if (tv_dict_add(d1, new_di) == OK) { hash_remove(&d2->dv_hashtab, hi2); - tv_dict_watcher_notify(d1, (const char *)new_di->di_key, &new_di->di_tv, NULL); + tv_dict_watcher_notify(d1, new_di->di_key, &new_di->di_tv, NULL); } } else { dictitem_T *const new_di = tv_dict_item_copy(di2); if (tv_dict_add(d1, new_di) == FAIL) { tv_dict_item_free(new_di); } else if (watched) { - tv_dict_watcher_notify(d1, (const char *)new_di->di_key, &new_di->di_tv, NULL); + tv_dict_watcher_notify(d1, new_di->di_key, &new_di->di_tv, NULL); } } } else if (*action == 'e') { @@ -2510,7 +2510,7 @@ void tv_dict_extend(dict_T *const d1, dict_T *const d2, const char *const action break; } // Disallow replacing a builtin function. - if (tv_dict_wrong_func_name(d1, &di2->di_tv, (const char *)di2->di_key)) { + if (tv_dict_wrong_func_name(d1, &di2->di_tv, di2->di_key)) { break; } @@ -2522,8 +2522,7 @@ void tv_dict_extend(dict_T *const d1, dict_T *const d2, const char *const action tv_copy(&di2->di_tv, &di1->di_tv); if (watched) { - tv_dict_watcher_notify(d1, (const char *)di1->di_key, &di1->di_tv, - &oldtv); + tv_dict_watcher_notify(d1, di1->di_key, &di1->di_tv, &oldtv); tv_clear(&oldtv); } } @@ -2558,7 +2557,7 @@ bool tv_dict_equal(dict_T *const d1, dict_T *const d2, const bool ic, const bool } TV_DICT_ITER(d1, di1, { - dictitem_T *const di2 = tv_dict_find(d2, (const char *)di1->di_key, -1); + dictitem_T *const di2 = tv_dict_find(d2, di1->di_key, -1); if (di2 == NULL) { return false; } @@ -2597,12 +2596,12 @@ dict_T *tv_dict_copy(const vimconv_T *const conv, dict_T *const orig, const bool } dictitem_T *new_di; if (conv == NULL || conv->vc_type == CONV_NONE) { - new_di = tv_dict_item_alloc((const char *)di->di_key); + new_di = tv_dict_item_alloc(di->di_key); } else { - size_t len = strlen((char *)di->di_key); - char *const key = (char *)string_convert(conv, (char *)di->di_key, &len); + size_t len = strlen(di->di_key); + char *const key = string_convert(conv, di->di_key, &len); if (key == NULL) { - new_di = tv_dict_item_alloc_len((const char *)di->di_key, len); + new_di = tv_dict_item_alloc_len(di->di_key, len); } else { new_di = tv_dict_item_alloc_len(key, len); xfree(key); @@ -2960,7 +2959,7 @@ static void tv_dict_list(typval_T *const tv, typval_T *const rettv, const DictLi tv_list_append_owned_tv(sub_l, (typval_T) { .v_type = VAR_STRING, .v_lock = VAR_UNLOCKED, - .vval.v_string = xstrdup((const char *)di->di_key), + .vval.v_string = xstrdup(di->di_key), }); tv_list_append_tv(sub_l, &di->di_tv); @@ -3132,7 +3131,7 @@ static inline int _nothing_conv_func_start(typval_T *const tv, char *const fun) } } else { func_unref(fun); - if ((const char *)fun != tv_empty_string) { + if (fun != tv_empty_string) { xfree(fun); } tv->vval.v_string = NULL; @@ -3805,7 +3804,7 @@ static const char *const str_errors[] = { [VAR_FUNC]= N_(FUNC_ERROR), [VAR_LIST]= N_("E730: using List as a String"), [VAR_DICT]= N_("E731: using Dictionary as a String"), - [VAR_FLOAT]= ((const char *)e_float_as_string), + [VAR_FLOAT]= e_float_as_string, [VAR_BLOB]= N_("E976: using Blob as a String"), [VAR_UNKNOWN]= N_("E908: using an invalid value as a String"), }; @@ -4116,7 +4115,7 @@ const char *tv_get_string_buf_chk(const typval_T *const tv, char *const buf) return buf; case VAR_STRING: if (tv->vval.v_string != NULL) { - return (const char *)tv->vval.v_string; + return tv->vval.v_string; } return ""; case VAR_BOOL: diff --git a/src/nvim/eval/userfunc.c b/src/nvim/eval/userfunc.c index 9f5d964075..99e8859ae9 100644 --- a/src/nvim/eval/userfunc.c +++ b/src/nvim/eval/userfunc.c @@ -1575,7 +1575,7 @@ int call_func(const char *funcname, int len, typval_T *rettv, int argcount_in, t XFREE_CLEAR(name); funcname = "v:lua"; } - } else if (fp != NULL || !builtin_function((const char *)rfname, -1)) { + } else if (fp != NULL || !builtin_function(rfname, -1)) { // User defined function. if (fp == NULL) { fp = find_func(rfname); @@ -1589,8 +1589,7 @@ int call_func(const char *funcname, int len, typval_T *rettv, int argcount_in, t fp = find_func(rfname); } // Try loading a package. - if (fp == NULL && script_autoload((const char *)rfname, strlen(rfname), - true) && !aborting()) { + if (fp == NULL && script_autoload(rfname, strlen(rfname), true) && !aborting()) { // Loaded a package, search for the function again. fp = find_func(rfname); } @@ -1666,7 +1665,7 @@ static void list_func_head(ufunc_T *fp, int indent, bool force) } msg_puts(force ? "function! " : "function "); if (fp->uf_name_exp != NULL) { - msg_puts((const char *)fp->uf_name_exp); + msg_puts(fp->uf_name_exp); } else { msg_puts(fp->uf_name); } @@ -1676,7 +1675,7 @@ static void list_func_head(ufunc_T *fp, int indent, bool force) if (j) { msg_puts(", "); } - msg_puts((const char *)FUNCARG(fp, j)); + msg_puts(FUNCARG(fp, j)); if (j >= fp->uf_args.ga_len - fp->uf_def_args.ga_len) { msg_puts(" = "); msg_puts(((char **)(fp->uf_def_args.ga_data)) @@ -1828,7 +1827,7 @@ char *trans_function_name(char **pp, bool skip, int flags, funcdict_T *fdp, part len = (int)strlen(lv.ll_exp_name); name = deref_func_name(lv.ll_exp_name, &len, partial, flags & TFN_NO_AUTOLOAD); - if ((const char *)name == lv.ll_exp_name) { + if (name == lv.ll_exp_name) { name = NULL; } } else if (!(flags & TFN_NO_DEREF)) { @@ -1881,8 +1880,7 @@ char *trans_function_name(char **pp, bool skip, int flags, funcdict_T *fdp, part lead = 0; // do nothing } else if (lead > 0) { lead = 3; - if ((lv.ll_exp_name != NULL && eval_fname_sid(lv.ll_exp_name)) - || eval_fname_sid((const char *)(*pp))) { + if ((lv.ll_exp_name != NULL && eval_fname_sid(lv.ll_exp_name)) || eval_fname_sid(*pp)) { // It's "s:" or "<SID>". if (current_sctx.sc_sid <= 0) { emsg(_(e_usingsid)); @@ -2209,7 +2207,7 @@ void ex_function(exarg_T *eap) if (KeyTyped && ui_has(kUICmdline)) { show_block = true; - ui_ext_cmdline_block_append(0, (const char *)eap->cmd); + ui_ext_cmdline_block_append(0, eap->cmd); } // find extra arguments "range", "dict", "abort" and "closure" @@ -2308,7 +2306,7 @@ void ex_function(exarg_T *eap) } if (show_block) { assert(indent >= 0); - ui_ext_cmdline_block_append((size_t)indent, (const char *)theline); + ui_ext_cmdline_block_append((size_t)indent, theline); } // Detect line continuation: SOURCING_LNUM increased more than one. @@ -2390,7 +2388,7 @@ void ex_function(exarg_T *eap) if (*p == '!') { p = skipwhite(p + 1); } - p += eval_fname_script((const char *)p); + p += eval_fname_script(p); xfree(trans_function_name(&p, true, 0, NULL, NULL)); if (*skipwhite(p) == '(') { if (nesting == MAX_FUNC_NESTING - 1) { @@ -2501,7 +2499,7 @@ void ex_function(exarg_T *eap) // If there are no errors, add the function if (fudi.fd_dict == NULL) { - v = find_var((const char *)name, strlen(name), &ht, false); + v = find_var(name, strlen(name), &ht, false); if (v != NULL && v->di_tv.v_type == VAR_FUNC) { emsg_funcname(N_("E707: Function name conflicts with variable: %s"), name); goto erret; @@ -2548,13 +2546,11 @@ void ex_function(exarg_T *eap) goto erret; } if (fudi.fd_di == NULL) { - if (value_check_lock(fudi.fd_dict->dv_lock, (const char *)eap->arg, - TV_CSTRING)) { + if (value_check_lock(fudi.fd_dict->dv_lock, eap->arg, TV_CSTRING)) { // Can't add a function to a locked dictionary goto erret; } - } else if (value_check_lock(fudi.fd_di->di_tv.v_lock, (const char *)eap->arg, - TV_CSTRING)) { + } else if (value_check_lock(fudi.fd_di->di_tv.v_lock, eap->arg, TV_CSTRING)) { // Can't change an existing function if it is locked goto erret; } @@ -2595,7 +2591,7 @@ void ex_function(exarg_T *eap) if (fudi.fd_dict != NULL) { if (fudi.fd_di == NULL) { // Add new dict entry - fudi.fd_di = tv_dict_item_alloc((const char *)fudi.fd_newkey); + fudi.fd_di = tv_dict_item_alloc(fudi.fd_newkey); if (tv_dict_add(fudi.fd_dict, fudi.fd_di) == FAIL) { xfree(fudi.fd_di); xfree(fp); diff --git a/src/nvim/eval/vars.c b/src/nvim/eval/vars.c index 43847cb986..e0f7af5718 100644 --- a/src/nvim/eval/vars.c +++ b/src/nvim/eval/vars.c @@ -215,7 +215,7 @@ static void ex_let_const(exarg_T *eap, const bool is_const) emsg(_(e_invarg)); } else if (!ends_excmd(*arg)) { // ":let var1 var2" - arg = (char *)list_arg_vars(eap, (const char *)arg, &first); + arg = (char *)list_arg_vars(eap, arg, &first); } else if (!eap->skip) { // ":let" list_glob_vars(&first); @@ -551,7 +551,7 @@ static const char *list_arg_vars(exarg_T *eap, const char *arg, int *first) xfree(tofree); } - arg = (const char *)skipwhite(arg); + arg = skipwhite(arg); } return arg; @@ -601,7 +601,7 @@ static char *ex_let_one(char *arg, typval_T *const tv, const bool copy, const bo char *s = vim_getenv(name); if (s != NULL) { tofree = concat_str(s, p); - p = (const char *)tofree; + p = tofree; xfree(s); } } @@ -725,7 +725,7 @@ static char *ex_let_one(char *arg, typval_T *const tv, const bool copy, const bo char *s = get_reg_contents(*arg == '@' ? '"' : *arg, kGRegExprSrc); if (s != NULL) { ptofree = concat_str(s, p); - p = (const char *)ptofree; + p = ptofree; xfree(s); } } @@ -798,7 +798,7 @@ static void ex_unletlock(exarg_T *eap, char *argstart, int deep, ex_unletlock_ca do { if (*arg == '$') { - lv.ll_name = (const char *)arg; + lv.ll_name = arg; lv.ll_tv = NULL; arg++; if (get_env_len((const char **)&arg) == 0) { @@ -1169,7 +1169,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, (const char *)v->di_key, (ptrdiff_t)strlen((char *)v->di_key), + list_one_var_a(prefix, v->di_key, (ptrdiff_t)strlen((char *)v->di_key), v->di_tv.v_type, (s == NULL ? "" : s), first); xfree(s); } diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c index ace254c2c9..a67a01bcea 100644 --- a/src/nvim/ex_cmds.c +++ b/src/nvim/ex_cmds.c @@ -1388,7 +1388,7 @@ char *make_filter_cmd(char *cmd, char *itmp, char *otmp) if (is_pwsh) { if (itmp != NULL) { xstrlcpy(buf, "& { Get-Content ", len - 1); // FIXME: should we add "-Encoding utf8"? - xstrlcat(buf, (const char *)itmp, len - 1); + xstrlcat(buf, itmp, len - 1); xstrlcat(buf, " | & ", len - 1); // FIXME: add `&` ourself or leave to user? xstrlcat(buf, cmd, len - 1); xstrlcat(buf, " }", len - 1); @@ -1409,7 +1409,7 @@ char *make_filter_cmd(char *cmd, char *itmp, char *otmp) if (itmp != NULL) { xstrlcat(buf, " < ", len - 1); - xstrlcat(buf, (const char *)itmp, len - 1); + xstrlcat(buf, itmp, len - 1); } #else // For shells that don't understand braces around commands, at least allow @@ -1426,9 +1426,9 @@ char *make_filter_cmd(char *cmd, char *itmp, char *otmp) } } xstrlcat(buf, " < ", len); - xstrlcat(buf, (const char *)itmp, len); + xstrlcat(buf, itmp, len); if (*p_shq == NUL) { - const char *const p = find_pipe((const char *)cmd); + const char *const p = find_pipe(cmd); if (p != NULL) { xstrlcat(buf, " ", len - 1); // Insert a space before the '|' for DOS xstrlcat(buf, p, len - 1); diff --git a/src/nvim/ex_cmds2.c b/src/nvim/ex_cmds2.c index a86676733f..6d190df939 100644 --- a/src/nvim/ex_cmds2.c +++ b/src/nvim/ex_cmds2.c @@ -814,7 +814,7 @@ static void script_host_do_range(char *name, exarg_T *eap) list_T *args = tv_list_alloc(3); tv_list_append_number(args, (int)eap->line1); tv_list_append_number(args, (int)eap->line2); - tv_list_append_string(args, (const char *)eap->arg, -1); + tv_list_append_string(args, eap->arg, -1); (void)eval_call_provider(name, "do_range", args, true); } } diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index bc8c7eead0..699c1da3a7 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -4452,7 +4452,7 @@ static void ex_highlight(exarg_T *eap) if (*eap->arg == NUL && eap->cmd[2] == '!') { msg(_("Greetings, Vim user!")); } - do_highlight((const char *)eap->arg, eap->forceit, false); + do_highlight(eap->arg, eap->forceit, false); } /// Call this function if we thought we were going to exit, but we won't @@ -5211,7 +5211,7 @@ void do_exedit(exarg_T *eap, win_T *old_curwin) int ms = msg_scroll; if (eap->nextcmd != NULL) { - stuffReadbuff((const char *)eap->nextcmd); + stuffReadbuff(eap->nextcmd); eap->nextcmd = NULL; } diff --git a/src/nvim/ex_eval.c b/src/nvim/ex_eval.c index 6fdd150571..fed8f549e6 100644 --- a/src/nvim/ex_eval.c +++ b/src/nvim/ex_eval.c @@ -1125,7 +1125,7 @@ void ex_endwhile(exarg_T *eap) /// Handle ":throw expr" void ex_throw(exarg_T *eap) { - const char *arg = (const char *)eap->arg; + const char *arg = eap->arg; char *value; if (*arg != NUL && *arg != '|' && *arg != '\n') { diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index cdbb41c8ae..4331de1d62 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -2947,7 +2947,7 @@ static void color_expr_cmdline(const CmdlineInfo *const colored_ccline, { ParserLine parser_lines[] = { { - .data = (const char *)colored_ccline->cmdbuff, + .data = colored_ccline->cmdbuff, .size = strlen(colored_ccline->cmdbuff), .allocated = false, }, @@ -3051,7 +3051,7 @@ static bool color_cmdline(CmdlineInfo *colored_ccline) bool can_free_cb = false; TryState tstate; Error err = ERROR_INIT; - const char *err_errmsg = (const char *)e_intern2; + const char *err_errmsg = e_intern2; bool dgc_ret = true; bool tl_ret = true; @@ -3084,8 +3084,7 @@ static bool color_cmdline(CmdlineInfo *colored_ccline) } if (colored_ccline->cmdbuff[colored_ccline->cmdlen] != NUL) { arg_allocated = true; - arg.vval.v_string = xmemdupz((const char *)colored_ccline->cmdbuff, - (size_t)colored_ccline->cmdlen); + arg.vval.v_string = xmemdupz(colored_ccline->cmdbuff, (size_t)colored_ccline->cmdlen); } // msg_start() called by e.g. :echo may shift command-line to the first column // even though msg_silent is here. Two ways to workaround this problem without @@ -3204,8 +3203,7 @@ color_cmdline_end: if (arg_allocated) { ccline_colors->cmdbuff = arg.vval.v_string; } else { - ccline_colors->cmdbuff = xmemdupz((const char *)colored_ccline->cmdbuff, - (size_t)colored_ccline->cmdlen); + ccline_colors->cmdbuff = xmemdupz(colored_ccline->cmdbuff, (size_t)colored_ccline->cmdlen); } tv_clear(&tv); return ret; @@ -4558,7 +4556,7 @@ bool is_in_cmdwin(void) char *script_get(exarg_T *const eap, size_t *const lenp) FUNC_ATTR_NONNULL_ALL FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_MALLOC { - const char *const cmd = (const char *)eap->arg; + const char *const cmd = eap->arg; if (cmd[0] != '<' || cmd[1] != '<' || eap->getline == NULL) { *lenp = strlen(eap->arg); @@ -4570,7 +4568,7 @@ char *script_get(exarg_T *const eap, size_t *const lenp) ga_init(&ga, 1, 0x400); } - const char *const end_pattern = (cmd[2] != NUL ? (const char *)skipwhite(cmd + 2) : "."); + const char *const end_pattern = (cmd[2] != NUL ? skipwhite(cmd + 2) : "."); for (;;) { char *const theline = eap->getline(eap->cstack->cs_looplevel > 0 ? -1 : NUL, eap->cookie, 0, true); diff --git a/src/nvim/file_search.c b/src/nvim/file_search.c index 2e9442e704..6782c0211b 100644 --- a/src/nvim/file_search.c +++ b/src/nvim/file_search.c @@ -1341,7 +1341,7 @@ char *find_file_in_path_option(char *ptr, size_t len, int options, int first, ch char *buf = NULL; int rel_to_curdir; - if (rel_fname != NULL && path_with_url((const char *)rel_fname)) { + if (rel_fname != NULL && path_with_url(rel_fname)) { // Do not attempt to search "relative" to a URL. #6009 rel_fname = NULL; } diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c index d76b22f65c..143ec988c9 100644 --- a/src/nvim/fileio.c +++ b/src/nvim/fileio.c @@ -145,7 +145,7 @@ void filemess(buf_T *buf, char *name, char *s, int attr) if (msg_silent != 0) { return; } - add_quoted_fname(IObuff, IOSIZE - 100, buf, (const char *)name); + add_quoted_fname(IObuff, IOSIZE - 100, buf, name); // Avoid an over-long translation to cause trouble. xstrlcat(IObuff, s, IOSIZE); // For the first message may have to start a new line. @@ -576,7 +576,7 @@ int readfile(char *fname, char *sfname, linenr_T from, linenr_T lines_to_skip, // Set swap file protection bits after creating it. if (swap_mode > 0 && curbuf->b_ml.ml_mfp != NULL && curbuf->b_ml.ml_mfp->mf_fname != NULL) { - const char *swap_fname = (const char *)curbuf->b_ml.ml_mfp->mf_fname; + const char *swap_fname = curbuf->b_ml.ml_mfp->mf_fname; // If the group-read bit is set but not the world-read bit, then // the group must be equal to the group of the original file. If @@ -1732,7 +1732,7 @@ failed: } if (!filtering && !(flags & READ_DUMMY) && !silent) { - add_quoted_fname(IObuff, IOSIZE, curbuf, (const char *)sfname); + add_quoted_fname(IObuff, IOSIZE, curbuf, sfname); c = false; #ifdef UNIX @@ -2372,7 +2372,7 @@ static int get_fileinfo_os(char *fname, FileInfo *file_info_old, bool overwritin *newfile = true; *perm = -1; } else { - *perm = os_getperm((const char *)fname); + *perm = os_getperm(fname); if (*perm < 0) { *newfile = true; } else if (os_isdir(fname)) { @@ -2611,7 +2611,7 @@ static int buf_write_make_backup(char *fname, bool append, FileInfo *file_info_o // set file protection same as original file, but // strip s-bit. - (void)os_setperm((const char *)(*backupp), perm & 0777); + (void)os_setperm(*backupp, perm & 0777); #ifdef UNIX // @@ -2621,8 +2621,7 @@ static int buf_write_make_backup(char *fname, bool append, FileInfo *file_info_o // if (file_info_new.stat.st_gid != file_info_old->stat.st_gid && os_chown(*backupp, (uv_uid_t)-1, (uv_gid_t)file_info_old->stat.st_gid) != 0) { - os_setperm((const char *)(*backupp), - ((int)perm & 0707) | (((int)perm & 07) << 3)); + os_setperm(*backupp, ((int)perm & 0707) | (((int)perm & 07) << 3)); } #endif @@ -2960,7 +2959,7 @@ int buf_write(buf_T *buf, char *fname, char *sfname, linenr_T start, linenr_T en && file_info_old.stat.st_uid == getuid() && vim_strchr(p_cpo, CPO_FWRITE) == NULL) { perm |= 0200; - (void)os_setperm((const char *)fname, (int)perm); + (void)os_setperm(fname, (int)perm); made_writable = true; } #endif @@ -3378,7 +3377,7 @@ restore_backup: } #endif if (perm >= 0) { // Set perm. of new file same as old file. - (void)os_setperm((const char *)wfname, (int)perm); + (void)os_setperm(wfname, (int)perm); } // Probably need to set the ACL before changing the user (can't set the // ACL on a file the user doesn't own). @@ -3459,7 +3458,7 @@ restore_backup: fname = sfname; // use shortname now, for the messages #endif if (!filtering) { - add_quoted_fname(IObuff, IOSIZE, buf, (const char *)fname); + add_quoted_fname(IObuff, IOSIZE, buf, fname); bool insert_space = false; if (write_info.bw_conv_error) { STRCAT(IObuff, _(" CONVERSION ERROR")); @@ -3563,7 +3562,7 @@ restore_backup: } } if (org != NULL) { - os_setperm(org, os_getperm((const char *)fname) & 0777); + os_setperm(org, os_getperm(fname) & 0777); xfree(org); } } @@ -3600,9 +3599,9 @@ nofail: if (err.msg != NULL) { // - 100 to save some space for further error message #ifndef UNIX - add_quoted_fname(IObuff, IOSIZE - 100, buf, (const char *)sfname); + add_quoted_fname(IObuff, IOSIZE - 100, buf, sfname); #else - add_quoted_fname(IObuff, IOSIZE - 100, buf, (const char *)fname); + add_quoted_fname(IObuff, IOSIZE - 100, buf, fname); #endif emit_err(&err); @@ -5295,7 +5294,7 @@ int delete_recursive(const char *name) if (readdir_core(&ga, exp, NULL, NULL) == OK) { for (int i = 0; i < ga.ga_len; i++) { vim_snprintf(NameBuff, MAXPATHL, "%s/%s", exp, ((char **)ga.ga_data)[i]); - if (delete_recursive((const char *)NameBuff) != 0) { + if (delete_recursive(NameBuff) != 0) { // Remember the failure but continue deleting any further // entries. result = -1; diff --git a/src/nvim/fold.c b/src/nvim/fold.c index 2b33f00c67..71984e806d 100644 --- a/src/nvim/fold.c +++ b/src/nvim/fold.c @@ -1786,7 +1786,7 @@ char *get_foldtext(win_T *wp, linenr_T lnum, linenr_T lnume, foldinfo_T foldinfo } } if (*p != NUL) { - p = transstr((const char *)text, true); + p = transstr(text, true); xfree(text); text = p; } diff --git a/src/nvim/help.c b/src/nvim/help.c index 728c890da4..10e9ecf281 100644 --- a/src/nvim/help.c +++ b/src/nvim/help.c @@ -976,7 +976,7 @@ static void helptags_one(char *dir, const char *ext, const char *tagfname, bool } p1 = vim_strchr(IObuff, '*'); // find first '*' while (p1 != NULL) { - p2 = strchr((const char *)p1 + 1, '*'); // Find second '*'. + p2 = strchr(p1 + 1, '*'); // Find second '*'. if (p2 != NULL && p2 > p1 + 1) { // Skip "*" and "**". for (s = p1 + 1; s < p2; s++) { if (*s == ' ' || *s == '\t' || *s == '|') { diff --git a/src/nvim/highlight_group.c b/src/nvim/highlight_group.c index bc0f783095..0acf1989c3 100644 --- a/src/nvim/highlight_group.c +++ b/src/nvim/highlight_group.c @@ -895,15 +895,15 @@ void do_highlight(const char *line, const bool forceit, const bool init) bool dodefault = false; // Isolate the name. - const char *name_end = (const char *)skiptowhite(line); - const char *linep = (const char *)skipwhite(name_end); + const char *name_end = skiptowhite(line); + const char *linep = skipwhite(name_end); // Check for "default" argument. if (strncmp(line, "default", (size_t)(name_end - line)) == 0) { dodefault = true; line = linep; - name_end = (const char *)skiptowhite(line); - linep = (const char *)skipwhite(name_end); + name_end = skiptowhite(line); + linep = skipwhite(name_end); } bool doclear = false; @@ -937,9 +937,9 @@ void do_highlight(const char *line, const bool forceit, const bool init) int to_id; HlGroup *hlgroup = NULL; - from_end = (const char *)skiptowhite(from_start); - to_start = (const char *)skipwhite(from_end); - to_end = (const char *)skiptowhite(to_start); + from_end = skiptowhite(from_start); + to_start = skipwhite(from_end); + to_end = skiptowhite(to_start); if (ends_excmd((uint8_t)(*from_start)) || ends_excmd((uint8_t)(*to_start))) { @@ -1015,8 +1015,8 @@ void do_highlight(const char *line, const bool forceit, const bool init) redraw_all_later(UPD_NOT_VALID); return; } - name_end = (const char *)skiptowhite(line); - linep = (const char *)skipwhite(name_end); + name_end = skiptowhite(line); + linep = skipwhite(name_end); } // Find the group name in the table. If it does not exist yet, add it. @@ -1073,7 +1073,7 @@ void do_highlight(const char *line, const bool forceit, const bool init) memcpy(key, key_start, key_len); key[key_len] = NUL; vim_strup(key); - linep = (const char *)skipwhite(linep); + linep = skipwhite(linep); if (strcmp(key, "NONE") == 0) { if (!init || hl_table[idx].sg_set == 0) { @@ -1094,7 +1094,7 @@ void do_highlight(const char *line, const bool forceit, const bool init) linep++; // Isolate the argument. - linep = (const char *)skipwhite(linep); + linep = skipwhite(linep); if (*linep == '\'') { // guifg='color name' arg_start = ++linep; linep = strchr(linep, '\''); @@ -1105,7 +1105,7 @@ void do_highlight(const char *line, const bool forceit, const bool init) } } else { arg_start = linep; - linep = (const char *)skiptowhite(linep); + linep = skiptowhite(linep); } if (linep == arg_start) { semsg(_("E417: missing argument: %s"), key_start); @@ -1361,7 +1361,7 @@ void do_highlight(const char *line, const bool forceit, const bool init) } // Continue with next argument. - linep = (const char *)skipwhite(linep); + linep = skipwhite(linep); } } @@ -2211,7 +2211,7 @@ void set_context_in_highlight_cmd(expand_T *xp, const char *arg) } // (part of) subcommand already typed - const char *p = (const char *)skiptowhite(arg); + const char *p = skiptowhite(arg); if (*p == NUL) { return; } @@ -2219,9 +2219,9 @@ void set_context_in_highlight_cmd(expand_T *xp, const char *arg) // past "default" or group name include_default = 0; if (strncmp("default", arg, (unsigned)(p - arg)) == 0) { - arg = (const char *)skipwhite(p); + arg = skipwhite(p); xp->xp_pattern = (char *)arg; - p = (const char *)skiptowhite(arg); + p = skiptowhite(arg); } if (*p == NUL) { return; @@ -2235,10 +2235,10 @@ void set_context_in_highlight_cmd(expand_T *xp, const char *arg) if (strncmp("link", arg, (unsigned)(p - arg)) == 0 || strncmp("clear", arg, (unsigned)(p - arg)) == 0) { xp->xp_pattern = skipwhite(p); - p = (const char *)skiptowhite(xp->xp_pattern); + p = skiptowhite(xp->xp_pattern); if (*p != NUL) { // past first group name xp->xp_pattern = skipwhite(p); - p = (const char *)skiptowhite(xp->xp_pattern); + p = skiptowhite(xp->xp_pattern); } } if (*p != NUL) { // past group name(s) @@ -2301,7 +2301,7 @@ const char *get_highlight_name_ext(expand_T *xp, int idx, bool skip_cleared) } else if (idx >= highlight_ga.ga_len) { return NULL; } - return (const char *)hl_table[idx].sg_name; + return hl_table[idx].sg_name; } color_name_table_T color_name_table[] = { diff --git a/src/nvim/insexpand.c b/src/nvim/insexpand.c index 78f400b39d..122c8393d7 100644 --- a/src/nvim/insexpand.c +++ b/src/nvim/insexpand.c @@ -1414,7 +1414,7 @@ static int thesaurus_add_words_in_line(char *fname, char **buf_arg, int dir, con // different classes, only separate words // with single-byte non-word characters. while (*ptr != NUL) { - const int l = utfc_ptr2len((const char *)ptr); + const int l = utfc_ptr2len(ptr); if (l < 2 && !vim_iswordc((uint8_t)(*ptr))) { break; @@ -2515,7 +2515,7 @@ static void ins_compl_add_dict(dict_T *dict) compl_opt_refresh_always = false; di_refresh = tv_dict_find(dict, S_LEN("refresh")); if (di_refresh != NULL && di_refresh->di_tv.v_type == VAR_STRING) { - const char *v = (const char *)di_refresh->di_tv.vval.v_string; + const char *v = di_refresh->di_tv.vval.v_string; if (v != NULL && strcmp(v, "always") == 0) { compl_opt_refresh_always = true; @@ -4301,7 +4301,7 @@ static void ins_compl_show_statusmsg(void) if (edit_submode_extra != NULL) { if (!p_smd) { msg_hist_off = true; - msg_attr((const char *)edit_submode_extra, + msg_attr(edit_submode_extra, (edit_submode_highl < HLF_COUNT ? HL_ATTR(edit_submode_highl) : 0)); msg_hist_off = false; diff --git a/src/nvim/lua/converter.c b/src/nvim/lua/converter.c index 6160b84485..9ff03bc67d 100644 --- a/src/nvim/lua/converter.c +++ b/src/nvim/lua/converter.c @@ -459,7 +459,7 @@ static bool typval_conv_special = false; TYPVAL_ENCODE_CONV_NUMBER(tv, flt) #define TYPVAL_ENCODE_CONV_STRING(tv, str, len) \ - lua_pushlstring(lstate, (const char *)(str), (len)) + lua_pushlstring(lstate, (str), (len)) #define TYPVAL_ENCODE_CONV_STR_STRING TYPVAL_ENCODE_CONV_STRING @@ -469,9 +469,7 @@ static bool typval_conv_special = false; #define TYPVAL_ENCODE_CONV_BLOB(tv, blob, len) \ do { \ const blob_T *const blob_ = (blob); \ - lua_pushlstring(lstate, \ - blob_ != NULL ? (const char *)blob_->bv_ga.ga_data : "", \ - (size_t)(len)); \ + lua_pushlstring(lstate, blob_ != NULL ? blob_->bv_ga.ga_data : "", (size_t)(len)); \ } while (0) #define TYPVAL_ENCODE_CONV_FUNC_START(tv, fun) \ diff --git a/src/nvim/lua/executor.c b/src/nvim/lua/executor.c index b5dd7a3e78..82db8445df 100644 --- a/src/nvim/lua/executor.c +++ b/src/nvim/lua/executor.c @@ -1105,7 +1105,7 @@ static int nlua_debug(lua_State *lstate) tv_clear(&input); return 0; } - if (luaL_loadbuffer(lstate, (const char *)input.vval.v_string, + if (luaL_loadbuffer(lstate, input.vval.v_string, strlen(input.vval.v_string), "=(debug command)")) { nlua_error(lstate, _("E5115: Error while loading debug string: %.*s")); } else if (nlua_pcall(lstate, 0, 0)) { @@ -1652,7 +1652,7 @@ void ex_luado(exarg_T *const eap) emsg(_("cannot save undo information")); return; } - const char *const cmd = (const char *)eap->arg; + const char *const cmd = eap->arg; const size_t cmd_len = strlen(cmd); lua_State *const lstate = global_lstate; @@ -1693,7 +1693,7 @@ void ex_luado(exarg_T *const eap) break; } lua_pushvalue(lstate, -1); - const char *const old_line = (const char *)ml_get_buf(curbuf, l, false); + const char *const old_line = ml_get_buf(curbuf, l, false); // Get length of old_line here as calling Lua code may free it. const size_t old_line_len = strlen(old_line); lua_pushstring(lstate, old_line); @@ -1729,7 +1729,7 @@ void ex_luado(exarg_T *const eap) void ex_luafile(exarg_T *const eap) FUNC_ATTR_NONNULL_ALL { - nlua_exec_file((const char *)eap->arg); + nlua_exec_file(eap->arg); } /// Executes Lua code from a file or "-" (stdin). @@ -1860,7 +1860,7 @@ int nlua_expand_pat(expand_T *xp, char *pat, int *num_results, char ***results) luaL_checktype(lstate, -1, LUA_TFUNCTION); // [ vim, vim._expand_pat, buf ] - lua_pushlstring(lstate, (const char *)pat, strlen(pat)); + lua_pushlstring(lstate, pat, strlen(pat)); if (nlua_pcall(lstate, 1, 2) != 0) { nlua_error(lstate, @@ -2092,7 +2092,7 @@ int nlua_do_ucmd(ucmd_T *cmd, exarg_T *eap, bool preview) lua_setfield(lstate, -2, "line2"); lua_newtable(lstate); // f-args table - lua_pushstring(lstate, (const char *)eap->arg); + lua_pushstring(lstate, eap->arg); lua_pushvalue(lstate, -1); // Reference for potential use on f-args lua_setfield(lstate, -4, "args"); diff --git a/src/nvim/mapping.c b/src/nvim/mapping.c index 2941d5965b..1887afef1c 100644 --- a/src/nvim/mapping.c +++ b/src/nvim/mapping.c @@ -1501,7 +1501,7 @@ bool check_abbr(int c, char *ptr, int col, int mincol) char *q = mp->m_keys; int match; - if (strchr((const char *)mp->m_keys, K_SPECIAL) != NULL) { + if (strchr(mp->m_keys, K_SPECIAL) != NULL) { // Might have K_SPECIAL escaped mp->m_keys. q = xstrdup(mp->m_keys); vim_unescape_ks(q); @@ -1811,8 +1811,7 @@ int makemap(FILE *fd, buf_T *buf) did_cpo = true; } else { const char specials[] = { (char)(uint8_t)K_SPECIAL, NL, NUL }; - if (strpbrk((const char *)mp->m_str, specials) != NULL - || strpbrk((const char *)mp->m_keys, specials) != NULL) { + if (strpbrk(mp->m_str, specials) != NULL || strpbrk(mp->m_keys, specials) != NULL) { did_cpo = true; } } @@ -2091,7 +2090,7 @@ static Dictionary mapblock_fill_dict(const mapblock_T *const mp, const char *lhs PUT(dict, "desc", STRING_OBJ(cstr_to_string(mp->m_desc))); } PUT(dict, "lhs", STRING_OBJ(cstr_as_string(lhs))); - PUT(dict, "lhsraw", STRING_OBJ(cstr_to_string((const char *)mp->m_keys))); + PUT(dict, "lhsraw", STRING_OBJ(cstr_to_string(mp->m_keys))); if (lhsrawalt != NULL) { // Also add the value for the simplified entry. PUT(dict, "lhsrawalt", STRING_OBJ(cstr_to_string(lhsrawalt))); diff --git a/src/nvim/match.c b/src/nvim/match.c index ccce78e59d..31a628bbff 100644 --- a/src/nvim/match.c +++ b/src/nvim/match.c @@ -938,10 +938,9 @@ void f_getmatches(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) tv_dict_add_list(dict, buf, (size_t)len, l); } } else { - tv_dict_add_str(dict, S_LEN("pattern"), (const char *)cur->mit_pattern); + tv_dict_add_str(dict, S_LEN("pattern"), cur->mit_pattern); } - tv_dict_add_str(dict, S_LEN("group"), - (const char *)syn_id2name(cur->mit_hlg_id)); + tv_dict_add_str(dict, S_LEN("group"), syn_id2name(cur->mit_hlg_id)); tv_dict_add_nr(dict, S_LEN("priority"), (varnumber_T)cur->mit_priority); tv_dict_add_nr(dict, S_LEN("id"), (varnumber_T)cur->mit_id); @@ -1166,9 +1165,8 @@ void f_matcharg(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) matchitem_T *const m = get_match(curwin, id); if (m != NULL) { - tv_list_append_string(rettv->vval.v_list, - (const char *)syn_id2name(m->mit_hlg_id), -1); - tv_list_append_string(rettv->vval.v_list, (const char *)m->mit_pattern, -1); + tv_list_append_string(rettv->vval.v_list, syn_id2name(m->mit_hlg_id), -1); + tv_list_append_string(rettv->vval.v_list, m->mit_pattern, -1); } else { tv_list_append_string(rettv->vval.v_list, NULL, 0); tv_list_append_string(rettv->vval.v_list, NULL, 0); diff --git a/src/nvim/memline.c b/src/nvim/memline.c index 51a4186775..1e2500fb53 100644 --- a/src/nvim/memline.c +++ b/src/nvim/memline.c @@ -1351,7 +1351,7 @@ int recover_names(char *fname, int list, int nr, char **fname_out) // print the swap file name msg_outnum((long)++file_count); msg_puts(". "); - msg_puts((const char *)path_tail(files[i])); + msg_puts(path_tail(files[i])); msg_putchar('\n'); (void)swapfile_info(files[i]); } @@ -1508,7 +1508,7 @@ static time_t swapfile_info(char *fname) if (char_to_long(b0.b0_pid) != 0L) { msg_puts(_("\n process ID: ")); msg_outnum(char_to_long(b0.b0_pid)); - if (swapfile_process_running(&b0, (const char *)fname)) { + if (swapfile_process_running(&b0, fname)) { msg_puts(_(" (STILL RUNNING)")); process_still_running = true; } diff --git a/src/nvim/message.c b/src/nvim/message.c index 6524ae708e..f78980c859 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -1537,7 +1537,7 @@ const char *msg_outtrans_one(const char *p, int attr) msg_outtrans_len_attr(p, l, attr); return p + l; } - msg_puts_attr((const char *)transchar_byte_buf(NULL, (uint8_t)(*p)), attr); + msg_puts_attr(transchar_byte_buf(NULL, (uint8_t)(*p)), attr); return p + 1; } @@ -1582,8 +1582,7 @@ int msg_outtrans_len_attr(const char *msgstr, int len, int attr) msg_puts_attr_len(plain_start, str - plain_start, attr); } plain_start = str + mb_l; - msg_puts_attr((const char *)transchar_buf(NULL, c), - (attr == 0 ? HL_ATTR(HLF_8) : attr)); + msg_puts_attr(transchar_buf(NULL, c), attr == 0 ? HL_ATTR(HLF_8) : attr); retval += char2cells(c); } len -= mb_l - 1; @@ -1777,7 +1776,7 @@ const char *str2special(const char **const sp, const bool replace_spaces, const || c < ' ' || (replace_spaces && c == ' ') || (replace_lt && c == '<')) { - return (const char *)get_special_key_name(c, modifiers); + return get_special_key_name(c, modifiers); } buf[0] = (char)c; buf[1] = NUL; diff --git a/src/nvim/normal.c b/src/nvim/normal.c index 66c24fb444..b11d5a3c32 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -668,7 +668,7 @@ static void normal_redraw_mode_message(NormalState *s) keep_msg = kmsg; kmsg = xstrdup(keep_msg); - msg_attr((const char *)kmsg, keep_msg_attr); + msg_attr(kmsg, keep_msg_attr); xfree(kmsg); } setcursor(); @@ -1336,7 +1336,7 @@ static void normal_redraw(NormalState *s) // check for duplicates. Never put this message in // history. msg_hist_off = true; - msg_attr((const char *)p, keep_msg_attr); + msg_attr(p, keep_msg_attr); msg_hist_off = false; xfree(p); } @@ -3512,7 +3512,7 @@ static void nv_ident(cmdarg_T *cap) ptr = xstrnsave(ptr, n); if (kp_ex) { // Escape the argument properly for an Ex command - p = vim_strsave_fnameescape((const char *)ptr, VSE_NONE); + p = vim_strsave_fnameescape(ptr, VSE_NONE); } else { // Escape the argument properly for a shell command p = vim_strsave_shellescape(ptr, true, true); @@ -5334,7 +5334,7 @@ static void nv_g_dollar_cmd(cmdarg_T *cap) coladvance((colnr_T)i); // if the character doesn't fit move one back - if (curwin->w_cursor.col > 0 && utf_ptr2cells((const char *)get_cursor_pos_ptr()) > 1) { + if (curwin->w_cursor.col > 0 && utf_ptr2cells(get_cursor_pos_ptr()) > 1) { colnr_T vcol; getvvcol(curwin, &curwin->w_cursor, NULL, NULL, &vcol); diff --git a/src/nvim/ops.c b/src/nvim/ops.c index c6564e427e..9aacfcad30 100644 --- a/src/nvim/ops.c +++ b/src/nvim/ops.c @@ -926,7 +926,7 @@ int do_record(int c) if (p != NULL) { // Remove escaping for K_SPECIAL in multi-byte chars. vim_unescape_ks(p); - (void)tv_dict_add_str(dict, S_LEN("regcontents"), (const char *)p); + (void)tv_dict_add_str(dict, S_LEN("regcontents"), p); } // Name of requested register, or empty string for unnamed operation. @@ -1273,7 +1273,7 @@ int insert_reg(int regname, bool literally_arg) if (arg == NULL) { return FAIL; } - stuffescaped((const char *)arg, literally); + stuffescaped(arg, literally); if (allocated) { xfree(arg); } @@ -1288,7 +1288,7 @@ int insert_reg(int regname, bool literally_arg) AppendCharToRedobuff(regname); do_put(regname, NULL, BACKWARD, 1L, PUT_CURSEND); } else { - stuffescaped((const char *)reg->y_array[i], literally); + stuffescaped(reg->y_array[i], literally); } // Insert a newline between lines and after last line if // y_type is kMTLineWise. @@ -2867,7 +2867,7 @@ static void do_autocmd_textyankpost(oparg_T *oap, yankreg_T *reg) // The yanked text contents. list_T *const list = tv_list_alloc((ptrdiff_t)reg->y_size); for (size_t i = 0; i < reg->y_size; i++) { - tv_list_append_string(list, (const char *)reg->y_array[i], -1); + tv_list_append_string(list, reg->y_array[i], -1); } tv_list_set_lock(list, VAR_FIXED); (void)tv_dict_add_list(dict, S_LEN("regcontents"), list); @@ -4963,7 +4963,7 @@ void *get_reg_contents(int regname, int flags) if (flags & kGRegList) { list_T *const list = tv_list_alloc((ptrdiff_t)reg->y_size); for (size_t i = 0; i < reg->y_size; i++) { - tv_list_append_string(list, (const char *)reg->y_array[i], -1); + tv_list_append_string(list, reg->y_array[i], -1); } return list; @@ -5608,13 +5608,13 @@ static void op_colon(oparg_T *oap) stuffReadbuff("!"); } if (oap->op_type == OP_INDENT) { - stuffReadbuff((const char *)get_equalprg()); + stuffReadbuff(get_equalprg()); stuffReadbuff("\n"); } else if (oap->op_type == OP_FORMAT) { if (*curbuf->b_p_fp != NUL) { - stuffReadbuff((const char *)curbuf->b_p_fp); + stuffReadbuff(curbuf->b_p_fp); } else if (*p_fp != NUL) { - stuffReadbuff((const char *)p_fp); + stuffReadbuff(p_fp); } else { stuffReadbuff("fmt"); } @@ -6639,7 +6639,7 @@ static bool get_clipboard(int name, yankreg_T **target, bool quiet) if (TV_LIST_ITEM_TV(li)->v_type != VAR_STRING) { goto err; } - reg->y_array[tv_idx++] = xstrdupnul((const char *)TV_LIST_ITEM_TV(li)->vval.v_string); + reg->y_array[tv_idx++] = xstrdupnul(TV_LIST_ITEM_TV(li)->vval.v_string); }); if (reg->y_size > 0 && strlen(reg->y_array[reg->y_size - 1]) == 0) { @@ -6700,7 +6700,7 @@ static void set_clipboard(int name, yankreg_T *reg) list_T *const lines = tv_list_alloc((ptrdiff_t)reg->y_size + (reg->y_type != kMTCharWise)); for (size_t i = 0; i < reg->y_size; i++) { - tv_list_append_string(lines, (const char *)reg->y_array[i], -1); + tv_list_append_string(lines, reg->y_array[i], -1); } char regtype; @@ -6910,7 +6910,7 @@ bcount_t get_region_bytecount(buf_T *buf, linenr_T start_lnum, linenr_T end_lnum if (start_lnum == end_lnum) { return end_col - start_col; } - const char *first = (const char *)ml_get_buf(buf, start_lnum, false); + const char *first = ml_get_buf(buf, start_lnum, false); bcount_t deleted_bytes = (bcount_t)strlen(first) - start_col + 1; for (linenr_T i = 1; i <= end_lnum - start_lnum - 1; i++) { diff --git a/src/nvim/option.c b/src/nvim/option.c index a5170715d6..f266dd8c4e 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -1235,7 +1235,7 @@ static int parse_option_name(char *arg, int *keyp, int *lenp, int *opt_idxp) return FAIL; } if (arg[1] == 't' && arg[2] == '_') { // could be term code - opt_idx = findoption_len((const char *)arg + 1, (size_t)(len - 1)); + opt_idx = findoption_len(arg + 1, (size_t)(len - 1)); } len++; if (opt_idx == -1) { @@ -1251,7 +1251,7 @@ static int parse_option_name(char *arg, int *keyp, int *lenp, int *opt_idxp) len++; } } - opt_idx = findoption_len((const char *)arg, (size_t)len); + opt_idx = findoption_len(arg, (size_t)len); if (opt_idx == -1) { key = find_key_option(arg, false); } @@ -1869,7 +1869,7 @@ void check_blending(win_T *wp) /// Handle setting `winhighlight' in window "wp" bool parse_winhl_opt(win_T *wp) { - const char *p = (const char *)wp->w_p_winhl; + const char *p = wp->w_p_winhl; if (!*p) { if (wp->w_ns_hl_winhl && wp->w_ns_hl == wp->w_ns_hl_winhl) { @@ -4694,7 +4694,7 @@ void set_context_in_set_cmd(expand_T *xp, char *arg, int opt_flags) return; } nextchar = *p; - opt_idx = findoption_len((const char *)arg, (size_t)(p - arg)); + opt_idx = findoption_len(arg, (size_t)(p - arg)); if (opt_idx == -1 || options[opt_idx].var == NULL) { xp->xp_context = EXPAND_NOTHING; return; @@ -5509,7 +5509,7 @@ int win_signcol_count(win_T *wp) /// Return the number of requested sign columns, based on user / configuration. int win_signcol_configured(win_T *wp, int *is_fixed) { - const char *scl = (const char *)wp->w_p_scl; + const char *scl = wp->w_p_scl; if (is_fixed) { *is_fixed = 1; @@ -5607,7 +5607,7 @@ long get_sidescrolloff_value(win_T *wp) Dictionary get_vimoption(String name, int scope, buf_T *buf, win_T *win, Error *err) { - int opt_idx = findoption_len((const char *)name.data, name.size); + int opt_idx = findoption_len(name.data, name.size); VALIDATE_S(opt_idx >= 0, "option (not found)", name.data, { return (Dictionary)ARRAY_DICT_INIT; }); diff --git a/src/nvim/os/env.c b/src/nvim/os/env.c index b167bf02fd..0b06877f3c 100644 --- a/src/nvim/os/env.c +++ b/src/nvim/os/env.c @@ -845,7 +845,7 @@ const void *vim_env_iter(const char delim, const char *const val, const void *co const char **const dir, size_t *const len) FUNC_ATTR_NONNULL_ARG(2, 4, 5) FUNC_ATTR_WARN_UNUSED_RESULT { - const char *varval = (const char *)iter; + const char *varval = iter; if (varval == NULL) { varval = val; } @@ -876,7 +876,7 @@ const void *vim_env_iter_rev(const char delim, const char *const val, const void const char **const dir, size_t *const len) FUNC_ATTR_NONNULL_ARG(2, 4, 5) FUNC_ATTR_WARN_UNUSED_RESULT { - const char *varend = (const char *)iter; + const char *varend = iter; if (varend == NULL) { varend = val + strlen(val) - 1; } diff --git a/src/nvim/os/shell.c b/src/nvim/os/shell.c index e990db3296..41b176eb41 100644 --- a/src/nvim/os/shell.c +++ b/src/nvim/os/shell.c @@ -1180,7 +1180,7 @@ static size_t tokenize(const char *const str, char **const argv) } argc++; - p = (const char *)skipwhite((p + len)); + p = skipwhite((p + len)); } return argc; diff --git a/src/nvim/path.c b/src/nvim/path.c index 973e5eaec4..e68a06821a 100644 --- a/src/nvim/path.c +++ b/src/nvim/path.c @@ -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((const char *)path); + char *dir_end = (char *)gettail_dir(path); char *pathsep_p; char *path_cutoff; diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c index c17a6366fe..8d9dc4e9c8 100644 --- a/src/nvim/quickfix.c +++ b/src/nvim/quickfix.c @@ -5795,28 +5795,19 @@ static int get_qfline_items(qfline_T *qfp, list_T *list) buf[0] = qfp->qf_type; buf[1] = NUL; if (tv_dict_add_nr(dict, S_LEN("bufnr"), (varnumber_T)bufnum) == FAIL - || (tv_dict_add_nr(dict, S_LEN("lnum"), (varnumber_T)qfp->qf_lnum) - == FAIL) - || (tv_dict_add_nr(dict, S_LEN("end_lnum"), (varnumber_T)qfp->qf_end_lnum) - == FAIL) + || (tv_dict_add_nr(dict, S_LEN("lnum"), (varnumber_T)qfp->qf_lnum) == FAIL) + || (tv_dict_add_nr(dict, S_LEN("end_lnum"), (varnumber_T)qfp->qf_end_lnum) == FAIL) || (tv_dict_add_nr(dict, S_LEN("col"), (varnumber_T)qfp->qf_col) == FAIL) - || (tv_dict_add_nr(dict, S_LEN("end_col"), (varnumber_T)qfp->qf_end_col) - == FAIL) - || (tv_dict_add_nr(dict, S_LEN("vcol"), (varnumber_T)qfp->qf_viscol) - == FAIL) + || (tv_dict_add_nr(dict, S_LEN("end_col"), (varnumber_T)qfp->qf_end_col) == FAIL) + || (tv_dict_add_nr(dict, S_LEN("vcol"), (varnumber_T)qfp->qf_viscol) == FAIL) || (tv_dict_add_nr(dict, S_LEN("nr"), (varnumber_T)qfp->qf_nr) == FAIL) - || (tv_dict_add_str(dict, S_LEN("module"), - (qfp->qf_module == NULL ? "" : (const char *)qfp->qf_module)) - == FAIL) - || (tv_dict_add_str(dict, S_LEN("pattern"), - (qfp->qf_pattern == NULL ? "" : (const char *)qfp->qf_pattern)) + || (tv_dict_add_str(dict, S_LEN("module"), (qfp->qf_module == NULL ? "" : qfp->qf_module)) == FAIL) - || (tv_dict_add_str(dict, S_LEN("text"), - (qfp->qf_text == NULL ? "" : (const char *)qfp->qf_text)) + || (tv_dict_add_str(dict, S_LEN("pattern"), (qfp->qf_pattern == NULL ? "" : qfp->qf_pattern)) == FAIL) - || (tv_dict_add_str(dict, S_LEN("type"), (const char *)buf) == FAIL) - || (tv_dict_add_nr(dict, S_LEN("valid"), (varnumber_T)qfp->qf_valid) - == FAIL)) { + || (tv_dict_add_str(dict, S_LEN("text"), (qfp->qf_text == NULL ? "" : qfp->qf_text)) == FAIL) + || (tv_dict_add_str(dict, S_LEN("type"), buf) == FAIL) + || (tv_dict_add_nr(dict, S_LEN("valid"), (varnumber_T)qfp->qf_valid) == FAIL)) { // tv_dict_add* fail only if key already exist, but this is a newly // allocated dictionary which is thus guaranteed to have no existing keys. abort(); @@ -6039,8 +6030,7 @@ static int qf_getprop_qfidx(qf_info_T *qi, dict_T *what) qf_idx = INVALID_QFIDX; } } - } else if (di->di_tv.v_type == VAR_STRING - && strequal((const char *)di->di_tv.vval.v_string, "$")) { + } else if (di->di_tv.v_type == VAR_STRING && strequal(di->di_tv.vval.v_string, "$")) { // Get the last quickfix list number qf_idx = qi->qf_listcount - 1; } else { @@ -6069,7 +6059,7 @@ static int qf_getprop_defaults(qf_info_T *qi, int flags, int locstack, dict_T *r int status = OK; if (flags & QF_GETLIST_TITLE) { - status = tv_dict_add_str(retdict, S_LEN("title"), (const char *)""); + status = tv_dict_add_str(retdict, S_LEN("title"), ""); } if ((status == OK) && (flags & QF_GETLIST_ITEMS)) { list_T *l = tv_list_alloc(kListLenMayKnow); @@ -6082,7 +6072,7 @@ static int qf_getprop_defaults(qf_info_T *qi, int flags, int locstack, dict_T *r status = tv_dict_add_nr(retdict, S_LEN("winid"), qf_winid(qi)); } if ((status == OK) && (flags & QF_GETLIST_CONTEXT)) { - status = tv_dict_add_str(retdict, S_LEN("context"), (const char *)""); + status = tv_dict_add_str(retdict, S_LEN("context"), ""); } if ((status == OK) && (flags & QF_GETLIST_ID)) { status = tv_dict_add_nr(retdict, S_LEN("id"), 0); @@ -6112,8 +6102,7 @@ static int qf_getprop_defaults(qf_info_T *qi, int flags, int locstack, dict_T *r /// Return the quickfix list title as 'title' in retdict static int qf_getprop_title(qf_list_T *qfl, dict_T *retdict) { - return tv_dict_add_str(retdict, S_LEN("title"), - (const char *)qfl->qf_title); + return tv_dict_add_str(retdict, S_LEN("title"), qfl->qf_title); } // Returns the identifier of the window used to display files from a location @@ -6462,8 +6451,7 @@ static int qf_setprop_get_qfidx(const qf_info_T *qi, const dict_T *what, int act } else if (action != ' ') { *newlist = false; // use the specified list } - } else if (di->di_tv.v_type == VAR_STRING - && strequal((const char *)di->di_tv.vval.v_string, "$")) { + } else if (di->di_tv.v_type == VAR_STRING && strequal(di->di_tv.vval.v_string, "$")) { if (!qf_stack_empty(qi)) { qf_idx = qi->qf_listcount - 1; } else if (*newlist) { diff --git a/src/nvim/regexp.c b/src/nvim/regexp.c index 4e3a78f10e..94796f0ed3 100644 --- a/src/nvim/regexp.c +++ b/src/nvim/regexp.c @@ -97,7 +97,7 @@ static int toggle_Magic(int x) #define EMSG2_RET_NULL(m, c) \ return (semsg((m), (c) ? "" : "\\"), rc_did_emsg = true, (void *)NULL) #define EMSG3_RET_NULL(m, c, a) \ - return (semsg((const char *)(m), (c) ? "" : "\\", (a)), rc_did_emsg = true, (void *)NULL) + return (semsg((m), (c) ? "" : "\\", (a)), rc_did_emsg = true, (void *)NULL) #define EMSG2_RET_FAIL(m, c) \ return (semsg((m), (c) ? "" : "\\"), rc_did_emsg = true, FAIL) #define EMSG_ONE_RET_NULL EMSG2_RET_NULL(_("E369: invalid item in %s%%[]"), reg_magic == MAGIC_ALL) @@ -2237,12 +2237,12 @@ list_T *reg_submatch_list(int no) tv_list_append_string(list, s, ecol); } } else { - s = (const char *)rsm.sm_match->startp[no]; + s = rsm.sm_match->startp[no]; if (s == NULL || rsm.sm_match->endp[no] == NULL) { return NULL; } list = tv_list_alloc(1); - tv_list_append_string(list, s, (const char *)rsm.sm_match->endp[no] - s); + tv_list_append_string(list, s, rsm.sm_match->endp[no] - s); } tv_list_ref(list); diff --git a/src/nvim/runtime.c b/src/nvim/runtime.c index 5d1c104dc5..c02e12ae61 100644 --- a/src/nvim/runtime.c +++ b/src/nvim/runtime.c @@ -910,7 +910,7 @@ static int add_pack_dir_to_rtp(char *fname, bool is_pack) } const char *insp = NULL; const char *after_insp = NULL; - for (const char *entry = (const char *)p_rtp; *entry != NUL;) { + for (const char *entry = p_rtp; *entry != NUL;) { const char *cur_entry = entry; copy_option_part((char **)&entry, buf, MAXPATHL, ","); @@ -945,7 +945,7 @@ static int add_pack_dir_to_rtp(char *fname, bool is_pack) if (insp == NULL) { // Both "fname" and "after" not found, append at the end. - insp = (const char *)p_rtp + strlen(p_rtp); + insp = p_rtp + strlen(p_rtp); } // check if rtp/pack/name/start/name/after exists @@ -966,7 +966,7 @@ static int add_pack_dir_to_rtp(char *fname, bool is_pack) // We now have 'rtp' parts: {keep}{keep_after}{rest}. // Create new_rtp, first: {keep},{fname} - size_t keep = (size_t)(insp - (const char *)p_rtp); + size_t keep = (size_t)(insp - p_rtp); memmove(new_rtp, p_rtp, keep); size_t new_rtp_len = keep; if (*insp == NUL) { @@ -979,7 +979,7 @@ static int add_pack_dir_to_rtp(char *fname, bool is_pack) } if (afterlen > 0 && after_insp != NULL) { - size_t keep_after = (size_t)(after_insp - (const char *)p_rtp); + size_t keep_after = (size_t)(after_insp - p_rtp); // Add to new_rtp: {keep},{fname}{keep_after},{afterdir} memmove(new_rtp + new_rtp_len, p_rtp + keep, keep_after - keep); @@ -1061,7 +1061,7 @@ static void add_pack_plugin(bool opt, char *fname, void *cookie) char *buf = xmalloc(MAXPATHL); bool found = false; - const char *p = (const char *)p_rtp; + const char *p = p_rtp; while (*p != NUL) { copy_option_part((char **)&p, buf, MAXPATHL, ","); if (path_fnamecmp(buf, fname) == 0) { @@ -1925,12 +1925,10 @@ static void cmd_source_buffer(const exarg_T *const eap) .offset = 0, }; if (curbuf->b_fname - && path_with_extension((const char *)curbuf->b_fname, "lua")) { - nlua_source_using_linegetter(get_str_line, (void *)&cookie, - ":source (no file)"); + && path_with_extension(curbuf->b_fname, "lua")) { + nlua_source_using_linegetter(get_str_line, (void *)&cookie, ":source (no file)"); } else { - source_using_linegetter((void *)&cookie, get_str_line, - ":source (no file)"); + source_using_linegetter((void *)&cookie, get_str_line, ":source (no file)"); } ga_clear(&ga); } @@ -2134,12 +2132,12 @@ int do_source(char *fname, int check_other, int is_vimrc, int *ret_sid) cookie.conv.vc_type = CONV_NONE; // no conversion - if (path_with_extension((const char *)fname_exp, "lua")) { + if (path_with_extension(fname_exp, "lua")) { const sctx_T current_sctx_backup = current_sctx; current_sctx.sc_sid = SID_LUA; current_sctx.sc_lnum = 0; // Source the file as lua - nlua_exec_file((const char *)fname_exp); + nlua_exec_file(fname_exp); current_sctx = current_sctx_backup; } else { // Read the first line so we can check for a UTF-8 BOM. diff --git a/src/nvim/search.c b/src/nvim/search.c index 525cec8b02..c39dae1421 100644 --- a/src/nvim/search.c +++ b/src/nvim/search.c @@ -1468,7 +1468,7 @@ int search_for_exact_line(buf_T *buf, pos_T *pos, Direction dir, char *pat) // when adding lines the matching line may be empty but it is not // ignored because we are interested in the next line -- Acevedo if (compl_status_adding() && !compl_status_sol()) { - if (mb_strcmp_ic((bool)p_ic, (const char *)p, (const char *)pat) == 0) { + if (mb_strcmp_ic((bool)p_ic, p, pat) == 0) { return OK; } } else if (*p != NUL) { // Ignore empty lines. @@ -2777,21 +2777,21 @@ void f_searchcount(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) return; } dict = argvars[0].vval.v_dict; - di = tv_dict_find(dict, (const char *)"timeout", -1); + di = tv_dict_find(dict, "timeout", -1); if (di != NULL) { timeout = (long)tv_get_number_chk(&di->di_tv, &error); if (error) { return; } } - di = tv_dict_find(dict, (const char *)"maxcount", -1); + di = tv_dict_find(dict, "maxcount", -1); if (di != NULL) { maxcount = (int)tv_get_number_chk(&di->di_tv, &error); if (error) { return; } } - di = tv_dict_find(dict, (const char *)"recompute", -1); + di = tv_dict_find(dict, "recompute", -1); if (di != NULL) { recompute = tv_get_number_chk(&di->di_tv, &error); if (error) { @@ -2805,7 +2805,7 @@ void f_searchcount(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) return; } } - di = tv_dict_find(dict, (const char *)"pos", -1); + di = tv_dict_find(dict, "pos", -1); if (di != NULL) { if (di->di_tv.v_type != VAR_LIST) { semsg(_(e_invarg2), "pos"); @@ -3227,7 +3227,7 @@ static void fuzzy_match_in_list(list_T *const l, char *const str, const bool mat // For a dict, either use the specified key to lookup the string or // use the specified callback function to get the string. if (key != NULL) { - itemstr = tv_dict_get_string(tv->vval.v_dict, (const char *)key, false); + itemstr = tv_dict_get_string(tv->vval.v_dict, key, false); } else { typval_T argv[2]; diff --git a/src/nvim/shada.c b/src/nvim/shada.c index 3f816d0172..72e71ff46f 100644 --- a/src/nvim/shada.c +++ b/src/nvim/shada.c @@ -1491,7 +1491,7 @@ static char *shada_filename(const char *file) // If shell is not performing them then they should be done in main.c // where arguments are parsed, *not here*. expand_env((char *)file, &(NameBuff[0]), MAXPATHL); - file = (const char *)&(NameBuff[0]); + file = &(NameBuff[0]); } } return xstrdup(file); @@ -1548,9 +1548,9 @@ static ShaDaWriteResult shada_pack_entry(msgpack_packer *const packer, ShadaEntr if (!HASHITEM_EMPTY(hi)) { \ todo--; \ dictitem_T *const di = TV_DICT_HI2DI(hi); \ - const size_t key_len = strlen((const char *)hi->hi_key); \ + const size_t key_len = strlen(hi->hi_key); \ msgpack_pack_str(spacker, key_len); \ - msgpack_pack_str_body(spacker, (const char *)hi->hi_key, key_len); \ + msgpack_pack_str_body(spacker, hi->hi_key, key_len); \ if (encode_vim_to_msgpack(spacker, &di->di_tv, \ _("additional data of ShaDa " what)) \ == FAIL) { \ @@ -2208,7 +2208,7 @@ static inline ShaDaWriteResult shada_read_when_writing(ShaDaReadDef *const sd_re shada_free_shada_entry(&entry); break; } - const char *const fname = (const char *)entry.data.filemark.fname; + const char *const fname = entry.data.filemark.fname; khiter_t k; int kh_ret; k = kh_put(file_marks, &wms->file_marks, fname, &kh_ret); @@ -2714,17 +2714,17 @@ static ShaDaWriteResult shada_write(ShaDaWriteDef *const sd_writer, ShaDaReadDef const char *fname; if (fm.fmark.fnum == 0) { assert(fm.fname != NULL); - if (shada_removable((const char *)fm.fname)) { + if (shada_removable(fm.fname)) { continue; } - fname = (const char *)fm.fname; + fname = fm.fname; } else { const buf_T *const buf = buflist_findnr(fm.fmark.fnum); if (buf == NULL || buf->b_ffname == NULL || in_bufset(&removable_bufs, buf)) { continue; } - fname = (const char *)buf->b_ffname; + fname = buf->b_ffname; } const PossiblyFreedShadaEntry pf_entry = { .can_free_entry = false, @@ -2761,7 +2761,7 @@ static ShaDaWriteResult shada_write(ShaDaWriteDef *const sd_writer, ShaDaReadDef continue; } const void *local_marks_iter = NULL; - const char *const fname = (const char *)buf->b_ffname; + const char *const fname = buf->b_ffname; khiter_t k; int kh_ret; k = kh_put(file_marks, &wms->file_marks, fname, &kh_ret); diff --git a/src/nvim/spell.c b/src/nvim/spell.c index 6623ba47af..593e2f4d89 100644 --- a/src/nvim/spell.c +++ b/src/nvim/spell.c @@ -1316,7 +1316,7 @@ size_t spell_move_to(win_T *wp, int dir, bool allwords, bool curline, hlf_T *att // Copy the line into "buf" and append the start of the next line if // possible. Note: this ml_get_buf() may make "line" invalid, check // for empty line first. - bool empty_line = *skipwhite((const char *)line) == NUL; + bool empty_line = *skipwhite(line) == NUL; STRCPY(buf, line); if (lnum < wp->w_buffer->b_ml.ml_line_count) { spell_cat_line(buf + strlen(buf), @@ -1743,7 +1743,7 @@ void count_common_word(slang_T *lp, char *word, int len, uint8_t count) wordcount_T *wc; hash_T hash = hash_hash(p); const size_t p_len = strlen(p); - hashitem_T *hi = hash_lookup(&lp->sl_wordcount, (const char *)p, p_len, hash); + hashitem_T *hi = hash_lookup(&lp->sl_wordcount, p, p_len, hash); if (HASHITEM_EMPTY(hi)) { wc = xmalloc(offsetof(wordcount_T, wc_word) + p_len + 1); memcpy(wc->wc_word, p, p_len + 1); @@ -3129,9 +3129,9 @@ void ex_spellinfo(exarg_T *eap) for (int lpi = 0; lpi < curwin->w_s->b_langp.ga_len && !got_int; lpi++) { langp_T *const lp = LANGP_ENTRY(curwin->w_s->b_langp, lpi); msg_puts("file: "); - msg_puts((const char *)lp->lp_slang->sl_fname); + msg_puts(lp->lp_slang->sl_fname); msg_putchar('\n'); - const char *const p = (const char *)lp->lp_slang->sl_info; + const char *const p = lp->lp_slang->sl_info; if (p != NULL) { msg_puts(p); msg_putchar('\n'); diff --git a/src/nvim/spellfile.c b/src/nvim/spellfile.c index b5e0698240..e6b3ccaa90 100644 --- a/src/nvim/spellfile.c +++ b/src/nvim/spellfile.c @@ -5712,7 +5712,7 @@ static void init_spellfile(void) ((fname != NULL && strstr(path_tail(fname), ".ascii.") != NULL) ? "ascii" - : (const char *)spell_enc())); + : spell_enc())); set_option_value_give_err("spellfile", 0L, buf, OPT_LOCAL); break; } @@ -5851,7 +5851,7 @@ static void set_map_str(slang_T *lp, char *map) utf_char2bytes(headc, b + cl + 1); b[cl + 1 + headcl] = NUL; hash = hash_hash(b); - hi = hash_lookup(&lp->sl_map_hash, (const char *)b, strlen(b), hash); + hi = hash_lookup(&lp->sl_map_hash, b, strlen(b), hash); if (HASHITEM_EMPTY(hi)) { hash_add_item(&lp->sl_map_hash, hi, b, hash); } else { diff --git a/src/nvim/spellsuggest.c b/src/nvim/spellsuggest.c index d28460a63d..e029d949fd 100644 --- a/src/nvim/spellsuggest.c +++ b/src/nvim/spellsuggest.c @@ -2794,7 +2794,7 @@ static void add_sound_suggest(suginfo_T *su, char *goodword, int score, langp_T // remember the words that have been done. hash_T hash = hash_hash(goodword); const size_t goodword_len = strlen(goodword); - hashitem_T *hi = hash_lookup(&slang->sl_sounddone, (const char *)goodword, goodword_len, hash); + hashitem_T *hi = hash_lookup(&slang->sl_sounddone, goodword, goodword_len, hash); if (HASHITEM_EMPTY(hi)) { sft = xmalloc(offsetof(sftword_T, sft_word) + goodword_len + 1); sft->sft_score = (int16_t)score; diff --git a/src/nvim/statusline.c b/src/nvim/statusline.c index b36b703309..3c603ed033 100644 --- a/src/nvim/statusline.c +++ b/src/nvim/statusline.c @@ -1482,7 +1482,7 @@ int build_stl_str_hl(win_T *wp, char *out, size_t outlen, char *fmt, char *opt_n // If the output of the expression needs to be evaluated // replace the %{} block with the result of evaluation if (reevaluate && str != NULL && *str != 0 - && strchr((const char *)str, '%') != NULL + && strchr(str, '%') != NULL && evaldepth < MAX_STL_EVAL_DEPTH) { size_t parsed_usefmt = (size_t)(block_start - usefmt); size_t str_length = strlen(str); diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c index 6b8cce4858..24c7568651 100644 --- a/src/nvim/syntax.c +++ b/src/nvim/syntax.c @@ -3749,7 +3749,7 @@ static void add_keyword(char *const name, const int id, const int flags, hashtab_T *const ht = (curwin->w_s->b_syn_ic) ? &curwin->w_s->b_keywtab_ic : &curwin->w_s->b_keywtab; - hashitem_T *const hi = hash_lookup(ht, (const char *)kp->keyword, + hashitem_T *const hi = hash_lookup(ht, kp->keyword, strlen(kp->keyword), hash); // even though it looks like only the kp->keyword member is @@ -5370,7 +5370,7 @@ void set_context_in_syntax_cmd(expand_T *xp, const char *arg) } // (part of) subcommand already typed - const char *p = (const char *)skiptowhite(arg); + const char *p = skiptowhite(arg); if (*p == NUL) { return; } diff --git a/src/nvim/tag.c b/src/nvim/tag.c index a00112c126..06532f47c1 100644 --- a/src/nvim/tag.c +++ b/src/nvim/tag.c @@ -1081,7 +1081,7 @@ static int add_llist_tags(char *tag, int num_matches, char **matches) tv_list_append_dict(list, dict); tv_dict_add_str(dict, S_LEN("text"), tag_name); - tv_dict_add_str(dict, S_LEN("filename"), (const char *)fname); + tv_dict_add_str(dict, S_LEN("filename"), fname); tv_dict_add_nr(dict, S_LEN("lnum"), lnum); if (lnum == 0) { tv_dict_add_str(dict, S_LEN("pattern"), cmd); @@ -1246,10 +1246,10 @@ static int find_tagfunc_tags(char *pat, garray_T *ga, int *match_count, int flag // create 'info' dict argument dict_T *const d = tv_dict_alloc_lock(VAR_FIXED); if (tag != NULL && tag->user_data != NULL) { - tv_dict_add_str(d, S_LEN("user_data"), (const char *)tag->user_data); + tv_dict_add_str(d, S_LEN("user_data"), tag->user_data); } if (buf_ffname != NULL) { - tv_dict_add_str(d, S_LEN("buf_ffname"), (const char *)buf_ffname); + tv_dict_add_str(d, S_LEN("buf_ffname"), buf_ffname); } d->dv_refcount++; @@ -2067,7 +2067,7 @@ static void findtags_add_match(findtags_state_T *st, tagptrs_T *tagpp, findtags_ // follow after it. E.g. help tags store the priority // after the NUL. *hash = hash_hash(mfp); - hi = hash_lookup(&st->ht_match[mtt], (const char *)mfp, strlen(mfp), *hash); + hi = hash_lookup(&st->ht_match[mtt], mfp, strlen(mfp), *hash); if (HASHITEM_EMPTY(hi)) { hash_add_item(&st->ht_match[mtt], hi, mfp, *hash); GA_APPEND(char *, &st->ga_match[mtt], mfp); @@ -3408,11 +3408,11 @@ static void get_tag_details(taggy_T *tag, dict_T *retdict) list_T *pos; fmark_T *fmark; - tv_dict_add_str(retdict, S_LEN("tagname"), (const char *)tag->tagname); + tv_dict_add_str(retdict, S_LEN("tagname"), tag->tagname); tv_dict_add_nr(retdict, S_LEN("matchnr"), tag->cur_match + 1); tv_dict_add_nr(retdict, S_LEN("bufnr"), tag->cur_fnum); if (tag->user_data) { - tv_dict_add_str(retdict, S_LEN("user_data"), (const char *)tag->user_data); + tv_dict_add_str(retdict, S_LEN("user_data"), tag->user_data); } pos = tv_list_alloc(4); diff --git a/src/nvim/testing.c b/src/nvim/testing.c index 2b5284e15e..907940f64a 100644 --- a/src/nvim/testing.c +++ b/src/nvim/testing.c @@ -185,16 +185,14 @@ static void fill_assert_error(garray_T *gap, typval_T *opt_msg_tv, char *exp_str int todo = (int)exp_d->dv_hashtab.ht_used; for (const hashitem_T *hi = exp_d->dv_hashtab.ht_array; todo > 0; hi++) { if (!HASHITEM_EMPTY(hi)) { - dictitem_T *item2 = tv_dict_find(got_d, (const char *)hi->hi_key, -1); + dictitem_T *item2 = tv_dict_find(got_d, hi->hi_key, -1); if (item2 == NULL || !tv_equal(&TV_DICT_HI2DI(hi)->di_tv, &item2->di_tv, false, false)) { // item of exp_d not present in got_d or values differ. const size_t key_len = strlen(hi->hi_key); - tv_dict_add_tv(exp_tv->vval.v_dict, (const char *)hi->hi_key, key_len, - &TV_DICT_HI2DI(hi)->di_tv); + tv_dict_add_tv(exp_tv->vval.v_dict, hi->hi_key, key_len, &TV_DICT_HI2DI(hi)->di_tv); if (item2 != NULL) { - tv_dict_add_tv(got_tv->vval.v_dict, (const char *)hi->hi_key, key_len, - &item2->di_tv); + tv_dict_add_tv(got_tv->vval.v_dict, hi->hi_key, key_len, &item2->di_tv); } } else { omitted++; @@ -207,12 +205,11 @@ static void fill_assert_error(garray_T *gap, typval_T *opt_msg_tv, char *exp_str todo = (int)got_d->dv_hashtab.ht_used; for (const hashitem_T *hi = got_d->dv_hashtab.ht_array; todo > 0; hi++) { if (!HASHITEM_EMPTY(hi)) { - dictitem_T *item2 = tv_dict_find(exp_d, (const char *)hi->hi_key, -1); + dictitem_T *item2 = tv_dict_find(exp_d, hi->hi_key, -1); if (item2 == NULL) { // item of got_d not present in exp_d const size_t key_len = strlen(hi->hi_key); - tv_dict_add_tv(got_tv->vval.v_dict, (const char *)hi->hi_key, key_len, - &TV_DICT_HI2DI(hi)->di_tv); + tv_dict_add_tv(got_tv->vval.v_dict, hi->hi_key, key_len, &TV_DICT_HI2DI(hi)->di_tv); } todo--; } diff --git a/src/nvim/ui_client.c b/src/nvim/ui_client.c index 25ff63ea2d..b93b31f7dc 100644 --- a/src/nvim/ui_client.c +++ b/src/nvim/ui_client.c @@ -43,7 +43,7 @@ uint64_t ui_client_start_server(int argc, char **argv) varnumber_T exit_status; char **args = xmalloc(((size_t)(2 + argc)) * sizeof(char *)); int args_idx = 0; - args[args_idx++] = xstrdup((const char *)get_vim_var_str(VV_PROGPATH)); + args[args_idx++] = xstrdup(get_vim_var_str(VV_PROGPATH)); args[args_idx++] = xstrdup("--embed"); for (int i = 1; i < argc; i++) { args[args_idx++] = xstrdup(argv[i]); diff --git a/src/nvim/undo.c b/src/nvim/undo.c index 873970fc39..132c84231f 100644 --- a/src/nvim/undo.c +++ b/src/nvim/undo.c @@ -1179,7 +1179,7 @@ void u_write_undo(const char *const name, const bool forceit, buf_T *const buf, // allow the user to access the undo file. int perm = 0600; if (buf->b_ffname != NULL) { - perm = os_getperm((const char *)buf->b_ffname); + perm = os_getperm(buf->b_ffname); if (perm < 0) { perm = 0600; } diff --git a/src/nvim/usercmd.c b/src/nvim/usercmd.c index 8c2f8533d8..4cd58bb91b 100644 --- a/src/nvim/usercmd.c +++ b/src/nvim/usercmd.c @@ -234,7 +234,7 @@ const char *set_context_in_user_cmd(expand_T *xp, const char *arg_in) // Check for attributes while (*arg == '-') { arg++; // Skip "-". - p = (const char *)skiptowhite(arg); + p = skiptowhite(arg); if (*p == NUL) { // Cursor is still in the attribute. p = strchr(arg, '='); @@ -262,11 +262,11 @@ const char *set_context_in_user_cmd(expand_T *xp, const char *arg_in) } return NULL; } - arg = (const char *)skipwhite(p); + arg = skipwhite(p); } // After the attributes comes the new command name. - p = (const char *)skiptowhite(arg); + p = skiptowhite(arg); if (*p == NUL) { xp->xp_context = EXPAND_USER_COMMANDS; xp->xp_pattern = (char *)arg; @@ -274,7 +274,7 @@ const char *set_context_in_user_cmd(expand_T *xp, const char *arg_in) } // And finally comes a normal command. - return (const char *)skipwhite(p); + return skipwhite(p); } /// Set the completion context for the argument of a user defined command. @@ -292,7 +292,7 @@ const char *set_context_in_user_cmdarg(const char *cmd FUNC_ATTR_UNUSED, const c } if (context == EXPAND_MENUS) { - return (const char *)set_context_in_menu_cmd(xp, cmd, (char *)arg, forceit); + return set_context_in_menu_cmd(xp, cmd, (char *)arg, forceit); } if (context == EXPAND_COMMANDS) { return arg; diff --git a/src/nvim/window.c b/src/nvim/window.c index b41d054ac3..75fa61fb1e 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -899,7 +899,7 @@ void win_check_anchored_floats(win_T *win) /// Return the number of fold columns to display int win_fdccol_count(win_T *wp) { - const char *fdc = (const char *)wp->w_p_fdc; + const char *fdc = wp->w_p_fdc; // auto:<NUM> if (strncmp(fdc, "auto", 4) == 0) { |