From e31b32a293f6ba8708499a176234f8be1df6a145 Mon Sep 17 00:00:00 2001 From: Dundar Goc Date: Thu, 5 May 2022 13:36:14 +0200 Subject: refactor: replace char_u variables and functions with char Work on https://github.com/neovim/neovim/issues/459 --- src/nvim/api/vim.c | 25 +++---- src/nvim/api/vimscript.c | 6 +- src/nvim/api/win_config.c | 4 +- src/nvim/arabic.c | 4 +- src/nvim/autocmd.c | 14 ++-- src/nvim/buffer.c | 96 ++++++++++++------------ src/nvim/change.c | 14 ++-- src/nvim/charset.c | 10 +-- src/nvim/context.c | 2 +- src/nvim/debugger.c | 8 +- src/nvim/diff.c | 16 ++-- src/nvim/digraph.c | 16 ++-- src/nvim/edit.c | 35 ++++----- src/nvim/eval.c | 145 ++++++++++++++++++------------------- src/nvim/eval/decode.c | 9 +-- src/nvim/eval/funcs.c | 50 +++++++------ src/nvim/eval/userfunc.c | 74 +++++++++---------- src/nvim/ex_cmds.c | 22 +++--- src/nvim/ex_cmds2.c | 16 ++-- src/nvim/ex_docmd.c | 126 ++++++++++++++++---------------- src/nvim/ex_eval.c | 2 +- src/nvim/ex_getln.c | 37 +++++----- src/nvim/fileio.c | 6 +- src/nvim/fold.c | 6 +- src/nvim/getchar.c | 95 ++++++++++++------------ src/nvim/grid.c | 13 ++-- src/nvim/grid.h | 4 +- src/nvim/hardcopy.c | 14 ++-- src/nvim/highlight_group.c | 22 +++--- src/nvim/if_cscope.c | 2 +- src/nvim/indent.c | 4 +- src/nvim/indent_c.c | 143 +++++++++++++++++++----------------- src/nvim/keymap.c | 12 +-- src/nvim/lua/executor.c | 4 +- src/nvim/macros.h | 2 +- src/nvim/mark.c | 2 +- src/nvim/match.c | 6 +- src/nvim/mbyte.c | 14 ++-- src/nvim/menu.c | 28 +++---- src/nvim/message.c | 12 +-- src/nvim/normal.c | 6 +- src/nvim/ops.c | 77 ++++++++++---------- src/nvim/ops.h | 10 +-- src/nvim/option.c | 16 ++-- src/nvim/os/env.c | 4 +- src/nvim/os/shell.c | 8 +- src/nvim/path.c | 2 +- src/nvim/quickfix.c | 12 +-- src/nvim/regexp.c | 8 +- src/nvim/regexp_bt.c | 2 +- src/nvim/regexp_nfa.c | 2 +- src/nvim/runtime.c | 36 ++++----- src/nvim/runtime.h | 2 +- src/nvim/screen.c | 20 +++-- src/nvim/search.c | 32 ++++---- src/nvim/shada.c | 4 +- src/nvim/sign.c | 14 ++-- src/nvim/spell.c | 64 ++++++++-------- src/nvim/spellfile.c | 12 +-- src/nvim/strings.c | 4 +- src/nvim/syntax.c | 44 +++++------ src/nvim/tag.c | 6 +- src/nvim/terminal.c | 3 +- src/nvim/viml/parser/expressions.c | 2 +- src/nvim/window.c | 4 +- 65 files changed, 758 insertions(+), 756 deletions(-) (limited to 'src') diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c index 185c043b06..5e7e51762a 100644 --- a/src/nvim/api/vim.c +++ b/src/nvim/api/vim.c @@ -245,11 +245,11 @@ void nvim_feedkeys(String keys, String mode, Boolean escape_ks) if (escape_ks) { // Need to escape K_SPECIAL before putting the string in the // typeahead buffer. - keys_esc = (char *)vim_strsave_escape_ks((char_u *)keys.data); + keys_esc = vim_strsave_escape_ks(keys.data); } else { keys_esc = keys.data; } - ins_typebuf((char_u *)keys_esc, (remap ? REMAP_YES : REMAP_NONE), + ins_typebuf(keys_esc, (remap ? REMAP_YES : REMAP_NONE), insert ? 0 : typebuf.tb_len, !typed, false); if (vgetc_busy) { typebuf_was_filled = true; @@ -416,7 +416,7 @@ String nvim_replace_termcodes(String str, Boolean from_part, Boolean do_lt, Bool } char *ptr = NULL; - replace_termcodes((char_u *)str.data, str.size, (char_u **)&ptr, flags, NULL, CPO_TO_CPO_FLAGS); + replace_termcodes(str.data, str.size, &ptr, flags, NULL, CPO_TO_CPO_FLAGS); return cstr_as_string(ptr); } @@ -513,14 +513,13 @@ ArrayOf(String) nvim_get_runtime_file(String name, Boolean all, Error *err) TRY_WRAP({ try_start(); - do_in_runtimepath((char_u *)(name.size ? name.data : ""), - flags, find_runtime_cb, &rv); + do_in_runtimepath((name.size ? name.data : ""), flags, find_runtime_cb, &rv); try_end(err); }); return rv; } -static void find_runtime_cb(char_u *fname, void *cookie) +static void find_runtime_cb(char *fname, void *cookie) { Array *rv = (Array *)cookie; if (fname != NULL) { @@ -563,13 +562,13 @@ void nvim_set_current_dir(String dir, Error *err) return; } - char_u string[MAXPATHL]; + char string[MAXPATHL]; memcpy(string, dir.data, dir.size); string[dir.size] = NUL; try_start(); - if (!changedir_func((char *)string, kCdScopeGlobal)) { + if (!changedir_func(string, kCdScopeGlobal)) { if (!try_end(err)) { api_set_error(err, kErrorTypeException, "Failed to change directory"); } @@ -722,7 +721,7 @@ Object nvim_get_option_value(String name, Dict(option) *opts, Error *err) long numval = 0; char *stringval = NULL; - switch (get_option_value(name.data, &numval, (char_u **)&stringval, scope)) { + switch (get_option_value(name.data, &numval, &stringval, scope)) { case 0: rv = STRING_OBJ(cstr_as_string(stringval)); break; @@ -1339,7 +1338,7 @@ Boolean nvim_paste(String data, Boolean crlf, Integer phase, Error *err) for (size_t i = 0; i < lines.size; i++) { String s = lines.items[i].data.string; assert(s.size <= INT_MAX); - AppendToRedobuffLit((char_u *)s.data, (int)s.size); + AppendToRedobuffLit(s.data, (int)s.size); // readfile()-style: "\n" is indicated by presence of N+1 item. if (i + 1 < lines.size) { AppendCharToRedobuff(NL); @@ -1392,7 +1391,7 @@ void nvim_put(ArrayOf(String) lines, String type, Boolean after, Boolean follow, goto cleanup; } String line = lines.items[i].data.string; - reg->y_array[i] = (char_u *)xmemdupz(line.data, line.size); + reg->y_array[i] = xmemdupz(line.data, line.size); memchrsub(reg->y_array[i], NUL, NL, line.size); } @@ -2352,9 +2351,9 @@ Dictionary nvim_eval_statusline(String str, Dict(eval_statusline) *opts, Error * ewp->w_p_crb = false; int width = build_stl_str_hl(ewp, - (char_u *)buf, + buf, sizeof(buf), - (char_u *)str.data, + str.data, false, fillchar, maxwidth, diff --git a/src/nvim/api/vimscript.c b/src/nvim/api/vimscript.c index 9396435466..c4a301839f 100644 --- a/src/nvim/api/vimscript.c +++ b/src/nvim/api/vimscript.c @@ -197,7 +197,7 @@ static Object _call_function(String fn, Array args, dict_T *self, Error *err) funcexe.selfdict = self; // call_func() retval is deceptive, ignore it. Instead we set `msg_list` // (see above) to capture abort-causing non-exception errors. - (void)call_func((char_u *)fn.data, (int)fn.size, &rettv, (int)args.size, + (void)call_func(fn.data, (int)fn.size, &rettv, (int)args.size, vim_args, &funcexe); if (!try_end(err)) { rv = vim_to_object(&rettv); @@ -290,7 +290,7 @@ Object nvim_call_dict_function(Object dict, String fn, Array args, Error *err) goto end; } fn = (String) { - .data = (char *)di->di_tv.vval.v_string, + .data = di->di_tv.vval.v_string, .size = STRLEN(di->di_tv.vval.v_string), }; } @@ -831,7 +831,7 @@ Dictionary nvim_parse_cmd(String str, Dictionary opts, Error *err) bool done = false; while (!done) { - done = uc_split_args_iter((char_u *)ea.arg, length, &end, buf, &len); + done = uc_split_args_iter(ea.arg, length, &end, buf, &len); if (len > 0) { ADD(args, STRING_OBJ(cstrn_to_string(buf, len))); } diff --git a/src/nvim/api/win_config.c b/src/nvim/api/win_config.c index e7704f72d7..0d8bdbec61 100644 --- a/src/nvim/api/win_config.c +++ b/src/nvim/api/win_config.c @@ -264,7 +264,7 @@ Dictionary nvim_win_get_config(Window window, Error *err) String s = cstrn_to_string((const char *)config->border_chars[i], sizeof(schar_T)); int hi_id = config->border_hl_ids[i]; - char_u *hi_name = syn_id2name(hi_id); + char *hi_name = (char *)syn_id2name(hi_id); if (hi_name[0]) { ADD(tuple, STRING_OBJ(s)); ADD(tuple, STRING_OBJ(cstr_to_string((const char *)hi_name))); @@ -387,7 +387,7 @@ static void parse_border_style(Object style, FloatConfig *fconfig, Error *err) return; } if (string.size - && mb_string2cells_len((char_u *)string.data, string.size) > 1) { + && mb_string2cells_len(string.data, string.size) > 1) { api_set_error(err, kErrorTypeValidation, "border chars must be one cell"); return; diff --git a/src/nvim/arabic.c b/src/nvim/arabic.c index db78e0e68f..e76a75d37a 100644 --- a/src/nvim/arabic.c +++ b/src/nvim/arabic.c @@ -957,11 +957,11 @@ int arabic_shape(int c, int *ccp, int *c1p, int prev_c, int prev_c1, int next_c) } if ((curr_c != c) && (ccp != NULL)) { - char_u buf[MB_MAXBYTES + 1]; + char buf[MB_MAXBYTES + 1]; // Update the first byte of the character utf_char2bytes(curr_c, buf); - *ccp = buf[0]; + *ccp = (uint8_t)buf[0]; } // Return the shaped character diff --git a/src/nvim/autocmd.c b/src/nvim/autocmd.c index b015a3fce0..1f8d6e6a1f 100644 --- a/src/nvim/autocmd.c +++ b/src/nvim/autocmd.c @@ -780,7 +780,7 @@ void do_autocmd(char *arg_in, int forceit) return; } - pat = (char *)skipwhite((char_u *)pat); + pat = skipwhite(pat); if (*pat == '|') { pat = ""; cmd = ""; @@ -811,7 +811,7 @@ void do_autocmd(char *arg_in, int forceit) } } - cmd = (char *)skipwhite((char_u *)cmd); + cmd = skipwhite(cmd); bool invalid_flags = false; for (size_t i = 0; i < 2; i++) { @@ -1216,7 +1216,7 @@ int do_doautocmd(char *arg_start, bool do_msg, bool *did_something) return FAIL; } - fname = (char *)skipwhite((char_u *)fname); + fname = skipwhite(fname); // Loop over the events. while (*arg && !ends_excmd(*arg) && !ascii_iswhite(*arg)) { @@ -1298,7 +1298,7 @@ bool check_nomodeline(char **argp) FUNC_ATTR_NONNULL_ALL FUNC_ATTR_WARN_UNUSED_RESULT { if (STRNCMP(*argp, "", 12) == 0) { - *argp = (char *)skipwhite((char_u *)(*argp) + 12); + *argp = skipwhite(*argp + 12); return false; } return true; @@ -2246,7 +2246,7 @@ char *set_context_in_autocmd(expand_T *xp, char *arg, int doautocmd) } // skip over pattern - arg = (char *)skipwhite((char_u *)p); + arg = skipwhite(p); while (*arg && (!ascii_iswhite(*arg) || arg[-1] == '\\')) { arg++; } @@ -2615,7 +2615,7 @@ static int arg_augroup_get(char **argp) if (group == AUGROUP_ERROR) { group = AUGROUP_ALL; // no match, use all groups } else { - *argp = (char *)skipwhite((char_u *)p); // match, skip over group name + *argp = skipwhite(p); // match, skip over group name } xfree(group_name); } @@ -2632,7 +2632,7 @@ static bool arg_autocmd_flag_get(bool *flag, char **cmd_ptr, char *pattern, int } *flag = true; - *cmd_ptr = (char *)skipwhite((char_u *)(*cmd_ptr) + len); + *cmd_ptr = skipwhite(*cmd_ptr + len); } return false; diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c index 9839f499eb..107f61919a 100644 --- a/src/nvim/buffer.c +++ b/src/nvim/buffer.c @@ -979,7 +979,7 @@ char *do_bufdel(int command, char_u *arg, int addr_count, int start_bnr, int end break; } } else { // addr_count == 1 - arg = skipwhite(arg); + arg = (char_u *)skipwhite((char *)arg); if (*arg == NUL) { break; } @@ -3151,8 +3151,8 @@ void maketitle(void) use_sandbox = was_set_insecurely(curwin, "titlestring", 0); called_emsg = false; - build_stl_str_hl(curwin, (char_u *)buf, sizeof(buf), - p_titlestring, use_sandbox, + build_stl_str_hl(curwin, buf, sizeof(buf), + (char *)p_titlestring, use_sandbox, 0, maxlen, NULL, NULL); title_str = (char_u *)buf; if (called_emsg) { @@ -3269,8 +3269,8 @@ void maketitle(void) use_sandbox = was_set_insecurely(curwin, "iconstring", 0); called_emsg = false; - build_stl_str_hl(curwin, icon_str, sizeof(buf), - p_iconstring, use_sandbox, + build_stl_str_hl(curwin, (char *)icon_str, sizeof(buf), + (char *)p_iconstring, use_sandbox, 0, 0, NULL, NULL); if (called_emsg) { set_string_option_direct("iconstring", -1, @@ -3383,8 +3383,8 @@ typedef enum { /// @param tabtab Tab clicks definition (can be NULL). /// /// @return The final width of the statusline -int build_stl_str_hl(win_T *wp, char_u *out, size_t outlen, char_u *fmt, int use_sandbox, - int fillchar, int maxwidth, stl_hlrec_t **hltab, StlClickRecord **tabtab) +int build_stl_str_hl(win_T *wp, char *out, size_t outlen, char *fmt, int use_sandbox, int fillchar, + int maxwidth, stl_hlrec_t **hltab, StlClickRecord **tabtab) { static size_t stl_items_len = 20; // Initial value, grows as needed. static stl_item_t *stl_items = NULL; @@ -3395,8 +3395,8 @@ int build_stl_str_hl(win_T *wp, char_u *out, size_t outlen, char_u *fmt, int use #define TMPLEN 70 char buf_tmp[TMPLEN]; - char_u win_tmp[TMPLEN]; - char_u *usefmt = fmt; + char win_tmp[TMPLEN]; + char *usefmt = fmt; const int save_must_redraw = must_redraw; const int save_redr_type = curwin->w_redr_type; @@ -3421,7 +3421,7 @@ int build_stl_str_hl(win_T *wp, char_u *out, size_t outlen, char_u *fmt, int use }; set_var(S_LEN("g:statusline_winid"), &tv, false); - usefmt = (char_u *)eval_to_string_safe((char *)fmt + 2, NULL, use_sandbox); + usefmt = eval_to_string_safe(fmt + 2, NULL, use_sandbox); if (usefmt == NULL) { usefmt = fmt; } @@ -3467,17 +3467,17 @@ int build_stl_str_hl(win_T *wp, char_u *out, size_t outlen, char_u *fmt, int use bool prevchar_isitem = false; // out_p is the current position in the output buffer - char_u *out_p = out; + char *out_p = out; // out_end_p is the last valid character in the output buffer // Note: The null termination character must occur here or earlier, // so any user-visible characters must occur before here. - char_u *out_end_p = (out + outlen) - 1; + char *out_end_p = (out + outlen) - 1; // Proceed character by character through the statusline format string // fmt_p is the current position in the input buffer - for (char_u *fmt_p = usefmt; *fmt_p;) { + for (char *fmt_p = usefmt; *fmt_p;) { if (curitem == (int)stl_items_len) { size_t new_len = stl_items_len * 3 / 2; @@ -3534,7 +3534,7 @@ int build_stl_str_hl(win_T *wp, char_u *out, size_t outlen, char_u *fmt, int use continue; } stl_items[curitem].type = Separate; - stl_items[curitem++].start = out_p; + stl_items[curitem++].start = (char_u *)out_p; continue; } @@ -3542,7 +3542,7 @@ int build_stl_str_hl(win_T *wp, char_u *out, size_t outlen, char_u *fmt, int use if (*fmt_p == STL_TRUNCMARK) { fmt_p++; stl_items[curitem].type = Trunc; - stl_items[curitem++].start = out_p; + stl_items[curitem++].start = (char_u *)out_p; continue; } @@ -3591,7 +3591,7 @@ int build_stl_str_hl(win_T *wp, char_u *out, size_t outlen, char_u *fmt, int use } if (n == curitem && group_start_userhl == group_end_userhl) { // empty group - out_p = t; + out_p = (char *)t; group_len = 0; for (n = stl_groupitems[groupdepth] + 1; n < curitem; n++) { // do not use the highlighting from the removed group @@ -3601,7 +3601,7 @@ int build_stl_str_hl(win_T *wp, char_u *out, size_t outlen, char_u *fmt, int use // adjust the start position of TabPage to the next // item position if (stl_items[n].type == TabPage) { - stl_items[n].start = out_p; + stl_items[n].start = (char_u *)out_p; } } } @@ -3624,7 +3624,7 @@ int build_stl_str_hl(win_T *wp, char_u *out, size_t outlen, char_u *fmt, int use *t = '<'; // { Move the truncated output - memmove(t + 1, t + n, (size_t)(out_p - (t + n))); + memmove(t + 1, t + n, (size_t)((char_u *)out_p - (t + n))); out_p = out_p - n + 1; // Fill up space left over by half a double-wide char. while (++group_len < stl_items[stl_groupitems[groupdepth]].minwid) { @@ -3657,7 +3657,7 @@ int build_stl_str_hl(win_T *wp, char_u *out, size_t outlen, char_u *fmt, int use } else { // { Move the group to the right group_len = (min_group_width - group_len) * utf_char2len(fillchar); - memmove(t + group_len, t, (size_t)(out_p - t)); + memmove(t + group_len, t, (size_t)((char_u *)out_p - t)); if (out_p + group_len >= (out_end_p + 1)) { group_len = (long)(out_end_p - out_p); } @@ -3696,14 +3696,14 @@ int build_stl_str_hl(win_T *wp, char_u *out, size_t outlen, char_u *fmt, int use // The first digit group is the item's min width if (ascii_isdigit(*fmt_p)) { - minwid = getdigits_int(&fmt_p, false, 0); + minwid = getdigits_int((char_u **)&fmt_p, false, 0); } // User highlight groups override the min width field // to denote the styling to use. if (*fmt_p == STL_USER_HL) { stl_items[curitem].type = Highlight; - stl_items[curitem].start = out_p; + stl_items[curitem].start = (char_u *)out_p; stl_items[curitem].minwid = minwid > 9 ? 1 : minwid; fmt_p++; curitem++; @@ -3749,7 +3749,7 @@ int build_stl_str_hl(win_T *wp, char_u *out, size_t outlen, char_u *fmt, int use } } stl_items[curitem].type = TabPage; - stl_items[curitem].start = out_p; + stl_items[curitem].start = (char_u *)out_p; stl_items[curitem].minwid = minwid; fmt_p++; curitem++; @@ -3758,7 +3758,7 @@ int build_stl_str_hl(win_T *wp, char_u *out, size_t outlen, char_u *fmt, int use if (*fmt_p == STL_CLICK_FUNC) { fmt_p++; - char *t = (char *)fmt_p; + char *t = fmt_p; while (*fmt_p != STL_CLICK_FUNC && *fmt_p) { fmt_p++; } @@ -3766,8 +3766,8 @@ int build_stl_str_hl(win_T *wp, char_u *out, size_t outlen, char_u *fmt, int use break; } stl_items[curitem].type = ClickFunc; - stl_items[curitem].start = out_p; - stl_items[curitem].cmd = xmemdupz(t, (size_t)(((char *)fmt_p - t))); + stl_items[curitem].start = (char_u *)out_p; + stl_items[curitem].cmd = xmemdupz(t, (size_t)(fmt_p - t)); stl_items[curitem].minwid = minwid; fmt_p++; curitem++; @@ -3779,7 +3779,7 @@ int build_stl_str_hl(win_T *wp, char_u *out, size_t outlen, char_u *fmt, int use if (*fmt_p == '.') { fmt_p++; if (ascii_isdigit(*fmt_p)) { - maxwid = getdigits_int(&fmt_p, false, 50); + maxwid = getdigits_int((char_u **)&fmt_p, false, 50); } } @@ -3791,7 +3791,7 @@ int build_stl_str_hl(win_T *wp, char_u *out, size_t outlen, char_u *fmt, int use if (*fmt_p == '(') { stl_groupitems[groupdepth++] = curitem; stl_items[curitem].type = Group; - stl_items[curitem].start = out_p; + stl_items[curitem].start = (char_u *)out_p; stl_items[curitem].minwid = minwid; stl_items[curitem].maxwid = maxwid; fmt_p++; @@ -3814,7 +3814,7 @@ int build_stl_str_hl(win_T *wp, char_u *out, size_t outlen, char_u *fmt, int use } // The status line item type - char_u opt = *fmt_p++; + char opt = *fmt_p++; // OK - now for the real work NumberBase base = kNumBaseDecimal; @@ -3845,7 +3845,7 @@ int build_stl_str_hl(win_T *wp, char_u *out, size_t outlen, char_u *fmt, int use break; case STL_VIM_EXPR: // '{' { - char_u *block_start = fmt_p - 1; + char *block_start = fmt_p - 1; int reevaluate = (*fmt_p == '%'); itemisflag = true; @@ -3855,7 +3855,7 @@ int build_stl_str_hl(win_T *wp, char_u *out, size_t outlen, char_u *fmt, int use // Attempt to copy the expression to evaluate into // the output buffer as a null-terminated string. - char_u *t = out_p; + char *t = out_p; while ((*fmt_p != '}' || (reevaluate && fmt_p[-1] != '%')) && *fmt_p != NUL && out_p < out_end_p) { *out_p++ = *fmt_p++; @@ -3893,7 +3893,7 @@ int build_stl_str_hl(win_T *wp, char_u *out, size_t outlen, char_u *fmt, int use } // Note: The result stored in `t` is unused. - str = eval_to_string_safe((char *)out_p, (char **)&t, use_sandbox); + str = eval_to_string_safe(out_p, &t, use_sandbox); curwin = save_curwin; curbuf = save_curbuf; @@ -3943,7 +3943,7 @@ int build_stl_str_hl(win_T *wp, char_u *out, size_t outlen, char_u *fmt, int use xfree(usefmt); } XFREE_CLEAR(str); - usefmt = new_fmt; + usefmt = (char *)new_fmt; fmt_p = usefmt + parsed_usefmt; evaldepth++; continue; @@ -4125,7 +4125,7 @@ int build_stl_str_hl(win_T *wp, char_u *out, size_t outlen, char_u *fmt, int use case STL_HIGHLIGHT: { // { The name of the highlight is surrounded by `#` - char_u *t = fmt_p; + char *t = fmt_p; while (*fmt_p != '#' && *fmt_p != NUL) { fmt_p++; } @@ -4134,8 +4134,8 @@ int build_stl_str_hl(win_T *wp, char_u *out, size_t outlen, char_u *fmt, int use // Create a highlight item based on the name if (*fmt_p == '#') { stl_items[curitem].type = Highlight; - stl_items[curitem].start = out_p; - stl_items[curitem].minwid = -syn_name2id_len(t, (size_t)(fmt_p - t)); + stl_items[curitem].start = (char_u *)out_p; + stl_items[curitem].minwid = -syn_name2id_len((char_u *)t, (size_t)(fmt_p - t)); curitem++; fmt_p++; } @@ -4146,14 +4146,14 @@ int build_stl_str_hl(win_T *wp, char_u *out, size_t outlen, char_u *fmt, int use // If we made it this far, the item is normal and starts at // our current position in the output buffer. // Non-normal items would have `continued`. - stl_items[curitem].start = out_p; + stl_items[curitem].start = (char_u *)out_p; stl_items[curitem].type = Normal; // Copy the item string into the output buffer if (str != NULL && *str) { // { Skip the leading `,` or ` ` if the item is a flag // and the proper conditions are met - char_u *t = (char_u *)str; + char *t = str; if (itemisflag) { if ((t[0] && t[1]) && ((!prevchar_isitem && *t == ',') @@ -4164,7 +4164,7 @@ int build_stl_str_hl(win_T *wp, char_u *out, size_t outlen, char_u *fmt, int use } // } - long l = vim_strsize(t); + long l = vim_strsize((char_u *)t); // If this item is non-empty, record that the last thing // we put in the output buffer was an item @@ -4175,8 +4175,8 @@ int build_stl_str_hl(win_T *wp, char_u *out, size_t outlen, char_u *fmt, int use // If the item is too wide, truncate it from the beginning if (l > maxwid) { while (l >= maxwid) { - l -= ptr2cells(t); - t += utfc_ptr2len((char *)t); + l -= ptr2cells((char_u *)t); + t += utfc_ptr2len(t); } // Early out if there isn't enough room for the truncation marker @@ -4292,11 +4292,9 @@ int build_stl_str_hl(win_T *wp, char_u *out, size_t outlen, char_u *fmt, int use *++t = 0; // } - vim_snprintf((char *)out_p, remaining_buf_len, (char *)nstr, - 0, num, n); + vim_snprintf(out_p, remaining_buf_len, (char *)nstr, 0, num, n); } else { - vim_snprintf((char *)out_p, remaining_buf_len, (char *)nstr, - minwid, num); + vim_snprintf(out_p, remaining_buf_len, (char *)nstr, minwid, num); } // Advance the output buffer position to the end of the @@ -4333,7 +4331,7 @@ int build_stl_str_hl(win_T *wp, char_u *out, size_t outlen, char_u *fmt, int use // We have now processed the entire statusline format string. // What follows is post-processing to handle alignment and highlighting. - int width = vim_strsize(out); + int width = vim_strsize((char_u *)out); if (maxwidth > 0 && width > maxwidth) { // Result is too long, must truncate somewhere. int item_idx = 0; @@ -4341,7 +4339,7 @@ int build_stl_str_hl(win_T *wp, char_u *out, size_t outlen, char_u *fmt, int use // If there are no items, truncate from beginning if (itemcnt == 0) { - trunc_p = out; + trunc_p = (char_u *)out; // Otherwise, look for the truncation item } else { @@ -4364,7 +4362,7 @@ int build_stl_str_hl(win_T *wp, char_u *out, size_t outlen, char_u *fmt, int use if (width - vim_strsize(trunc_p) >= maxwidth) { // Walk from the beginning of the // string to find the last character that will fit. - trunc_p = out; + trunc_p = (char_u *)out; width = 0; for (;;) { width += ptr2cells(trunc_p); @@ -5179,7 +5177,7 @@ static int chk_modeline(linenr_T lnum, int flags) if (*e == ':' && (s[0] != 'V' - || STRNCMP(skipwhite(e + 1), "set", 3) == 0) + || STRNCMP(skipwhite((char *)e + 1), "set", 3) == 0) && (s[3] == ':' || (VIM_VERSION_100 >= vers && isdigit(s[3])) || (VIM_VERSION_100 < vers && s[3] == '<') @@ -5209,7 +5207,7 @@ static int chk_modeline(linenr_T lnum, int flags) end = false; while (end == false) { - s = skipwhite(s); + s = (char_u *)skipwhite((char *)s); if (*s == NUL) { break; } diff --git a/src/nvim/change.c b/src/nvim/change.c index 426310488a..abc000d236 100644 --- a/src/nvim/change.c +++ b/src/nvim/change.c @@ -550,7 +550,7 @@ void ins_bytes_len(char_u *p, size_t len) void ins_char(int c) { char_u buf[MB_MAXBYTES + 1]; - size_t n = (size_t)utf_char2bytes(c, buf); + size_t n = (size_t)utf_char2bytes(c, (char *)buf); // When "c" is 0x100, 0x200, etc. we don't want to insert a NUL byte. // Happens for CTRL-Vu9900. @@ -1010,7 +1010,7 @@ int open_line(int dir, int flags, int second_line_indent, bool *did_do_comment) && !(State & VREPLACE_FLAG)) { p_extra = saved_line + curwin->w_cursor.col; if (do_si) { // need first char after new line break - p = skipwhite(p_extra); + p = (char_u *)skipwhite((char *)p_extra); first_char = *p; } extra_len = (int)STRLEN(p_extra); @@ -1077,7 +1077,7 @@ int open_line(int dir, int flags, int second_line_indent, bool *did_do_comment) // */ // #define IN_THE_WAY // This should line up here; - p = skipwhite(ptr); + p = (char_u *)skipwhite((char *)ptr); if (p[0] == '/' && p[1] == '*') { p++; } @@ -1160,7 +1160,7 @@ int open_line(int dir, int flags, int second_line_indent, bool *did_do_comment) newindent = get_indent(); } } - p = skipwhite(ptr); + p = (char_u *)skipwhite((char *)ptr); if (*p == '}') { // if line starts with '}': do indent did_si = true; } else { // can delete indent when '{' typed @@ -1296,7 +1296,7 @@ int open_line(int dir, int flags, int second_line_indent, bool *did_do_comment) // Remember where the end is, might want to use it to find the // start (for C-comments). if (dir == FORWARD) { - comment_end = skipwhite(saved_line); + comment_end = (char_u *)skipwhite((char *)saved_line); lead_len = 0; break; } @@ -1426,7 +1426,7 @@ int open_line(int dir, int flags, int second_line_indent, bool *did_do_comment) } } } else { // left adjusted leader - p = skipwhite(leader); + p = (char_u *)skipwhite((char *)leader); // Compute the length of the replaced characters in // screen characters, not bytes. Move the part that is // not to be overwritten. @@ -1500,7 +1500,7 @@ int open_line(int dir, int flags, int second_line_indent, bool *did_do_comment) while (off > 0 && lead_len > 0 && leader[lead_len - 1] == ' ') { // Don't do it when there is a tab before the space - if (vim_strchr(skipwhite(leader), '\t') != NULL) { + if (vim_strchr((char_u *)skipwhite((char *)leader), '\t') != NULL) { break; } lead_len--; diff --git a/src/nvim/charset.c b/src/nvim/charset.c index 6012c2ebc6..466d943c3e 100644 --- a/src/nvim/charset.c +++ b/src/nvim/charset.c @@ -488,7 +488,7 @@ char_u *str_foldcase(char_u *str, int orglen, char_u *buf, int buflen) } } } - (void)utf_char2bytes(lc, STR_PTR(i)); + (void)utf_char2bytes(lc, (char *)STR_PTR(i)); } // skip to next multi-byte char @@ -1144,11 +1144,11 @@ void getvcols(win_T *wp, pos_T *pos1, pos_T *pos2, colnr_T *left, colnr_T *right /// @param[in] p String to skip in. /// /// @return Pointer to character after the skipped whitespace. -char_u *skipwhite(const char_u *const p) +char *skipwhite(const char *const p) FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL FUNC_ATTR_NONNULL_RET { - return skipwhite_len(p, STRLEN(p)); + return (char *)skipwhite_len((char_u *)p, STRLEN(p)); } /// Like `skipwhite`, but skip up to `len` characters. @@ -1179,7 +1179,7 @@ intptr_t getwhitecols_curline(void) intptr_t getwhitecols(const char_u *p) FUNC_ATTR_PURE { - return skipwhite(p) - p; + return (char_u *)skipwhite((char *)p) - p; } /// Skip over digits @@ -1400,7 +1400,7 @@ long getdigits_long(char_u **pp, bool strict, long def) bool vim_isblankline(char_u *lbuf) FUNC_ATTR_PURE { - char_u *p = skipwhite(lbuf); + char_u *p = (char_u *)skipwhite((char *)lbuf); return *p == NUL || *p == '\r' || *p == '\n'; } diff --git a/src/nvim/context.c b/src/nvim/context.c index c30a05a3c8..0e0d8fdfde 100644 --- a/src/nvim/context.c +++ b/src/nvim/context.c @@ -130,7 +130,7 @@ bool ctx_restore(Context *ctx, const int flags) } char_u *op_shada; - get_option_value("shada", NULL, &op_shada, OPT_GLOBAL); + get_option_value("shada", NULL, (char **)&op_shada, OPT_GLOBAL); set_option_value("shada", 0L, "!,'100,%", OPT_GLOBAL); if (flags & kCtxRegs) { diff --git a/src/nvim/debugger.c b/src/nvim/debugger.c index 96bc4db71e..662b9bfb0a 100644 --- a/src/nvim/debugger.c +++ b/src/nvim/debugger.c @@ -141,7 +141,7 @@ void do_debug(char_u *cmd) // If this is a debug command, set "last_cmd". // If not, reset "last_cmd". // For a blank line use previous command. - p = skipwhite(cmdline); + p = (char_u *)skipwhite((char *)cmdline); if (*p != NUL) { switch (*p) { case 'c': @@ -242,7 +242,7 @@ void do_debug(char_u *cmd) if (*p == NUL) { do_showbacktrace(cmd); } else { - p = skipwhite(p); + p = (char_u *)skipwhite((char *)p); do_setdebugtracelevel(p); } continue; @@ -501,14 +501,14 @@ static int dbg_parsearg(char_u *arg, garray_T *gap) semsg(_(e_invarg2), p); return FAIL; } - p = skipwhite(p + 4); + p = (char_u *)skipwhite((char *)p + 4); // Find optional line number. if (here) { bp->dbg_lnum = curwin->w_cursor.lnum; } else if (gap != &prof_ga && ascii_isdigit(*p)) { bp->dbg_lnum = getdigits_long(&p, true, 0); - p = skipwhite(p); + p = (char_u *)skipwhite((char *)p); } else { bp->dbg_lnum = 0; } diff --git a/src/nvim/diff.c b/src/nvim/diff.c index 7e296ebf52..55992f3fae 100644 --- a/src/nvim/diff.c +++ b/src/nvim/diff.c @@ -754,7 +754,7 @@ static int diff_write_buffer(buf_T *buf, diffin_T *din) c = utf_fold(c); } const int orig_len = utfc_ptr2len((char *)s); - if (utf_char2bytes(c, cbuf) != orig_len) { + if (utf_char2bytes(c, (char *)cbuf) != orig_len) { // TODO(Bram): handle byte length difference memmove(ptr + len, s, (size_t)orig_len); } else { @@ -1970,7 +1970,7 @@ static bool diff_equal_char(const char_u *const p1, const char_u *const p2, int static int diff_cmp(char_u *s1, char_u *s2) { if ((diff_flags & DIFF_IBLANK) - && (*skipwhite(s1) == NUL || *skipwhite(s2) == NUL)) { + && (*(char_u *)skipwhite((char *)s1) == NUL || *skipwhite((char *)s2) == NUL)) { return 0; } @@ -1991,8 +1991,8 @@ static int diff_cmp(char_u *s1, char_u *s2) && ascii_iswhite(*p1) && ascii_iswhite(*p2)) || ((diff_flags & DIFF_IWHITEALL) && (ascii_iswhite(*p1) || ascii_iswhite(*p2)))) { - p1 = skipwhite(p1); - p2 = skipwhite(p2); + p1 = (char_u *)skipwhite((char *)p1); + p2 = (char_u *)skipwhite((char *)p2); } else { int l; if (!diff_equal_char(p1, p2, &l)) { @@ -2004,8 +2004,8 @@ static int diff_cmp(char_u *s1, char_u *s2) } // Ignore trailing white space. - p1 = skipwhite(p1); - p2 = skipwhite(p2); + p1 = (char_u *)skipwhite((char *)p1); + p2 = (char_u *)skipwhite((char *)p2); if ((*p1 != NUL) || (*p2 != NUL)) { return 1; @@ -2334,8 +2334,8 @@ bool diff_find_change(win_T *wp, linenr_T lnum, int *startp, int *endp) || ((diff_flags & DIFF_IWHITEALL) && (ascii_iswhite(line_org[si_org]) || ascii_iswhite(line_new[si_new])))) { - si_org = (int)(skipwhite(line_org + si_org) - line_org); - si_new = (int)(skipwhite(line_new + si_new) - line_new); + si_org = (int)((char_u *)skipwhite((char *)line_org + si_org) - line_org); + si_new = (int)((char_u *)skipwhite((char *)line_new + si_new) - line_new); } else { if (!diff_equal_char(line_org + si_org, line_new + si_new, &l)) { break; diff --git a/src/nvim/digraph.c b/src/nvim/digraph.c index 7d95cf5184..84073b352b 100644 --- a/src/nvim/digraph.c +++ b/src/nvim/digraph.c @@ -1646,7 +1646,7 @@ bool check_digraph_chars_valid(int char1, int char2) { if (char2 == 0) { char_u msg[MB_MAXBYTES + 1]; - msg[utf_char2bytes(char1, msg)] = NUL; + msg[utf_char2bytes(char1, (char *)msg)] = NUL; semsg(_(e_digraph_must_be_just_two_characters_str), msg); return false; } @@ -1664,7 +1664,7 @@ bool check_digraph_chars_valid(int char1, int char2) void putdigraph(char_u *str) { while (*str != NUL) { - str = skipwhite(str); + str = (char_u *)skipwhite((char *)str); if (*str == NUL) { return; @@ -1676,7 +1676,7 @@ void putdigraph(char_u *str) return; } - str = skipwhite(str); + str = (char_u *)skipwhite((char *)str); if (!ascii_isdigit(*str)) { emsg(_(e_number_exp)); @@ -1745,7 +1745,7 @@ static void digraph_getlist_appendpair(const digr_T *dp, list_T *l) tv_list_append_string(l2, (char *)buf, -1); char_u *p = buf; - p += utf_char2bytes(dp->result, p); + p += utf_char2bytes(dp->result, (char *)p); *p = NUL; tv_list_append_string(l2, (char *)buf, -1); } @@ -1853,7 +1853,7 @@ static void printdigraph(const digr_T *dp, result_T *previous) if (utf_iscomposing(dp->result)) { *p++ = ' '; } - p += utf_char2bytes(dp->result, p); + p += utf_char2bytes(dp->result, (char *)p); *p = NUL; msg_outtrans_attr(buf, HL_ATTR(HLF_8)); @@ -1933,7 +1933,7 @@ void f_digraph_get(typval_T *argvars, typval_T *rettv, FunPtr fptr) int code = digraph_get(digraphs[0], digraphs[1], false); char_u buf[NUMBUFLEN]; - buf[utf_char2bytes(code, buf)] = NUL; + buf[utf_char2bytes(code, (char *)buf)] = NUL; rettv->vval.v_string = (char *)vim_strsave(buf); } @@ -2093,13 +2093,13 @@ void ex_loadkeymap(exarg_T *eap) break; } - char_u *p = skipwhite(line); + char_u *p = (char_u *)skipwhite((char *)line); if ((*p != '"') && (*p != NUL)) { kmap_T *kp = GA_APPEND_VIA_PTR(kmap_T, &curbuf->b_kmap_ga); s = skiptowhite(p); kp->from = vim_strnsave(p, (size_t)(s - p)); - p = skipwhite(s); + p = (char_u *)skipwhite((char *)s); s = skiptowhite(p); kp->to = vim_strnsave(p, (size_t)(s - p)); diff --git a/src/nvim/edit.c b/src/nvim/edit.c index e7c9eea27b..5002ef2710 100644 --- a/src/nvim/edit.c +++ b/src/nvim/edit.c @@ -1339,7 +1339,7 @@ normalchar: ins_char(s->c); } } - AppendToRedobuffLit(str, -1); + AppendToRedobuffLit((char *)str, -1); } xfree(str); s->c = NUL; @@ -2354,7 +2354,7 @@ int ins_compl_add_infercase(char_u *str_arg, int len, bool icase, char_u *fname, char_u *p = IObuff; i = 0; while (i < actual_len && (p - IObuff + 6) < IOSIZE) { - p += utf_char2bytes(wca[i++], p); + p += utf_char2bytes(wca[i++], (char *)p); } *p = NUL; } @@ -3515,7 +3515,7 @@ static void ins_compl_addleader(int c) if ((cc = utf_char2len(c)) > 1) { char_u buf[MB_MAXBYTES + 1]; - utf_char2bytes(c, buf); + utf_char2bytes(c, (char *)buf); buf[cc] = NUL; ins_char_bytes(buf, (size_t)cc); } else { @@ -3939,7 +3939,7 @@ static void ins_compl_fixRedoBufForLeader(char_u *ptr_arg) } else { len = 0; } - AppendToRedobuffLit(ptr + len, -1); + AppendToRedobuffLit((char *)ptr + len, -1); } /* @@ -4513,7 +4513,7 @@ static int ins_compl_get_exp(pos_T *ini) } ptr = ml_get_buf(ins_buf, pos->lnum + 1, false); if (!p_paste) { - ptr = skipwhite(ptr); + ptr = (char_u *)skipwhite((char *)ptr); } } len = (int)STRLEN(ptr); @@ -4541,7 +4541,7 @@ static int ins_compl_get_exp(pos_T *ini) // compl_length, so the next STRNCPY always works -- Acevedo STRNCPY(IObuff, ptr, len); ptr = ml_get_buf(ins_buf, pos->lnum + 1, false); - tmp_ptr = ptr = skipwhite(ptr); + tmp_ptr = ptr = (char_u *)skipwhite((char *)ptr); // Find start of next word. tmp_ptr = find_word_start(tmp_ptr); // Find end of next word. @@ -5126,8 +5126,9 @@ static int ins_complete(int c, bool enable_pum) * mode but first we need to redefine compl_startpos */ if (compl_cont_status & CONT_S_IPOS) { compl_cont_status |= CONT_SOL; - compl_startpos.col = (colnr_T)(skipwhite(line + compl_length - + compl_startpos.col) - line); + compl_startpos.col = (colnr_T)((char_u *)skipwhite((char *)line + + compl_length + + compl_startpos.col) - line); } compl_col = compl_startpos.col; } @@ -5739,8 +5740,8 @@ static void insert_special(int c, int allow_modmask, int ctrlv) } p[len - 1] = NUL; ins_str(p); - AppendToRedobuffLit(p, -1); - ctrlv = FALSE; + AppendToRedobuffLit((char *)p, -1); + ctrlv = false; } } if (stop_arrow() == OK) { @@ -5942,7 +5943,7 @@ void insertchar(int c, int flags, int second_indent) i = 0; } if (buf[i] != NUL) { - AppendToRedobuffLit(buf + i, -1); + AppendToRedobuffLit((char *)buf + i, -1); } } else { int cc; @@ -5950,7 +5951,7 @@ void insertchar(int c, int flags, int second_indent) if ((cc = utf_char2len(c)) > 1) { char_u buf[MB_MAXBYTES + 1]; - utf_char2bytes(c, buf); + utf_char2bytes(c, (char *)buf); buf[cc] = NUL; ins_char_bytes(buf, (size_t)cc); AppendCharToRedobuff(c); @@ -6853,7 +6854,7 @@ char_u *add_char2buf(int c, char_u *s) FUNC_ATTR_NONNULL_ALL FUNC_ATTR_WARN_UNUSED_RESULT { char_u temp[MB_MAXBYTES + 1]; - const int len = utf_char2bytes(c, temp); + const int len = utf_char2bytes(c, (char *)temp); for (int i = 0; i < len; i++) { c = temp[i]; // Need to escape K_SPECIAL like in the typeahead buffer. @@ -7557,7 +7558,7 @@ bool in_cinkeys(int keytyped, int when, bool line_is_empty) } else if (*look == 'e') { if (try_match && keytyped == 'e' && curwin->w_cursor.col >= 4) { p = get_cursor_line_ptr(); - if (skipwhite(p) == p + curwin->w_cursor.col - 4 + if ((char_u *)skipwhite((char *)p) == p + curwin->w_cursor.col - 4 && STRNCMP(p + curwin->w_cursor.col - 4, "else", 4) == 0) { return true; } @@ -8226,7 +8227,7 @@ static void ins_shift(int c, int lastc) change_indent(c == Ctrl_D ? INDENT_DEC : INDENT_INC, 0, TRUE, 0, TRUE); } - if (did_ai && *skipwhite(get_cursor_line_ptr()) != NUL) { + if (did_ai && *skipwhite((char *)get_cursor_line_ptr()) != NUL) { did_ai = false; } did_si = false; @@ -9413,7 +9414,7 @@ static void ins_try_si(int c) old_pos = curwin->w_cursor; i = get_indent(); while (curwin->w_cursor.lnum > 1) { - ptr = skipwhite(ml_get(--(curwin->w_cursor.lnum))); + ptr = (char_u *)skipwhite((char *)ml_get(--(curwin->w_cursor.lnum))); // ignore empty lines and lines starting with '#'. if (*ptr != '#' && *ptr != NUL) { @@ -9479,7 +9480,7 @@ static char_u *do_insert_char_pre(int c) if (!has_event(EVENT_INSERTCHARPRE)) { return NULL; } - buf[utf_char2bytes(c, (char_u *)buf)] = NUL; + buf[utf_char2bytes(c, buf)] = NUL; // Lock the text to avoid weird things from happening. textlock++; diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 901976bb16..01f913dd70 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -778,7 +778,7 @@ int eval_expr_typval(const typval_T *expr, typval_T *argv, int argc, typval_T *r return FAIL; } funcexe.evaluate = true; - if (call_func((char_u *)s, -1, rettv, argc, argv, &funcexe) == FAIL) { + if (call_func(s, -1, rettv, argc, argv, &funcexe) == FAIL) { return FAIL; } } else if (expr->v_type == VAR_PARTIAL) { @@ -789,7 +789,7 @@ int eval_expr_typval(const typval_T *expr, typval_T *argv, int argc, typval_T *r } funcexe.evaluate = true; funcexe.partial = partial; - if (call_func((char_u *)s, -1, rettv, argc, argv, &funcexe) == FAIL) { + if (call_func(s, -1, rettv, argc, argv, &funcexe) == FAIL) { return FAIL; } } else { @@ -798,11 +798,11 @@ int eval_expr_typval(const typval_T *expr, typval_T *argv, int argc, typval_T *r if (s == NULL) { return FAIL; } - s = (char *)skipwhite((char_u *)s); + s = skipwhite(s); if (eval1_emsg(&s, rettv, true) == FAIL) { return FAIL; } - if (*skipwhite((char_u *)s) != NUL) { // check for trailing chars after expr + if (*skipwhite(s) != NUL) { // check for trailing chars after expr tv_clear(rettv); semsg(_(e_invexpr2), s); return FAIL; @@ -865,7 +865,7 @@ int skip_expr(char **pp) { typval_T rettv; - *pp = (char *)skipwhite((char_u *)(*pp)); + *pp = skipwhite(*pp); return eval1(pp, &rettv, false); } @@ -938,7 +938,7 @@ varnumber_T eval_to_number(char *expr) { typval_T rettv; varnumber_T retval; - char *p = (char *)skipwhite((char_u *)expr); + char *p = skipwhite(expr); ++emsg_off; @@ -1014,7 +1014,7 @@ list_T *eval_spell_expr(char *badword, char *expr) typval_T save_val; typval_T rettv; list_T *list = NULL; - char *p = (char *)skipwhite((char_u *)expr); + char *p = skipwhite(expr); // Set "v:val" to the bad word. prepare_vimvar(VV_VAL, &save_val); @@ -1096,7 +1096,7 @@ int call_vim_function(const char *func, int argc, typval_T *argv, typval_T *rett funcexe.lastline = curwin->w_cursor.lnum; funcexe.evaluate = true; funcexe.partial = pt; - ret = call_func((char_u *)func, len, rettv, argc, argv, &funcexe); + ret = call_func(func, len, rettv, argc, argv, &funcexe); fail: if (ret == FAIL) { @@ -1287,10 +1287,10 @@ static list_T *heredoc_get(exarg_T *eap, char *cmd) } // Check for the optional 'trim' word before the marker - cmd = (char *)skipwhite((char_u *)cmd); + cmd = skipwhite(cmd); if (STRNCMP(cmd, "trim", 4) == 0 && (cmd[4] == NUL || ascii_iswhite(cmd[4]))) { - cmd = (char *)skipwhite((char_u *)cmd + 4); + cmd = skipwhite(cmd + 4); // Trim the indentation from all the lines in the here document. // The amount of indentation trimmed is the same as the indentation of @@ -1306,9 +1306,9 @@ static list_T *heredoc_get(exarg_T *eap, char *cmd) // The marker is the next word. if (*cmd != NUL && *cmd != '"') { - marker = (char *)skipwhite((char_u *)cmd); + marker = skipwhite(cmd); p = (char *)skiptowhite((char_u *)marker); - if (*skipwhite((char_u *)p) != NUL && *skipwhite((char_u *)p) != '"') { + if (*skipwhite(p) != NUL && *skipwhite(p) != '"') { emsg(_(e_trailing)); return NULL; } @@ -1406,7 +1406,7 @@ static void ex_let_const(exarg_T *eap, const bool is_const) if (argend > arg && argend[-1] == '.') { // For var.='str'. argend--; } - expr = (char *)skipwhite((char_u *)argend); + expr = skipwhite(argend); if (*expr != '=' && !((vim_strchr((char_u *)"+-*/%.", *expr) != NULL && expr[1] == '=') || STRNCMP(expr, "..=", 3) == 0)) { // ":let" without "=": list variables @@ -1449,9 +1449,9 @@ static void ex_let_const(exarg_T *eap, const bool is_const) expr++; } } - expr = (char *)skipwhite((char_u *)expr + 2); + expr = skipwhite(expr + 2); } else { - expr = (char *)skipwhite((char_u *)expr + 1); + expr = skipwhite(expr + 1); } if (eap->skip) { @@ -1522,7 +1522,7 @@ static int ex_let_vars(char *arg_start, typval_T *tv, int copy, int semicolon, i listitem_T *item = tv_list_first(l); size_t rest_len = tv_list_len(l); while (*arg != ']') { - arg = (char *)skipwhite((char_u *)arg + 1); + arg = skipwhite(arg + 1); arg = ex_let_one(arg, TV_LIST_ITEM_TV(item), true, is_const, ",;]", op); if (arg == NULL) { return FAIL; @@ -1530,7 +1530,7 @@ static int ex_let_vars(char *arg_start, typval_T *tv, int copy, int semicolon, i rest_len--; item = TV_LIST_ITEM_NEXT(l, item); - arg = (char *)skipwhite((char_u *)arg); + arg = skipwhite(arg); if (*arg == ';') { /* Put the rest of the list (may be empty) in the var after ';'. * Create a new list for this. */ @@ -1545,7 +1545,7 @@ static int ex_let_vars(char *arg_start, typval_T *tv, int copy, int semicolon, i ltv.vval.v_list = rest_list; tv_list_ref(rest_list); - arg = ex_let_one((char *)skipwhite((char_u *)arg + 1), <v, false, is_const, "]", op); + arg = ex_let_one(skipwhite(arg + 1), <v, false, is_const, "]", op); tv_clear(<v); if (arg == NULL) { return FAIL; @@ -1575,7 +1575,7 @@ static const char *skip_var_list(const char *arg, int *var_count, int *semicolon // "[var, var]": find the matching ']'. p = arg; for (;;) { - p = (char *)skipwhite((char_u *)p + 1); // skip whites after '[', ';' or ',' + p = skipwhite(p + 1); // skip whites after '[', ';' or ',' s = skip_var_one((char *)p); if (s == p) { semsg(_(e_invarg2), p); @@ -1583,7 +1583,7 @@ static const char *skip_var_list(const char *arg, int *var_count, int *semicolon } ++*var_count; - p = (char *)skipwhite((char_u *)s); + p = skipwhite(s); if (*p == ']') { break; } else if (*p == ';') { @@ -1766,7 +1766,7 @@ static const char *list_arg_vars(exarg_T *eap, const char *arg, int *first) xfree(tofree); } - arg = (const char *)skipwhite((const char_u *)arg); + arg = (const char *)skipwhite(arg); } return arg; @@ -1812,7 +1812,7 @@ static char *ex_let_one(char *arg, typval_T *const tv, const bool copy, const bo if (op != NULL && vim_strchr((char_u *)"+-*/%", *op) != NULL) { semsg(_(e_letwrong), op); } else if (endchars != NULL - && vim_strchr((char_u *)endchars, *skipwhite((char_u *)arg)) == NULL) { + && vim_strchr((char_u *)endchars, *skipwhite(arg)) == NULL) { emsg(_(e_letunexp)); } else if (!check_secure()) { const char c1 = name[len]; @@ -1855,7 +1855,7 @@ static char *ex_let_one(char *arg, typval_T *const tv, const bool copy, const bo char *const p = (char *)find_option_end((const char **)&arg, &opt_flags); if (p == NULL || (endchars != NULL - && vim_strchr((char_u *)endchars, *skipwhite((const char_u *)p)) == NULL)) { + && vim_strchr((char_u *)endchars, *skipwhite(p)) == NULL)) { emsg(_(e_letunexp)); } else { int opt_type; @@ -1871,8 +1871,7 @@ static char *ex_let_one(char *arg, typval_T *const tv, const bool copy, const bo s = tv_get_string_chk(tv); // != NULL if number or string. } if (s != NULL && op != NULL && *op != '=') { - opt_type = get_option_value(arg, &numval, (char_u **)&stringval, - opt_flags); + opt_type = get_option_value(arg, &numval, &stringval, opt_flags); if ((opt_type == 1 && *op == '.') || (opt_type == 0 && *op != '.')) { semsg(_(e_letwrong), op); @@ -1918,7 +1917,7 @@ static char *ex_let_one(char *arg, typval_T *const tv, const bool copy, const bo if (op != NULL && vim_strchr((char_u *)"+-*/%", *op) != NULL) { semsg(_(e_letwrong), op); } else if (endchars != NULL - && vim_strchr((char_u *)endchars, *skipwhite((char_u *)arg + 1)) == NULL) { + && vim_strchr((char_u *)endchars, *skipwhite(arg + 1)) == NULL) { emsg(_(e_letunexp)); } else { char *s; @@ -1950,7 +1949,7 @@ static char *ex_let_one(char *arg, typval_T *const tv, const bool copy, const bo char *const p = get_lval(arg, tv, &lv, false, false, 0, FNE_CHECK_START); if (p != NULL && lv.ll_name != NULL) { - if (endchars != NULL && vim_strchr((char_u *)endchars, *skipwhite((char_u *)p)) == NULL) { + if (endchars != NULL && vim_strchr((char_u *)endchars, *skipwhite(p)) == NULL) { emsg(_(e_letunexp)); } else { set_var_lval(&lv, p, tv, copy, is_const, op); @@ -2098,7 +2097,7 @@ char *get_lval(char *const name, typval_T *const rettv, lval_T *const lp, const p = key + len; } else { // Get the index [expr] or the first index [expr: ]. - p = (char *)skipwhite((char_u *)p + 1); + p = skipwhite(p + 1); if (*p == ':') { empty1 = true; } else { @@ -2111,7 +2110,7 @@ char *get_lval(char *const name, typval_T *const rettv, lval_T *const lp, const tv_clear(&var1); return NULL; } - p = (char *)skipwhite((char_u *)p); + p = skipwhite(p); } // Optionally get the second index [ :expr]. @@ -2132,7 +2131,7 @@ char *get_lval(char *const name, typval_T *const rettv, lval_T *const lp, const tv_clear(&var1); return NULL; } - p = (char *)skipwhite((char_u *)p + 1); + p = skipwhite(p + 1); if (*p == ']') { lp->ll_empty2 = true; } else { @@ -2577,7 +2576,7 @@ void *eval_for_line(const char *arg, bool *errp, char **nextcmdp, int skip) return fi; } - expr = (char *)skipwhite((char_u *)expr); + expr = skipwhite(expr); if (expr[0] != 'i' || expr[1] != 'n' || !ascii_iswhite(expr[2])) { emsg(_("E690: Missing \"in\" after :for")); return fi; @@ -2586,7 +2585,7 @@ void *eval_for_line(const char *arg, bool *errp, char **nextcmdp, int skip) if (skip) { ++emsg_skip; } - if (eval0((char *)skipwhite((char_u *)expr + 2), &tv, nextcmdp, !skip) == OK) { + if (eval0(skipwhite(expr + 2), &tv, nextcmdp, !skip) == OK) { *errp = false; if (!skip) { if (tv.v_type == VAR_LIST) { @@ -2798,10 +2797,10 @@ void set_context_for_expression(expand_T *xp, char *arg, cmdidx_T cmdidx) for (;;) { char *const n = (char *)skiptowhite((char_u *)arg); - if (n == arg || ascii_iswhite_or_nul(*skipwhite((char_u *)n))) { + if (n == arg || ascii_iswhite_or_nul(*skipwhite(n))) { break; } - arg = (char *)skipwhite((char_u *)n); + arg = skipwhite(n); } } @@ -2826,7 +2825,7 @@ void ex_lockvar(exarg_T *eap) deep = -1; } else if (ascii_isdigit(*arg)) { deep = getdigits_int((char_u **)&arg, false, -1); - arg = (char *)skipwhite((char_u *)arg); + arg = skipwhite(arg); } ex_unletlock(eap, arg, deep, do_lock_var); @@ -2891,7 +2890,7 @@ static void ex_unletlock(exarg_T *eap, char *argstart, int deep, ex_unletlock_ca clear_lval(&lv); } } - arg = (char *)skipwhite((char_u *)name_end); + arg = skipwhite(name_end); } while (!ends_excmd(*arg)); eap->nextcmd = (char *)check_nextcmd((char_u *)arg); @@ -3355,7 +3354,7 @@ int eval0(char *arg, typval_T *rettv, char **nextcmd, int evaluate) const int did_emsg_before = did_emsg; const int called_emsg_before = called_emsg; - p = (char *)skipwhite((char_u *)arg); + p = skipwhite(arg); ret = eval1(&p, rettv, evaluate); if (ret == FAIL || !ends_excmd(*p)) { if (ret != FAIL) { @@ -3418,7 +3417,7 @@ int eval1(char **arg, typval_T *rettv, int evaluate) /* * Get the second variable. */ - *arg = (char *)skipwhite((char_u *)(*arg) + 1); + *arg = skipwhite(*arg + 1); if (eval1(arg, rettv, evaluate && result) == FAIL) { // recursive! return FAIL; } @@ -3437,7 +3436,7 @@ int eval1(char **arg, typval_T *rettv, int evaluate) /* * Get the third variable. */ - *arg = (char *)skipwhite((char_u *)(*arg) + 1); + *arg = skipwhite(*arg + 1); if (eval1(arg, &var2, evaluate && !result) == FAIL) { // Recursive! if (evaluate && result) { tv_clear(rettv); @@ -3495,7 +3494,7 @@ static int eval2(char **arg, typval_T *rettv, int evaluate) /* * Get the second variable. */ - *arg = (char *)skipwhite((char_u *)(*arg) + 2); + *arg = skipwhite(*arg + 2); if (eval3(arg, &var2, evaluate && !result) == FAIL) { return FAIL; } @@ -3564,7 +3563,7 @@ static int eval3(char **arg, typval_T *rettv, int evaluate) /* * Get the second variable. */ - *arg = (char *)skipwhite((char_u *)(*arg) + 2); + *arg = skipwhite(*arg + 2); if (eval4(arg, &var2, evaluate && result) == FAIL) { return FAIL; } @@ -3683,7 +3682,7 @@ static int eval4(char **arg, typval_T *rettv, int evaluate) } // Get the second variable. - *arg = (char *)skipwhite((char_u *)p + len); + *arg = skipwhite(p + len); if (eval5(arg, &var2, evaluate) == FAIL) { tv_clear(rettv); return FAIL; @@ -3757,7 +3756,7 @@ static int eval5(char **arg, typval_T *rettv, int evaluate) if (op == '.' && *(*arg + 1) == '.') { // ..string concatenation (*arg)++; } - *arg = (char *)skipwhite((char_u *)(*arg) + 1); + *arg = skipwhite(*arg + 1); if (eval6(arg, &var2, evaluate, op == '.') == FAIL) { tv_clear(rettv); return FAIL; @@ -3930,7 +3929,7 @@ static int eval6(char **arg, typval_T *rettv, int evaluate, int want_string) /* * Get the second variable. */ - *arg = (char *)skipwhite((char_u *)(*arg) + 1); + *arg = skipwhite(*arg + 1); if (eval7(arg, &var2, evaluate, false) == FAIL) { return FAIL; } @@ -4042,7 +4041,7 @@ static int eval7(char **arg, typval_T *rettv, int evaluate, int want_string) // Skip '!', '-' and '+' characters. They are handled later. start_leader = *arg; while (**arg == '!' || **arg == '-' || **arg == '+') { - *arg = (char *)skipwhite((char_u *)(*arg) + 1); + *arg = skipwhite(*arg + 1); } end_leader = *arg; @@ -4195,7 +4194,7 @@ static int eval7(char **arg, typval_T *rettv, int evaluate, int want_string) // nested expression: (expression). case '(': - *arg = (char *)skipwhite((char_u *)(*arg) + 1); + *arg = skipwhite(*arg + 1); ret = eval1(arg, rettv, evaluate); // recursive! if (**arg == ')') { ++*arg; @@ -4235,7 +4234,7 @@ static int eval7(char **arg, typval_T *rettv, int evaluate, int want_string) xfree(alias); } - *arg = (char *)skipwhite((char_u *)(*arg)); + *arg = skipwhite(*arg); // Handle following '[', '(' and '.' for expr[expr], expr.name, // expr(expr), expr->name(expr) @@ -4377,7 +4376,7 @@ static int eval_lambda(char **const arg, typval_T *const rettv, const bool evalu return FAIL; } else if (**arg != '(') { if (verbose) { - if (*skipwhite((char_u *)(*arg)) == '(') { + if (*skipwhite(*arg) == '(') { emsg(_(e_nowhitespace)); } else { semsg(_(e_missingparen), "lambda"); @@ -4419,7 +4418,7 @@ static int eval_method(char **const arg, typval_T *const rettv, const bool evalu if (STRNCMP(name, "v:lua.", 6) == 0) { lua_funcname = name + 6; *arg = (char *)skip_luafunc_name((const char *)lua_funcname); - *arg = (char *)skipwhite((char_u *)(*arg)); // to detect trailing whitespace later + *arg = skipwhite(*arg); // to detect trailing whitespace later len = *arg - lua_funcname; } else { char *alias; @@ -4530,14 +4529,14 @@ static int eval_index(char **arg, typval_T *rettv, int evaluate, int verbose) if (len == 0) { return FAIL; } - *arg = (char *)skipwhite((char_u *)key + len); + *arg = skipwhite(key + len); } else { /* * something[idx] * * Get the (first) variable from inside the []. */ - *arg = (char *)skipwhite((char_u *)(*arg) + 1); + *arg = skipwhite(*arg + 1); if (**arg == ':') { empty1 = true; } else if (eval1(arg, &var1, evaluate) == FAIL) { // Recursive! @@ -4553,7 +4552,7 @@ static int eval_index(char **arg, typval_T *rettv, int evaluate, int verbose) */ if (**arg == ':') { range = true; - *arg = (char *)skipwhite((char_u *)(*arg) + 1); + *arg = skipwhite(*arg + 1); if (**arg == ']') { empty2 = true; } else if (eval1(arg, &var2, evaluate) == FAIL) { // Recursive! @@ -4582,7 +4581,7 @@ static int eval_index(char **arg, typval_T *rettv, int evaluate, int verbose) } return FAIL; } - *arg = (char *)skipwhite((char_u *)(*arg) + 1); // skip the ']' + *arg = skipwhite(*arg + 1); // skip the ']' } if (evaluate) { @@ -4815,7 +4814,7 @@ int get_option_tv(const char **const arg, typval_T *const rettv, const bool eval char c = *option_end; *option_end = NUL; opt_type = get_option_value(*arg, &numval, - rettv == NULL ? NULL : (char_u **)&stringval, opt_flags); + rettv == NULL ? NULL : &stringval, opt_flags); if (opt_type == -3) { // invalid name if (rettv != NULL) { @@ -4929,7 +4928,7 @@ static int get_string_tv(char **arg, typval_T *rettv, int evaluate) // For "\u" store the number according to // 'encoding'. if (c != 'X') { - name += utf_char2bytes(nr, (char_u *)name); + name += utf_char2bytes(nr, name); } else { *name++ = nr; } @@ -5095,7 +5094,7 @@ static int get_list_tv(char **arg, typval_T *rettv, int evaluate) l = tv_list_alloc(kListLenShouldKnow); } - *arg = (char *)skipwhite((char_u *)(*arg) + 1); + *arg = skipwhite(*arg + 1); while (**arg != ']' && **arg != NUL) { typval_T tv; if (eval1(arg, &tv, evaluate) == FAIL) { // Recursive! @@ -5113,7 +5112,7 @@ static int get_list_tv(char **arg, typval_T *rettv, int evaluate) semsg(_("E696: Missing comma in List: %s"), *arg); goto failret; } - *arg = (char *)skipwhite((char_u *)(*arg) + 1); + *arg = skipwhite(*arg + 1); } if (**arg != ']') { @@ -5125,7 +5124,7 @@ failret: return FAIL; } - *arg = (char *)skipwhite((char_u *)(*arg) + 1); + *arg = skipwhite(*arg + 1); if (evaluate) { tv_list_set_ret(rettv, l); } @@ -5700,7 +5699,7 @@ static int get_literal_key(char **arg, typval_T *tv) tv->v_type = VAR_STRING; tv->vval.v_string = xstrnsave(*arg, p - *arg); - *arg = (char *)skipwhite((char_u *)p); + *arg = skipwhite(p); return OK; } @@ -5715,7 +5714,7 @@ static int dict_get_tv(char **arg, typval_T *rettv, int evaluate, bool literal) typval_T tv; char *key = NULL; dictitem_T *item; - char *start = (char *)skipwhite((char_u *)(*arg) + 1); + char *start = skipwhite(*arg + 1); char buf[NUMBUFLEN]; /* @@ -5729,7 +5728,7 @@ static int dict_get_tv(char **arg, typval_T *rettv, int evaluate, bool literal) if (eval1(&start, &tv, false) == FAIL) { // recursive! return FAIL; } - if (*skipwhite((char_u *)start) == '}') { + if (*skipwhite(start) == '}') { return NOTDONE; } } @@ -5740,7 +5739,7 @@ static int dict_get_tv(char **arg, typval_T *rettv, int evaluate, bool literal) tvkey.v_type = VAR_UNKNOWN; tv.v_type = VAR_UNKNOWN; - *arg = (char *)skipwhite((char_u *)(*arg) + 1); + *arg = skipwhite(*arg + 1); while (**arg != '}' && **arg != NUL) { if ((literal ? get_literal_key(arg, &tvkey) @@ -5761,7 +5760,7 @@ static int dict_get_tv(char **arg, typval_T *rettv, int evaluate, bool literal) } } - *arg = (char *)skipwhite((char_u *)(*arg) + 1); + *arg = skipwhite(*arg + 1); if (eval1(arg, &tv, evaluate) == FAIL) { // Recursive! if (evaluate) { tv_clear(&tvkey); @@ -5792,7 +5791,7 @@ static int dict_get_tv(char **arg, typval_T *rettv, int evaluate, bool literal) semsg(_("E722: Missing comma in Dictionary: %s"), *arg); goto failret; } - *arg = (char *)skipwhite((char_u *)(*arg) + 1); + *arg = skipwhite(*arg + 1); } if (**arg != '}') { @@ -5804,7 +5803,7 @@ failret: return FAIL; } - *arg = (char *)skipwhite((char_u *)(*arg) + 1); + *arg = skipwhite(*arg + 1); if (evaluate) { tv_dict_set_ret(rettv, d); } @@ -7267,7 +7266,7 @@ bool callback_call(Callback *const callback, const int argcount_in, typval_T *co funcexe.lastline = curwin->w_cursor.lnum; funcexe.evaluate = true; funcexe.partial = partial; - return call_func((char_u *)name, -1, rettv, argcount_in, argvars_in, &funcexe); + return call_func(name, -1, rettv, argcount_in, argvars_in, &funcexe); } static bool set_ref_in_callback(Callback *callback, int copyID, ht_stack_T **ht_stack, @@ -7969,7 +7968,7 @@ int get_id_len(const char **const arg) } len = (int)(p - *arg); - *arg = (const char *)skipwhite((const char_u *)p); + *arg = (const char *)skipwhite(p); return len; } @@ -8009,7 +8008,7 @@ int get_name_len(const char **const arg, char **alias, bool evaluate, bool verbo if (expr_start != NULL) { if (!evaluate) { len += (int)(p - *arg); - *arg = (const char *)skipwhite((const char_u *)p); + *arg = (const char *)skipwhite(p); return len; } @@ -8022,7 +8021,7 @@ int get_name_len(const char **const arg, char **alias, bool evaluate, bool verbo return -1; } *alias = temp_string; - *arg = (const char *)skipwhite((const char_u *)p); + *arg = (const char *)skipwhite(p); return (int)STRLEN(temp_string); } @@ -8231,7 +8230,7 @@ void set_vim_var_char(int c) { char buf[MB_MAXBYTES + 1]; - buf[utf_char2bytes(c, (char_u *)buf)] = NUL; + buf[utf_char2bytes(c, buf)] = NUL; set_vim_var_string(VV_CHAR, buf, -1); } @@ -9473,7 +9472,7 @@ void ex_echo(exarg_T *eap) xfree(tofree); } tv_clear(&rettv); - arg = (char *)skipwhite((char_u *)arg); + arg = skipwhite(arg); } eap->nextcmd = (char *)check_nextcmd((char_u *)arg); @@ -9539,7 +9538,7 @@ void ex_execute(exarg_T *eap) } tv_clear(&rettv); - arg = (char *)skipwhite((char_u *)arg); + arg = skipwhite(arg); } if (ret != FAIL && ga.ga_data != NULL) { @@ -10569,7 +10568,7 @@ typval_T eval_call_provider(char *provider, char *method, list_T *arguments, boo funcexe.firstline = curwin->w_cursor.lnum; funcexe.lastline = curwin->w_cursor.lnum; funcexe.evaluate = true; - (void)call_func((const char_u *)func, name_len, &rettv, 2, argvars, &funcexe); + (void)call_func(func, name_len, &rettv, 2, argvars, &funcexe); tv_list_unref(arguments); // Restore caller scope information diff --git a/src/nvim/eval/decode.c b/src/nvim/eval/decode.c index 93e0a6cfb7..2dd18c0942 100644 --- a/src/nvim/eval/decode.c +++ b/src/nvim/eval/decode.c @@ -415,7 +415,7 @@ static inline int parse_json_string(const char *const buf, const size_t buf_len, #define PUT_FST_IN_PAIR(fst_in_pair, str_end) \ do { \ if (fst_in_pair != 0) { \ - str_end += utf_char2bytes(fst_in_pair, (char_u *)str_end); \ + str_end += utf_char2bytes(fst_in_pair, str_end); \ fst_in_pair = 0; \ } \ } while (0) @@ -440,15 +440,14 @@ static inline int parse_json_string(const char *const buf, const size_t buf_len, fst_in_pair = (int)ch; } else if (SURROGATE_LO_START <= ch && ch <= SURROGATE_LO_END && fst_in_pair != 0) { - const int full_char = ( - (int)(ch - SURROGATE_LO_START) + const int full_char = ((int)(ch - SURROGATE_LO_START) + ((fst_in_pair - SURROGATE_HI_START) << 10) + SURROGATE_FIRST_CHAR); - str_end += utf_char2bytes(full_char, (char_u *)str_end); + str_end += utf_char2bytes(full_char, str_end); fst_in_pair = 0; } else { PUT_FST_IN_PAIR(fst_in_pair, str_end); - str_end += utf_char2bytes((int)ch, (char_u *)str_end); + str_end += utf_char2bytes((int)ch, str_end); } break; } diff --git a/src/nvim/eval/funcs.c b/src/nvim/eval/funcs.c index 7946ed75e1..e2f456e399 100644 --- a/src/nvim/eval/funcs.c +++ b/src/nvim/eval/funcs.c @@ -1893,7 +1893,7 @@ static void f_eval(typval_T *argvars, typval_T *rettv, FunPtr fptr) { const char *s = tv_get_string_chk(&argvars[0]); if (s != NULL) { - s = (const char *)skipwhite((const char_u *)s); + s = (const char *)skipwhite(s); } const char *const expr_start = s; @@ -2079,7 +2079,7 @@ static void f_exists(typval_T *argvars, typval_T *rettv, FunPtr fptr) } } else if (*p == '&' || *p == '+') { // Option. n = (get_option_tv(&p, NULL, true) == OK); - if (*skipwhite((const char_u *)p) != NUL) { + if (*skipwhite(p) != NUL) { n = false; // Trailing garbage. } } else if (*p == '*') { // Internal or user defined function. @@ -2572,14 +2572,14 @@ static void f_foldtext(typval_T *argvars, typval_T *rettv, FunPtr fptr) } // Find interesting text in this line. - s = skipwhite(ml_get(lnum)); + s = (char_u *)skipwhite((char *)ml_get(lnum)); // skip C comment-start if (s[0] == '/' && (s[1] == '*' || s[1] == '/')) { - s = skipwhite(s + 2); - if (*skipwhite(s) == NUL && lnum + 1 < foldend) { - s = skipwhite(ml_get(lnum + 1)); + s = (char_u *)skipwhite((char *)s + 2); + if (*skipwhite((char *)s) == NUL && lnum + 1 < foldend) { + s = (char_u *)skipwhite((char *)ml_get(lnum + 1)); if (*s == '*') { - s = skipwhite(s + 1); + s = (char_u *)skipwhite((char *)s + 1); } } } @@ -3035,7 +3035,7 @@ static void getchar_common(typval_T *argvars, typval_T *rettv) temp[i++] = K_SECOND(n); temp[i++] = K_THIRD(n); } else { - i += utf_char2bytes(n, temp + i); + i += utf_char2bytes(n, (char *)temp + i); } assert(i < 10); temp[i++] = NUL; @@ -3087,7 +3087,7 @@ static void f_getcharstr(typval_T *argvars, typval_T *rettv, FunPtr fptr) int i = 0; if (n != 0) { - i += utf_char2bytes(n, temp); + i += utf_char2bytes(n, (char *)temp); } assert(i < 7); temp[i++] = NUL; @@ -5649,7 +5649,7 @@ static void f_list2str(typval_T *argvars, typval_T *rettv, FunPtr fptr) char_u buf[MB_MAXBYTES + 1]; TV_LIST_ITER_CONST(l, li, { - buf[utf_char2bytes(tv_get_number(TV_LIST_ITEM_TV(li)), buf)] = NUL; + buf[utf_char2bytes(tv_get_number(TV_LIST_ITEM_TV(li)), (char *)buf)] = NUL; ga_concat(&ga, (char *)buf); }); ga_append(&ga, NUL); @@ -5707,12 +5707,16 @@ static void get_maparg(typval_T *argvars, typval_T *rettv, int exact) mode = get_map_mode((char **)&which, 0); char_u *keys_simplified - = replace_termcodes(keys, STRLEN(keys), &keys_buf, flags, &did_simplify, CPO_TO_CPO_FLAGS); + = (char_u *)replace_termcodes((char *)keys, + STRLEN(keys), (char **)&keys_buf, flags, &did_simplify, + CPO_TO_CPO_FLAGS); rhs = check_map(keys_simplified, mode, exact, false, abbr, &mp, &buffer_local, &rhs_lua); if (did_simplify) { // When the lhs is being simplified the not-simplified keys are // preferred for printing, like in do_map(). - (void)replace_termcodes(keys, STRLEN(keys), &alt_keys_buf, flags | REPTERM_NO_SIMPLIFY, NULL, + (void)replace_termcodes((char *)keys, + STRLEN(keys), + (char **)&alt_keys_buf, flags | REPTERM_NO_SIMPLIFY, NULL, CPO_TO_CPO_FLAGS); rhs = check_map(alt_keys_buf, mode, exact, false, abbr, &mp, &buffer_local, &rhs_lua); } @@ -6307,7 +6311,7 @@ static void f_nextnonblank(typval_T *argvars, typval_T *rettv, FunPtr fptr) lnum = 0; break; } - if (*skipwhite(ml_get(lnum)) != NUL) { + if (*skipwhite((char *)ml_get(lnum)) != NUL) { break; } } @@ -6339,7 +6343,7 @@ static void f_nr2char(typval_T *argvars, typval_T *rettv, FunPtr fptr) } char buf[MB_MAXBYTES]; - const int len = utf_char2bytes((int)num, (char_u *)buf); + const int len = utf_char2bytes((int)num, buf); rettv->v_type = VAR_STRING; rettv->vval.v_string = xmemdupz(buf, (size_t)len); @@ -6395,7 +6399,7 @@ static void f_prevnonblank(typval_T *argvars, typval_T *rettv, FunPtr fptr) if (lnum < 1 || lnum > curbuf->b_ml.ml_line_count) { lnum = 0; } else { - while (lnum >= 1 && *skipwhite(ml_get(lnum)) == NUL) { + while (lnum >= 1 && *skipwhite((char *)ml_get(lnum)) == NUL) { lnum--; } } @@ -7568,7 +7572,7 @@ static void f_reduce(typval_T *argvars, typval_T *rettv, FunPtr fptr) argv[0] = *rettv; argv[1] = *TV_LIST_ITEM_TV(li); rettv->v_type = VAR_UNKNOWN; - const int r = call_func(func_name, -1, rettv, 2, argv, &funcexe); + const int r = call_func((char *)func_name, -1, rettv, 2, argv, &funcexe); tv_clear(&argv[0]); if (r == FAIL || called_emsg != called_emsg_start) { break; @@ -7601,7 +7605,7 @@ static void f_reduce(typval_T *argvars, typval_T *rettv, FunPtr fptr) argv[0] = *rettv; argv[1].v_type = VAR_NUMBER; argv[1].vval.v_number = tv_blob_get(b, i); - if (call_func(func_name, -1, rettv, 2, argv, &funcexe) == FAIL) { + if (call_func((char *)func_name, -1, rettv, 2, argv, &funcexe) == FAIL) { return; } } @@ -9379,7 +9383,7 @@ static int item_compare2(const void *s1, const void *s2, bool keep_zero) funcexe.evaluate = true; funcexe.partial = partial; funcexe.selfdict = sortinfo->item_compare_selfdict; - res = call_func((const char_u *)func_name, -1, &rettv, 2, argv, &funcexe); + res = call_func(func_name, -1, &rettv, 2, argv, &funcexe); tv_clear(&argv[0]); tv_clear(&argv[1]); @@ -9850,11 +9854,11 @@ static void f_stdpath(typval_T *argvars, typval_T *rettv, FunPtr fptr) /// "str2float()" function static void f_str2float(typval_T *argvars, typval_T *rettv, FunPtr fptr) { - char_u *p = skipwhite((const char_u *)tv_get_string(&argvars[0])); + char_u *p = (char_u *)skipwhite(tv_get_string(&argvars[0])); bool isneg = (*p == '-'); if (*p == '+' || *p == '-') { - p = skipwhite(p + 1); + p = (char_u *)skipwhite((char *)p + 1); } (void)string2float((char *)p, &rettv->vval.v_float); if (isneg) { @@ -9892,10 +9896,10 @@ static void f_str2nr(typval_T *argvars, typval_T *rettv, FunPtr fptr) } } - char_u *p = skipwhite((const char_u *)tv_get_string(&argvars[0])); + char_u *p = (char_u *)skipwhite(tv_get_string(&argvars[0])); bool isneg = (*p == '-'); if (*p == '+' || *p == '-') { - p = skipwhite(p + 1); + p = (char_u *)skipwhite((char *)p + 1); } switch (base) { case 2: @@ -10488,7 +10492,7 @@ static void f_synconcealed(typval_T *argvars, typval_T *rettv, FunPtr fptr) : curwin->w_p_lcs_chars.conceal; } if (cchar != NUL) { - utf_char2bytes(cchar, str); + utf_char2bytes(cchar, (char *)str); } } } diff --git a/src/nvim/eval/userfunc.c b/src/nvim/eval/userfunc.c index c518b11a65..d6a63993c6 100644 --- a/src/nvim/eval/userfunc.c +++ b/src/nvim/eval/userfunc.c @@ -125,12 +125,12 @@ static int get_function_args(char_u **argp, char_u endchar, garray_T *newargs, i *p = c; } - if (*skipwhite(p) == '=' && default_args != NULL) { + if (*skipwhite((char *)p) == '=' && default_args != NULL) { typval_T rettv; any_default = true; - p = skipwhite(p) + 1; - p = skipwhite(p); + p = (char_u *)skipwhite((char *)p) + 1; + p = (char_u *)skipwhite((char *)p); char_u *expr = p; if (eval1((char **)&p, &rettv, false) != FAIL) { ga_grow(default_args, 1); @@ -159,7 +159,7 @@ static int get_function_args(char_u **argp, char_u endchar, garray_T *newargs, i mustend = true; } } - p = skipwhite(p); + p = (char_u *)skipwhite((char *)p); if (mustend && *p != endchar) { if (!skip) { semsg(_(e_invarg2), *argp); @@ -222,7 +222,7 @@ int get_lambda_tv(char_u **arg, typval_T *rettv, bool evaluate) partial_T *pt = NULL; int varargs; int ret; - char_u *start = skipwhite(*arg + 1); + char_u *start = (char_u *)skipwhite((char *)(*arg) + 1); char_u *s, *e; bool *old_eval_lavars = eval_lavars_used; bool eval_lavars = false; @@ -239,7 +239,7 @@ int get_lambda_tv(char_u **arg, typval_T *rettv, bool evaluate) } else { pnewargs = NULL; } - *arg = skipwhite(*arg + 1); + *arg = (char_u *)skipwhite((char *)(*arg) + 1); ret = get_function_args(arg, '-', pnewargs, &varargs, NULL, false); if (ret == FAIL || **arg != '>') { goto errret; @@ -251,14 +251,14 @@ int get_lambda_tv(char_u **arg, typval_T *rettv, bool evaluate) } // Get the start and the end of the expression. - *arg = skipwhite(*arg + 1); + *arg = (char_u *)skipwhite((char *)(*arg) + 1); s = *arg; ret = skip_expr((char **)arg); if (ret == FAIL) { goto errret; } e = *arg; - *arg = skipwhite(*arg); + *arg = (char_u *)skipwhite((char *)(*arg)); if (**arg != '}') { goto errret; } @@ -422,7 +422,7 @@ int get_func_tv(const char_u *name, int len, typval_T *rettv, char_u **arg, func argp = *arg; while (argcount < MAX_FUNC_ARGS - (funcexe->partial == NULL ? 0 : funcexe->partial->pt_argc)) { - argp = skipwhite(argp + 1); // skip the '(' or ',' + argp = (char_u *)skipwhite((char *)argp + 1); // skip the '(' or ',' if (*argp == ')' || *argp == ',' || *argp == NUL) { break; } @@ -455,7 +455,7 @@ int get_func_tv(const char_u *name, int len, typval_T *rettv, char_u **arg, func ((typval_T **)funcargs.ga_data)[funcargs.ga_len++] = &argvars[i]; } } - ret = call_func(name, len, rettv, argcount, argvars, funcexe); + ret = call_func((char *)name, len, rettv, argcount, argvars, funcexe); funcargs.ga_len -= i; } else if (!aborting()) { @@ -470,7 +470,7 @@ int get_func_tv(const char_u *name, int len, typval_T *rettv, char_u **arg, func tv_clear(&argvars[argcount]); } - *arg = skipwhite(argp); + *arg = (char_u *)skipwhite((char *)argp); return ret; } @@ -1370,7 +1370,7 @@ int func_call(char_u *name, typval_T *args, partial_T *partial, dict_T *selfdict funcexe.evaluate = true; funcexe.partial = partial; funcexe.selfdict = selfdict; - r = call_func(name, -1, rettv, argc, argv, &funcexe); + r = call_func((char *)name, -1, rettv, argc, argv, &funcexe); func_call_skip_call: // Free the arguments. @@ -1442,8 +1442,8 @@ static void argv_add_base(typval_T *const basetv, typval_T **const argvars, int /// @return FAIL if function cannot be called, else OK (even if an error /// occurred while executing the function! Set `msg_list` to capture /// the error, see do_cmdline()). -int call_func(const char_u *funcname, int len, typval_T *rettv, int argcount_in, - typval_T *argvars_in, funcexe_T *funcexe) +int call_func(const char *funcname, int len, typval_T *rettv, int argcount_in, typval_T *argvars_in, + funcexe_T *funcexe) FUNC_ATTR_NONNULL_ARG(1, 3, 5, 6) { int ret = FAIL; @@ -1475,7 +1475,7 @@ int call_func(const char_u *funcname, int len, typval_T *rettv, int argcount_in, if (fp == NULL) { // Make a copy of the name, if it comes from a funcref variable it could // be changed or deleted in the called function. - name = vim_strnsave(funcname, (size_t)len); + name = vim_strnsave((char_u *)funcname, (size_t)len); fname = fname_trans_sid(name, fname_buf, &tofree, &error); } @@ -1522,11 +1522,11 @@ int call_func(const char_u *funcname, int len, typval_T *rettv, int argcount_in, if (len > 0) { error = ERROR_NONE; argv_add_base(funcexe->basetv, &argvars, &argcount, argv, &argv_base); - nlua_typval_call((const char *)funcname, (size_t)len, argvars, argcount, rettv); + nlua_typval_call(funcname, (size_t)len, argvars, argcount, rettv); } else { // v:lua was called directly; show its name in the emsg XFREE_CLEAR(name); - funcname = (const char_u *)"v:lua"; + funcname = "v:lua"; } } else if (fp != NULL || !builtin_function((const char *)rfname, -1)) { // User defined function. @@ -1608,7 +1608,7 @@ theend: // Report an error unless the argument evaluation or function call has been // cancelled due to an aborting error, an interrupt, or an exception. if (!aborting()) { - user_func_error(error, (name != NULL) ? name : funcname); + user_func_error(error, (name != NULL) ? name : (char_u *)funcname); } // clear the copies made from the partial @@ -2039,7 +2039,7 @@ void ex_function(exarg_T *eap) // - exclude line numbers from function body // if (!paren) { - if (!ends_excmd(*skipwhite(p))) { + if (!ends_excmd(*skipwhite((char *)p))) { emsg(_(e_trailing)); goto ret_free; } @@ -2083,7 +2083,7 @@ void ex_function(exarg_T *eap) /* * ":function name(arg1, arg2)" Define function. */ - p = skipwhite(p); + p = (char_u *)skipwhite((char *)p); if (*p != '(') { if (!eap->skip) { semsg(_("E124: Missing '(': %s"), eap->arg); @@ -2094,7 +2094,7 @@ void ex_function(exarg_T *eap) p = vim_strchr(p, '('); } } - p = skipwhite(p + 1); + p = (char_u *)skipwhite((char *)p + 1); ga_init(&newargs, (int)sizeof(char_u *), 3); ga_init(&newlines, (int)sizeof(char_u *), 3); @@ -2135,7 +2135,7 @@ void ex_function(exarg_T *eap) // find extra arguments "range", "dict", "abort" and "closure" for (;;) { - p = skipwhite(p); + p = (char_u *)skipwhite((char *)p); if (STRNCMP(p, "range", 5) == 0) { flags |= FC_RANGE; p += 5; @@ -2249,13 +2249,13 @@ void ex_function(exarg_T *eap) // * ":python < 0) { give_warning2((char_u *)_("W22: Text found after :endfunction: %s"), @@ -2313,11 +2313,11 @@ void ex_function(exarg_T *eap) // Check for defining a function inside this function. if (checkforcmd((char **)&p, "function", 2)) { if (*p == '!') { - p = skipwhite(p + 1); + p = (char_u *)skipwhite((char *)p + 1); } p += eval_fname_script((const char *)p); xfree(trans_function_name(&p, true, 0, NULL, NULL)); - if (*skipwhite(p) == '(') { + if (*skipwhite((char *)p) == '(') { nesting++; indent += 2; } @@ -2340,7 +2340,7 @@ void ex_function(exarg_T *eap) } // heredoc: Check for ":python <line1].st_u.num.value, NULL, 0, false); } } else { - s = (char *)skipwhite((char_u *)p); + s = skipwhite(p); if (*s == '+') { - s = (char *)skipwhite((char_u *)s + 1); + s = skipwhite(s + 1); } if (*s == NUL) { @@ -1215,7 +1215,7 @@ void do_bang(int addr_count, exarg_T *eap, bool forceit, bool do_in, bool do_out // buffername. char *cmd = (char *)vim_strsave_escaped((char_u *)prevcmd, (char_u *)"%#"); - AppendToRedobuffLit((char_u *)cmd, -1); + AppendToRedobuffLit(cmd, -1); xfree(cmd); AppendToRedobuff("\n"); bangredo = false; @@ -2768,7 +2768,7 @@ int do_ecmd(int fnum, char *ffname, char *sfname, exarg_T *eap, linenr_T newlnum const char *text = (char *)get_cursor_line_ptr(); if (curwin->w_cursor.lnum != orig_pos.lnum - || curwin->w_cursor.col != (int)(skipwhite((char_u *)text) - (char_u *)text)) { + || curwin->w_cursor.col != (int)(skipwhite(text) - text)) { newlnum = curwin->w_cursor.lnum; newcol = curwin->w_cursor.col; } @@ -3573,7 +3573,7 @@ static buf_T *do_sub(exarg_T *eap, proftime_T timeout, bool do_buf_event, handle bool save_do_ask = subflags.do_ask; // remember user specified 'c' flag // check for a trailing count - cmd = (char *)skipwhite((char_u *)cmd); + cmd = skipwhite(cmd); if (ascii_isdigit(*cmd)) { i = getdigits_long((char_u **)&cmd, true, 0); if (i <= 0 && !eap->skip && subflags.do_error) { @@ -3590,7 +3590,7 @@ static buf_T *do_sub(exarg_T *eap, proftime_T timeout, bool do_buf_event, handle /* * check for trailing command or garbage */ - cmd = (char *)skipwhite((char_u *)cmd); + cmd = skipwhite(cmd); if (*cmd && *cmd != '"') { // if not end-of-line or comment eap->nextcmd = (char *)check_nextcmd((char_u *)cmd); if (eap->nextcmd == NULL) { @@ -5819,10 +5819,10 @@ static void do_helptags(char *dirname, bool add_help_tags, bool ignore_writeerr) FreeWild(filecount, (char_u **)files); } -static void helptags_cb(char_u *fname, void *cookie) +static void helptags_cb(char *fname, void *cookie) FUNC_ATTR_NONNULL_ALL { - do_helptags((char *)fname, *(bool *)cookie, true); + do_helptags(fname, *(bool *)cookie, true); } /// ":helptags" @@ -5835,7 +5835,7 @@ void ex_helptags(exarg_T *eap) // Check for ":helptags ++t {dir}". if (STRNCMP(eap->arg, "++t", 3) == 0 && ascii_iswhite(eap->arg[3])) { add_help_tags = true; - eap->arg = (char *)skipwhite((char_u *)eap->arg + 3); + eap->arg = skipwhite(eap->arg + 3); } if (STRCMP(eap->arg, "ALL") == 0) { diff --git a/src/nvim/ex_cmds2.c b/src/nvim/ex_cmds2.c index 5fa95c818c..d1dcb28dbd 100644 --- a/src/nvim/ex_cmds2.c +++ b/src/nvim/ex_cmds2.c @@ -102,7 +102,7 @@ void ex_profile(exarg_T *eap) e = (char *)skiptowhite((char_u *)eap->arg); len = (int)(e - eap->arg); - e = (char *)skipwhite((char_u *)e); + e = skipwhite(e); if (len == 5 && STRNCMP(eap->arg, "start", 5) == 0 && *e != NUL) { xfree(profile_fname); @@ -227,7 +227,7 @@ void set_context_in_profile_cmd(expand_T *xp, const char *arg) if ((const char *)end_subcmd - arg == 5 && strncmp(arg, "start", 5) == 0) { xp->xp_context = EXPAND_FILES; - xp->xp_pattern = (char *)skipwhite((const char_u *)end_subcmd); + xp->xp_pattern = skipwhite((char *)end_subcmd); return; } @@ -835,7 +835,7 @@ static char *do_one_arg(char *str) *p++ = *str; } } - str = (char *)skipwhite((char_u *)str); + str = skipwhite(str); *p = NUL; return str; @@ -2345,7 +2345,7 @@ char_u *getsourceline(int c, void *cookie, int indent, bool do_concat) // Also check for a comment in between continuation lines: "\ . sp->nextline = get_one_sourceline(sp); if (sp->nextline != NULL - && (*(p = (char *)skipwhite((char_u *)sp->nextline)) == '\\' + && (*(p = skipwhite(sp->nextline)) == '\\' || (p[0] == '"' && p[1] == '\\' && p[2] == ' '))) { garray_T ga; @@ -2794,19 +2794,19 @@ void ex_language(exarg_T *eap) if ((*p == NUL || ascii_iswhite(*p)) && p - eap->arg >= 3) { if (STRNICMP(eap->arg, "messages", p - eap->arg) == 0) { what = VIM_LC_MESSAGES; - name = (char *)skipwhite((char_u *)p); + name = skipwhite(p); whatstr = "messages "; } else if (STRNICMP(eap->arg, "ctype", p - eap->arg) == 0) { what = LC_CTYPE; - name = (char *)skipwhite((char_u *)p); + name = skipwhite(p); whatstr = "ctype "; } else if (STRNICMP(eap->arg, "time", p - eap->arg) == 0) { what = LC_TIME; - name = (char *)skipwhite((char_u *)p); + name = skipwhite(p); whatstr = "time "; } else if (STRNICMP(eap->arg, "collate", p - eap->arg) == 0) { what = LC_COLLATE; - name = (char *)skipwhite((char_u *)p); + name = skipwhite(p); whatstr = "collate "; } } diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index eed2a38a4f..316006befd 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -1205,11 +1205,11 @@ static void get_wincmd_addr_type(char *arg, exarg_T *eap) static char *skip_colon_white(const char *p, bool skipleadingwhite) { if (skipleadingwhite) { - p = (char *)skipwhite((char_u *)p); + p = skipwhite(p); } while (*p == ':') { - p = (char *)skipwhite((char_u *)p + 1); + p = skipwhite(p + 1); } return (char *)p; @@ -1231,7 +1231,7 @@ static void set_cmd_addr_type(exarg_T *eap, char_u *p) } // :wincmd range depends on the argument if (eap->cmdidx == CMD_wincmd && p != NULL) { - get_wincmd_addr_type((char *)skipwhite(p), eap); + get_wincmd_addr_type(skipwhite((char *)p), eap); } // :.cc in quickfix window uses line number if ((eap->cmdidx == CMD_cc || eap->cmdidx == CMD_ll) && bt_quickfix(curbuf)) { @@ -1315,7 +1315,7 @@ static void parse_register(exarg_T *eap) } eap->arg += STRLEN(eap->arg); } - eap->arg = (char *)skipwhite((char_u *)eap->arg); + eap->arg = skipwhite(eap->arg); } } } @@ -1331,7 +1331,7 @@ static int parse_count(exarg_T *eap, char **errormsg, bool validate) && (!(eap->argt & EX_BUFNAME) || *(p = (char *)skipdigits((char_u *)eap->arg + 1)) == NUL || ascii_iswhite(*p))) { n = getdigits_long((char_u **)&eap->arg, false, -1); - eap->arg = (char *)skipwhite((char_u *)eap->arg); + eap->arg = skipwhite(eap->arg); if (n <= 0 && (eap->argt & EX_ZEROR) == 0) { if (errormsg != NULL) { *errormsg = _(e_zerocount); @@ -1422,7 +1422,7 @@ bool parse_cmdline(char *cmdline, exarg_T *eap, CmdParseInfo *cmdinfo, char **er // Skip ranges to find command name since we need the command to know what kind of range it uses eap->cmd = skip_range(eap->cmd, NULL); if (*eap->cmd == '*') { - eap->cmd = (char *)skipwhite((char_u *)eap->cmd + 1); + eap->cmd = skipwhite(eap->cmd + 1); } p = find_command(eap, NULL); @@ -1467,7 +1467,7 @@ bool parse_cmdline(char *cmdline, exarg_T *eap, CmdParseInfo *cmdinfo, char **er if (eap->cmdidx == CMD_bang) { eap->arg = p; } else { - eap->arg = (char *)skipwhite((char_u *)p); + eap->arg = skipwhite(p); } // Don't treat ":r! filter" like a bang @@ -1604,7 +1604,7 @@ static char *do_one_cmd(char **cmdlinep, int flags, cstack_T *cstack, LineGetter cmd = ea.cmd; ea.cmd = skip_range(ea.cmd, NULL); if (*ea.cmd == '*') { - ea.cmd = (char *)skipwhite((char_u *)ea.cmd + 1); + ea.cmd = skipwhite(ea.cmd + 1); } p = find_command(&ea, NULL); @@ -1882,7 +1882,7 @@ static char *do_one_cmd(char **cmdlinep, int flags, cstack_T *cstack, LineGetter if (ea.cmdidx == CMD_bang) { ea.arg = p; } else { - ea.arg = (char *)skipwhite((char_u *)p); + ea.arg = skipwhite(p); } // ":file" cannot be run with an argument when "curbuf->b_ro_locked" is set @@ -1909,7 +1909,7 @@ static char *do_one_cmd(char **cmdlinep, int flags, cstack_T *cstack, LineGetter errormsg = _("E494: Use w or w>>"); goto doend; } - ea.arg = (char *)skipwhite((char_u *)ea.arg + 1); + ea.arg = skipwhite(ea.arg + 1); ea.append = true; } else if (*ea.arg == '!' && ea.cmdidx == CMD_write) { // :w !filter ++ea.arg; @@ -1933,7 +1933,7 @@ static char *do_one_cmd(char **cmdlinep, int flags, cstack_T *cstack, LineGetter ea.arg++; ea.amount++; } - ea.arg = (char *)skipwhite((char_u *)ea.arg); + ea.arg = skipwhite(ea.arg); } /* @@ -2133,7 +2133,7 @@ static char *do_one_cmd(char **cmdlinep, int flags, cstack_T *cstack, LineGetter goto doend; } ea.addr_count = 1; - ea.arg = (char *)skipwhite((char_u *)p); + ea.arg = skipwhite(p); } // The :try command saves the emsg_silent flag, reset it here when @@ -2343,7 +2343,7 @@ int parse_command_modifiers(exarg_T *eap, char **errormsg, bool skip_only) } if (*p == '!') { cmdmod.filter_force = true; - p = (char *)skipwhite((char_u *)p + 1); + p = skipwhite(p + 1); if (*p == NUL || ends_excmd(*p)) { break; } @@ -2433,7 +2433,7 @@ int parse_command_modifiers(exarg_T *eap, char **errormsg, bool skip_only) } if (*eap->cmd == '!' && !ascii_iswhite(eap->cmd[-1])) { // ":silent!", but not "silent !cmd" - eap->cmd = (char *)skipwhite((char_u *)eap->cmd + 1); + eap->cmd = skipwhite(eap->cmd + 1); if (!skip_only) { emsg_silent++; eap->did_esilent++; @@ -2598,7 +2598,7 @@ int parse_cmd_address(exarg_T *eap, char **errormsg, bool silent) // Will give an error later if a range is found. break; } - eap->cmd = (char *)skipwhite((char_u *)eap->cmd); + eap->cmd = skipwhite(eap->cmd); lnum = get_address(eap, &eap->cmd, eap->addr_type, eap->skip, silent, eap->addr_count == 0, address_count++); if (eap->cmd == NULL) { // error detected @@ -2738,7 +2738,7 @@ int checkforcmd(char **pp, char *cmd, int len) } } if (i >= len && !isalpha((*pp)[i])) { - *pp = (char *)skipwhite((char_u *)(*pp) + i); + *pp = skipwhite(*pp + i); return true; } return FALSE; @@ -3032,7 +3032,7 @@ int modifier_len(char *cmd) char *p = cmd; if (ascii_isdigit(*cmd)) { - p = (char *)skipwhite(skipdigits((char_u *)cmd + 1)); + p = skipwhite((char *)skipdigits((char_u *)cmd + 1)); } for (int i = 0; i < (int)ARRAY_SIZE(cmdmods); i++) { int j; @@ -3083,7 +3083,7 @@ int cmd_exists(const char *const name) if (ascii_isdigit(*name) && ea.cmdidx != CMD_match) { return 0; } - if (*skipwhite((char_u *)p) != NUL) { + if (*skipwhite(p) != NUL) { return 0; // trailing garbage } return ea.cmdidx == CMD_SIZE ? 0 : (full ? 2 : 1); @@ -3266,7 +3266,7 @@ const char *set_one_cmd_context(expand_T *xp, const char *buff) ea.argt = cmdnames[(int)ea.cmdidx].cmd_argt; } - const char *arg = (const char *)skipwhite((const char_u *)p); + const char *arg = (const char *)skipwhite(p); // Skip over ++argopt argument if ((ea.argt & EX_ARGOPT) && *arg != NUL && strncmp(arg, "++", 2) == 0) { @@ -3274,7 +3274,7 @@ const char *set_one_cmd_context(expand_T *xp, const char *buff) while (*p && !ascii_isspace(*p)) { MB_PTR_ADV(p); } - arg = (const char *)skipwhite((const char_u *)p); + arg = (const char *)skipwhite(p); } if (ea.cmdidx == CMD_write || ea.cmdidx == CMD_update) { @@ -3282,7 +3282,7 @@ const char *set_one_cmd_context(expand_T *xp, const char *buff) if (*++arg == '>') { arg++; } - arg = (const char *)skipwhite((const char_u *)arg); + arg = (const char *)skipwhite(arg); } else if (*arg == '!' && ea.cmdidx == CMD_write) { // :w !filter arg++; usefilter = true; @@ -3301,7 +3301,7 @@ const char *set_one_cmd_context(expand_T *xp, const char *buff) while (*arg == *cmd) { // allow any number of '>' or '<' arg++; } - arg = (const char *)skipwhite((const char_u *)arg); + arg = (const char *)skipwhite(arg); } // Does command allow "+command"? @@ -3316,7 +3316,7 @@ const char *set_one_cmd_context(expand_T *xp, const char *buff) } // Skip space(s) after +command to get to the real argument. - arg = (const char *)skipwhite((const char_u *)arg); + arg = (const char *)skipwhite(arg); } /* @@ -3378,7 +3378,7 @@ const char *set_one_cmd_context(expand_T *xp, const char *buff) * Allow spaces within back-quotes to count as part of the argument * being expanded. */ - xp->xp_pattern = (char *)skipwhite((const char_u *)arg); + xp->xp_pattern = skipwhite(arg); p = (const char *)xp->xp_pattern; while (*p != NUL) { c = utf_ptr2char(p); @@ -3431,7 +3431,7 @@ const char *set_one_cmd_context(expand_T *xp, const char *buff) xp->xp_shell = TRUE; #endif // When still after the command name expand executables. - if ((char_u *)xp->xp_pattern == skipwhite((const char_u *)arg)) { + if ((char_u *)xp->xp_pattern == (char_u *)skipwhite(arg)) { xp->xp_context = EXPAND_SHELLCMD; } } @@ -3536,13 +3536,13 @@ const char *set_one_cmd_context(expand_T *xp, const char *buff) xp->xp_context = EXPAND_NOTHING; return NULL; } - return (const char *)skipwhite((const char_u *)arg); + return (const char *)skipwhite(arg); case CMD_match: if (*arg == NUL || !ends_excmd(*arg)) { // also complete "None" set_context_in_echohl_cmd(xp, arg); - arg = (const char *)skipwhite(skiptowhite((const char_u *)arg)); + arg = (const char *)skipwhite((char *)skiptowhite((const char_u *)arg)); if (*arg != NUL) { xp->xp_context = EXPAND_NOTHING; arg = (const char *)skip_regexp((char_u *)arg + 1, (uint8_t)(*arg), @@ -3587,7 +3587,7 @@ const char *set_one_cmd_context(expand_T *xp, const char *buff) } return NULL; } - arg = (const char *)skipwhite((char_u *)p); + arg = (const char *)skipwhite(p); } // After the attributes comes the new command name. @@ -3599,7 +3599,7 @@ const char *set_one_cmd_context(expand_T *xp, const char *buff) } // And finally comes a normal command. - return (const char *)skipwhite((const char_u *)p); + return (const char *)skipwhite(p); case CMD_delcommand: xp->xp_context = EXPAND_USER_COMMANDS; @@ -3660,7 +3660,7 @@ const char *set_one_cmd_context(expand_T *xp, const char *buff) case CMD_isplit: case CMD_dsplit: // Skip count. - arg = (const char *)skipwhite(skipdigits((const char_u *)arg)); + arg = (const char *)skipwhite((char *)skipdigits((const char_u *)arg)); if (*arg == '/') { // Match regexp, not just whole words. for (++arg; *arg && *arg != '/'; arg++) { if (*arg == '\\' && arg[1] != NUL) { @@ -3668,7 +3668,7 @@ const char *set_one_cmd_context(expand_T *xp, const char *buff) } } if (*arg) { - arg = (const char *)skipwhite((const char_u *)arg + 1); + arg = (const char *)skipwhite(arg + 1); // Check for trailing illegal characters. if (*arg && strchr("|\"\n", *arg) == NULL) { @@ -3946,7 +3946,7 @@ const char *set_one_cmd_context(expand_T *xp, const char *buff) || strncmp(arg, "time", (size_t)(p - arg)) == 0 || strncmp(arg, "collate", (size_t)(p - arg)) == 0) { xp->xp_context = EXPAND_LOCALES; - xp->xp_pattern = (char *)skipwhite((const char_u *)p); + xp->xp_pattern = skipwhite(p); } else { xp->xp_context = EXPAND_NOTHING; } @@ -4078,7 +4078,7 @@ static linenr_T get_address(exarg_T *eap, char **ptr, cmd_addr_T addr_type, int linenr_T lnum; buf_T *buf; - cmd = (char *)skipwhite((char_u *)(*ptr)); + cmd = skipwhite(*ptr); lnum = MAXLNUM; do { switch (*cmd) { @@ -4291,7 +4291,7 @@ static linenr_T get_address(exarg_T *eap, char **ptr, cmd_addr_T addr_type, int } for (;;) { - cmd = (char *)skipwhite((char_u *)cmd); + cmd = skipwhite(cmd); if (*cmd != '-' && *cmd != '+' && !ascii_isdigit(*cmd)) { break; } @@ -4389,7 +4389,7 @@ static void get_flags(exarg_T *eap) } else { eap->flags |= EXFLAG_NR; } - eap->arg = (char *)skipwhite((char_u *)eap->arg + 1); + eap->arg = skipwhite(eap->arg + 1); } } @@ -4567,7 +4567,7 @@ static char *replace_makeprg(exarg_T *eap, char *p, char **cmdlinep) } } - p = (char *)skipwhite((char_u *)p); + p = skipwhite(p); if ((pos = strstr(program, "$*")) != NULL) { // replace $* by given arguments @@ -4892,7 +4892,7 @@ static char *getargcmd(char **argp) } } - arg = (char *)skipwhite((char_u *)arg); // skip over spaces + arg = skipwhite(arg); // skip over spaces *argp = arg; } return command; @@ -4952,14 +4952,14 @@ static int getargopt(exarg_T *eap) if (!checkforcmd(&arg, "binary", 3)) { return FAIL; } - eap->arg = (char *)skipwhite((char_u *)arg); + eap->arg = skipwhite(arg); return OK; } // ":read ++edit file" if (STRNCMP(arg, "edit", 4) == 0) { eap->read_edit = true; - eap->arg = (char *)skipwhite((char_u *)arg + 4); + eap->arg = skipwhite(arg + 4); return OK; } @@ -4988,7 +4988,7 @@ static int getargopt(exarg_T *eap) arg++; *pp = (int)(arg - eap->cmd); arg = skip_cmd_arg(arg, false); - eap->arg = (char *)skipwhite((char_u *)arg); + eap->arg = skipwhite(arg); *arg = NUL; if (pp == &eap->force_ff) { @@ -5077,7 +5077,7 @@ static int get_tabpage_arg(exarg_T *eap) tab_number = 0; } else { tab_number = (int)eap->line2; - if (!unaccept_arg0 && *skipwhite((char_u *)(*eap->cmdlinep)) == '-') { + if (!unaccept_arg0 && *skipwhite(*eap->cmdlinep) == '-') { tab_number--; if (tab_number < unaccept_arg0) { eap->errmsg = e_invarg; @@ -5280,7 +5280,7 @@ char_u *find_nextcmd(const char_u *p) /// @return NULL if it isn't, the following character if it is. char_u *check_nextcmd(char_u *p) { - char *s = (char *)skipwhite(p); + char *s = skipwhite((char *)p); if (*s == '|' || *s == '\n') { return (char_u *)(s + 1); @@ -5362,7 +5362,7 @@ int uc_add_command(char *name, size_t name_len, char *rep, uint32_t argt, long d char *rep_buf = NULL; garray_T *gap; - replace_termcodes((char_u *)rep, STRLEN(rep), (char_u **)&rep_buf, 0, NULL, CPO_TO_CPO_FLAGS); + replace_termcodes(rep, STRLEN(rep), &rep_buf, 0, NULL, CPO_TO_CPO_FLAGS); if (rep_buf == NULL) { // Can't replace termcodes - try using the string as is rep_buf = xstrdup(rep); @@ -5859,7 +5859,7 @@ static void ex_command(exarg_T *eap) &addr_type_arg) == FAIL) { return; } - p = (char *)skipwhite((char_u *)end); + p = skipwhite(end); } // Get the name (if any) and skip to the following argument. @@ -5873,7 +5873,7 @@ static void ex_command(exarg_T *eap) // If there is nothing after the name, and no attributes were specified, // we are listing commands - p = (char *)skipwhite((char_u *)end); + p = skipwhite(end); if (!has_attr && ends_excmd(*p)) { uc_list(name, name_len); } else if (!ASCII_ISUPPER(*name)) { @@ -5923,7 +5923,7 @@ static void ex_delcommand(exarg_T *eap) if (STRNCMP(arg, "-buffer", 7) == 0 && ascii_iswhite(arg[7])) { buffer_only = true; - arg = (char *)skipwhite((char_u *)arg + 7); + arg = skipwhite(arg + 7); } gap = &curbuf->b_ucmds; @@ -5968,7 +5968,7 @@ static void ex_delcommand(exarg_T *eap) /// @param[out] len Length of string in {buf} /// /// @return true if iteration is complete, else false -bool uc_split_args_iter(const char_u *arg, size_t arglen, size_t *end, char *buf, size_t *len) +bool uc_split_args_iter(const char *arg, size_t arglen, size_t *end, char *buf, size_t *len) { if (!arglen) { return true; @@ -5982,9 +5982,9 @@ bool uc_split_args_iter(const char_u *arg, size_t arglen, size_t *end, char *buf size_t l = 0; for (; pos < arglen - 1; pos++) { if (arg[pos] == '\\' && (arg[pos + 1] == '\\' || ascii_iswhite(arg[pos + 1]))) { - buf[l++] = (char)arg[++pos]; + buf[l++] = arg[++pos]; } else { - buf[l++] = (char)arg[pos]; + buf[l++] = arg[pos]; if (ascii_iswhite(arg[pos + 1])) { *end = pos + 1; *len = l; @@ -5994,7 +5994,7 @@ bool uc_split_args_iter(const char_u *arg, size_t arglen, size_t *end, char *buf } if (pos < arglen && !ascii_iswhite(arg[pos])) { - buf[l++] = (char)arg[pos]; + buf[l++] = arg[pos]; } *len = l; @@ -6024,7 +6024,7 @@ static char *uc_split_args(char *arg, size_t *lenp) len += 2; p += 1; } else if (ascii_iswhite(*p)) { - p = (char *)skipwhite((char_u *)p); + p = skipwhite(p); if (*p == NUL) { break; } @@ -6054,7 +6054,7 @@ static char *uc_split_args(char *arg, size_t *lenp) *q++ = '\\'; *q++ = *p++; } else if (ascii_iswhite(*p)) { - p = (char *)skipwhite((char_u *)p); + p = skipwhite(p); if (*p == NUL) { break; } @@ -7856,7 +7856,7 @@ static void ex_syncbind(exarg_T *eap) ctrl_o[0] = Ctrl_O; ctrl_o[1] = 0; - ins_typebuf((char_u *)ctrl_o, REMAP_NONE, 0, true, false); + ins_typebuf(ctrl_o, REMAP_NONE, 0, true, false); } } } @@ -8190,7 +8190,7 @@ static void ex_winsize(exarg_T *eap) return; } int w = getdigits_int((char_u **)&arg, false, 10); - arg = (char *)skipwhite((char_u *)arg); + arg = skipwhite(arg); char *p = arg; int h = getdigits_int((char_u **)&arg, false, 10); if (*p != NUL && *arg == NUL) { @@ -8218,7 +8218,7 @@ static void ex_wincmd(exarg_T *eap) } eap->nextcmd = (char *)check_nextcmd((char_u *)p); - p = (char *)skipwhite((char_u *)p); + p = skipwhite(p); if (*p != NUL && *p != '"' && eap->nextcmd == NULL) { emsg(_(e_invarg)); } else if (!eap->skip) { @@ -8515,7 +8515,7 @@ static void ex_redir(exarg_T *eap) } else { mode = "w"; } - arg = (char *)skipwhite((char_u *)arg); + arg = skipwhite(arg); close_redir(); @@ -8565,7 +8565,7 @@ static void ex_redir(exarg_T *eap) append = FALSE; } - if (var_redir_start((char *)skipwhite((char_u *)arg), append) == OK) { + if (var_redir_start(skipwhite(arg), append) == OK) { redir_vname = 1; } } else { // TODO(vim): redirect to a buffer @@ -8930,7 +8930,7 @@ static void ex_stopinsert(exarg_T *eap) void exec_normal_cmd(char_u *cmd, int remap, bool silent) { // Stuff the argument into the typeahead buffer. - ins_typebuf(cmd, remap, 0, true, silent); + ins_typebuf((char *)cmd, remap, 0, true, silent); exec_normal(false); } @@ -8996,7 +8996,7 @@ static void ex_findpat(exarg_T *eap) n = 1; if (ascii_isdigit(*eap->arg)) { // get count n = getdigits_long((char_u **)&eap->arg, false, 0); - eap->arg = (char *)skipwhite((char_u *)eap->arg); + eap->arg = skipwhite(eap->arg); } if (*eap->arg == '/') { // Match regexp, not just whole words whole = false; @@ -9004,7 +9004,7 @@ static void ex_findpat(exarg_T *eap) p = (char *)skip_regexp((char_u *)eap->arg, '/', p_magic, NULL); if (*p) { *p++ = NUL; - p = (char *)skipwhite((char_u *)p); + p = skipwhite(p); // Check for trailing illegal characters. if (!ends_excmd(*p)) { @@ -9660,12 +9660,12 @@ static void ex_filetype(exarg_T *eap) for (;;) { if (STRNCMP(arg, "plugin", 6) == 0) { plugin = true; - arg = (char *)skipwhite((char_u *)arg + 6); + arg = skipwhite(arg + 6); continue; } if (STRNCMP(arg, "indent", 6) == 0) { indent = true; - arg = (char *)skipwhite((char_u *)arg + 6); + arg = skipwhite(arg + 6); continue; } break; @@ -9885,7 +9885,7 @@ bool cmd_can_preview(char *cmd) // parse the command line ea.cmd = skip_range(cmd, NULL); if (*ea.cmd == '*') { - ea.cmd = (char *)skipwhite((char_u *)ea.cmd + 1); + ea.cmd = skipwhite(ea.cmd + 1); } char *end = find_command(&ea, NULL); diff --git a/src/nvim/ex_eval.c b/src/nvim/ex_eval.c index c00f27a3c1..976a19300b 100644 --- a/src/nvim/ex_eval.c +++ b/src/nvim/ex_eval.c @@ -1342,7 +1342,7 @@ void ex_catch(exarg_T *eap) */ if (!skip && (cstack->cs_flags[idx] & CSF_THROWN) && !(cstack->cs_flags[idx] & CSF_CAUGHT)) { - if (end != NULL && *end != NUL && !ends_excmd(*skipwhite((char_u *)end + 1))) { + if (end != NULL && *end != NUL && !ends_excmd(*skipwhite(end + 1))) { emsg(_(e_trailing)); return; } diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 771e84651f..8792e9673a 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -301,7 +301,7 @@ static char_u *get_healthcheck_names(expand_T *xp, int idx) "lua/**/**/health.lua" }; // NOLINT for (int i = 0; i < 3; i++) { struct healthchecks_cookie hcookie = { .names = &healthchecks.names, .is_lua = i != 0 }; - do_in_runtimepath((char_u *)patterns[i], DIP_ALL, get_healthcheck_cb, &hcookie); + do_in_runtimepath(patterns[i], DIP_ALL, get_healthcheck_cb, &hcookie); if (healthchecks.names.ga_len > 0) { ga_remove_duplicate_strings(&healthchecks.names); @@ -319,7 +319,7 @@ static char_u *get_healthcheck_names(expand_T *xp, int idx) /// Used as a callback for do_in_runtimepath /// @param[in] path Expanded path to a possible healthcheck. /// @param[out] cookie Array where names will be inserted. -static void get_healthcheck_cb(char_u *path, void *cookie) +static void get_healthcheck_cb(char *path, void *cookie) { if (path != NULL) { struct healthchecks_cookie *hcookie = (struct healthchecks_cookie *)cookie; @@ -335,7 +335,7 @@ static void get_healthcheck_cb(char_u *path, void *cookie) pattern = ".*[\\/]\\([^\\/]*\\)\\.vim$"; } - res = (char_u *)do_string_sub((char *)path, pattern, sub, NULL, "g"); + res = (char_u *)do_string_sub(path, pattern, sub, NULL, "g"); if (hcookie->is_lua && res != NULL) { // Replace slashes with dots as represented by the healthcheck plugin. char_u *ares = (char_u *)do_string_sub((char *)res, "[\\/]", ".", NULL, "g"); @@ -403,7 +403,7 @@ static bool do_incsearch_highlighting(int firstc, int *search_delim, incsearch_s // Skip over "substitute" to find the pattern separator. for (p = cmd; ASCII_ISALPHA(*p); p++) {} - if (*skipwhite(p) == NUL) { + if (*skipwhite((char *)p) == NUL) { goto theend; } @@ -419,9 +419,9 @@ static bool do_incsearch_highlighting(int firstc, int *search_delim, incsearch_s } else if (STRNCMP(cmd, "sort", MAX(p - cmd, 3)) == 0) { // skip over ! and flags if (*p == '!') { - p = skipwhite(p + 1); + p = (char_u *)skipwhite((char *)p + 1); } - while (ASCII_ISALPHA(*(p = skipwhite(p)))) { + while (ASCII_ISALPHA(*(p = (char_u *)skipwhite((char *)p)))) { p++; } if (*p == NUL) { @@ -435,7 +435,7 @@ static bool do_incsearch_highlighting(int firstc, int *search_delim, incsearch_s // skip over "!/". if (*p == '!') { p++; - if (*skipwhite(p) == NUL) { + if (*skipwhite((char *)p) == NUL) { goto theend; } } @@ -446,7 +446,7 @@ static bool do_incsearch_highlighting(int firstc, int *search_delim, incsearch_s goto theend; } - p = skipwhite(p); + p = (char_u *)skipwhite((char *)p); delim = (delim_optional && vim_isIDc(*p)) ? ' ' : *p++; *search_delim = delim; end = skip_regexp(p, delim, p_magic, NULL); @@ -2276,7 +2276,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, IObuff); + int j = utf_char2bytes(s->c, (char *)IObuff); IObuff[j] = NUL; // exclude composing chars put_on_cmdline(IObuff, j, true); } @@ -3073,11 +3073,11 @@ static void draw_cmdline(int start, int len) u8c = arabic_shape(u8c, NULL, &u8cc[0], pc, pc1, nc); - newlen += utf_char2bytes(u8c, arshape_buf + newlen); + newlen += utf_char2bytes(u8c, (char *)arshape_buf + newlen); if (u8cc[0] != 0) { - newlen += utf_char2bytes(u8cc[0], arshape_buf + newlen); + newlen += utf_char2bytes(u8cc[0], (char *)arshape_buf + newlen); if (u8cc[1] != 0) { - newlen += utf_char2bytes(u8cc[1], arshape_buf + newlen); + newlen += utf_char2bytes(u8cc[1], (char *)arshape_buf + newlen); } } } else { @@ -6233,20 +6233,20 @@ int get_list_range(char_u **str, int *num1, int *num2) int first = false; varnumber_T num; - *str = skipwhite(*str); + *str = (char_u *)skipwhite((char *)(*str)); if (**str == '-' || ascii_isdigit(**str)) { // parse "from" part of range vim_str2nr(*str, NULL, &len, 0, &num, NULL, 0, false); *str += len; *num1 = (int)num; first = true; } - *str = skipwhite(*str); + *str = (char_u *)skipwhite((char *)(*str)); if (**str == ',') { // parse "to" part of range - *str = skipwhite(*str + 1); + *str = (char_u *)skipwhite((char *)(*str) + 1); vim_str2nr(*str, NULL, &len, 0, &num, NULL, 0, false); if (len > 0) { *num2 = (int)num; - *str = skipwhite(*str + len); + *str = (char_u *)skipwhite((char *)(*str) + len); } else if (!first) { // no number given at all return FAIL; } @@ -6639,10 +6639,7 @@ char *script_get(exarg_T *const eap, size_t *const lenp) ga_init(&ga, 1, 0x400); } - const char *const end_pattern = ( - cmd[2] != NUL - ? (const char *)skipwhite((const char_u *)cmd + 2) - : "."); + const char *const end_pattern = (cmd[2] != NUL ? (const char *)skipwhite(cmd + 2) : "."); for (;;) { char *const theline = (char *)eap->getline(eap->cstack->cs_looplevel > 0 ? -1 : NUL, eap->cookie, 0, true); diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c index ad0440e0b3..a132c2db43 100644 --- a/src/nvim/fileio.c +++ b/src/nvim/fileio.c @@ -1401,7 +1401,7 @@ retry: assert(u8c <= INT_MAX); // produce UTF-8 dest -= utf_char2len((int)u8c); - (void)utf_char2bytes((int)u8c, dest); + (void)utf_char2bytes((int)u8c, (char *)dest); } // move the linerest to before the converted characters @@ -3943,8 +3943,8 @@ static int buf_write_bytes(struct bw_info *ip) * Convert latin1 in the buffer to UTF-8 in the file. */ p = ip->bw_conv_buf; // translate to buffer - for (wlen = 0; wlen < len; ++wlen) { - p += utf_char2bytes(buf[wlen], p); + for (wlen = 0; wlen < len; wlen++) { + p += utf_char2bytes(buf[wlen], (char *)p); } buf = ip->bw_conv_buf; len = (int)(p - ip->bw_conv_buf); diff --git a/src/nvim/fold.c b/src/nvim/fold.c index 56f3f4893d..3e1b66fde3 100644 --- a/src/nvim/fold.c +++ b/src/nvim/fold.c @@ -1840,7 +1840,7 @@ void foldtext_cleanup(char_u *str) bool did2 = false; // Ignore leading and trailing white space in 'commentstring'. - char_u *cms_start = skipwhite(curbuf->b_p_cms); + char_u *cms_start = (char_u *)skipwhite((char *)curbuf->b_p_cms); size_t cms_slen = STRLEN(cms_start); while (cms_slen > 0 && ascii_iswhite(cms_start[cms_slen - 1])) { --cms_slen; @@ -1859,7 +1859,7 @@ void foldtext_cleanup(char_u *str) } // skip "%s" and white space after it - s = skipwhite(cms_end + 2); + s = (char_u *)skipwhite((char *)cms_end + 2); cms_elen -= (size_t)(s - cms_end); cms_end = s; } @@ -2907,7 +2907,7 @@ static void foldlevelIndent(fline_T *flp) linenr_T lnum = flp->lnum + flp->off; buf = flp->wp->w_buffer; - s = skipwhite(ml_get_buf(buf, lnum, false)); + s = (char_u *)skipwhite((char *)ml_get_buf(buf, lnum, false)); // empty line or lines starting with a character in 'foldignore': level // depends on surrounding lines diff --git a/src/nvim/getchar.c b/src/nvim/getchar.c index 5f2a4a281b..05ee4cbafd 100644 --- a/src/nvim/getchar.c +++ b/src/nvim/getchar.c @@ -319,7 +319,7 @@ static void add_char_buff(buffheader_T *buf, int c) if (IS_SPECIAL(c)) { len = 1; } else { - len = utf_char2bytes(c, bytes); + len = utf_char2bytes(c, (char *)bytes); } for (int i = 0; i < len; i++) { @@ -537,18 +537,18 @@ void AppendToRedobuff(const char *s) /// /// @param str String to append /// @param len Length of `str` or -1 for up to the NUL. -void AppendToRedobuffLit(const char_u *str, int len) +void AppendToRedobuffLit(const char *str, int len) { if (block_redo) { return; } - const char *s = (const char *)str; - while (len < 0 ? *s != NUL : s - (const char *)str < len) { + const char *s = str; + while (len < 0 ? *s != NUL : s - str < len) { // Put a string of normal characters in the redo buffer (that's // faster). const char *start = s; - while (*s >= ' ' && *s < DEL && (len < 0 || s - (const char *)str < len)) { + while (*s >= ' ' && *s < DEL && (len < 0 || s - str < len)) { s++; } @@ -561,7 +561,7 @@ void AppendToRedobuffLit(const char_u *str, int len) add_buff(&redobuff, start, (long)(s - start)); } - if (*s == NUL || (len >= 0 && s - (const char *)str >= len)) { + if (*s == NUL || (len >= 0 && s - str >= len)) { break; } @@ -866,7 +866,7 @@ void init_default_mappings(void) // If silent is true, cmd_silent is set when the characters are obtained. // // return FAIL for failure, OK otherwise -int ins_typebuf(char_u *str, int noremap, int offset, bool nottyped, bool silent) +int ins_typebuf(char *str, int noremap, int offset, bool nottyped, bool silent) { char_u *s1, *s2; int addlen; @@ -1010,7 +1010,7 @@ int ins_char_typebuf(int c, int modifier) *end = NUL; len = (int)(end - buf); } - (void)ins_typebuf(buf, KeyNoremap, 0, !KeyTyped, cmd_silent); + (void)ins_typebuf((char *)buf, KeyNoremap, 0, !KeyTyped, cmd_silent); return len; } @@ -1758,7 +1758,7 @@ static int put_string_in_typebuf(int offset, int slen, char_u *string, int new_s del_typebuf(-extra, offset); } else if (extra > 0) { // insert the extra space we need - if (ins_typebuf(string + slen, REMAP_YES, offset, false, false) == FAIL) { + if (ins_typebuf((char *)string + slen, REMAP_YES, offset, false, false) == FAIL) { return FAIL; } } @@ -1816,7 +1816,7 @@ static int check_simplify_modifier(int max_offset) new_string[2] = (char_u)K_THIRD(new_c); len = 3; } else { - len = utf_char2bytes(new_c, new_string); + len = utf_char2bytes(new_c, (char *)new_string); } if (modifier == 0) { if (put_string_in_typebuf(offset, 4, new_string, len) == FAIL) { @@ -2116,7 +2116,7 @@ static int handle_mapping(int *keylenp, bool *timedout, int *mapdepth) // mode temporarily. Append K_SELECT to switch back to Select mode. if (VIsual_active && VIsual_select && (mp->m_mode & VISUAL)) { VIsual_select = false; - (void)ins_typebuf(K_SELECT_STRING, REMAP_NONE, 0, true, false); + (void)ins_typebuf((char *)K_SELECT_STRING, REMAP_NONE, 0, true, false); } // Copy the values from *mp that are used, because evaluating the @@ -2202,7 +2202,7 @@ static int handle_mapping(int *keylenp, bool *timedout, int *mapdepth) } else { noremap = REMAP_SKIP; } - i = ins_typebuf(map_str, noremap, 0, true, cmd_silent || save_m_silent); + i = ins_typebuf((char *)map_str, noremap, 0, true, cmd_silent || save_m_silent); if (save_m_expr) { xfree(map_str); } @@ -2874,15 +2874,13 @@ void set_maparg_lhs_rhs(const char *const orig_lhs, const size_t orig_lhs_len, // If something like is simplified to 0x08 then mark it as simplified. bool did_simplify = false; const int flags = REPTERM_FROM_PART | REPTERM_DO_LT; - char *replaced = (char *)replace_termcodes((char_u *)orig_lhs, orig_lhs_len, (char_u **)&lhs_buf, - flags, &did_simplify, - cpo_flags); + char *replaced = replace_termcodes(orig_lhs, orig_lhs_len, &lhs_buf, flags, &did_simplify, + cpo_flags); mapargs->lhs_len = STRLEN(replaced); STRLCPY(mapargs->lhs, replaced, sizeof(mapargs->lhs)); if (did_simplify) { - replaced = (char *)replace_termcodes((char_u *)orig_lhs, orig_lhs_len, (char_u **)&alt_lhs_buf, - flags | REPTERM_NO_SIMPLIFY, - NULL, cpo_flags); + replaced = replace_termcodes(orig_lhs, orig_lhs_len, &alt_lhs_buf, flags | REPTERM_NO_SIMPLIFY, + NULL, cpo_flags); mapargs->alt_lhs_len = STRLEN(replaced); STRLCPY(mapargs->alt_lhs, replaced, sizeof(mapargs->alt_lhs)); } else { @@ -2901,8 +2899,8 @@ void set_maparg_lhs_rhs(const char *const orig_lhs, const size_t orig_lhs_len, mapargs->rhs_len = 0; mapargs->rhs_is_noop = true; } else { - replaced = (char *)replace_termcodes((char_u *)orig_rhs, orig_rhs_len, (char_u **)&rhs_buf, - REPTERM_DO_LT | REPTERM_NO_SIMPLIFY, NULL, cpo_flags); + replaced = replace_termcodes(orig_rhs, orig_rhs_len, &rhs_buf, + REPTERM_DO_LT | REPTERM_NO_SIMPLIFY, NULL, cpo_flags); mapargs->rhs_len = STRLEN(replaced); // XXX: even when orig_rhs is non-empty, replace_termcodes may produce an empty string. mapargs->rhs_is_noop = orig_rhs[0] != NUL && mapargs->rhs_len == 0; @@ -2947,7 +2945,7 @@ void set_maparg_lhs_rhs(const char *const orig_lhs, const size_t orig_lhs_len, int str_to_mapargs(const char_u *strargs, bool is_unmap, MapArguments *mapargs) { const char_u *to_parse = strargs; - to_parse = skipwhite(to_parse); + to_parse = (char_u *)skipwhite((char *)to_parse); MapArguments parsed_args; // copy these into mapargs "all at once" when done memset(&parsed_args, 0, sizeof(parsed_args)); @@ -2955,43 +2953,43 @@ int str_to_mapargs(const char_u *strargs, bool is_unmap, MapArguments *mapargs) // any order. while (true) { if (STRNCMP(to_parse, "", 8) == 0) { - to_parse = skipwhite(to_parse + 8); + to_parse = (char_u *)skipwhite((char *)to_parse + 8); parsed_args.buffer = true; continue; } if (STRNCMP(to_parse, "", 8) == 0) { - to_parse = skipwhite(to_parse + 8); + to_parse = (char_u *)skipwhite((char *)to_parse + 8); parsed_args.nowait = true; continue; } if (STRNCMP(to_parse, "", 8) == 0) { - to_parse = skipwhite(to_parse + 8); + to_parse = (char_u *)skipwhite((char *)to_parse + 8); parsed_args.silent = true; continue; } // Ignore obsolete "" modifier. if (STRNCMP(to_parse, "", 9) == 0) { - to_parse = skipwhite(to_parse + 9); + to_parse = (char_u *)skipwhite((char *)to_parse + 9); continue; } if (STRNCMP(to_parse, "