diff options
| author | bfredl <bjorn.linse@gmail.com> | 2022-05-09 10:29:51 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-05-09 10:29:51 +0200 |
| commit | dfeb5b47bcde7984b2b1820f0268d0d5d736f98d (patch) | |
| tree | 87e129c92affece6421d4585b5d5c20996891ec5 /src | |
| parent | dbdd58e548fcf55848359b696275fd848756db7b (diff) | |
| parent | e31b32a293f6ba8708499a176234f8be1df6a145 (diff) | |
| download | rneovim-dfeb5b47bcde7984b2b1820f0268d0d5d736f98d.tar.gz rneovim-dfeb5b47bcde7984b2b1820f0268d0d5d736f98d.tar.bz2 rneovim-dfeb5b47bcde7984b2b1820f0268d0d5d736f98d.zip | |
Merge pull request #18466 from dundargoc/refactor/remove-char_u
refactor: replace char_u variables and functions with char
Diffstat (limited to 'src')
65 files changed, 758 insertions, 756 deletions
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, "<nomodeline>", 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++; |