diff options
author | dundargoc <33953936+dundargoc@users.noreply.github.com> | 2023-01-09 15:37:34 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-09 22:37:34 +0800 |
commit | 50f03773f4b9f4638489ccfd0503dc9e39e5de78 (patch) | |
tree | 2471c7596d233b66cacc36986bea0a31e9ba96ea | |
parent | 9cd7edc6ad884f59b0be9dda3523ff88f4dca705 (diff) | |
download | rneovim-50f03773f4b9f4638489ccfd0503dc9e39e5de78.tar.gz rneovim-50f03773f4b9f4638489ccfd0503dc9e39e5de78.tar.bz2 rneovim-50f03773f4b9f4638489ccfd0503dc9e39e5de78.zip |
refactor: replace char_u with char 18 (#21237)
refactor: replace char_u with char
Work on https://github.com/neovim/neovim/issues/459
45 files changed, 451 insertions, 451 deletions
diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c index 58abec351b..e6d0dcb8cf 100644 --- a/src/nvim/buffer.c +++ b/src/nvim/buffer.c @@ -1089,7 +1089,7 @@ char *do_bufdel(int command, char *arg, int addr_count, int start_bnr, int end_b } else { STRCPY(IObuff, _("E517: No buffers were wiped out")); } - errormsg = (char *)IObuff; + errormsg = IObuff; } else if (deleted >= p_report) { if (command == DOBUF_UNLOAD) { smsg(NGETTEXT("%d buffer unloaded", "%d buffers unloaded", deleted), @@ -2762,7 +2762,7 @@ void buflist_list(exarg_T *eap) if (buf_spname(buf) != NULL) { xstrlcpy(NameBuff, buf_spname(buf), MAXPATHL); } else { - home_replace(buf, buf->b_fname, (char *)NameBuff, MAXPATHL, true); + home_replace(buf, buf->b_fname, NameBuff, MAXPATHL, true); } if (message_filtered(NameBuff)) { @@ -2778,7 +2778,7 @@ void buflist_list(exarg_T *eap) } msg_putchar('\n'); - len = vim_snprintf((char *)IObuff, IOSIZE - 20, "%3d%c%c%c%c%c \"%s\"", + len = vim_snprintf(IObuff, IOSIZE - 20, "%3d%c%c%c%c%c \"%s\"", buf->b_fnum, buf->b_p_bl ? ' ' : 'u', buf == curbuf ? '%' : (curwin->w_alt_fnum == buf->b_fnum ? '#' : ' '), @@ -2792,18 +2792,18 @@ void buflist_list(exarg_T *eap) } // put "line 999" in column 40 or after the file name - i = 40 - vim_strsize((char *)IObuff); + i = 40 - vim_strsize(IObuff); do { IObuff[len++] = ' '; } while (--i > 0 && len < IOSIZE - 18); if (vim_strchr(eap->arg, 't') && buf->b_last_used) { - undo_fmt_time((char_u *)IObuff + len, (size_t)(IOSIZE - len), buf->b_last_used); + undo_fmt_time(IObuff + len, (size_t)(IOSIZE - len), buf->b_last_used); } else { - vim_snprintf((char *)IObuff + len, (size_t)(IOSIZE - len), _("line %" PRId64), + vim_snprintf(IObuff + len, (size_t)(IOSIZE - len), _("line %" PRId64), buf == curbuf ? (int64_t)curwin->w_cursor.lnum : (int64_t)buflist_findlnum(buf)); } - msg_outtrans((char *)IObuff); + msg_outtrans(IObuff); line_breakcheck(); } diff --git a/src/nvim/channel.c b/src/nvim/channel.c index 386ec832eb..65bb87bc2c 100644 --- a/src/nvim/channel.c +++ b/src/nvim/channel.c @@ -215,7 +215,7 @@ void channel_create_event(Channel *chan, const char *ext_source) // external events should be included. source = ext_source; } else { - eval_fmt_source_name_line((char *)IObuff, sizeof(IObuff)); + eval_fmt_source_name_line(IObuff, sizeof(IObuff)); source = (const char *)IObuff; } diff --git a/src/nvim/charset.c b/src/nvim/charset.c index 51ea7f3205..4115743e1c 100644 --- a/src/nvim/charset.c +++ b/src/nvim/charset.c @@ -439,7 +439,7 @@ size_t kv_transstr(StringBuilder *str, const char *const s, bool untab) /// /// When "buf" is NULL, return an allocated string. /// Otherwise, put the result in buf, limited by buflen, and return buf. -char_u *str_foldcase(char_u *str, int orglen, char *buf, int buflen) +char *str_foldcase(char *str, int orglen, char *buf, int buflen) FUNC_ATTR_NONNULL_RET { garray_T ga; @@ -518,9 +518,9 @@ char_u *str_foldcase(char_u *str, int orglen, char *buf, int buflen) } if (buf == NULL) { - return (char_u *)ga.ga_data; + return ga.ga_data; } - return (char_u *)buf; + return buf; } // Catch 22: g_chartab[] can't be initialized before the options are @@ -809,10 +809,10 @@ bool vim_iswordc_buf(const int c, buf_T *const buf) /// @param p pointer to the multi-byte character /// /// @return true if "p" points to a keyword character. -bool vim_iswordp(const char_u *const p) +bool vim_iswordp(const char *const p) FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL { - return vim_iswordp_buf((char *)p, curbuf); + return vim_iswordp_buf(p, curbuf); } /// Just like vim_iswordc_buf() but uses a pointer to the (multi-byte) diff --git a/src/nvim/cmdexpand.c b/src/nvim/cmdexpand.c index a1030389a9..761e915131 100644 --- a/src/nvim/cmdexpand.c +++ b/src/nvim/cmdexpand.c @@ -107,7 +107,7 @@ static int sort_func_compare(const void *s1, const void *s2) static void ExpandEscape(expand_T *xp, char_u *str, int numfiles, char **files, int options) { int i; - char_u *p; + char *p; const int vse_what = xp->xp_context == EXPAND_BUFFERS ? VSE_BUFFER : VSE_NONE; // May change home directory back to "~" @@ -126,9 +126,9 @@ static void ExpandEscape(expand_T *xp, char_u *str, int numfiles, char **files, for (i = 0; i < numfiles; i++) { // for ":set path=" we need to escape spaces twice if (xp->xp_backslash == XP_BS_THREE) { - p = vim_strsave_escaped((char_u *)files[i], (char_u *)" "); + p = (char *)vim_strsave_escaped((char_u *)files[i], (char_u *)" "); xfree(files[i]); - files[i] = (char *)p; + files[i] = p; #if defined(BACKSLASH_IN_FILENAME) p = vim_strsave_escaped(files[i], (char_u *)" "); xfree(files[i]); @@ -136,13 +136,13 @@ static void ExpandEscape(expand_T *xp, char_u *str, int numfiles, char **files, #endif } #ifdef BACKSLASH_IN_FILENAME - p = (char_u *)vim_strsave_fnameescape((const char *)files[i], vse_what); + p = vim_strsave_fnameescape((const char *)files[i], vse_what); #else - p = (char_u *)vim_strsave_fnameescape((const char *)files[i], - xp->xp_shell ? VSE_SHELL : vse_what); + p = vim_strsave_fnameescape((const char *)files[i], + xp->xp_shell ? VSE_SHELL : vse_what); #endif xfree(files[i]); - files[i] = (char *)p; + files[i] = p; // If 'str' starts with "\~", replace "~" at start of // files[i] with "\~". @@ -161,9 +161,9 @@ static void ExpandEscape(expand_T *xp, char_u *str, int numfiles, char **files, // Insert a backslash before characters in a tag name that // would terminate the ":tag" command. for (i = 0; i < numfiles; i++) { - p = vim_strsave_escaped((char_u *)files[i], (char_u *)"\\|\""); + p = (char *)vim_strsave_escaped((char_u *)files[i], (char_u *)"\\|\""); xfree(files[i]); - files[i] = (char *)p; + files[i] = p; } } } @@ -180,7 +180,7 @@ int nextwild(expand_T *xp, int type, int options, bool escape) { CmdlineInfo *const ccline = get_cmdline_info(); int i, j; - char_u *p1; + char *p1; char *p2; int difflen; @@ -214,14 +214,14 @@ int nextwild(expand_T *xp, int type, int options, bool escape) p2 = ExpandOne(xp, NULL, NULL, 0, type); } else { // Translate string into pattern and expand it. - p1 = (char_u *)addstar(xp->xp_pattern, xp->xp_pattern_len, xp->xp_context); + p1 = addstar(xp->xp_pattern, xp->xp_pattern_len, xp->xp_context); const int use_options = (options | WILD_HOME_REPLACE | WILD_ADD_SLASH | WILD_SILENT | (escape ? WILD_ESCAPE : 0) | (p_wic ? WILD_ICASE : 0)); - p2 = ExpandOne(xp, (char *)p1, xstrnsave(&ccline->cmdbuff[i], xp->xp_pattern_len), + p2 = ExpandOne(xp, p1, xstrnsave(&ccline->cmdbuff[i], xp->xp_pattern_len), use_options, type); xfree(p1); @@ -358,16 +358,16 @@ static void redraw_wildmenu(expand_T *xp, int num_matches, char **matches, int m { #define L_MATCH(m) (showtail ? showmatches_gettail(matches[m], false) : matches[m]) int row; - char_u *buf; + char *buf; int len; int clen; // length in screen cells int fillchar; int attr; int i; bool highlight = true; - char_u *selstart = NULL; + char *selstart = NULL; int selstart_col = 0; - char_u *selend = NULL; + char *selend = NULL; static int first_match = 0; bool add_left = false; char *s; @@ -450,7 +450,7 @@ static void redraw_wildmenu(expand_T *xp, int num_matches, char **matches, int m || xp->xp_context == EXPAND_MENUNAMES); if (emenu && menu_is_separator(s)) { STRCPY(buf + len, transchar('|')); - l = (int)strlen((char *)buf + len); + l = (int)strlen(buf + len); len += l; clen += l; } else { @@ -520,10 +520,10 @@ static void redraw_wildmenu(expand_T *xp, int num_matches, char **matches, int m ScreenGrid *grid = (wild_menu_showing == WM_SCROLLED) ? &msg_grid_adj : &default_grid; - grid_puts(grid, (char *)buf, row, 0, attr); + grid_puts(grid, buf, row, 0, attr); if (selstart != NULL && highlight) { *selend = NUL; - grid_puts(grid, (char *)selstart, row, selstart_col, HL_ATTR(HLF_WM)); + grid_puts(grid, selstart, row, selstart_col, HL_ATTR(HLF_WM)); } grid_fill(grid, row, row + 1, clen, Columns, @@ -835,14 +835,14 @@ int showmatches(expand_T *xp, int wildmenu) int maxlen; int lines; int columns; - char_u *p; + char *p; int lastlen; int attr; int showtail; if (xp->xp_numfiles == -1) { set_expand_context(xp); - i = expand_cmdline(xp, (char_u *)ccline->cmdbuff, ccline->cmdpos, + i = expand_cmdline(xp, ccline->cmdbuff, ccline->cmdpos, &num_files, &files_found); showtail = expand_showtail(xp); if (i != EXPAND_OK) { @@ -903,8 +903,8 @@ int showmatches(expand_T *xp, int wildmenu) if (!showtail && (xp->xp_context == EXPAND_FILES || xp->xp_context == EXPAND_SHELLCMD || xp->xp_context == EXPAND_BUFFERS)) { - home_replace(NULL, files_found[i], (char *)NameBuff, MAXPATHL, true); - j = vim_strsize((char *)NameBuff); + home_replace(NULL, files_found[i], NameBuff, MAXPATHL, true); + j = vim_strsize(NameBuff); } else { j = vim_strsize(L_SHOWFILE(i)); } @@ -940,11 +940,11 @@ int showmatches(expand_T *xp, int wildmenu) for (k = i; k < num_files; k += lines) { if (xp->xp_context == EXPAND_TAGS_LISTFILES) { msg_outtrans_attr(files_found[k], HL_ATTR(HLF_D)); - p = (char_u *)files_found[k] + strlen(files_found[k]) + 1; + p = files_found[k] + strlen(files_found[k]) + 1; msg_advance(maxlen + 1); msg_puts((const char *)p); msg_advance(maxlen + 3); - msg_outtrans_long_attr((char *)p + 2, HL_ATTR(HLF_D)); + msg_outtrans_long_attr(p + 2, HL_ATTR(HLF_D)); break; } for (j = maxlen - lastlen; --j >= 0;) { @@ -958,10 +958,10 @@ int showmatches(expand_T *xp, int wildmenu) // Expansion was done before and special characters // were escaped, need to halve backslashes. Also // $HOME has been replaced with ~/. - char_u *exp_path = expand_env_save_opt((char_u *)files_found[k], true); - char_u *path = exp_path != NULL ? exp_path : (char_u *)files_found[k]; - char_u *halved_slash = (char_u *)backslash_halve_save((char *)path); - j = os_isdir((char *)halved_slash); + char *exp_path = (char *)expand_env_save_opt((char_u *)files_found[k], true); + char *path = exp_path != NULL ? exp_path : files_found[k]; + char *halved_slash = backslash_halve_save(path); + j = os_isdir(halved_slash); xfree(exp_path); if (halved_slash != path) { xfree(halved_slash); @@ -971,16 +971,16 @@ int showmatches(expand_T *xp, int wildmenu) j = os_isdir(files_found[k]); } if (showtail) { - p = (char_u *)L_SHOWFILE(k); + p = L_SHOWFILE(k); } else { - home_replace(NULL, files_found[k], (char *)NameBuff, MAXPATHL, true); - p = (char_u *)NameBuff; + home_replace(NULL, files_found[k], NameBuff, MAXPATHL, true); + p = NameBuff; } } else { j = false; - p = (char_u *)L_SHOWFILE(k); + p = L_SHOWFILE(k); } - lastlen = msg_outtrans_attr((char *)p, j ? attr : 0); + lastlen = msg_outtrans_attr(p, j ? attr : 0); } if (msg_col > 0) { // when not wrapped around msg_clr_eos(); @@ -1008,11 +1008,11 @@ int showmatches(expand_T *xp, int wildmenu) /// Return the tail of file name path "s", ignoring a trailing "/". static char *showmatches_gettail(char *s, bool eager) { - char_u *p; - char_u *t = (char_u *)s; + char *p; + char *t = s; bool had_sep = false; - for (p = (char_u *)s; *p != NUL;) { + for (p = s; *p != NUL;) { if (vim_ispathsep(*p) #ifdef BACKSLASH_IN_FILENAME && !rem_backslash(p) @@ -1029,7 +1029,7 @@ static char *showmatches_gettail(char *s, bool eager) } MB_PTR_ADV(p); } - return (char *)t; + return t; } /// Return true if we only need to show the tail of completion matches. @@ -1037,8 +1037,8 @@ static char *showmatches_gettail(char *s, bool eager) /// returned. static bool expand_showtail(expand_T *xp) { - char_u *s; - char_u *end; + char *s; + char *end; // When not completing file names a "/" may mean something different. if (xp->xp_context != EXPAND_FILES @@ -1047,15 +1047,15 @@ static bool expand_showtail(expand_T *xp) return false; } - end = (char_u *)path_tail(xp->xp_pattern); - if (end == (char_u *)xp->xp_pattern) { // there is no path separator + end = path_tail(xp->xp_pattern); + if (end == xp->xp_pattern) { // there is no path separator return false; } - for (s = (char_u *)xp->xp_pattern; s < end; s++) { + for (s = xp->xp_pattern; s < end; s++) { // Skip escaped wildcards. Only when the backslash is not a path // separator, on DOS the '*' "path\*\file" must not be skipped. - if (rem_backslash((char *)s)) { + if (rem_backslash(s)) { s++; } else if (vim_strchr("*?[", *s) != NULL) { return false; @@ -2149,9 +2149,9 @@ void set_cmd_context(expand_T *xp, char_u *str, int len, int col, int use_ccline /// @param col position of cursor /// @param matchcount return: nr of matches /// @param matches return: array of pointers to matches -int expand_cmdline(expand_T *xp, const char_u *str, int col, int *matchcount, char ***matches) +int expand_cmdline(expand_T *xp, const char *str, int col, int *matchcount, char ***matches) { - char_u *file_str = NULL; + char *file_str = NULL; int options = WILD_ADD_SLASH|WILD_SILENT; if (xp->xp_context == EXPAND_UNSUCCESSFUL) { @@ -2164,16 +2164,16 @@ int expand_cmdline(expand_T *xp, const char_u *str, int col, int *matchcount, ch } // add star to file name, or convert to regexp if not exp. files. - assert((str + col) - (char_u *)xp->xp_pattern >= 0); - xp->xp_pattern_len = (size_t)((str + col) - (char_u *)xp->xp_pattern); - file_str = (char_u *)addstar(xp->xp_pattern, xp->xp_pattern_len, xp->xp_context); + assert((str + col) - xp->xp_pattern >= 0); + xp->xp_pattern_len = (size_t)((str + col) - xp->xp_pattern); + file_str = addstar(xp->xp_pattern, xp->xp_pattern_len, xp->xp_context); if (p_wic) { options += WILD_ICASE; } // find all files that match the description - if (ExpandFromContext(xp, (char *)file_str, matchcount, matches, options) == FAIL) { + if (ExpandFromContext(xp, file_str, matchcount, matches, options) == FAIL) { *matchcount = 0; *matches = NULL; } @@ -2424,7 +2424,7 @@ static int ExpandFromContext(expand_T *xp, char *pat, int *num_file, char ***fil } if (xp->xp_context == EXPAND_TAGS || xp->xp_context == EXPAND_TAGS_LISTFILES) { - return expand_tags(xp->xp_context == EXPAND_TAGS, (char_u *)pat, num_file, file); + return expand_tags(xp->xp_context == EXPAND_TAGS, pat, num_file, file); } if (xp->xp_context == EXPAND_COLORS) { char *directories[] = { "colors", NULL }; @@ -3097,7 +3097,7 @@ void wildmenu_cleanup(CmdlineInfo *cclp) /// "getcompletion()" function void f_getcompletion(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) { - char_u *pat; + char *pat; expand_T xpc; bool filtered = false; int options = WILD_SILENT | WILD_USE_NL | WILD_ADD_SLASH @@ -3155,8 +3155,8 @@ void f_getcompletion(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) } theend: - pat = (char_u *)addstar(xpc.xp_pattern, xpc.xp_pattern_len, xpc.xp_context); - ExpandOne(&xpc, (char *)pat, NULL, options, WILD_ALL_KEEP); + pat = addstar(xpc.xp_pattern, xpc.xp_pattern_len, xpc.xp_context); + ExpandOne(&xpc, pat, NULL, options, WILD_ALL_KEEP); tv_list_alloc_ret(rettv, xpc.xp_numfiles); for (int i = 0; i < xpc.xp_numfiles; i++) { diff --git a/src/nvim/cmdhist.c b/src/nvim/cmdhist.c index 0556a56d5d..d12ac87bbb 100644 --- a/src/nvim/cmdhist.c +++ b/src/nvim/cmdhist.c @@ -648,7 +648,7 @@ void ex_history(exarg_T *eap) STRCPY(IObuff, "\n # "); assert(history_names[histype1] != NULL); STRCAT(STRCAT(IObuff, history_names[histype1]), " history"); - msg_puts_title((char *)IObuff); + msg_puts_title(IObuff); idx = hisidx[histype1]; hist = history[histype1]; j = hisidx1; @@ -667,15 +667,15 @@ void ex_history(exarg_T *eap) if (hist[i].hisstr != NULL && hist[i].hisnum >= j && hist[i].hisnum <= k) { msg_putchar('\n'); - snprintf((char *)IObuff, IOSIZE, "%c%6d ", i == idx ? '>' : ' ', + snprintf(IObuff, IOSIZE, "%c%6d ", i == idx ? '>' : ' ', hist[i].hisnum); if (vim_strsize(hist[i].hisstr) > Columns - 10) { - trunc_string(hist[i].hisstr, (char *)IObuff + strlen(IObuff), + trunc_string(hist[i].hisstr, IObuff + strlen(IObuff), Columns - 10, IOSIZE - (int)strlen(IObuff)); } else { STRCAT(IObuff, hist[i].hisstr); } - msg_outtrans((char *)IObuff); + msg_outtrans(IObuff); } if (i == idx) { break; diff --git a/src/nvim/edit.c b/src/nvim/edit.c index 611dab41a2..5646abf3c4 100644 --- a/src/nvim/edit.c +++ b/src/nvim/edit.c @@ -3167,7 +3167,7 @@ bool in_cinkeys(int keytyped, int when, bool line_is_empty) line = get_cursor_line_ptr(); for (s = line + curwin->w_cursor.col; s > line; s = n) { n = (char *)mb_prevptr((char_u *)line, (char_u *)s); - if (!vim_iswordp((char_u *)n)) { + if (!vim_iswordp(n)) { break; } } diff --git a/src/nvim/eval/encode.c b/src/nvim/eval/encode.c index b7ef109f06..03d4862550 100644 --- a/src/nvim/eval/encode.c +++ b/src/nvim/eval/encode.c @@ -141,9 +141,9 @@ static int conv_error(const char *const msg, const MPConvStack *const mpstack, 1))->hi_key }, }; char *const key = encode_tv2string(&key_tv, NULL); - vim_snprintf((char *)IObuff, IOSIZE, key_msg, key); + vim_snprintf(IObuff, IOSIZE, key_msg, key); xfree(key); - ga_concat(&msg_ga, (char *)IObuff); + ga_concat(&msg_ga, IObuff); break; } case kMPConvPairs: @@ -163,8 +163,8 @@ static int conv_error(const char *const msg, const MPConvStack *const mpstack, || li == NULL || (TV_LIST_ITEM_TV(li)->v_type != VAR_LIST && tv_list_len(TV_LIST_ITEM_TV(li)->vval.v_list) <= 0)) { - vim_snprintf((char *)IObuff, IOSIZE, idx_msg, idx); - ga_concat(&msg_ga, (char *)IObuff); + vim_snprintf(IObuff, IOSIZE, idx_msg, idx); + ga_concat(&msg_ga, IObuff); } else { assert(li != NULL); listitem_T *const first_item = @@ -172,9 +172,9 @@ static int conv_error(const char *const msg, const MPConvStack *const mpstack, assert(first_item != NULL); typval_T key_tv = *TV_LIST_ITEM_TV(first_item); char *const key = encode_tv2echo(&key_tv, NULL); - vim_snprintf((char *)IObuff, IOSIZE, key_pair_msg, key, idx); + vim_snprintf(IObuff, IOSIZE, key_pair_msg, key, idx); xfree(key); - ga_concat(&msg_ga, (char *)IObuff); + ga_concat(&msg_ga, IObuff); } break; } @@ -193,8 +193,8 @@ static int conv_error(const char *const msg, const MPConvStack *const mpstack, break; case kMPConvPartialList: { const int idx = (int)(v.data.a.arg - v.data.a.argv) - 1; - vim_snprintf((char *)IObuff, IOSIZE, partial_arg_i_msg, idx); - ga_concat(&msg_ga, (char *)IObuff); + vim_snprintf(IObuff, IOSIZE, partial_arg_i_msg, idx); + ga_concat(&msg_ga, IObuff); break; } } diff --git a/src/nvim/eval/funcs.c b/src/nvim/eval/funcs.c index b79a69bc6e..5cb4dc2631 100644 --- a/src/nvim/eval/funcs.c +++ b/src/nvim/eval/funcs.c @@ -169,13 +169,13 @@ char *get_function_name(expand_T *xp, int idx) intidx = -1; } if (intidx < 0) { - char_u *name = (char_u *)get_user_func_name(xp, idx); + char *name = get_user_func_name(xp, idx); if (name != NULL) { if (*name != NUL && *name != '<' && strncmp("g:", xp->xp_pattern, 2) == 0) { - return cat_prefix_varname('g', (char *)name); + return cat_prefix_varname('g', name); } - return (char *)name; + return name; } } @@ -192,7 +192,7 @@ char *get_function_name(expand_T *xp, int idx) } else { IObuff[key_len + 1] = NUL; } - return (char *)IObuff; + return IObuff; } /// Function given to ExpandGeneric() to obtain the list of internal or @@ -205,9 +205,9 @@ char *get_expr_name(expand_T *xp, int idx) intidx = -1; } if (intidx < 0) { - char_u *name = (char_u *)get_function_name(xp, idx); + char *name = get_function_name(xp, idx); if (name != NULL) { - return (char *)name; + return name; } } return get_user_var_name(xp, ++intidx); @@ -548,19 +548,19 @@ static void f_call(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) } bool owned = false; - char_u *func; + char *func; partial_T *partial = NULL; if (argvars[0].v_type == VAR_FUNC) { - func = (char_u *)argvars[0].vval.v_string; + func = argvars[0].vval.v_string; } else if (argvars[0].v_type == VAR_PARTIAL) { partial = argvars[0].vval.v_partial; - func = (char_u *)partial_name(partial); + func = partial_name(partial); } else if (nlua_is_table_from_lua(&argvars[0])) { // TODO(tjdevries): UnifiedCallback - func = nlua_register_table_as_callable(&argvars[0]); + func = (char *)nlua_register_table_as_callable(&argvars[0]); owned = true; } else { - func = (char_u *)tv_get_string(&argvars[0]); + func = (char *)tv_get_string(&argvars[0]); } if (*func == NUL) { @@ -572,16 +572,16 @@ static void f_call(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) if (argvars[2].v_type != VAR_DICT) { emsg(_(e_dictreq)); if (owned) { - func_unref(func); + func_unref((char_u *)func); } return; } selfdict = argvars[2].vval.v_dict; } - func_call(func, &argvars[1], partial, selfdict, rettv); + func_call((char_u *)func, &argvars[1], partial, selfdict, rettv); if (owned) { - func_unref(func); + func_unref((char_u *)func); } } @@ -949,7 +949,7 @@ static void f_count(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) if (argvars[0].v_type == VAR_STRING) { const char *expr = tv_get_string_chk(&argvars[1]); - const char_u *p = (char_u *)argvars[0].vval.v_string; + const char *p = argvars[0].vval.v_string; if (!error && expr != NULL && *expr != NUL && p != NULL) { if (ic) { @@ -964,8 +964,8 @@ static void f_count(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) } } } else { - char_u *next; - while ((next = (char_u *)strstr((char *)p, (char *)expr)) != NULL) { + char *next; + while ((next = strstr((char *)p, (char *)expr)) != NULL) { n++; p = next + strlen(expr); } @@ -1531,14 +1531,14 @@ static void f_escape(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) /// "getenv()" function static void f_getenv(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) { - char_u *p = (char_u *)vim_getenv(tv_get_string(&argvars[0])); + char *p = vim_getenv(tv_get_string(&argvars[0])); if (p == NULL) { rettv->v_type = VAR_SPECIAL; rettv->vval.v_special = kSpecialVarNull; return; } - rettv->vval.v_string = (char *)p; + rettv->vval.v_string = p; rettv->v_type = VAR_STRING; } @@ -1771,7 +1771,7 @@ static void f_expand(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) } size_t len; char *errormsg = NULL; - char_u *result = eval_vars((char_u *)s, (char_u *)s, &len, NULL, &errormsg, NULL, false); + char *result = (char *)eval_vars((char_u *)s, (char_u *)s, &len, NULL, &errormsg, NULL, false); if (p_verbose == 0) { emsg_off--; } else if (errormsg != NULL) { @@ -1784,7 +1784,7 @@ static void f_expand(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) } XFREE_CLEAR(result); } else { - rettv->vval.v_string = (char *)result; + rettv->vval.v_string = result; } } else { // When the optional second argument is non-zero, don't remove matches @@ -2022,8 +2022,8 @@ static void f_filewritable(typval_T *argvars, typval_T *rettv, EvalFuncData fptr static void findfilendir(typval_T *argvars, typval_T *rettv, int find_what) { - char_u *fresult = NULL; - char_u *path = *curbuf->b_p_path == NUL ? p_path : (char_u *)curbuf->b_p_path; + char *fresult = NULL; + char *path = *curbuf->b_p_path == NUL ? (char *)p_path : curbuf->b_p_path; int count = 1; bool first = true; bool error = false; @@ -2040,7 +2040,7 @@ static void findfilendir(typval_T *argvars, typval_T *rettv, int find_what) error = true; } else { if (*p != NUL) { - path = (char_u *)p; + path = (char *)p; } if (argvars[2].v_type != VAR_UNKNOWN) { @@ -2058,13 +2058,13 @@ static void findfilendir(typval_T *argvars, typval_T *rettv, int find_what) if (rettv->v_type == VAR_STRING || rettv->v_type == VAR_LIST) { xfree(fresult); } - fresult = (char_u *)find_file_in_path_option(first ? (char *)fname : NULL, - first ? strlen(fname) : 0, - 0, first, (char *)path, - find_what, curbuf->b_ffname, - (find_what == FINDFILE_DIR - ? "" - : curbuf->b_p_sua)); + fresult = find_file_in_path_option(first ? (char *)fname : NULL, + first ? strlen(fname) : 0, + 0, first, path, + find_what, curbuf->b_ffname, + (find_what == FINDFILE_DIR + ? "" + : curbuf->b_p_sua)); first = false; if (fresult != NULL && rettv->v_type == VAR_LIST) { @@ -2074,7 +2074,7 @@ static void findfilendir(typval_T *argvars, typval_T *rettv, int find_what) } if (rettv->v_type == VAR_STRING) { - rettv->vval.v_string = (char *)fresult; + rettv->vval.v_string = fresult; } } @@ -2138,7 +2138,7 @@ static void f_fnameescape(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) /// "fnamemodify({fname}, {mods})" function static void f_fnamemodify(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) { - char_u *fbuf = NULL; + char *fbuf = NULL; size_t len = 0; char buf[NUMBUFLEN]; const char *fname = tv_get_string_chk(&argvars[0]); @@ -2150,7 +2150,7 @@ static void f_fnamemodify(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) if (*mods != NUL) { size_t usedlen = 0; (void)modify_fname((char *)mods, false, &usedlen, - (char **)&fname, (char **)&fbuf, &len); + (char **)&fname, &fbuf, &len); } } @@ -2545,7 +2545,7 @@ static void f_getfontname(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) static void f_getfperm(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) { char *perm = NULL; - char_u flags[] = "rwx"; + char flags[] = "rwx"; const char *filename = tv_get_string(&argvars[0]); int32_t file_perm = os_getperm(filename); @@ -2553,7 +2553,7 @@ static void f_getfperm(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) perm = xstrdup("---------"); for (int i = 0; i < 9; i++) { if (file_perm & (1 << (8 - i))) { - perm[i] = (char)flags[i % 3]; + perm[i] = flags[i % 3]; } } } @@ -6780,14 +6780,14 @@ long do_searchpair(const char *spat, const char *mpat, const char *epat, int dir // Make two search patterns: start/end (pat2, for in nested pairs) and // start/middle/end (pat3, for the top pair). const size_t pat2_len = strlen(spat) + strlen(epat) + 17; - char_u *pat2 = xmalloc(pat2_len); + char *pat2 = xmalloc(pat2_len); const size_t pat3_len = strlen(spat) + strlen(mpat) + strlen(epat) + 25; - char_u *pat3 = xmalloc(pat3_len); - snprintf((char *)pat2, pat2_len, "\\m\\(%s\\m\\)\\|\\(%s\\m\\)", spat, epat); + char *pat3 = xmalloc(pat3_len); + snprintf(pat2, pat2_len, "\\m\\(%s\\m\\)\\|\\(%s\\m\\)", spat, epat); if (*mpat == NUL) { STRCPY(pat3, pat2); } else { - snprintf((char *)pat3, pat3_len, + snprintf(pat3, pat3_len, "\\m\\(%s\\m\\)\\|\\(%s\\m\\)\\|\\(%s\\m\\)", spat, epat, mpat); } if (flags & SP_START) { @@ -6804,14 +6804,14 @@ long do_searchpair(const char *spat, const char *mpat, const char *epat, int dir clearpos(&firstpos); pos_T foundpos; clearpos(&foundpos); - char_u *pat = pat3; + char *pat = pat3; for (;;) { searchit_arg_T sia = { .sa_stop_lnum = lnum_stop, .sa_tm = &tm, }; - int n = searchit(curwin, curbuf, &pos, NULL, dir, pat, 1L, + int n = searchit(curwin, curbuf, &pos, NULL, dir, (char_u *)pat, 1L, options, RE_SEARCH, &sia); if (n == FAIL || (firstpos.lnum != 0 && equalpos(pos, firstpos))) { // didn't find it or found the first match again: FAIL @@ -7755,10 +7755,10 @@ static void f_str2float(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) static void f_str2list(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) { tv_list_alloc_ret(rettv, kListLenUnknown); - const char_u *p = (const char_u *)tv_get_string(&argvars[0]); + const char *p = tv_get_string(&argvars[0]); - for (; *p != NUL; p += utf_ptr2len((char *)p)) { - tv_list_append_number(rettv->vval.v_list, utf_ptr2char((char *)p)); + for (; *p != NUL; p += utf_ptr2len(p)) { + tv_list_append_number(rettv->vval.v_list, utf_ptr2char(p)); } } @@ -7779,10 +7779,10 @@ static void f_str2nr(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) } } - char_u *p = (char_u *)skipwhite(tv_get_string(&argvars[0])); + char *p = skipwhite(tv_get_string(&argvars[0])); bool isneg = (*p == '-'); if (*p == '+' || *p == '-') { - p = (char_u *)skipwhite((char *)p + 1); + p = skipwhite(p + 1); } switch (base) { case 2: @@ -7796,7 +7796,7 @@ static void f_str2nr(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) break; } varnumber_T n; - vim_str2nr((char *)p, NULL, NULL, what, &n, NULL, 0, false); + vim_str2nr(p, NULL, NULL, what, &n, NULL, 0, false); // Text after the number is silently ignored. if (isneg) { rettv->vval.v_number = -n; @@ -8372,7 +8372,7 @@ static void f_synconcealed(typval_T *argvars, typval_T *rettv, EvalFuncData fptr int syntax_flags = 0; int cchar; int matchid = 0; - char_u str[NUMBUFLEN]; + char str[NUMBUFLEN]; tv_list_set_ret(rettv, NULL); @@ -8396,7 +8396,7 @@ static void f_synconcealed(typval_T *argvars, typval_T *rettv, EvalFuncData fptr : curwin->w_p_lcs_chars.conceal; } if (cchar != NUL) { - utf_char2bytes(cchar, (char *)str); + utf_char2bytes(cchar, str); } } } @@ -8404,7 +8404,7 @@ static void f_synconcealed(typval_T *argvars, typval_T *rettv, EvalFuncData fptr tv_list_alloc_ret(rettv, 3); tv_list_append_number(rettv->vval.v_list, (syntax_flags & HL_CONCEAL) != 0); // -1 to auto-determine strlen - tv_list_append_string(rettv->vval.v_list, (const char *)str, -1); + tv_list_append_string(rettv->vval.v_list, str, -1); tv_list_append_number(rettv->vval.v_list, matchid); } @@ -8497,7 +8497,7 @@ static void f_taglist(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) fname = tv_get_string(&argvars[1]); } (void)get_tags(tv_list_alloc_ret(rettv, kListLenUnknown), - (char_u *)tag_pattern, (char_u *)fname); + (char *)tag_pattern, (char *)fname); } /// "tempname()" function @@ -8591,9 +8591,9 @@ static void f_termopen(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) int pid = chan->stream.pty.process.pid; // "./…" => "/home/foo/…" - vim_FullName(cwd, (char *)NameBuff, sizeof(NameBuff), false); + vim_FullName(cwd, NameBuff, sizeof(NameBuff), false); // "/home/foo/…" => "~/…" - size_t len = home_replace(NULL, (char *)NameBuff, (char *)IObuff, sizeof(IObuff), true); + size_t len = home_replace(NULL, NameBuff, IObuff, sizeof(IObuff), true); // Trim slash. if (len != 1 && (IObuff[len - 1] == '\\' || IObuff[len - 1] == '/')) { IObuff[len - 1] = '\0'; @@ -8606,14 +8606,14 @@ static void f_termopen(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) } // Terminal URI: "term://$CWD//$PID:$CMD" - snprintf((char *)NameBuff, sizeof(NameBuff), "term://%s//%d:%s", - (char *)IObuff, pid, cmd); + snprintf(NameBuff, sizeof(NameBuff), "term://%s//%d:%s", + IObuff, pid, cmd); // at this point the buffer has no terminal instance associated yet, so unset // the 'swapfile' option to ensure no swap file will be created curbuf->b_p_swf = false; apply_autocmds(EVENT_BUFFILEPRE, NULL, NULL, false, curbuf); - (void)setfname(curbuf, (char *)NameBuff, NULL, true); + (void)setfname(curbuf, NameBuff, NULL, true); apply_autocmds(EVENT_BUFFILEPOST, NULL, NULL, false, curbuf); // Save the job id and pid in b:terminal_job_{id,pid} diff --git a/src/nvim/eval/userfunc.c b/src/nvim/eval/userfunc.c index 9f6aa0776c..54c4285453 100644 --- a/src/nvim/eval/userfunc.c +++ b/src/nvim/eval/userfunc.c @@ -259,13 +259,13 @@ int get_lambda_tv(char **arg, typval_T *rettv, bool evaluate) partial_T *pt = NULL; int varargs; int ret; - char_u *start = (char_u *)skipwhite(*arg + 1); + char *start = skipwhite(*arg + 1); char *s, *e; bool *old_eval_lavars = eval_lavars_used; bool eval_lavars = false; // First, check if this is a lambda expression. "->" must exists. - ret = get_function_args((char **)&start, '-', NULL, NULL, NULL, true); + ret = get_function_args(&start, '-', NULL, NULL, NULL, true); if (ret == FAIL || *start != '>') { return NOTDONE; } @@ -2765,7 +2765,7 @@ char *get_user_func_name(expand_T *xp, int idx) STRCAT(IObuff, ")"); } } - return (char *)IObuff; + return IObuff; } return NULL; } @@ -2950,7 +2950,7 @@ static int can_free_funccal(funccall_T *fc, int copyID) /// ":return [expr]" void ex_return(exarg_T *eap) { - char_u *arg = (char_u *)eap->arg; + char *arg = eap->arg; typval_T rettv; int returning = false; @@ -2965,7 +2965,7 @@ void ex_return(exarg_T *eap) eap->nextcmd = NULL; if ((*arg != NUL && *arg != '|' && *arg != '\n') - && eval0((char *)arg, &rettv, &eap->nextcmd, !eap->skip) != FAIL) { + && eval0(arg, &rettv, &eap->nextcmd, !eap->skip) != FAIL) { if (!eap->skip) { returning = do_return(eap, false, true, &rettv); } else { @@ -2988,7 +2988,7 @@ void ex_return(exarg_T *eap) if (returning) { eap->nextcmd = NULL; } else if (eap->nextcmd == NULL) { // no argument - eap->nextcmd = check_nextcmd((char *)arg); + eap->nextcmd = check_nextcmd(arg); } if (eap->skip) { @@ -2999,9 +2999,9 @@ void ex_return(exarg_T *eap) /// ":1,25call func(arg1, arg2)" function call. void ex_call(exarg_T *eap) { - char_u *arg = (char_u *)eap->arg; - char_u *startarg; - char_u *name; + char *arg = eap->arg; + char *startarg; + char *name; char *tofree; int len; typval_T rettv; @@ -3023,7 +3023,7 @@ void ex_call(exarg_T *eap) return; } - tofree = (char *)trans_function_name((char **)&arg, false, TFN_INT, &fudi, &partial); + tofree = (char *)trans_function_name(&arg, false, TFN_INT, &fudi, &partial); if (fudi.fd_newkey != NULL) { // Still need to give an error message for missing key. semsg(_(e_dictkey), fudi.fd_newkey); @@ -3043,11 +3043,11 @@ void ex_call(exarg_T *eap) // contents. For VAR_PARTIAL get its partial, unless we already have one // from trans_function_name(). len = (int)strlen(tofree); - name = deref_func_name(tofree, &len, partial != NULL ? NULL : &partial, false); + name = (char *)deref_func_name(tofree, &len, partial != NULL ? NULL : &partial, false); // Skip white space to allow ":call func ()". Not good, but required for // backward compatibility. - startarg = (char_u *)skipwhite((char *)arg); + startarg = skipwhite(arg); rettv.v_type = VAR_UNKNOWN; // tv_clear() uses this. if (*startarg != '(') { @@ -3077,7 +3077,7 @@ void ex_call(exarg_T *eap) funcexe.fe_evaluate = true; funcexe.fe_partial = partial; funcexe.fe_selfdict = fudi.fd_dict; - if (get_func_tv(name, -1, &rettv, (char **)&arg, &funcexe) == FAIL) { + if (get_func_tv((char_u *)name, -1, &rettv, &arg, &funcexe) == FAIL) { failed = true; break; } @@ -3114,7 +3114,7 @@ void ex_call(exarg_T *eap) semsg(_(e_trailing_arg), arg); } } else { - eap->nextcmd = check_nextcmd((char *)arg); + eap->nextcmd = check_nextcmd(arg); } } @@ -3219,7 +3219,7 @@ char *get_return_cmd(void *rettv) STRCPY(IObuff + IOSIZE - 4, "..."); } xfree(tofree); - return xstrdup((char *)IObuff); + return xstrdup(IObuff); } /// Get next function line. @@ -3296,21 +3296,21 @@ int func_has_abort(void *cookie) /// Changes "rettv" in-place. void make_partial(dict_T *const selfdict, typval_T *const rettv) { - char_u *fname; - char_u *tofree = NULL; + char *fname; + char *tofree = NULL; ufunc_T *fp; - char_u fname_buf[FLEN_FIXED + 1]; + char fname_buf[FLEN_FIXED + 1]; int error; if (rettv->v_type == VAR_PARTIAL && rettv->vval.v_partial->pt_func != NULL) { fp = rettv->vval.v_partial->pt_func; } else { fname = rettv->v_type == VAR_FUNC || rettv->v_type == VAR_STRING - ? (char_u *)rettv->vval.v_string - : (char_u *)rettv->vval.v_partial->pt_name; + ? rettv->vval.v_string + : rettv->vval.v_partial->pt_name; // Translate "s:func" to the stored function name. - fname = (char_u *)fname_trans_sid((char *)fname, (char *)fname_buf, (char **)&tofree, &error); - fp = find_func(fname); + fname = fname_trans_sid(fname, (char *)fname_buf, &tofree, &error); + fp = find_func((char_u *)fname); xfree(tofree); } @@ -3646,17 +3646,17 @@ bool set_ref_in_func(char_u *name, ufunc_T *fp_in, int copyID) ufunc_T *fp = fp_in; funccall_T *fc; int error = FCERR_NONE; - char_u fname_buf[FLEN_FIXED + 1]; - char_u *tofree = NULL; - char_u *fname; + char fname_buf[FLEN_FIXED + 1]; + char *tofree = NULL; + char *fname; bool abort = false; if (name == NULL && fp_in == NULL) { return false; } if (fp_in == NULL) { - fname = (char_u *)fname_trans_sid((char *)name, (char *)fname_buf, (char **)&tofree, &error); - fp = find_func(fname); + fname = fname_trans_sid((char *)name, (char *)fname_buf, &tofree, &error); + fp = find_func((char_u *)fname); } if (fp != NULL) { for (fc = fp->uf_scoped; fc != NULL; fc = fc->func->uf_scoped) { diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c index 8d230c699d..8861d0e7e3 100644 --- a/src/nvim/ex_cmds.c +++ b/src/nvim/ex_cmds.c @@ -160,12 +160,12 @@ void do_ascii(const exarg_T *const eap) dig = (char *)get_digraph_for_char(cval); if (dig != NULL) { - iobuff_len += (size_t)vim_snprintf((char *)IObuff + iobuff_len, + iobuff_len += (size_t)vim_snprintf(IObuff + iobuff_len, sizeof(IObuff) - iobuff_len, _("<%s>%s%s %d, Hex %02x, Oct %03o, Digr %s"), transchar(c), buf1, buf2, cval, cval, cval, dig); } else { - iobuff_len += (size_t)vim_snprintf((char *)IObuff + iobuff_len, + iobuff_len += (size_t)vim_snprintf(IObuff + iobuff_len, sizeof(IObuff) - iobuff_len, _("<%s>%s%s %d, Hex %02x, Octal %03o"), transchar(c), buf1, buf2, cval, cval, cval); @@ -204,18 +204,18 @@ void do_ascii(const exarg_T *const eap) if (utf_iscomposing(c)) { IObuff[iobuff_len++] = ' '; // Draw composing char on top of a space. } - iobuff_len += (size_t)utf_char2bytes(c, (char *)IObuff + iobuff_len); + iobuff_len += (size_t)utf_char2bytes(c, IObuff + iobuff_len); dig = (char *)get_digraph_for_char(c); if (dig != NULL) { - iobuff_len += (size_t)vim_snprintf((char *)IObuff + iobuff_len, + iobuff_len += (size_t)vim_snprintf(IObuff + iobuff_len, sizeof(IObuff) - iobuff_len, (c < 0x10000 ? _("> %d, Hex %04x, Oct %o, Digr %s") : _("> %d, Hex %08x, Oct %o, Digr %s")), c, c, c, dig); } else { - iobuff_len += (size_t)vim_snprintf((char *)IObuff + iobuff_len, + iobuff_len += (size_t)vim_snprintf(IObuff + iobuff_len, sizeof(IObuff) - iobuff_len, (c < 0x10000 ? _("> %d, Hex %04x, Octal %o") @@ -228,10 +228,10 @@ void do_ascii(const exarg_T *const eap) c = cc[ci++]; } if (ci != MAX_MCO && c != 0) { - xstrlcpy((char *)IObuff + iobuff_len, " ...", sizeof(IObuff) - iobuff_len); + xstrlcpy(IObuff + iobuff_len, " ...", sizeof(IObuff) - iobuff_len); } - msg((char *)IObuff); + msg(IObuff); } /// ":left", ":center" and ":right": align text. diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index 7921fe0fc2..e847f74289 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -869,10 +869,10 @@ void handle_did_throw(void) // interrupt message is given elsewhere. switch (current_exception->type) { case ET_USER: - vim_snprintf((char *)IObuff, IOSIZE, + vim_snprintf(IObuff, IOSIZE, _("E605: Exception not caught: %s"), current_exception->value); - p = xstrdup((char *)IObuff); + p = xstrdup(IObuff); break; case ET_ERROR: messages = current_exception->messages; @@ -1445,7 +1445,7 @@ bool parse_cmdline(char *cmdline, exarg_T *eap, CmdParseInfo *cmdinfo, char **er // If the modifier was parsed OK the error must be in the following command char *cmdname = after_modifier ? after_modifier : cmdline; append_command(cmdname); - *errormsg = (char *)IObuff; + *errormsg = IObuff; goto end; } @@ -2038,7 +2038,7 @@ static char *do_one_cmd(char **cmdlinep, int flags, cstack_T *cstack, LineGetter if (!(flags & DOCMD_VERBOSE)) { append_command(cmdname); } - errormsg = (char *)IObuff; + errormsg = IObuff; did_emsg_syntax = true; verify_command(cmdname); } @@ -2307,9 +2307,9 @@ doend: if (errormsg != NULL && *errormsg != NUL && !did_emsg) { if (flags & DOCMD_VERBOSE) { - if (errormsg != (char *)IObuff) { + if (errormsg != IObuff) { STRCPY(IObuff, errormsg); - errormsg = (char *)IObuff; + errormsg = IObuff; } append_command(*ea.cmdlinep); } @@ -2870,8 +2870,8 @@ static void append_command(char *cmd) if (len > IOSIZE - 100) { // Not enough space, truncate and put in "...". - d = (char *)IObuff + IOSIZE - 100; - d -= utf_head_off((char *)IObuff, d); + d = IObuff + IOSIZE - 100; + d -= utf_head_off(IObuff, d); STRCPY(d, "..."); } STRCAT(IObuff, ": "); @@ -3840,7 +3840,7 @@ int expand_filename(exarg_T *eap, char **cmdlinep, char **errormsgp) || vim_strchr(eap->arg, '~') != NULL) { expand_env_esc(eap->arg, NameBuff, MAXPATHL, true, true, NULL); has_wildcards = path_has_wildcard(NameBuff); - p = (char *)NameBuff; + p = NameBuff; } else { p = NULL; } @@ -5089,8 +5089,8 @@ static void ex_tabs(exarg_T *eap) } msg_putchar('\n'); - vim_snprintf((char *)IObuff, IOSIZE, _("Tab page %d"), tabcount++); - msg_outtrans_attr((char *)IObuff, HL_ATTR(HLF_T)); + vim_snprintf(IObuff, IOSIZE, _("Tab page %d"), tabcount++); + msg_outtrans_attr(IObuff, HL_ATTR(HLF_T)); os_breakcheck(); FOR_ALL_WINDOWS_IN_TAB(wp, tp) { @@ -5106,9 +5106,9 @@ static void ex_tabs(exarg_T *eap) if (buf_spname(wp->w_buffer) != NULL) { xstrlcpy(IObuff, buf_spname(wp->w_buffer), IOSIZE); } else { - home_replace(wp->w_buffer, wp->w_buffer->b_fname, (char *)IObuff, IOSIZE, true); + home_replace(wp->w_buffer, wp->w_buffer->b_fname, IObuff, IOSIZE, true); } - msg_outtrans((char *)IObuff); + msg_outtrans(IObuff); os_breakcheck(); } } @@ -5559,7 +5559,7 @@ bool changedir_func(char *new_dir, CdScope scope) #endif // Use NameBuff for home directory name. expand_env("$HOME", NameBuff, MAXPATHL); - new_dir = (char *)NameBuff; + new_dir = NameBuff; } bool dir_differs = pdir == NULL || pathcmp(pdir, new_dir, -1) != 0; @@ -5640,9 +5640,9 @@ static void ex_pwd(exarg_T *eap) } else if (curtab->tp_localdir != NULL) { context = "tabpage"; } - smsg("[%s] %s", context, (char *)NameBuff); + smsg("[%s] %s", context, NameBuff); } else { - msg((char *)NameBuff); + msg(NameBuff); } } else { emsg(_("E187: Unknown")); diff --git a/src/nvim/ex_eval.c b/src/nvim/ex_eval.c index 137e94145a..6450892e39 100644 --- a/src/nvim/ex_eval.c +++ b/src/nvim/ex_eval.c @@ -538,7 +538,7 @@ static void discard_exception(except_T *excp, bool was_finished) if (p_verbose >= 13 || debug_break_level > 0) { int save_msg_silent = msg_silent; - saved_IObuff = xstrdup((char *)IObuff); + saved_IObuff = xstrdup(IObuff); if (debug_break_level > 0) { msg_silent = false; // display messages } else { @@ -592,12 +592,12 @@ static void catch_exception(except_T *excp) set_vim_var_string(VV_EXCEPTION, excp->value, -1); if (*excp->throw_name != NUL) { if (excp->throw_lnum != 0) { - vim_snprintf((char *)IObuff, IOSIZE, _("%s, line %" PRId64), + vim_snprintf(IObuff, IOSIZE, _("%s, line %" PRId64), excp->throw_name, (int64_t)excp->throw_lnum); } else { - vim_snprintf((char *)IObuff, IOSIZE, "%s", excp->throw_name); + vim_snprintf(IObuff, IOSIZE, "%s", excp->throw_name); } - set_vim_var_string(VV_THROWPOINT, (char *)IObuff, -1); + set_vim_var_string(VV_THROWPOINT, IObuff, -1); } else { // throw_name not set on an exception from a command that was typed. set_vim_var_string(VV_THROWPOINT, NULL, -1); @@ -641,14 +641,14 @@ static void finish_exception(except_T *excp) set_vim_var_string(VV_EXCEPTION, caught_stack->value, -1); if (*caught_stack->throw_name != NUL) { if (caught_stack->throw_lnum != 0) { - vim_snprintf((char *)IObuff, IOSIZE, + vim_snprintf(IObuff, IOSIZE, _("%s, line %" PRId64), caught_stack->throw_name, (int64_t)caught_stack->throw_lnum); } else { - vim_snprintf((char *)IObuff, IOSIZE, "%s", + vim_snprintf(IObuff, IOSIZE, "%s", caught_stack->throw_name); } - set_vim_var_string(VV_THROWPOINT, (char *)IObuff, -1); + set_vim_var_string(VV_THROWPOINT, IObuff, -1); } else { // throw_name not set on an exception from a command that was // typed. @@ -714,9 +714,9 @@ static void report_pending(int action, int pending, void *value) default: if (pending & CSTP_THROW) { - vim_snprintf((char *)IObuff, IOSIZE, + vim_snprintf(IObuff, IOSIZE, mesg, _("Exception")); - mesg = concat_str((char *)IObuff, ": %s"); + mesg = concat_str(IObuff, ": %s"); s = ((except_T *)value)->value; } else if ((pending & CSTP_ERROR) && (pending & CSTP_INTERRUPT)) { s = _("Error and interrupt"); diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 16aaca8a24..93d137eab9 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -2099,7 +2099,7 @@ static int command_line_handle_key(CommandLineState *s) if (IS_SPECIAL(s->c) || mod_mask != 0) { put_on_cmdline(get_special_key_name(s->c, mod_mask), -1, true); } else { - int j = utf_char2bytes(s->c, (char *)IObuff); + int j = utf_char2bytes(s->c, IObuff); IObuff[j] = NUL; // exclude composing chars put_on_cmdline((char_u *)IObuff, j, true); } diff --git a/src/nvim/file_search.c b/src/nvim/file_search.c index b1742c04c3..5c5839cb08 100644 --- a/src/nvim/file_search.c +++ b/src/nvim/file_search.c @@ -1408,7 +1408,7 @@ char *find_file_in_path_option(char *ptr, size_t len, int options, int first, ch && rel_fname != NULL && strlen(rel_fname) + l < MAXPATHL) { STRCPY(NameBuff, rel_fname); - STRCPY(path_tail((char *)NameBuff), ff_file_to_find); + STRCPY(path_tail(NameBuff), ff_file_to_find); l = strlen(NameBuff); } else { STRCPY(NameBuff, ff_file_to_find); @@ -1429,7 +1429,7 @@ char *find_file_in_path_option(char *ptr, size_t len, int options, int first, ch break; } assert(MAXPATHL >= l); - copy_option_part(&buf, (char *)NameBuff + l, MAXPATHL - l, ","); + copy_option_part(&buf, NameBuff + l, MAXPATHL - l, ","); } } } @@ -1587,7 +1587,7 @@ int vim_chdirfile(char *fname, CdCause cause) NameBuff[0] = NUL; } - if (pathcmp(dir, (char *)NameBuff, -1) == 0) { + if (pathcmp(dir, NameBuff, -1) == 0) { // nothing to do return OK; } diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c index 6ebc382ab5..fb45157d9c 100644 --- a/src/nvim/fileio.c +++ b/src/nvim/fileio.c @@ -138,7 +138,7 @@ void filemess(buf_T *buf, char *name, char *s, int attr) if (msg_silent != 0) { return; } - add_quoted_fname((char *)IObuff, IOSIZE - 100, buf, (const char *)name); + add_quoted_fname(IObuff, IOSIZE - 100, buf, (const char *)name); // Avoid an over-long translation to cause trouble. xstrlcat(IObuff, s, IOSIZE); // For the first message may have to start a new line. @@ -155,7 +155,7 @@ void filemess(buf_T *buf, char *name, char *s, int attr) msg_scroll = msg_scroll_save; msg_scrolled_ign = true; // may truncate the message to avoid a hit-return prompt - msg_outtrans_attr(msg_may_trunc(false, (char *)IObuff), attr); + msg_outtrans_attr(msg_may_trunc(false, IObuff), attr); msg_clr_eos(); ui_flush(); msg_scrolled_ign = false; @@ -1758,7 +1758,7 @@ failed: } if (!filtering && !(flags & READ_DUMMY) && !silent) { - add_quoted_fname((char *)IObuff, IOSIZE, curbuf, (const char *)sfname); + add_quoted_fname(IObuff, IOSIZE, curbuf, (const char *)sfname); c = false; #ifdef UNIX @@ -1823,7 +1823,7 @@ failed: msg_scrolled_ign = true; if (!read_stdin && !read_buffer) { - p = (char_u *)msg_trunc_attr((char *)IObuff, false, 0); + p = (char_u *)msg_trunc_attr(IObuff, false, 0); } if (read_stdin || read_buffer || restart_edit != 0 @@ -2615,21 +2615,21 @@ int buf_write(buf_T *buf, char *fname, char *sfname, linenr_T start, linenr_T en // arbitrary numbers). STRCPY(IObuff, fname); for (i = 4913;; i += 123) { - char *tail = path_tail((char *)IObuff); + char *tail = path_tail(IObuff); size_t size = (size_t)(tail - IObuff); snprintf(tail, IOSIZE - size, "%d", i); - if (!os_fileinfo_link((char *)IObuff, &file_info)) { + if (!os_fileinfo_link(IObuff, &file_info)) { break; } } - fd = os_open((char *)IObuff, + fd = os_open(IObuff, O_CREAT|O_WRONLY|O_EXCL|O_NOFOLLOW, (int)perm); if (fd < 0) { // can't write in directory backup_copy = true; } else { #ifdef UNIX os_fchown(fd, (uv_uid_t)file_info_old.stat.st_uid, (uv_gid_t)file_info_old.stat.st_gid); - if (!os_fileinfo((char *)IObuff, &file_info) + if (!os_fileinfo(IObuff, &file_info) || file_info.stat.st_uid != file_info_old.stat.st_uid || file_info.stat.st_gid != file_info_old.stat.st_gid || (long)file_info.stat.st_mode != perm) { @@ -2639,7 +2639,7 @@ int buf_write(buf_T *buf, char *fname, char *sfname, linenr_T start, linenr_T en // Close the file before removing it, on MS-Windows we // can't delete an open file. close(fd); - os_remove((char *)IObuff); + os_remove(IObuff); } } } @@ -2693,16 +2693,16 @@ int buf_write(buf_T *buf, char *fname, char *sfname, linenr_T start, linenr_T en dirp = p_bdir; while (*dirp) { // Isolate one directory name, using an entry in 'bdir'. - size_t dir_len = copy_option_part(&dirp, (char *)IObuff, IOSIZE, ","); - p = (char *)IObuff + dir_len; - bool trailing_pathseps = after_pathsep((char *)IObuff, p) && p[-1] == p[-2]; + size_t dir_len = copy_option_part(&dirp, IObuff, IOSIZE, ","); + p = IObuff + dir_len; + bool trailing_pathseps = after_pathsep(IObuff, p) && p[-1] == p[-2]; if (trailing_pathseps) { IObuff[dir_len - 2] = NUL; } - if (*dirp == NUL && !os_isdir((char *)IObuff)) { + if (*dirp == NUL && !os_isdir(IObuff)) { int ret; char *failed_dir; - if ((ret = os_mkdir_recurse((char *)IObuff, 0755, &failed_dir)) != 0) { + if ((ret = os_mkdir_recurse(IObuff, 0755, &failed_dir)) != 0) { semsg(_("E303: Unable to create directory \"%s\" for backup file: %s"), failed_dir, os_strerror(ret)); xfree(failed_dir); @@ -2710,14 +2710,14 @@ int buf_write(buf_T *buf, char *fname, char *sfname, linenr_T start, linenr_T en } if (trailing_pathseps) { // Ends with '//', Use Full path - if ((p = make_percent_swname((char *)IObuff, fname)) + if ((p = make_percent_swname(IObuff, fname)) != NULL) { backup = modname(p, backup_ext, no_prepend_dot); xfree(p); } } - rootname = get_file_in_dir(fname, (char *)IObuff); + rootname = get_file_in_dir(fname, IObuff); if (rootname == NULL) { some_error = true; // out of memory goto nobackup; @@ -2844,16 +2844,16 @@ nobackup: dirp = p_bdir; while (*dirp) { // Isolate one directory name and make the backup file name. - size_t dir_len = copy_option_part(&dirp, (char *)IObuff, IOSIZE, ","); - p = (char *)IObuff + dir_len; - bool trailing_pathseps = after_pathsep((char *)IObuff, p) && p[-1] == p[-2]; + size_t dir_len = copy_option_part(&dirp, IObuff, IOSIZE, ","); + p = IObuff + dir_len; + bool trailing_pathseps = after_pathsep(IObuff, p) && p[-1] == p[-2]; if (trailing_pathseps) { IObuff[dir_len - 2] = NUL; } - if (*dirp == NUL && !os_isdir((char *)IObuff)) { + if (*dirp == NUL && !os_isdir(IObuff)) { int ret; char *failed_dir; - if ((ret = os_mkdir_recurse((char *)IObuff, 0755, &failed_dir)) != 0) { + if ((ret = os_mkdir_recurse(IObuff, 0755, &failed_dir)) != 0) { semsg(_("E303: Unable to create directory \"%s\" for backup file: %s"), failed_dir, os_strerror(ret)); xfree(failed_dir); @@ -2861,7 +2861,7 @@ nobackup: } if (trailing_pathseps) { // path ends with '//', use full path - if ((p = make_percent_swname((char *)IObuff, fname)) + if ((p = make_percent_swname(IObuff, fname)) != NULL) { backup = modname(p, backup_ext, no_prepend_dot); xfree(p); @@ -2869,7 +2869,7 @@ nobackup: } if (backup == NULL) { - rootname = get_file_in_dir(fname, (char *)IObuff); + rootname = get_file_in_dir(fname, IObuff); if (rootname == NULL) { backup = NULL; } else { @@ -3419,13 +3419,13 @@ restore_backup: fname = sfname; // use shortname now, for the messages #endif if (!filtering) { - add_quoted_fname((char *)IObuff, IOSIZE, buf, (const char *)fname); + add_quoted_fname(IObuff, IOSIZE, buf, (const char *)fname); c = false; if (write_info.bw_conv_error) { STRCAT(IObuff, _(" CONVERSION ERROR")); c = true; if (write_info.bw_conv_error_lnum != 0) { - vim_snprintf_add((char *)IObuff, IOSIZE, _(" in line %" PRId64 ";"), + vim_snprintf_add(IObuff, IOSIZE, _(" in line %" PRId64 ";"), (int64_t)write_info.bw_conv_error_lnum); } } else if (notconverted) { @@ -3459,7 +3459,7 @@ restore_backup: } } - set_keep_msg(msg_trunc_attr((char *)IObuff, false, 0), 0); + set_keep_msg(msg_trunc_attr(IObuff, false, 0), 0); } // When written everything correctly: reset 'modified'. Unless not @@ -3564,9 +3564,9 @@ nofail: if (errmsg != NULL) { // - 100 to save some space for further error message #ifndef UNIX - add_quoted_fname((char *)IObuff, IOSIZE - 100, buf, (const char *)sfname); + add_quoted_fname(IObuff, IOSIZE - 100, buf, (const char *)sfname); #else - add_quoted_fname((char *)IObuff, IOSIZE - 100, buf, (const char *)fname); + add_quoted_fname(IObuff, IOSIZE - 100, buf, (const char *)fname); #endif if (errnum != NULL) { if (errmsgarg != 0) { @@ -5317,7 +5317,7 @@ int delete_recursive(const char *name) garray_T ga; if (readdir_core(&ga, exp, NULL, NULL) == OK) { for (int i = 0; i < ga.ga_len; i++) { - vim_snprintf((char *)NameBuff, MAXPATHL, "%s/%s", exp, ((char_u **)ga.ga_data)[i]); + vim_snprintf(NameBuff, MAXPATHL, "%s/%s", exp, ((char_u **)ga.ga_data)[i]); if (delete_recursive((const char *)NameBuff) != 0) { // Remember the failure but continue deleting any further // entries. diff --git a/src/nvim/getchar.c b/src/nvim/getchar.c index 5a2589cc66..b9e3b6b902 100644 --- a/src/nvim/getchar.c +++ b/src/nvim/getchar.c @@ -1275,7 +1275,7 @@ void openscript(char *name, bool directly) // use NameBuff for expanded name expand_env(name, NameBuff, MAXPATHL); int error; - if ((scriptin[curscript] = file_open_new(&error, (char *)NameBuff, + if ((scriptin[curscript] = file_open_new(&error, NameBuff, kFileReadOnly, 0)) == NULL) { semsg(_(e_notopen_2), name, os_strerror(error)); if (curscript) { diff --git a/src/nvim/help.c b/src/nvim/help.c index af28c37910..0a695a0aa7 100644 --- a/src/nvim/help.c +++ b/src/nvim/help.c @@ -372,7 +372,7 @@ int find_help_tags(const char *arg, int *num_matches, char ***matches, bool keep "!=?", "!~?", "<=?", "<?", "==?", "=~?", ">=?", ">?", "is?", "isnot?" }; - char *d = (char *)IObuff; // assume IObuff is long enough! + char *d = IObuff; // assume IObuff is long enough! d[0] = NUL; if (STRNICMP(arg, "expr-", 5) == 0) { @@ -550,7 +550,7 @@ int find_help_tags(const char *arg, int *num_matches, char ***matches, bool keep if (keep_lang) { flags |= TAG_KEEP_LANG; } - if (find_tags((char *)IObuff, num_matches, matches, flags, MAXCOL, NULL) == OK + if (find_tags(IObuff, num_matches, matches, flags, MAXCOL, NULL) == OK && *num_matches > 0) { // Sort the matches found on the heuristic number that is after the // tag name. @@ -716,10 +716,10 @@ void fix_help_buffer(void) // $VIMRUNTIME. char *p = p_rtp; while (*p != NUL) { - copy_option_part(&p, (char *)NameBuff, MAXPATHL, ","); + copy_option_part(&p, NameBuff, MAXPATHL, ","); char *const rt = vim_getenv("VIMRUNTIME"); if (rt != NULL - && path_full_compare(rt, (char *)NameBuff, false, true) != kEqualFiles) { + && path_full_compare(rt, NameBuff, false, true) != kEqualFiles) { int fcount; char **fnames; char *s; @@ -727,7 +727,7 @@ void fix_help_buffer(void) char *cp; // Find all "doc/ *.txt" files in this directory. - if (!add_pathsep((char *)NameBuff) + if (!add_pathsep(NameBuff) || xstrlcat(NameBuff, "doc/*.??[tx]", // NOLINT sizeof(NameBuff)) >= MAXPATHL) { emsg(_(e_fnametoolong)); @@ -736,7 +736,7 @@ void fix_help_buffer(void) // Note: We cannot just do `&NameBuff` because it is a statically sized array // so `NameBuff == &NameBuff` according to C semantics. - char *buff_list[1] = { (char *)NameBuff }; + char *buff_list[1] = { NameBuff }; if (gen_expand_wildcards(1, buff_list, &fcount, &fnames, EW_FILE|EW_SILENT) == OK && fcount > 0) { @@ -785,7 +785,7 @@ void fix_help_buffer(void) } vim_fgets(IObuff, IOSIZE, fd); if (IObuff[0] == '*' - && (s = vim_strchr((char *)IObuff + 1, '*')) + && (s = vim_strchr(IObuff + 1, '*')) != NULL) { TriState this_utf = kNone; // Change tag definition to a @@ -818,13 +818,13 @@ void fix_help_buffer(void) p_enc); if (vc.vc_type == CONV_NONE) { // No conversion needed. - cp = (char *)IObuff; + cp = IObuff; } else { // Do the conversion. If it fails // use the unconverted text. - cp = string_convert(&vc, (char *)IObuff, NULL); + cp = string_convert(&vc, IObuff, NULL); if (cp == NULL) { - cp = (char *)IObuff; + cp = IObuff; } } convert_setup(&vc, NULL, NULL); @@ -890,7 +890,7 @@ static void helptags_one(char *dir, const char *ext, const char *tagfname, bool // Note: We cannot just do `&NameBuff` because it is a statically sized array // so `NameBuff == &NameBuff` according to C semantics. - char *buff_list[1] = { (char *)NameBuff }; + char *buff_list[1] = { NameBuff }; const int res = gen_expand_wildcards(1, buff_list, &filecount, &files, EW_FILE|EW_SILENT); if (res == FAIL || filecount == 0) { @@ -906,13 +906,13 @@ static void helptags_one(char *dir, const char *ext, const char *tagfname, bool // Open the tags file for writing. // Do this before scanning through all the files. memcpy(NameBuff, dir, dirlen + 1); - if (!add_pathsep((char *)NameBuff) + if (!add_pathsep(NameBuff) || xstrlcat(NameBuff, tagfname, sizeof(NameBuff)) >= MAXPATHL) { emsg(_(e_fnametoolong)); return; } - FILE *const fd_tags = os_fopen((char *)NameBuff, "w"); + FILE *const fd_tags = os_fopen(NameBuff, "w"); if (fd_tags == NULL) { if (!ignore_writeerr) { semsg(_("E152: Cannot open %s for writing"), NameBuff); @@ -947,7 +947,7 @@ static void helptags_one(char *dir, const char *ext, const char *tagfname, bool if (firstline) { // Detect utf-8 file by a non-ASCII char in the first line. TriState this_utf8 = kNone; - for (s = (char *)IObuff; *s != NUL; s++) { + for (s = IObuff; *s != NUL; s++) { if ((char_u)(*s) >= 0x80) { this_utf8 = kTrue; const int l = utf_ptr2len(s); @@ -1033,10 +1033,10 @@ static void helptags_one(char *dir, const char *ext, const char *tagfname, bool while (*p1 == *p2) { if (*p2 == '\t') { *p2 = NUL; - vim_snprintf((char *)NameBuff, MAXPATHL, + vim_snprintf(NameBuff, MAXPATHL, _("E154: Duplicate tag \"%s\" in file %s/%s"), ((char_u **)ga.ga_data)[i], dir, p2 + 1); - emsg((char *)NameBuff); + emsg(NameBuff); *p2 = '\t'; break; } @@ -1098,7 +1098,7 @@ static void do_helptags(char *dirname, bool add_help_tags, bool ignore_writeerr) // Note: We cannot just do `&NameBuff` because it is a statically sized array // so `NameBuff == &NameBuff` according to C semantics. - char *buff_list[1] = { (char *)NameBuff }; + char *buff_list[1] = { NameBuff }; if (gen_expand_wildcards(1, buff_list, &filecount, &files, EW_FILE|EW_SILENT) == FAIL || filecount == 0) { diff --git a/src/nvim/insexpand.c b/src/nvim/insexpand.c index 27d522d759..f2ee299211 100644 --- a/src/nvim/insexpand.c +++ b/src/nvim/insexpand.c @@ -653,7 +653,7 @@ static char_u *ins_compl_infercase_gettext(const char_u *str, int char_len, int // Generate encoding specific output from wide character array. garray_T gap; - char *p = (char *)IObuff; + char *p = IObuff; int i = 0; ga_init(&gap, 1, 500); while (i < char_len) { @@ -662,7 +662,7 @@ static char_u *ins_compl_infercase_gettext(const char_u *str, int char_len, int assert(gap.ga_data != NULL); // suppress clang "Dereference of NULL pointer" p = (char *)gap.ga_data + gap.ga_len; gap.ga_len += utf_char2bytes(wca[i++], p); - } else if ((p - (char *)IObuff) + 6 >= IOSIZE) { + } else if ((p - IObuff) + 6 >= IOSIZE) { // Multi-byte characters can occupy up to five bytes more than // ASCII characters, and we also need one byte for NUL, so when // getting to six bytes from the edge of IObuff switch to using a @@ -1452,9 +1452,9 @@ static void ins_compl_files(int count, char **files, int thesaurus, int flags, r fp = os_fopen(files[i], "r"); // open dictionary file if (flags != DICT_EXACT && !shortmess(SHM_COMPLETIONSCAN)) { msg_hist_off = true; // reset in msg_trunc_attr() - vim_snprintf((char *)IObuff, IOSIZE, + vim_snprintf(IObuff, IOSIZE, _("Scanning dictionary: %s"), files[i]); - (void)msg_trunc_attr((char *)IObuff, true, HL_ATTR(HLF_R)); + (void)msg_trunc_attr(IObuff, true, HL_ATTR(HLF_R)); } if (fp == NULL) { @@ -2880,13 +2880,13 @@ static int process_next_cpt_value(ins_compl_next_state_T *st, int *compl_type_ar } if (!shortmess(SHM_COMPLETIONSCAN)) { msg_hist_off = true; // reset in msg_trunc_attr() - vim_snprintf((char *)IObuff, IOSIZE, _("Scanning: %s"), + vim_snprintf(IObuff, IOSIZE, _("Scanning: %s"), st->ins_buf->b_fname == NULL ? buf_spname(st->ins_buf) : st->ins_buf->b_sfname == NULL ? st->ins_buf->b_fname : st->ins_buf->b_sfname); - (void)msg_trunc_attr((char *)IObuff, true, HL_ATTR(HLF_R)); + (void)msg_trunc_attr(IObuff, true, HL_ATTR(HLF_R)); } } else if (*st->e_cpt == NUL) { status = INS_COMPL_CPT_END; @@ -2911,15 +2911,15 @@ static int process_next_cpt_value(ins_compl_next_state_T *st, int *compl_type_ar compl_type = CTRL_X_TAGS; if (!shortmess(SHM_COMPLETIONSCAN)) { msg_hist_off = true; // reset in msg_trunc_attr() - vim_snprintf((char *)IObuff, IOSIZE, "%s", _("Scanning tags.")); - (void)msg_trunc_attr((char *)IObuff, true, HL_ATTR(HLF_R)); + vim_snprintf(IObuff, IOSIZE, "%s", _("Scanning tags.")); + (void)msg_trunc_attr(IObuff, true, HL_ATTR(HLF_R)); } } else { compl_type = -1; } // in any case e_cpt is advanced to the next entry - (void)copy_option_part(&st->e_cpt, (char *)IObuff, IOSIZE, ","); + (void)copy_option_part(&st->e_cpt, IObuff, IOSIZE, ","); st->found_all = true; if (compl_type == -1) { @@ -3019,7 +3019,7 @@ static void get_next_cmdline_completion(void) { char **matches; int num_matches; - if (expand_cmdline(&compl_xp, (char_u *)compl_pattern, + if (expand_cmdline(&compl_xp, compl_pattern, (int)strlen(compl_pattern), &num_matches, &matches) == EXPAND_OK) { ins_compl_add_matches(num_matches, matches, false); @@ -3067,7 +3067,7 @@ static char_u *ins_comp_get_next_word_or_line(buf_T *ins_buf, pos_T *cur_match_p if (compl_status_adding() && compl_length <= (int)strlen(tmp_ptr)) { tmp_ptr += compl_length; // Skip if already inside a word. - if (vim_iswordp((char_u *)tmp_ptr)) { + if (vim_iswordp(tmp_ptr)) { return NULL; } // Find start of next word. @@ -3483,9 +3483,9 @@ static void ins_compl_show_filename(void) } } msg_hist_off = true; - vim_snprintf((char *)IObuff, IOSIZE, "%s %s%s", lead, + vim_snprintf(IObuff, IOSIZE, "%s %s%s", lead, s > compl_shown_match->cp_fname ? "<" : "", s); - msg((char *)IObuff); + msg(IObuff); msg_hist_off = false; redraw_cmdline = false; // don't overwrite! } @@ -3824,7 +3824,7 @@ static int get_normal_compl_info(char *line, int startcol, colnr_T curs_col) compl_length = curs_col - startcol; } if (p_ic) { - compl_pattern = (char *)str_foldcase((char_u *)line + compl_col, compl_length, NULL, 0); + compl_pattern = str_foldcase(line + compl_col, compl_length, NULL, 0); } else { compl_pattern = xstrnsave(line + compl_col, (size_t)compl_length); } @@ -3833,16 +3833,16 @@ static int get_normal_compl_info(char *line, int startcol, colnr_T curs_col) // we need up to 2 extra chars for the prefix compl_pattern = xmalloc(quote_meta(NULL, (char_u *)line + compl_col, compl_length) + 2); - if (!vim_iswordp((char_u *)line + compl_col) + if (!vim_iswordp(line + compl_col) || (compl_col > 0 - && (vim_iswordp(mb_prevptr((char_u *)line, (char_u *)line + compl_col))))) { + && (vim_iswordp((char *)mb_prevptr((char_u *)line, (char_u *)line + compl_col))))) { prefix = ""; } STRCPY(compl_pattern, prefix); (void)quote_meta((char_u *)compl_pattern + strlen(prefix), (char_u *)line + compl_col, compl_length); } else if (--startcol < 0 - || !vim_iswordp(mb_prevptr((char_u *)line, (char_u *)line + startcol + 1))) { + || !vim_iswordp((char *)mb_prevptr((char_u *)line, (char_u *)line + startcol + 1))) { // Match any word of at least two chars compl_pattern = xstrdup("\\<\\k\\k"); compl_col += curs_col; @@ -3891,7 +3891,7 @@ static int get_wholeline_compl_info(char *line, colnr_T curs_col) compl_length = 0; } if (p_ic) { - compl_pattern = (char *)str_foldcase((char_u *)line + compl_col, compl_length, NULL, 0); + compl_pattern = str_foldcase(line + compl_col, compl_length, NULL, 0); } else { compl_pattern = xstrnsave(line + compl_col, (size_t)compl_length); } diff --git a/src/nvim/lua/executor.c b/src/nvim/lua/executor.c index cd022068ce..12ddbd094f 100644 --- a/src/nvim/lua/executor.c +++ b/src/nvim/lua/executor.c @@ -1052,8 +1052,8 @@ static int nlua_require(lua_State *const lstate) time_push(&rel_time, &start_time); int status = lua_pcall(lstate, 1, 1, 0); if (status == 0) { - vim_snprintf((char *)IObuff, IOSIZE, "require('%s')", name); - time_msg((char *)IObuff, &start_time); + vim_snprintf(IObuff, IOSIZE, "require('%s')", name); + time_msg(IObuff, &start_time); } time_pop(rel_time); @@ -1342,7 +1342,7 @@ void nlua_typval_eval(const String str, typval_T *const arg, typval_T *const ret const size_t lcmd_len = sizeof(EVALHEADER) - 1 + str.size + 1; char *lcmd; if (lcmd_len < IOSIZE) { - lcmd = (char *)IObuff; + lcmd = IObuff; } else { lcmd = xmalloc(lcmd_len); } @@ -1352,7 +1352,7 @@ void nlua_typval_eval(const String str, typval_T *const arg, typval_T *const ret #undef EVALHEADER nlua_typval_exec(lcmd, lcmd_len, "luaeval()", arg, 1, true, ret_tv); - if (lcmd != (char *)IObuff) { + if (lcmd != IObuff) { xfree(lcmd); } } @@ -1366,7 +1366,7 @@ void nlua_typval_call(const char *str, size_t len, typval_T *const args, int arg const size_t lcmd_len = sizeof(CALLHEADER) - 1 + len + sizeof(CALLSUFFIX) - 1; char *lcmd; if (lcmd_len < IOSIZE) { - lcmd = (char *)IObuff; + lcmd = IObuff; } else { lcmd = xmalloc(lcmd_len); } @@ -1379,7 +1379,7 @@ void nlua_typval_call(const char *str, size_t len, typval_T *const args, int arg nlua_typval_exec(lcmd, lcmd_len, "v:lua", args, argcount, false, ret_tv); - if (lcmd != (char *)IObuff) { + if (lcmd != IObuff) { xfree(lcmd); } } @@ -1645,7 +1645,7 @@ void ex_luado(exarg_T *const eap) + (sizeof(DOEND) - 1)); char *lcmd; if (lcmd_len < IOSIZE) { - lcmd = (char *)IObuff; + lcmd = IObuff; } else { lcmd = xmalloc(lcmd_len + 1); } diff --git a/src/nvim/lua/treesitter.c b/src/nvim/lua/treesitter.c index d77e210c6a..fecf746036 100644 --- a/src/nvim/lua/treesitter.c +++ b/src/nvim/lua/treesitter.c @@ -182,19 +182,19 @@ int tslua_add_language(lua_State *L) uv_lib_t lib; if (uv_dlopen(path, &lib)) { - snprintf((char *)IObuff, IOSIZE, "Failed to load parser: uv_dlopen: %s", + snprintf(IObuff, IOSIZE, "Failed to load parser: uv_dlopen: %s", uv_dlerror(&lib)); uv_dlclose(&lib); - lua_pushstring(L, (char *)IObuff); + lua_pushstring(L, IObuff); return lua_error(L); } TSLanguage *(*lang_parser)(void); if (uv_dlsym(&lib, symbol_buf, (void **)&lang_parser)) { - snprintf((char *)IObuff, IOSIZE, "Failed to load parser: uv_dlsym: %s", + snprintf(IObuff, IOSIZE, "Failed to load parser: uv_dlsym: %s", uv_dlerror(&lib)); uv_dlclose(&lib); - lua_pushstring(L, (char *)IObuff); + lua_pushstring(L, IObuff); return lua_error(L); } diff --git a/src/nvim/main.c b/src/nvim/main.c index 953385836b..048fdd4052 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -1336,7 +1336,7 @@ static void command_line_scan(mparm_T *parmp) case 's': // "-s {scriptin}" read from script file if (parmp->scriptin != NULL) { scripterror: - vim_snprintf((char *)IObuff, IOSIZE, + vim_snprintf(IObuff, IOSIZE, _("Attempt to open script file again: \"%s %s\"\n"), argv[-1], argv[0]); os_errmsg(IObuff); @@ -1514,8 +1514,8 @@ static void handle_quickfix(mparm_T *paramp) if (paramp->use_ef != NULL) { set_string_option_direct("ef", -1, paramp->use_ef, OPT_FREE, SID_CARG); } - vim_snprintf((char *)IObuff, IOSIZE, "cfile %s", p_ef); - if (qf_init(NULL, (char *)p_ef, p_efm, true, (char *)IObuff, p_menc) < 0) { + vim_snprintf(IObuff, IOSIZE, "cfile %s", p_ef); + if (qf_init(NULL, (char *)p_ef, p_efm, true, IObuff, p_menc) < 0) { msg_putchar('\n'); os_exit(3); } @@ -1530,8 +1530,8 @@ static void handle_tag(char_u *tagname) if (tagname != NULL) { swap_exists_did_quit = false; - vim_snprintf((char *)IObuff, IOSIZE, "ta %s", tagname); - do_cmdline_cmd((char *)IObuff); + vim_snprintf(IObuff, IOSIZE, "ta %s", tagname); + do_cmdline_cmd(IObuff); TIME_MSG("jumping to tag"); // If the user doesn't want to edit the file then we quit here. diff --git a/src/nvim/mapping.c b/src/nvim/mapping.c index 199cc7b369..757855c350 100644 --- a/src/nvim/mapping.c +++ b/src/nvim/mapping.c @@ -589,13 +589,13 @@ static int buf_do_map(int maptype, MapArguments *args, int mode, bool is_abbrev, // vi-compatible way. int same = -1; - const int first = vim_iswordp((char_u *)lhs); + const int first = vim_iswordp(lhs); int last = first; p = (char *)lhs + utfc_ptr2len((char *)lhs); n = 1; while (p < (char *)lhs + len) { n++; // nr of (multi-byte) chars - last = vim_iswordp((char_u *)p); // type of last char + last = vim_iswordp(p); // type of last char if (same == -1 && last != first) { same = n - 1; // count of same char type } @@ -1419,18 +1419,18 @@ bool check_abbr(int c, char *ptr, int col, int mincol) { bool vim_abbr; char_u *p = mb_prevptr((char_u *)ptr, (char_u *)ptr + col); - if (!vim_iswordp(p)) { + if (!vim_iswordp((char *)p)) { vim_abbr = true; // Vim added abbr. } else { vim_abbr = false; // vi compatible abbr. if (p > (char_u *)ptr) { - is_id = vim_iswordp(mb_prevptr((char_u *)ptr, p)); + is_id = vim_iswordp((char *)mb_prevptr((char_u *)ptr, p)); } } clen = 1; while (p > (char_u *)ptr + mincol) { p = mb_prevptr((char_u *)ptr, p); - if (ascii_isspace(*p) || (!vim_abbr && is_id != vim_iswordp(p))) { + if (ascii_isspace(*p) || (!vim_abbr && is_id != vim_iswordp((char *)p))) { p += utfc_ptr2len((char *)p); break; } diff --git a/src/nvim/mark.c b/src/nvim/mark.c index 0d4a95ebab..af3f1e3679 100644 --- a/src/nvim/mark.c +++ b/src/nvim/mark.c @@ -899,8 +899,8 @@ static void show_one_mark(int c, char_u *arg, pos_T *p, char_u *name_arg, int cu } msg_putchar('\n'); if (!got_int) { - snprintf((char *)IObuff, IOSIZE, " %c %6" PRIdLINENR " %4d ", c, p->lnum, p->col); - msg_outtrans((char *)IObuff); + snprintf(IObuff, IOSIZE, " %c %6" PRIdLINENR " %4d ", c, p->lnum, p->col); + msg_outtrans(IObuff); if (name != NULL) { msg_outtrans_attr((char *)name, current ? HL_ATTR(HLF_D) : 0); } @@ -1022,11 +1022,11 @@ void ex_jumps(exarg_T *eap) xfree(name); break; } - snprintf((char *)IObuff, IOSIZE, "%c %2d %5" PRIdLINENR " %4d ", + snprintf(IObuff, IOSIZE, "%c %2d %5" PRIdLINENR " %4d ", i == curwin->w_jumplistidx ? '>' : ' ', i > curwin->w_jumplistidx ? i - curwin->w_jumplistidx : curwin->w_jumplistidx - i, curwin->w_jumplist[i].fmark.mark.lnum, curwin->w_jumplist[i].fmark.mark.col); - msg_outtrans((char *)IObuff); + msg_outtrans(IObuff); msg_outtrans_attr(name, curwin->w_jumplist[i].fmark.fnum == curbuf->b_fnum ? HL_ATTR(HLF_D) : 0); @@ -1066,7 +1066,7 @@ void ex_changes(exarg_T *eap) i > curwin->w_changelistidx ? i - curwin->w_changelistidx : curwin->w_changelistidx - i, (long)curbuf->b_changelist[i].mark.lnum, curbuf->b_changelist[i].mark.col); - msg_outtrans((char *)IObuff); + msg_outtrans(IObuff); name = (char_u *)mark_line(&curbuf->b_changelist[i].mark, 17); msg_outtrans_attr((char *)name, HL_ATTR(HLF_D)); xfree(name); diff --git a/src/nvim/mbyte.c b/src/nvim/mbyte.c index 450b84dced..e1a870071c 100644 --- a/src/nvim/mbyte.c +++ b/src/nvim/mbyte.c @@ -1557,7 +1557,7 @@ void show_utf8(void) } clen = utf_ptr2len((char *)line + i); } - sprintf((char *)IObuff + rlen, "%02x ", // NOLINT(runtime/printf) + sprintf(IObuff + rlen, "%02x ", // NOLINT(runtime/printf) (line[i] == NL) ? NUL : line[i]); // NUL is stored as NL clen--; rlen += (int)strlen(IObuff + rlen); @@ -1566,7 +1566,7 @@ void show_utf8(void) } } - msg((char *)IObuff); + msg(IObuff); } /// Return offset from "p" to the start of a character, including composing characters. diff --git a/src/nvim/memline.c b/src/nvim/memline.c index 8d92b30959..33223f6d1e 100644 --- a/src/nvim/memline.c +++ b/src/nvim/memline.c @@ -887,18 +887,18 @@ void ml_recover(bool checkext) // If .swp file name given directly, use name from swap file for buffer. if (directly) { expand_env((char *)b0p->b0_fname, NameBuff, MAXPATHL); - if (setfname(curbuf, (char *)NameBuff, NULL, true) == FAIL) { + if (setfname(curbuf, NameBuff, NULL, true) == FAIL) { goto theend; } } - home_replace(NULL, mfp->mf_fname, (char *)NameBuff, MAXPATHL, true); + home_replace(NULL, mfp->mf_fname, NameBuff, MAXPATHL, true); smsg(_("Using swap file \"%s\""), NameBuff); if (buf_spname(curbuf) != NULL) { xstrlcpy(NameBuff, buf_spname(curbuf), MAXPATHL); } else { - home_replace(NULL, curbuf->b_ffname, (char *)NameBuff, MAXPATHL, true); + home_replace(NULL, curbuf->b_ffname, NameBuff, MAXPATHL, true); } smsg(_("Original file \"%s\""), NameBuff); msg_putchar('\n'); diff --git a/src/nvim/message.c b/src/nvim/message.c index 8eea09ed13..e9d66ea184 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -491,10 +491,10 @@ int smsg(const char *s, ...) va_list arglist; va_start(arglist, s); - vim_vsnprintf((char *)IObuff, IOSIZE, s, arglist); + vim_vsnprintf(IObuff, IOSIZE, s, arglist); va_end(arglist); - return msg((char *)IObuff); + return msg(IObuff); } int smsg_attr(int attr, const char *s, ...) @@ -503,7 +503,7 @@ int smsg_attr(int attr, const char *s, ...) va_list arglist; va_start(arglist, s); - vim_vsnprintf((char *)IObuff, IOSIZE, s, arglist); + vim_vsnprintf(IObuff, IOSIZE, s, arglist); va_end(arglist); return msg_attr((const char *)IObuff, attr); } @@ -514,7 +514,7 @@ int smsg_attr_keep(int attr, const char *s, ...) va_list arglist; va_start(arglist, s); - vim_vsnprintf((char *)IObuff, IOSIZE, s, arglist); + vim_vsnprintf(IObuff, IOSIZE, s, arglist); va_end(arglist); return msg_attr_keep((const char *)IObuff, attr, true, false); } @@ -881,10 +881,10 @@ void msg_schedule_semsg(const char *const fmt, ...) { va_list ap; va_start(ap, fmt); - vim_vsnprintf((char *)IObuff, IOSIZE, fmt, ap); + vim_vsnprintf(IObuff, IOSIZE, fmt, ap); va_end(ap); - char *s = xstrdup((char *)IObuff); + char *s = xstrdup(IObuff); loop_schedule_deferred(&main_loop, event_create(msg_semsg_event, 1, s)); } @@ -3447,8 +3447,8 @@ void give_warning(char *message, bool hl) void give_warning2(char *const message, char *const a1, bool hl) { - vim_snprintf((char *)IObuff, IOSIZE, message, a1); - give_warning((char *)IObuff, hl); + vim_snprintf(IObuff, IOSIZE, message, a1); + give_warning(IObuff, hl); } /// Advance msg cursor to column "col". diff --git a/src/nvim/normal.c b/src/nvim/normal.c index 7979d2502e..6da71a9354 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -2285,7 +2285,7 @@ bool find_decl(char_u *ptr, size_t len, bool locally, bool thisblock, int flags_ // Put "\V" before the pattern to avoid that the special meaning of "." // and "~" causes trouble. assert(len <= INT_MAX); - sprintf((char *)pat, vim_iswordp(ptr) ? "\\V\\<%.*s\\>" : "\\V%.*s", // NOLINT(runtime/printf) + sprintf((char *)pat, vim_iswordp((char *)ptr) ? "\\V\\<%.*s\\>" : "\\V%.*s", // NOLINT(runtime/printf) (int)len, ptr); old_pos = curwin->w_cursor; save_p_ws = p_ws; @@ -3467,7 +3467,7 @@ static void nv_ident(cmdarg_T *cap) setpcmark(); curwin->w_cursor.col = (colnr_T)(ptr - get_cursor_line_ptr()); - if (!g_cmd && vim_iswordp((char_u *)ptr)) { + if (!g_cmd && vim_iswordp(ptr)) { STRCPY(buf, "\\<"); } no_smartcase = true; // don't use 'smartcase' now @@ -3549,7 +3549,7 @@ static void nv_ident(cmdarg_T *cap) // Execute the command. if (cmdchar == '*' || cmdchar == '#') { if (!g_cmd - && vim_iswordp(mb_prevptr((char_u *)get_cursor_line_ptr(), (char_u *)ptr))) { + && vim_iswordp((char *)mb_prevptr((char_u *)get_cursor_line_ptr(), (char_u *)ptr))) { STRCAT(buf, "\\>"); } diff --git a/src/nvim/ops.c b/src/nvim/ops.c index 2566108618..ec3ceca5bc 100644 --- a/src/nvim/ops.c +++ b/src/nvim/ops.c @@ -264,10 +264,10 @@ void op_shift(oparg_T *oap, int curs_top, int amount) "%" PRId64 " line %sed %d times", amount); char *msg_line_plural = NGETTEXT("%" PRId64 " lines %sed %d time", "%" PRId64 " lines %sed %d times", amount); - vim_snprintf((char *)IObuff, IOSIZE, + vim_snprintf(IObuff, IOSIZE, NGETTEXT(msg_line_single, msg_line_plural, oap->line_count), (int64_t)oap->line_count, op, amount); - msg_attr_keep((char *)IObuff, 0, true, false); + msg_attr_keep(IObuff, 0, true, false); } if ((cmdmod.cmod_flags & CMOD_LOCKMARKS) == 0) { @@ -5467,7 +5467,7 @@ void cursor_pos_info(dict_T *dict) if (char_count_cursor == byte_count_cursor && char_count == byte_count) { - vim_snprintf((char *)IObuff, IOSIZE, + vim_snprintf(IObuff, IOSIZE, _("Selected %s%" PRId64 " of %" PRId64 " Lines;" " %" PRId64 " of %" PRId64 " Words;" " %" PRId64 " of %" PRId64 " Bytes"), @@ -5476,7 +5476,7 @@ void cursor_pos_info(dict_T *dict) (int64_t)word_count_cursor, (int64_t)word_count, (int64_t)byte_count_cursor, (int64_t)byte_count); } else { - vim_snprintf((char *)IObuff, IOSIZE, + vim_snprintf(IObuff, IOSIZE, _("Selected %s%" PRId64 " of %" PRId64 " Lines;" " %" PRId64 " of %" PRId64 " Words;" " %" PRId64 " of %" PRId64 " Chars;" @@ -5496,7 +5496,7 @@ void cursor_pos_info(dict_T *dict) if (char_count_cursor == byte_count_cursor && char_count == byte_count) { - vim_snprintf((char *)IObuff, IOSIZE, + vim_snprintf(IObuff, IOSIZE, _("Col %s of %s; Line %" PRId64 " of %" PRId64 ";" " Word %" PRId64 " of %" PRId64 ";" " Byte %" PRId64 " of %" PRId64 ""), @@ -5506,7 +5506,7 @@ void cursor_pos_info(dict_T *dict) (int64_t)word_count_cursor, (int64_t)word_count, (int64_t)byte_count_cursor, (int64_t)byte_count); } else { - vim_snprintf((char *)IObuff, IOSIZE, + vim_snprintf(IObuff, IOSIZE, _("Col %s of %s; Line %" PRId64 " of %" PRId64 ";" " Word %" PRId64 " of %" PRId64 ";" " Char %" PRId64 " of %" PRId64 ";" @@ -5524,7 +5524,7 @@ void cursor_pos_info(dict_T *dict) bom_count = bomb_size(); if (dict == NULL && bom_count > 0) { const size_t len = strlen(IObuff); - vim_snprintf((char *)IObuff + len, IOSIZE - len, + vim_snprintf(IObuff + len, IOSIZE - len, _("(+%" PRId64 " for BOM)"), (int64_t)bom_count); } if (dict == NULL) { @@ -5535,7 +5535,7 @@ void cursor_pos_info(dict_T *dict) msg_start(); msg_scroll = true; } - msg((char *)IObuff); + msg(IObuff); p_shm = p; } } diff --git a/src/nvim/option.c b/src/nvim/option.c index 06de8be129..a6ec0a08c2 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -1465,10 +1465,10 @@ skip: IObuff[i + (arg - startarg)] = NUL; } // make sure all characters are printable - trans_characters((char *)IObuff, IOSIZE); + trans_characters(IObuff, IOSIZE); no_wait_return++; // wait_return() done later - emsg((char *)IObuff); // show error highlighted + emsg(IObuff); // show error highlighted no_wait_return--; return FAIL; @@ -3159,7 +3159,7 @@ static void showoptions(int all, int opt_flags) len = 1; // a toggle option fits always } else { option_value2string(p, opt_flags); - len = (int)strlen(p->fullname) + vim_strsize((char *)NameBuff) + 1; + len = (int)strlen(p->fullname) + vim_strsize(NameBuff) + 1; } if ((len <= INC - GAP && run == 1) || (len > INC - GAP && run == 2)) { @@ -3270,7 +3270,7 @@ static void showoneopt(vimoption_T *p, int opt_flags) msg_putchar('='); // put value string in NameBuff option_value2string(p, opt_flags); - msg_outtrans((char *)NameBuff); + msg_outtrans(NameBuff); } silent_mode = save_silent; @@ -4808,7 +4808,7 @@ static void option_value2string(vimoption_T *opp, int scope) } else if (wc != 0) { xstrlcpy(NameBuff, (char *)transchar((int)wc), sizeof(NameBuff)); } else { - snprintf((char *)NameBuff, + snprintf(NameBuff, sizeof(NameBuff), "%" PRId64, (int64_t)(*(long *)varp)); @@ -4821,7 +4821,7 @@ static void option_value2string(vimoption_T *opp, int scope) home_replace(NULL, varp, (char *)NameBuff, MAXPATHL, false); // Translate 'pastetoggle' into special key names. } else if ((char **)opp->var == &p_pt) { - str2specialbuf((const char *)p_pt, (char *)NameBuff, MAXPATHL); + str2specialbuf((const char *)p_pt, NameBuff, MAXPATHL); } else { xstrlcpy(NameBuff, varp, MAXPATHL); } diff --git a/src/nvim/os/signal.c b/src/nvim/os/signal.c index 08d24d47e2..b8daaabba2 100644 --- a/src/nvim/os/signal.c +++ b/src/nvim/os/signal.c @@ -172,7 +172,7 @@ static void deadly_signal(int signum) ILOG("got signal %d (%s)", signum, signal_name(signum)); - snprintf((char *)IObuff, sizeof(IObuff), "Vim: Caught deadly signal '%s'\r\n", + snprintf(IObuff, sizeof(IObuff), "Vim: Caught deadly signal '%s'\r\n", signal_name(signum)); // Preserve files and exit. diff --git a/src/nvim/path.c b/src/nvim/path.c index 0905c16e39..c78b899636 100644 --- a/src/nvim/path.c +++ b/src/nvim/path.c @@ -2442,8 +2442,8 @@ void path_guess_exepath(const char *argv0, char *buf, size_t bufsize) xstrlcpy(NameBuff, dir, dir_len + 1); xstrlcat(NameBuff, PATHSEPSTR, sizeof(NameBuff)); xstrlcat(NameBuff, argv0, sizeof(NameBuff)); - if (os_can_exe((char *)NameBuff, NULL, false)) { - xstrlcpy(buf, (char *)NameBuff, bufsize); + if (os_can_exe(NameBuff, NULL, false)) { + xstrlcpy(buf, NameBuff, bufsize); return; } } while (iter != NULL); diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c index 63a6dcec50..7d7bf9d8ba 100644 --- a/src/nvim/quickfix.c +++ b/src/nvim/quickfix.c @@ -673,7 +673,7 @@ static int qf_get_next_str_line(qfstate_T *state) if (len > IOSIZE - 2) { state->linebuf = qf_grow_linebuf(state, len); } else { - state->linebuf = (char *)IObuff; + state->linebuf = IObuff; state->linelen = len; } memcpy(state->linebuf, p_str, state->linelen); @@ -708,7 +708,7 @@ static int qf_get_next_list_line(qfstate_T *state) if (len > IOSIZE - 2) { state->linebuf = qf_grow_linebuf(state, len); } else { - state->linebuf = (char *)IObuff; + state->linebuf = IObuff; state->linelen = len; } @@ -733,7 +733,7 @@ static int qf_get_next_buf_line(qfstate_T *state) if (len > IOSIZE - 2) { state->linebuf = qf_grow_linebuf(state, len); } else { - state->linebuf = (char *)IObuff; + state->linebuf = IObuff; state->linelen = len; } xstrlcpy(state->linebuf, p_buf, state->linelen + 1); @@ -746,7 +746,7 @@ static int qf_get_next_file_line(qfstate_T *state) { retry: errno = 0; - if (fgets((char *)IObuff, IOSIZE, state->fd) == NULL) { + if (fgets(IObuff, IOSIZE, state->fd) == NULL) { if (errno == EINTR) { goto retry; } @@ -796,7 +796,7 @@ retry: // The current line is longer than LINE_MAXLEN, continue reading but // discard everything until EOL or EOF is reached. errno = 0; - if (fgets((char *)IObuff, IOSIZE, state->fd) == NULL) { + if (fgets(IObuff, IOSIZE, state->fd) == NULL) { if (errno == EINTR) { continue; } @@ -810,7 +810,7 @@ retry: state->linebuf = state->growbuf; state->linelen = growbuflen; } else { - state->linebuf = (char *)IObuff; + state->linebuf = IObuff; } // Convert a line if it contains a non-ASCII character @@ -2803,13 +2803,13 @@ static void qf_jump_print_msg(qf_info_T *qi, int qf_index, qfline_T *qf_ptr, buf update_screen(); } } - snprintf((char *)IObuff, IOSIZE, _("(%d of %d)%s%s: "), qf_index, + snprintf(IObuff, IOSIZE, _("(%d of %d)%s%s: "), qf_index, qf_get_curlist(qi)->qf_count, qf_ptr->qf_cleared ? _(" (line deleted)") : "", qf_types(qf_ptr->qf_type, qf_ptr->qf_nr)); // Add the message, skipping leading whitespace and newlines. int len = (int)strlen(IObuff); - qf_fmt_text(skipwhite(qf_ptr->qf_text), (char *)IObuff + len, IOSIZE - len); + qf_fmt_text(skipwhite(qf_ptr->qf_text), IObuff + len, IOSIZE - len); // Output the message. Overwrite to avoid scrolling when the 'O' // flag is present in 'shortmess'; But when not jumping, print the @@ -2821,7 +2821,7 @@ static void qf_jump_print_msg(qf_info_T *qi, int qf_index, qfline_T *qf_ptr, buf msg_scroll = false; } msg_ext_set_kind("quickfix"); - msg_attr_keep((char *)IObuff, 0, true, false); + msg_attr_keep(IObuff, 0, true, false); msg_scroll = (int)i; } @@ -3039,7 +3039,7 @@ static void qf_list_entry(qfline_T *qfp, int qf_idx, bool cursel) { char *fname = NULL; if (qfp->qf_module != NULL && *qfp->qf_module != NUL) { - vim_snprintf((char *)IObuff, IOSIZE, "%2d %s", qf_idx, qfp->qf_module); + vim_snprintf(IObuff, IOSIZE, "%2d %s", qf_idx, qfp->qf_module); } else { buf_T *buf; if (qfp->qf_fnum != 0 @@ -3050,9 +3050,9 @@ static void qf_list_entry(qfline_T *qfp, int qf_idx, bool cursel) } } if (fname == NULL) { - snprintf((char *)IObuff, IOSIZE, "%2d", qf_idx); + snprintf(IObuff, IOSIZE, "%2d", qf_idx); } else { - vim_snprintf((char *)IObuff, IOSIZE, "%2d %s", qf_idx, fname); + vim_snprintf(IObuff, IOSIZE, "%2d %s", qf_idx, fname); } } @@ -3077,7 +3077,7 @@ static void qf_list_entry(qfline_T *qfp, int qf_idx, bool cursel) } msg_putchar('\n'); - msg_outtrans_attr((char *)IObuff, cursel ? HL_ATTR(HLF_QFL) : qfFileAttr); + msg_outtrans_attr(IObuff, cursel ? HL_ATTR(HLF_QFL) : qfFileAttr); if (qfp->qf_lnum != 0) { msg_puts_attr(":", qfSepAttr); @@ -3085,13 +3085,13 @@ static void qf_list_entry(qfline_T *qfp, int qf_idx, bool cursel) if (qfp->qf_lnum == 0) { IObuff[0] = NUL; } else { - qf_range_text(qfp, (char *)IObuff, IOSIZE); + qf_range_text(qfp, IObuff, IOSIZE); } - vim_snprintf((char *)IObuff + strlen(IObuff), IOSIZE, "%s", qf_types(qfp->qf_type, qfp->qf_nr)); + vim_snprintf(IObuff + strlen(IObuff), IOSIZE, "%s", qf_types(qfp->qf_type, qfp->qf_nr)); msg_puts_attr((const char *)IObuff, qfLineAttr); msg_puts_attr(":", qfSepAttr); if (qfp->qf_pattern != NULL) { - qf_fmt_text(qfp->qf_pattern, (char *)IObuff, IOSIZE); + qf_fmt_text(qfp->qf_pattern, IObuff, IOSIZE); msg_puts((const char *)IObuff); msg_puts_attr(":", qfSepAttr); } @@ -3975,14 +3975,14 @@ static int qf_buf_add_line(qf_list_T *qfl, buf_T *buf, linenr_T lnum, const qfli IObuff[len++] = '|'; } if (qfp->qf_lnum > 0) { - qf_range_text(qfp, (char *)IObuff + len, IOSIZE - len); + qf_range_text(qfp, IObuff + len, IOSIZE - len); len += (int)strlen(IObuff + len); - snprintf((char *)IObuff + len, (size_t)(IOSIZE - len), "%s", qf_types(qfp->qf_type, - qfp->qf_nr)); + snprintf(IObuff + len, (size_t)(IOSIZE - len), "%s", qf_types(qfp->qf_type, + qfp->qf_nr)); len += (int)strlen(IObuff + len); } else if (qfp->qf_pattern != NULL) { - qf_fmt_text(qfp->qf_pattern, (char *)IObuff + len, IOSIZE - len); + qf_fmt_text(qfp->qf_pattern, IObuff + len, IOSIZE - len); len += (int)strlen(IObuff + len); } if (len < IOSIZE - 2) { @@ -3994,7 +3994,7 @@ static int qf_buf_add_line(qf_list_T *qfl, buf_T *buf, linenr_T lnum, const qfli // For an unrecognized line keep the indent, the compiler may // mark a word with ^^^^. qf_fmt_text(len > 3 ? skipwhite(qfp->qf_text) : qfp->qf_text, - (char *)IObuff + len, IOSIZE - len); + IObuff + len, IOSIZE - len); } if (ml_append_buf(buf, lnum, (char_u *)IObuff, @@ -6856,8 +6856,8 @@ void ex_cbuffer(exarg_T *eap) char *qf_title = qf_cmdtitle(*eap->cmdlinep); if (buf->b_sfname) { - vim_snprintf((char *)IObuff, IOSIZE, "%s (%s)", qf_title, buf->b_sfname); - qf_title = (char *)IObuff; + vim_snprintf(IObuff, IOSIZE, "%s (%s)", qf_title, buf->b_sfname); + qf_title = IObuff; } incr_quickfix_busy(); @@ -7002,7 +7002,7 @@ static void hgr_search_file(qf_list_T *qfl, char *fname, regmatch_T *p_regmatch) linenr_T lnum = 1; while (!vim_fgets(IObuff, IOSIZE, fd) && !got_int) { - char *line = (char *)IObuff; + char *line = IObuff; if (vim_regexec(p_regmatch, line, (colnr_T)0)) { int l = (int)strlen(line); @@ -7085,9 +7085,9 @@ static void hgr_search_in_rtp(qf_list_T *qfl, regmatch_T *p_regmatch, const char // Go through all directories in 'runtimepath' char *p = p_rtp; while (*p != NUL && !got_int) { - copy_option_part(&p, (char *)NameBuff, MAXPATHL, ","); + copy_option_part(&p, NameBuff, MAXPATHL, ","); - hgr_search_files_in_dir(qfl, (char *)NameBuff, p_regmatch, (char *)lang); + hgr_search_files_in_dir(qfl, NameBuff, p_regmatch, (char *)lang); } } diff --git a/src/nvim/runtime.c b/src/nvim/runtime.c index 0e1fe67e4a..e009b883ca 100644 --- a/src/nvim/runtime.c +++ b/src/nvim/runtime.c @@ -2085,8 +2085,8 @@ int do_source(char *fname, int check_other, int is_vimrc) } if (l_time_fd != NULL) { - vim_snprintf((char *)IObuff, IOSIZE, "sourcing %s", fname); - time_msg((char *)IObuff, &start_time); + vim_snprintf(IObuff, IOSIZE, "sourcing %s", fname); + time_msg(IObuff, &start_time); time_pop(rel_time); } @@ -2174,11 +2174,11 @@ void ex_scriptnames(exarg_T *eap) for (int i = 1; i <= script_items.ga_len && !got_int; i++) { if (SCRIPT_ITEM(i).sn_name != NULL) { - home_replace(NULL, SCRIPT_ITEM(i).sn_name, (char *)NameBuff, MAXPATHL, true); - vim_snprintf((char *)IObuff, IOSIZE, "%3d: %s", i, NameBuff); - if (!message_filtered((char *)IObuff)) { + home_replace(NULL, SCRIPT_ITEM(i).sn_name, NameBuff, MAXPATHL, true); + vim_snprintf(IObuff, IOSIZE, "%3d: %s", i, NameBuff); + if (!message_filtered(IObuff)) { msg_putchar('\n'); - msg_outtrans((char *)IObuff); + msg_outtrans(IObuff); line_breakcheck(); } } @@ -2220,16 +2220,16 @@ char *get_scriptname(LastSet last_set, bool *should_free) case SID_LUA: return _("Lua"); case SID_API_CLIENT: - snprintf((char *)IObuff, IOSIZE, _("API client (channel id %" PRIu64 ")"), last_set.channel_id); - return (char *)IObuff; + snprintf(IObuff, IOSIZE, _("API client (channel id %" PRIu64 ")"), last_set.channel_id); + return IObuff; case SID_STR: return _("anonymous :source"); default: { char *const sname = SCRIPT_ITEM(last_set.script_ctx.sc_sid).sn_name; if (sname == NULL) { - snprintf((char *)IObuff, IOSIZE, _("anonymous :source (script id %d)"), + snprintf(IObuff, IOSIZE, _("anonymous :source (script id %d)"), last_set.script_ctx.sc_sid); - return (char *)IObuff; + return IObuff; } *should_free = true; diff --git a/src/nvim/screen.c b/src/nvim/screen.c index 58aec2e84c..52ab2ad25e 100644 --- a/src/nvim/screen.c +++ b/src/nvim/screen.c @@ -547,8 +547,8 @@ int showmode(void) if (curwin->w_p_arab) { msg_puts_attr(_(" Arabic"), attr); } else if (get_keymap_str(curwin, " (%s)", - (char *)NameBuff, MAXPATHL)) { - msg_puts_attr((char *)NameBuff, attr); + NameBuff, MAXPATHL)) { + msg_puts_attr(NameBuff, attr); } } if ((State & MODE_INSERT) && p_paste) { @@ -683,9 +683,9 @@ void get_trans_bufname(buf_T *buf) if (buf_spname(buf) != NULL) { xstrlcpy(NameBuff, buf_spname(buf), MAXPATHL); } else { - home_replace(buf, buf->b_fname, (char *)NameBuff, MAXPATHL, true); + home_replace(buf, buf->b_fname, NameBuff, MAXPATHL, true); } - trans_characters((char *)NameBuff, MAXPATHL); + trans_characters(NameBuff, MAXPATHL); } /// Get the character to use in a separator between vertically split windows. diff --git a/src/nvim/search.c b/src/nvim/search.c index 51ad2b0cbb..73a62429bd 100644 --- a/src/nvim/search.c +++ b/src/nvim/search.c @@ -3678,10 +3678,10 @@ void find_pattern_in_path(char *ptr, Direction dir, size_t len, bool whole, bool files[depth].matched = false; if (action == ACTION_EXPAND) { msg_hist_off = true; // reset in msg_trunc_attr() - vim_snprintf((char *)IObuff, IOSIZE, + vim_snprintf(IObuff, IOSIZE, _("Scanning included file: %s"), (char *)new_fname); - msg_trunc_attr((char *)IObuff, true, HL_ATTR(HLF_R)); + msg_trunc_attr(IObuff, true, HL_ATTR(HLF_R)); } else if (p_verbose >= 5) { verbose_enter(); smsg(_("Searching included file %s"), @@ -3775,7 +3775,7 @@ search_line: char *aux = p = startp; if (compl_status_adding()) { p += ins_compl_len(); - if (vim_iswordp((char_u *)p)) { + if (vim_iswordp(p)) { goto exit_matched; } p = (char *)find_word_start((char_u *)p); @@ -4056,9 +4056,9 @@ static void show_pat_in_path(char *line, int type, bool did_show, int action, FI *(p + 1) = NUL; } if (action == ACTION_SHOW_ALL) { - snprintf((char *)IObuff, IOSIZE, "%3ld: ", count); // Show match nr. + snprintf(IObuff, IOSIZE, "%3ld: ", count); // Show match nr. msg_puts((const char *)IObuff); - snprintf((char *)IObuff, IOSIZE, "%4" PRIdLINENR, *lnum); // Show line nr. + snprintf(IObuff, IOSIZE, "%4" PRIdLINENR, *lnum); // Show line nr. // Highlight line numbers. msg_puts_attr((const char *)IObuff, HL_ATTR(HLF_N)); msg_puts(" "); diff --git a/src/nvim/shada.c b/src/nvim/shada.c index 151cb834be..8c17d8d8be 100644 --- a/src/nvim/shada.c +++ b/src/nvim/shada.c @@ -4017,7 +4017,7 @@ static bool shada_removable(const char *name) for (p = p_shada; *p;) { (void)copy_option_part(&p, part, ARRAY_SIZE(part), ", "); if (part[0] == 'r') { - home_replace(NULL, part + 1, (char *)NameBuff, MAXPATHL, true); + home_replace(NULL, part + 1, NameBuff, MAXPATHL, true); size_t n = strlen(NameBuff); if (mb_strnicmp(NameBuff, new_name, n) == 0) { retval = true; diff --git a/src/nvim/spell.c b/src/nvim/spell.c index 33dd76b704..10abd16ca7 100644 --- a/src/nvim/spell.c +++ b/src/nvim/spell.c @@ -3231,8 +3231,8 @@ void spell_dump_compl(char *pat, int ic, Direction *dir, int dumpflags_arg) if (do_region && region_names != NULL) { if (pat == NULL) { - vim_snprintf((char *)IObuff, IOSIZE, "/regions=%s", region_names); - ml_append(lnum++, (char *)IObuff, (colnr_T)0, false); + vim_snprintf(IObuff, IOSIZE, "/regions=%s", region_names); + ml_append(lnum++, IObuff, (colnr_T)0, false); } } else { do_region = false; @@ -3247,8 +3247,8 @@ void spell_dump_compl(char *pat, int ic, Direction *dir, int dumpflags_arg) } if (pat == NULL) { - vim_snprintf((char *)IObuff, IOSIZE, "# file: %s", slang->sl_fname); - ml_append(lnum++, (char *)IObuff, (colnr_T)0, false); + vim_snprintf(IObuff, IOSIZE, "# file: %s", slang->sl_fname); + ml_append(lnum++, IObuff, (colnr_T)0, false); } // When matching with a pattern and there are no prefixes only use @@ -3411,7 +3411,7 @@ static void dump_word(slang_T *slang, char *word, char *pat, Direction *dir, int // Include the word count for ":spelldump!". hi = hash_find(&slang->sl_wordcount, tw); if (!HASHITEM_EMPTY(hi)) { - vim_snprintf((char *)IObuff, IOSIZE, "%s\t%d", + vim_snprintf(IObuff, IOSIZE, "%s\t%d", tw, HI2WC(hi)->wc_count); p = IObuff; } diff --git a/src/nvim/spellfile.c b/src/nvim/spellfile.c index d01acd6300..5b99d0767c 100644 --- a/src/nvim/spellfile.c +++ b/src/nvim/spellfile.c @@ -2064,8 +2064,8 @@ static afffile_T *spell_read_aff(spellinfo_T *spin, char_u *fname) return NULL; } - vim_snprintf((char *)IObuff, IOSIZE, _("Reading affix file %s..."), fname); - spell_message(spin, (char *)IObuff); + vim_snprintf(IObuff, IOSIZE, _("Reading affix file %s..."), fname); + spell_message(spin, IObuff); // Only do REP lines when not done in another .aff file already. do_rep = GA_EMPTY(&spin->si_rep); @@ -3137,9 +3137,9 @@ static int spell_read_dic(spellinfo_T *spin, char_u *fname, afffile_T *affile) // The hashtable is only used to detect duplicated words. hash_init(&ht); - vim_snprintf((char *)IObuff, IOSIZE, + vim_snprintf(IObuff, IOSIZE, _("Reading dictionary file %s..."), fname); - spell_message(spin, (char *)IObuff); + spell_message(spin, IObuff); // start with a message for the first line spin->si_msg_count = 999999; @@ -3691,8 +3691,8 @@ static int spell_read_wordfile(spellinfo_T *spin, char_u *fname) return FAIL; } - vim_snprintf((char *)IObuff, IOSIZE, _("Reading word file %s..."), fname); - spell_message(spin, (char *)IObuff); + vim_snprintf(IObuff, IOSIZE, _("Reading word file %s..."), fname); + spell_message(spin, IObuff); // Read all the lines in the file one by one. while (!vim_fgets((char *)rline, MAXLINELEN, fd) && !got_int) { @@ -3834,9 +3834,9 @@ static int spell_read_wordfile(spellinfo_T *spin, char_u *fname) fclose(fd); if (spin->si_ascii && non_ascii > 0) { - vim_snprintf((char *)IObuff, IOSIZE, + vim_snprintf(IObuff, IOSIZE, _("Ignored %d words with non-ASCII characters"), non_ascii); - spell_message(spin, (char *)IObuff); + spell_message(spin, IObuff); } return retval; @@ -4226,10 +4226,10 @@ static void wordtree_compress(spellinfo_T *spin, wordnode_T *root, const char *n } else { perc = (tot - n) * 100 / tot; } - vim_snprintf((char *)IObuff, IOSIZE, + vim_snprintf(IObuff, IOSIZE, _("Compressed %s of %ld nodes; %ld (%ld%%) remaining"), name, tot, tot - n, perc); - spell_message(spin, (char *)IObuff); + spell_message(spin, IObuff); } #ifdef SPELL_PRINTTREE spell_print_tree(root->wn_sibling); @@ -5208,9 +5208,9 @@ static void sug_write(spellinfo_T *spin, char_u *fname) return; } - vim_snprintf((char *)IObuff, IOSIZE, + vim_snprintf(IObuff, IOSIZE, _("Writing suggestion file %s..."), fname); - spell_message(spin, (char *)IObuff); + spell_message(spin, IObuff); // <SUGHEADER>: <fileID> <versionnr> <timestamp> if (fwrite(VIMSUGMAGIC, VIMSUGMAGICL, (size_t)1, fd) != 1) { // <fileID> @@ -5264,9 +5264,9 @@ static void sug_write(spellinfo_T *spin, char_u *fname) emsg(_(e_write)); } - vim_snprintf((char *)IObuff, IOSIZE, + vim_snprintf(IObuff, IOSIZE, _("Estimated runtime memory use: %d bytes"), spin->si_memtot); - spell_message(spin, (char *)IObuff); + spell_message(spin, IObuff); theend: // close the file @@ -5445,16 +5445,16 @@ static void mkspell(int fcount, char **fnames, bool ascii, bool over_write, bool if (!error && !got_int) { // Write the info in the spell file. - vim_snprintf((char *)IObuff, IOSIZE, + vim_snprintf(IObuff, IOSIZE, _("Writing spell file %s..."), wfname); - spell_message(&spin, (char *)IObuff); + spell_message(&spin, IObuff); error = write_vim_spell(&spin, wfname) == FAIL; spell_message(&spin, _("Done!")); - vim_snprintf((char *)IObuff, IOSIZE, + vim_snprintf(IObuff, IOSIZE, _("Estimated runtime memory use: %d bytes"), spin.si_memtot); - spell_message(&spin, (char *)IObuff); + spell_message(&spin, IObuff); // If the file is loaded need to reload it. if (!error) { @@ -5616,7 +5616,7 @@ void spell_add_word(char *word, int len, SpellAddType what, int idx, bool undo) if (fseek(fd, fpos, SEEK_SET) == 0) { fputc('#', fd); if (undo) { - home_replace(NULL, fname, (char *)NameBuff, MAXPATHL, true); + home_replace(NULL, fname, NameBuff, MAXPATHL, true); smsg(_("Word '%.*s' removed from %s"), len, word, NameBuff); } } @@ -5666,7 +5666,7 @@ void spell_add_word(char *word, int len, SpellAddType what, int idx, bool undo) } fclose(fd); - home_replace(NULL, fname, (char *)NameBuff, MAXPATHL, true); + home_replace(NULL, fname, NameBuff, MAXPATHL, true); smsg(_("Word '%.*s' added to %s"), len, word, NameBuff); } } diff --git a/src/nvim/spellsuggest.c b/src/nvim/spellsuggest.c index bde61e753c..2768a89d6c 100644 --- a/src/nvim/spellsuggest.c +++ b/src/nvim/spellsuggest.c @@ -544,12 +544,12 @@ void spell_suggest(int count) msg_start(); msg_row = Rows - 1; // for when 'cmdheight' > 1 lines_left = Rows; // avoid more prompt - vim_snprintf((char *)IObuff, IOSIZE, _("Change \"%.*s\" to:"), + vim_snprintf(IObuff, IOSIZE, _("Change \"%.*s\" to:"), sug.su_badlen, sug.su_badptr); if (cmdmsg_rl && strncmp(IObuff, "Change", 6) == 0) { // And now the rabbit from the high hat: Avoid showing the // untranslated message rightleft. - vim_snprintf((char *)IObuff, IOSIZE, ":ot \"%.*s\" egnahC", + vim_snprintf(IObuff, IOSIZE, ":ot \"%.*s\" egnahC", sug.su_badlen, sug.su_badptr); } msg_puts((const char *)IObuff); @@ -567,18 +567,18 @@ void spell_suggest(int count) if (el > 0 && stp->st_wordlen + el <= MAXWLEN) { xstrlcpy(wcopy + stp->st_wordlen, sug.su_badptr + stp->st_orglen, (size_t)el + 1); } - vim_snprintf((char *)IObuff, IOSIZE, "%2d", i + 1); + vim_snprintf(IObuff, IOSIZE, "%2d", i + 1); if (cmdmsg_rl) { rl_mirror(IObuff); } msg_puts((const char *)IObuff); - vim_snprintf((char *)IObuff, IOSIZE, " \"%s\"", wcopy); + vim_snprintf(IObuff, IOSIZE, " \"%s\"", wcopy); msg_puts((const char *)IObuff); // The word may replace more than "su_badlen". if (sug.su_badlen < stp->st_orglen) { - vim_snprintf((char *)IObuff, IOSIZE, _(" < \"%.*s\""), + vim_snprintf(IObuff, IOSIZE, _(" < \"%.*s\""), stp->st_orglen, sug.su_badptr); msg_puts((const char *)IObuff); } @@ -586,11 +586,11 @@ void spell_suggest(int count) if (p_verbose > 0) { // Add the score. if (sps_flags & (SPS_DOUBLE | SPS_BEST)) { - vim_snprintf((char *)IObuff, IOSIZE, " (%s%d - %d)", + vim_snprintf(IObuff, IOSIZE, " (%s%d - %d)", stp->st_salscore ? "s " : "", stp->st_score, stp->st_altscore); } else { - vim_snprintf((char *)IObuff, IOSIZE, " (%d)", + vim_snprintf(IObuff, IOSIZE, " (%d)", stp->st_score); } if (cmdmsg_rl) { @@ -630,10 +630,10 @@ void spell_suggest(int count) // Replacing less than "su_badlen", append the remainder to // repl_to. repl_from = xstrnsave(sug.su_badptr, (size_t)sug.su_badlen); - vim_snprintf((char *)IObuff, IOSIZE, "%s%.*s", stp->st_word, + vim_snprintf(IObuff, IOSIZE, "%s%.*s", stp->st_word, sug.su_badlen - stp->st_orglen, sug.su_badptr + stp->st_orglen); - repl_to = xstrdup((char *)IObuff); + repl_to = xstrdup(IObuff); } else { // Replacing su_badlen or more, use the whole word. repl_from = xstrnsave(sug.su_badptr, (size_t)stp->st_orglen); diff --git a/src/nvim/statusline.c b/src/nvim/statusline.c index 80936251b0..0f28eae0d8 100644 --- a/src/nvim/statusline.c +++ b/src/nvim/statusline.c @@ -155,7 +155,7 @@ void win_redr_status(win_T *wp) grid_fill(&default_grid, row, row + 1, len + col, this_ru_col + col, fillchar, fillchar, attr); - if (get_keymap_str(wp, "<%s>", (char *)NameBuff, MAXPATHL) + if (get_keymap_str(wp, "<%s>", NameBuff, MAXPATHL) && this_ru_col - len > (int)(strlen(NameBuff) + 1)) { grid_puts(&default_grid, NameBuff, row, (int)((size_t)this_ru_col - strlen(NameBuff) - 1), attr); @@ -666,7 +666,7 @@ static void ui_ext_tabline_update(void) win_T *cwp = (tp == curtab) ? curwin : tp->tp_curwin; get_trans_bufname(cwp->w_buffer); - PUT_C(tab_info, "name", STRING_OBJ(arena_string(&arena, cstr_as_string((char *)NameBuff)))); + PUT_C(tab_info, "name", STRING_OBJ(arena_string(&arena, cstr_as_string(NameBuff)))); ADD_C(tabs, DICTIONARY_OBJ(tab_info)); } @@ -687,7 +687,7 @@ static void ui_ext_tabline_update(void) PUT_C(buffer_info, "buffer", BUFFER_OBJ(buf->handle)); get_trans_bufname(buf); - PUT_C(buffer_info, "name", STRING_OBJ(arena_string(&arena, cstr_as_string((char *)NameBuff)))); + PUT_C(buffer_info, "name", STRING_OBJ(arena_string(&arena, cstr_as_string(NameBuff)))); ADD_C(buffers, DICTIONARY_OBJ(buffer_info)); } @@ -787,7 +787,7 @@ void draw_tabline(void) if (modified || wincount > 1) { if (wincount > 1) { - vim_snprintf((char *)NameBuff, MAXPATHL, "%d", wincount); + vim_snprintf(NameBuff, MAXPATHL, "%d", wincount); len = (int)strlen(NameBuff); if (col + len >= Columns - 3) { break; @@ -807,7 +807,7 @@ void draw_tabline(void) // Get buffer name in NameBuff[] get_trans_bufname(cwp->w_buffer); shorten_dir(NameBuff); - len = vim_strsize((char *)NameBuff); + len = vim_strsize(NameBuff); p = (char_u *)NameBuff; while (len > room) { len -= ptr2cells((char *)p); @@ -1353,13 +1353,13 @@ int build_stl_str_hl(win_T *wp, char *out, size_t outlen, char *fmt, char *opt_n } else { char *t = (opt == STL_FULLPATH) ? wp->w_buffer->b_ffname : wp->w_buffer->b_fname; - home_replace(wp->w_buffer, t, (char *)NameBuff, MAXPATHL, true); + home_replace(wp->w_buffer, t, NameBuff, MAXPATHL, true); } - trans_characters((char *)NameBuff, MAXPATHL); + trans_characters(NameBuff, MAXPATHL); if (opt != STL_FILENAME) { - str = (char *)NameBuff; + str = NameBuff; } else { - str = path_tail((char *)NameBuff); + str = path_tail(NameBuff); } break; case STL_VIM_EXPR: // '{' diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c index 8f0d8d2041..87d537559a 100644 --- a/src/nvim/syntax.c +++ b/src/nvim/syntax.c @@ -2754,7 +2754,7 @@ static int check_keyword_id(char *const line, const int startcol, int *const end // ignoring case if (kp == NULL && syn_block->b_keywtab_ic.ht_used != 0) { - str_foldcase((char_u *)kwp, kwlen, keyword, MAXKEYWLEN + 1); + str_foldcase(kwp, kwlen, keyword, MAXKEYWLEN + 1); kp = match_keyword(keyword, &syn_block->b_keywtab_ic, cur_si); } @@ -3727,8 +3727,8 @@ static void add_keyword(char *const name, const int id, const int flags, { char name_folded[MAXKEYWLEN + 1]; const char *const name_ic = (curwin->w_s->b_syn_ic) - ? (char *)str_foldcase((char_u *)name, (int)strlen(name), name_folded, - sizeof(name_folded)) + ? str_foldcase(name, (int)strlen(name), name_folded, + sizeof(name_folded)) : name; keyentry_T *const kp = xmalloc(sizeof(keyentry_T) + strlen(name_ic)); diff --git a/src/nvim/tag.c b/src/nvim/tag.c index 72d7ae1154..42de9e1152 100644 --- a/src/nvim/tag.c +++ b/src/nvim/tag.c @@ -720,7 +720,7 @@ void do_tag(char *tag, int type, int count, int forceit, int verbose) && (num_matches > 1 || ic) && !skip_msg) { // Give an indication of the number of matching tags - snprintf((char *)IObuff, sizeof(IObuff), _("tag %d of %d%s"), + snprintf(IObuff, sizeof(IObuff), _("tag %d of %d%s"), cur_match + 1, num_matches, max_num_matches != MAXCOL ? _(" or more") : ""); @@ -732,11 +732,11 @@ void do_tag(char *tag, int type, int count, int forceit, int verbose) if (ic) { msg_attr((const char *)IObuff, HL_ATTR(HLF_W)); } else { - msg((char *)IObuff); + msg(IObuff); } msg_scroll = true; // Don't overwrite this message. } else { - give_warning((char *)IObuff, ic); + give_warning(IObuff, ic); } if (ic && !msg_scrolled && msg_silent == 0) { ui_flush(); @@ -745,8 +745,8 @@ void do_tag(char *tag, int type, int count, int forceit, int verbose) } // Let the SwapExists event know what tag we are jumping to. - vim_snprintf((char *)IObuff, IOSIZE, ":ta %s\r", name); - set_vim_var_string(VV_SWAPCOMMAND, (char *)IObuff, -1); + vim_snprintf(IObuff, IOSIZE, ":ta %s\r", name); + set_vim_var_string(VV_SWAPCOMMAND, IObuff, -1); // Jump to the desired match. i = jumpto_tag((char_u *)matches[cur_match], forceit, true); @@ -836,10 +836,10 @@ static void print_tag_list(int new_tag, int use_tagstack, int num_matches, char } else { *IObuff = ' '; } - vim_snprintf((char *)IObuff + 1, IOSIZE - 1, + vim_snprintf(IObuff + 1, IOSIZE - 1, "%2d %s ", i + 1, mt_names[matches[i][0] & MT_MASK]); - msg_puts((char *)IObuff); + msg_puts(IObuff); if (tagp.tagkind != NULL) { msg_outtrans_len((char *)tagp.tagkind, (int)(tagp.tagkind_end - tagp.tagkind)); @@ -1099,8 +1099,8 @@ static int add_llist_tags(char_u *tag, int num_matches, char **matches) } } - vim_snprintf((char *)IObuff, IOSIZE, "ltag %s", tag); - set_errorlist(curwin, list, ' ', (char *)IObuff, NULL); + vim_snprintf(IObuff, IOSIZE, "ltag %s", tag); + set_errorlist(curwin, list, ' ', IObuff, NULL); tv_list_free(list); XFREE_CLEAR(fname); @@ -1144,13 +1144,13 @@ void do_tags(exarg_T *eap) } msg_putchar('\n'); - vim_snprintf((char *)IObuff, IOSIZE, "%c%2d %2d %-15s %5" PRIdLINENR " ", + vim_snprintf(IObuff, IOSIZE, "%c%2d %2d %-15s %5" PRIdLINENR " ", i == tagstackidx ? '>' : ' ', i + 1, tagstack[i].cur_match + 1, tagstack[i].tagname, tagstack[i].fmark.mark.lnum); - msg_outtrans((char *)IObuff); + msg_outtrans(IObuff); msg_outtrans_attr((char *)name, tagstack[i].fmark.fnum == curbuf->b_fnum ? HL_ATTR(HLF_D) : 0); xfree(name); @@ -3227,7 +3227,7 @@ static void tagstack_clear_entry(taggy_T *item) } /// @param tagnames expand tag names -int expand_tags(int tagnames, char_u *pat, int *num_file, char ***file) +int expand_tags(int tagnames, char *pat, int *num_file, char ***file) { int i; int extra_flag; @@ -3244,11 +3244,11 @@ int expand_tags(int tagnames, char_u *pat, int *num_file, char ***file) extra_flag = 0; } if (pat[0] == '/') { - ret = find_tags((char *)pat + 1, num_file, file, + ret = find_tags(pat + 1, num_file, file, TAG_REGEXP | extra_flag | TAG_VERBOSE | TAG_NO_TAGFUNC, TAG_MANY, curbuf->b_ffname); } else { - ret = find_tags((char *)pat, num_file, file, + ret = find_tags(pat, num_file, file, TAG_REGEXP | extra_flag | TAG_VERBOSE | TAG_NO_TAGFUNC | TAG_NOIC, TAG_MANY, curbuf->b_ffname); } @@ -3324,17 +3324,17 @@ static int add_tag_field(dict_T *dict, const char *field_name, const char *start /// Add the tags matching the specified pattern "pat" to the list "list" /// as a dictionary. Use "buf_fname" for priority, unless NULL. -int get_tags(list_T *list, char_u *pat, char_u *buf_fname) +int get_tags(list_T *list, char *pat, char *buf_fname) { int num_matches, i, ret; char **matches; - char_u *full_fname; + char *full_fname; dict_T *dict; tagptrs_T tp; bool is_static; - ret = find_tags((char *)pat, &num_matches, &matches, - TAG_REGEXP | TAG_NOIC, MAXCOL, (char *)buf_fname); + ret = find_tags(pat, &num_matches, &matches, + TAG_REGEXP | TAG_NOIC, MAXCOL, buf_fname); if (ret == OK && num_matches > 0) { for (i = 0; i < num_matches; i++) { int parse_result = parse_match(matches[i], &tp); @@ -3354,9 +3354,9 @@ int get_tags(list_T *list, char_u *pat, char_u *buf_fname) dict = tv_dict_alloc(); tv_list_append_dict(list, dict); - full_fname = tag_full_fname(&tp); + full_fname = (char *)tag_full_fname(&tp); if (add_tag_field(dict, "name", tp.tagname, (char *)tp.tagname_end) == FAIL - || add_tag_field(dict, "filename", (char *)full_fname, NULL) == FAIL + || add_tag_field(dict, "filename", full_fname, NULL) == FAIL || add_tag_field(dict, "cmd", tp.command, (char *)tp.command_end) == FAIL || add_tag_field(dict, "kind", (char *)tp.tagkind, tp.tagkind ? (char *)tp.tagkind_end : NULL) == FAIL diff --git a/src/nvim/testing.c b/src/nvim/testing.c index 8c54d9ad32..edb24c6dc5 100644 --- a/src/nvim/testing.c +++ b/src/nvim/testing.c @@ -394,12 +394,12 @@ static int assert_equalfile(typval_T *argvars) char line2[200]; ptrdiff_t lineidx = 0; if (fd1 == NULL) { - snprintf((char *)IObuff, IOSIZE, (char *)e_notread, fname1); + snprintf(IObuff, IOSIZE, (char *)e_notread, fname1); } else { FILE *const fd2 = os_fopen(fname2, READBIN); if (fd2 == NULL) { fclose(fd1); - snprintf((char *)IObuff, IOSIZE, (char *)e_notread, fname2); + snprintf(IObuff, IOSIZE, (char *)e_notread, fname2); } else { int64_t linecount = 1; for (int64_t count = 0;; count++) { @@ -418,7 +418,7 @@ static int assert_equalfile(typval_T *argvars) line2[lineidx] = (char)c2; lineidx++; if (c1 != c2) { - snprintf((char *)IObuff, IOSIZE, + snprintf(IObuff, IOSIZE, "difference at byte %" PRId64 ", line %" PRId64, count, linecount); break; @@ -445,7 +445,7 @@ static int assert_equalfile(typval_T *argvars) xfree(tofree); ga_concat(&ga, ": "); } - ga_concat(&ga, (char *)IObuff); + ga_concat(&ga, IObuff); if (lineidx > 0) { line1[lineidx] = NUL; line2[lineidx] = NUL; diff --git a/src/nvim/undo.c b/src/nvim/undo.c index 9cbe5d5d9e..c39e11f266 100644 --- a/src/nvim/undo.c +++ b/src/nvim/undo.c @@ -2569,7 +2569,7 @@ static void u_undo_end(bool did_undo, bool absolute, bool quiet) if (uhp == NULL) { *msgbuf = NUL; } else { - undo_fmt_time(msgbuf, sizeof(msgbuf), uhp->uh_time); + undo_fmt_time((char *)msgbuf, sizeof(msgbuf), uhp->uh_time); } { @@ -2594,7 +2594,7 @@ static void u_undo_end(bool did_undo, bool absolute, bool quiet) } /// Put the timestamp of an undo header in "buf[buflen]" in a nice format. -void undo_fmt_time(char_u *buf, size_t buflen, time_t tt) +void undo_fmt_time(char *buf, size_t buflen, time_t tt) { if (time(NULL) - tt >= 100) { struct tm curtime; @@ -2602,17 +2602,17 @@ void undo_fmt_time(char_u *buf, size_t buflen, time_t tt) size_t n; if (time(NULL) - tt < (60L * 60L * 12L)) { // within 12 hours - n = strftime((char *)buf, buflen, "%H:%M:%S", &curtime); + n = strftime(buf, buflen, "%H:%M:%S", &curtime); } else { // longer ago - n = strftime((char *)buf, buflen, "%Y/%m/%d %H:%M:%S", &curtime); + n = strftime(buf, buflen, "%Y/%m/%d %H:%M:%S", &curtime); } if (n == 0) { buf[0] = NUL; } } else { int64_t seconds = time(NULL) - tt; - vim_snprintf((char *)buf, buflen, + vim_snprintf(buf, buflen, NGETTEXT("%" PRId64 " second ago", "%" PRId64 " seconds ago", (uint32_t)seconds), seconds); @@ -2654,15 +2654,15 @@ void ex_undolist(exarg_T *eap) while (uhp != NULL) { if (uhp->uh_prev.ptr == NULL && uhp->uh_walk != nomark && uhp->uh_walk != mark) { - vim_snprintf((char *)IObuff, IOSIZE, "%6ld %7d ", uhp->uh_seq, changes); - undo_fmt_time((char_u *)IObuff + strlen(IObuff), IOSIZE - strlen(IObuff), uhp->uh_time); + vim_snprintf(IObuff, IOSIZE, "%6ld %7d ", uhp->uh_seq, changes); + undo_fmt_time(IObuff + strlen(IObuff), IOSIZE - strlen(IObuff), uhp->uh_time); if (uhp->uh_save_nr > 0) { while (strlen(IObuff) < 33) { STRCAT(IObuff, " "); } - vim_snprintf_add((char *)IObuff, IOSIZE, " %3ld", uhp->uh_save_nr); + vim_snprintf_add(IObuff, IOSIZE, " %3ld", uhp->uh_save_nr); } - GA_APPEND(char *, &ga, xstrdup((char *)IObuff)); + GA_APPEND(char *, &ga, xstrdup(IObuff)); } uhp->uh_walk = mark; diff --git a/src/nvim/usercmd.c b/src/nvim/usercmd.c index bc47b1b807..0109c048ec 100644 --- a/src/nvim/usercmd.c +++ b/src/nvim/usercmd.c @@ -484,14 +484,14 @@ static void uc_list(char *name, size_t name_len) if (a & (EX_RANGE | EX_COUNT)) { if (a & EX_COUNT) { // -count=N - snprintf((char *)IObuff + len, IOSIZE, "%" PRId64 "c", + snprintf(IObuff + len, IOSIZE, "%" PRId64 "c", (int64_t)cmd->uc_def); len += (int)strlen(IObuff + len); } else if (a & EX_DFLALL) { IObuff[len++] = '%'; } else if (cmd->uc_def >= 0) { // -range=N - snprintf((char *)IObuff + len, IOSIZE, "%" PRId64 "", + snprintf(IObuff + len, IOSIZE, "%" PRId64 "", (int64_t)cmd->uc_def); len += (int)strlen(IObuff + len); } else { @@ -529,7 +529,7 @@ static void uc_list(char *name, size_t name_len) } while (len < 25 - over); IObuff[len] = '\0'; - msg_outtrans((char *)IObuff); + msg_outtrans(IObuff); if (cmd->uc_luaref != LUA_NOREF) { char *fn = nlua_funcref_str(cmd->uc_luaref); |