From f2141de9e462ed8976b2a59337c32a0fcba2a11d Mon Sep 17 00:00:00 2001 From: dundargoc <33953936+dundargoc@users.noreply.github.com> Date: Fri, 13 Jan 2023 00:35:39 +0100 Subject: refactor: replace char_u with char 20 (#21714) refactor: replace char_u with char Work on https://github.com/neovim/neovim/issues/459 --- src/nvim/cmdexpand.c | 6 +- src/nvim/digraph.c | 4 +- src/nvim/drawline.c | 41 +++++----- src/nvim/eval.c | 11 ++- src/nvim/eval/funcs.c | 9 +-- src/nvim/eval/userfunc.c | 134 +++++++++++++++----------------- src/nvim/eval/userfunc.h | 2 +- src/nvim/eval/vars.c | 4 +- src/nvim/eval/window.c | 10 +-- src/nvim/ex_cmds.c | 2 +- src/nvim/ex_cmds2.c | 4 +- src/nvim/ex_docmd.c | 6 +- src/nvim/ex_getln.c | 16 ++-- src/nvim/file_search.c | 36 ++++----- src/nvim/highlight_group.c | 2 +- src/nvim/insexpand.c | 2 +- src/nvim/keycodes.c | 4 +- src/nvim/main.c | 34 ++++---- src/nvim/mapping.c | 90 +++++++++++---------- src/nvim/mark.c | 4 +- src/nvim/match.c | 6 +- src/nvim/memfile.c | 4 +- src/nvim/memfile_defs.h | 2 +- src/nvim/memline.c | 18 ++--- src/nvim/normal.c | 64 +++++++-------- src/nvim/ops.c | 12 +-- src/nvim/option.c | 2 +- src/nvim/os/env.c | 2 +- src/nvim/os/shell.c | 2 +- src/nvim/path.c | 50 ++++++------ src/nvim/popupmenu.c | 32 ++++---- src/nvim/quickfix.c | 2 +- src/nvim/regexp.c | 2 +- src/nvim/search.c | 190 ++++++++++++++++++++++----------------------- src/nvim/spellfile.c | 8 +- src/nvim/strings.c | 48 ++++++------ src/nvim/syntax.c | 8 +- src/nvim/tag.c | 32 ++++---- src/nvim/textobject.c | 84 ++++++++++---------- 39 files changed, 488 insertions(+), 501 deletions(-) diff --git a/src/nvim/cmdexpand.c b/src/nvim/cmdexpand.c index d603e964e5..bd0fbe7359 100644 --- a/src/nvim/cmdexpand.c +++ b/src/nvim/cmdexpand.c @@ -126,7 +126,7 @@ static void ExpandEscape(expand_T *xp, char_u *str, int numfiles, char **files, for (i = 0; i < numfiles; i++) { // for ":set path=" we need to escape spaces twice if (xp->xp_backslash == XP_BS_THREE) { - p = (char *)vim_strsave_escaped((char_u *)files[i], (char_u *)" "); + p = vim_strsave_escaped(files[i], " "); xfree(files[i]); files[i] = p; #if defined(BACKSLASH_IN_FILENAME) @@ -161,7 +161,7 @@ static void ExpandEscape(expand_T *xp, char_u *str, int numfiles, char **files, // Insert a backslash before characters in a tag name that // would terminate the ":tag" command. for (i = 0; i < numfiles; i++) { - p = (char *)vim_strsave_escaped((char_u *)files[i], (char_u *)"\\|\""); + p = vim_strsave_escaped(files[i], "\\|\""); xfree(files[i]); files[i] = p; } @@ -2542,7 +2542,7 @@ static void ExpandGeneric(expand_T *xp, regmatch_T *regmatch, int *num_file, cha } if (vim_regexec(regmatch, str, (colnr_T)0)) { if (escaped) { - str = (char *)vim_strsave_escaped((char_u *)str, (char_u *)" \t\\."); + str = vim_strsave_escaped(str, " \t\\."); } else { str = xstrdup(str); } diff --git a/src/nvim/digraph.c b/src/nvim/digraph.c index 744520149f..1195d6a3f4 100644 --- a/src/nvim/digraph.c +++ b/src/nvim/digraph.c @@ -1656,8 +1656,8 @@ static void registerdigraph(int char1, int char2, int n) bool check_digraph_chars_valid(int char1, int char2) { if (char2 == 0) { - char_u msg[MB_MAXBYTES + 1]; - msg[utf_char2bytes(char1, (char *)msg)] = NUL; + char msg[MB_MAXBYTES + 1]; + msg[utf_char2bytes(char1, msg)] = NUL; semsg(_(e_digraph_must_be_just_two_characters_str), msg); return false; } diff --git a/src/nvim/drawline.c b/src/nvim/drawline.c index e54566c3e5..bbe78ab556 100644 --- a/src/nvim/drawline.c +++ b/src/nvim/drawline.c @@ -616,16 +616,15 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool nochange, int c_extra = NUL; // extra chars, all the same int c_final = NUL; // final char, mandatory if set int extra_attr = 0; // attributes when n_extra != 0 - static char_u *at_end_str = (char_u *)""; // used for p_extra when displaying - // curwin->w_p_lcs_chars.eol at - // end-of-line + static char *at_end_str = ""; // used for p_extra when displaying curwin->w_p_lcs_chars.eol + // at end-of-line int lcs_eol_one = wp->w_p_lcs_chars.eol; // 'eol' until it's been used int lcs_prec_todo = wp->w_p_lcs_chars.prec; // 'prec' until it's been used bool has_fold = foldinfo.fi_level != 0 && foldinfo.fi_lines > 0; // saved "extra" items for when draw_state becomes WL_LINE (again) int saved_n_extra = 0; - char_u *saved_p_extra = NULL; + char *saved_p_extra = NULL; int saved_c_extra = 0; int saved_c_final = 0; int saved_char_attr = 0; @@ -699,7 +698,7 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool nochange, bool has_decor = false; // this buffer has decoration int win_col_offset = 0; // offset for window columns - char_u buf_fold[FOLD_TEXT_LEN]; // Hold value returned by get_foldtext + char buf_fold[FOLD_TEXT_LEN]; // Hold value returned by get_foldtext bool area_active = false; @@ -1299,10 +1298,10 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool nochange, } if (wp->w_p_rl) { // reverse line numbers // like rl_mirror(), but keep the space at the end - char_u *p2 = (char_u *)skipwhite((char *)extra); - p2 = (char_u *)skiptowhite((char *)p2) - 1; - for (char_u *p1 = (char_u *)skipwhite((char *)extra); p1 < p2; p1++, p2--) { - const char_u t = *p1; + char *p2 = skipwhite((char *)extra); + p2 = skiptowhite(p2) - 1; + for (char *p1 = skipwhite((char *)extra); p1 < p2; p1++, p2--) { + const char t = *p1; *p1 = *p2; *p2 = t; } @@ -1452,7 +1451,7 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool nochange, n_extra = saved_n_extra; c_extra = saved_c_extra; c_final = saved_c_final; - p_extra = (char *)saved_p_extra; + p_extra = saved_p_extra; char_attr = saved_char_attr; } else { char_attr = 0; @@ -1494,10 +1493,10 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool nochange, linenr_T lnume = lnum + foldinfo.fi_lines - 1; memset(buf_fold, ' ', FOLD_TEXT_LEN); - p_extra = get_foldtext(wp, lnum, lnume, foldinfo, (char *)buf_fold); + p_extra = get_foldtext(wp, lnum, lnume, foldinfo, buf_fold); n_extra = (int)strlen(p_extra); - if (p_extra != (char *)buf_fold) { + if (p_extra != buf_fold) { xfree(p_extra_free); p_extra_free = p_extra; } @@ -2072,7 +2071,7 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool nochange, if (!wp->w_p_lbr || !wp->w_p_list) { n_extra = tab_len; } else { - char_u *p; + char *p; int i; int saved_nextra = n_extra; @@ -2101,7 +2100,7 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool nochange, memset(p, ' ', (size_t)len); p[len] = NUL; xfree(p_extra_free); - p_extra_free = (char *)p; + p_extra_free = p; for (i = 0; i < tab_len; i++) { if (*p == NUL) { tab_len = i; @@ -2113,7 +2112,7 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool nochange, if (wp->w_p_lcs_chars.tab3 && i == tab_len - 1) { lcs = wp->w_p_lcs_chars.tab3; } - p += utf_char2bytes(lcs, (char *)p); + p += utf_char2bytes(lcs, p); n_extra += utf_char2len(lcs) - (saved_nextra > 0 ? 1 : 0); } p_extra = p_extra_free; @@ -2187,7 +2186,7 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool nochange, && tocol != MAXCOL && vcol < tocol) { n_extra = 0; } else { - p_extra = (char *)at_end_str; + p_extra = at_end_str; n_extra = 1; c_extra = NUL; c_final = NUL; @@ -2215,17 +2214,17 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool nochange, c_extra = NUL; c_final = NUL; if (wp->w_p_lbr) { - char_u *p; + char *p; c = (uint8_t)(*p_extra); p = xmalloc((size_t)n_extra + 1); memset(p, ' ', (size_t)n_extra); - strncpy((char *)p, // NOLINT(runtime/printf) + strncpy(p, // NOLINT(runtime/printf) p_extra + 1, (size_t)strlen(p_extra) - 1); p[n_extra] = NUL; xfree(p_extra_free); - p_extra_free = p_extra = (char *)p; + p_extra_free = p_extra = p; } else { n_extra = byte2cells(c) - 1; c = (uint8_t)(*p_extra++); @@ -2740,7 +2739,7 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool nochange, || *ptr != NUL || filler_todo > 0 || (wp->w_p_list && wp->w_p_lcs_chars.eol != NUL - && p_extra != (char *)at_end_str) + && p_extra != at_end_str) || (n_extra != 0 && (c_extra != NUL || *p_extra != NUL)))) { bool wrap = wp->w_p_wrap // Wrapping enabled. @@ -2810,7 +2809,7 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool nochange, // reset the drawing state for the start of a wrapped line draw_state = WL_START; saved_n_extra = n_extra; - saved_p_extra = (char_u *)p_extra; + saved_p_extra = p_extra; saved_c_extra = c_extra; saved_c_final = c_final; saved_char_attr = char_attr; diff --git a/src/nvim/eval.c b/src/nvim/eval.c index de6f150304..74fd6f7e86 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -2213,7 +2213,7 @@ static int eval_func(char **const arg, char *const name, const int name_len, typ // If "s" is the name of a variable of type VAR_FUNC // use its contents. partial_T *partial; - s = (char *)deref_func_name((const char *)s, &len, &partial, !evaluate); + s = deref_func_name((const char *)s, &len, &partial, !evaluate); // Need to make a copy, in case evaluating the arguments makes // the name invalid. @@ -2226,7 +2226,7 @@ static int eval_func(char **const arg, char *const name, const int name_len, typ funcexe.fe_evaluate = evaluate; funcexe.fe_partial = partial; funcexe.fe_basetv = basetv; - int ret = get_func_tv((char_u *)s, len, rettv, arg, &funcexe); + int ret = get_func_tv(s, len, rettv, arg, &funcexe); xfree(s); @@ -3221,7 +3221,7 @@ static int call_func_rettv(char **const arg, typval_T *const rettv, const bool e funcexe.fe_partial = pt; funcexe.fe_selfdict = selfdict; funcexe.fe_basetv = basetv; - const int ret = get_func_tv((char_u *)funcname, is_lua ? (int)(*arg - funcname) : -1, rettv, + const int ret = get_func_tv(funcname, is_lua ? (int)(*arg - funcname) : -1, rettv, arg, &funcexe); // Clear the funcref afterwards, so that deleting it while @@ -5050,7 +5050,7 @@ void common_function(typval_T *argvars, typval_T *rettv, bool is_funcref) if (tv_list_len(list) == 0) { arg_idx = 0; } else if (tv_list_len(list) > MAX_FUNC_ARGS) { - emsg_funcname((char *)e_toomanyarg, (char_u *)s); + emsg_funcname((char *)e_toomanyarg, s); xfree(name); goto theend; } @@ -7675,8 +7675,7 @@ int store_session_globals(FILE *fd) && var_flavour((char *)this_var->di_key) == VAR_FLAVOUR_SESSION) { // Escape special characters with a backslash. Turn a LF and // CR into \n and \r. - char *const p = (char *)vim_strsave_escaped((const char_u *)tv_get_string(&this_var->di_tv), - (const char_u *)"\\\"\n\r"); + char *const p = (char *)vim_strsave_escaped(tv_get_string(&this_var->di_tv), "\\\"\n\r"); for (char *t = p; *t != NUL; t++) { if (*t == '\n') { *t = 'n'; diff --git a/src/nvim/eval/funcs.c b/src/nvim/eval/funcs.c index a87698a9f9..7820b837da 100644 --- a/src/nvim/eval/funcs.c +++ b/src/nvim/eval/funcs.c @@ -1522,9 +1522,8 @@ static void f_escape(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) { char buf[NUMBUFLEN]; - rettv->vval.v_string = (char *)vim_strsave_escaped((const char_u *)tv_get_string(&argvars[0]), - (const char_u *)tv_get_string_buf(&argvars[1], - buf)); + rettv->vval.v_string = vim_strsave_escaped(tv_get_string(&argvars[0]), + tv_get_string_buf(&argvars[1], buf)); rettv->v_type = VAR_STRING; } @@ -2245,7 +2244,7 @@ static void f_get(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) const char *const what = tv_get_string(&argvars[1]); if (strcmp(what, "func") == 0 || strcmp(what, "name") == 0) { - const char *name = (const char *)partial_name(pt); + const char *name = partial_name(pt); rettv->v_type = (*what == 'f' ? VAR_FUNC : VAR_STRING); assert(name != NULL); if (rettv->v_type == VAR_FUNC) { @@ -2253,7 +2252,7 @@ static void f_get(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) } if (*what == 'n' && pt->pt_name == NULL && pt->pt_func != NULL) { // use instead of the byte code - name = (const char *)printable_func_name(pt->pt_func); + name = printable_func_name(pt->pt_func); } rettv->vval.v_string = xstrdup(name); } else if (strcmp(what, "dict") == 0) { diff --git a/src/nvim/eval/userfunc.c b/src/nvim/eval/userfunc.c index 9078050067..1c0fe20248 100644 --- a/src/nvim/eval/userfunc.c +++ b/src/nvim/eval/userfunc.c @@ -93,10 +93,10 @@ static int get_function_args(char **argp, char_u endchar, garray_T *newargs, int int i; if (newargs != NULL) { - ga_init(newargs, (int)sizeof(char_u *), 3); + ga_init(newargs, (int)sizeof(char *), 3); } if (default_args != NULL) { - ga_init(default_args, (int)sizeof(char_u *), 3); + ga_init(default_args, (int)sizeof(char *), 3); } if (varargs != NULL) { @@ -312,7 +312,7 @@ int get_lambda_tv(char **arg, typval_T *rettv, bool evaluate) fp = xcalloc(1, offsetof(ufunc_T, uf_name) + strlen(name) + 1); pt = xcalloc(1, sizeof(partial_T)); - ga_init(&newlines, (int)sizeof(char_u *), 1); + ga_init(&newlines, (int)sizeof(char *), 1); ga_grow(&newlines, 1); // Add "return " before the expression. @@ -330,7 +330,7 @@ int get_lambda_tv(char **arg, typval_T *rettv, bool evaluate) set_ufunc_name(fp, name); hash_add(&func_hashtab, UF2HIKEY(fp)); fp->uf_args = newargs; - ga_init(&fp->uf_def_args, (int)sizeof(char_u *), 1); + ga_init(&fp->uf_def_args, (int)sizeof(char *), 1); fp->uf_lines = newlines; if (current_funccal != NULL && eval_lavars) { flags |= FC_CLOSURE; @@ -383,7 +383,7 @@ errret: /// was not found. /// /// @return name of the function. -char_u *deref_func_name(const char *name, int *lenp, partial_T **const partialp, bool no_autoload) +char *deref_func_name(const char *name, int *lenp, partial_T **const partialp, bool no_autoload) FUNC_ATTR_NONNULL_ARG(1, 2) { if (partialp != NULL) { @@ -394,10 +394,10 @@ char_u *deref_func_name(const char *name, int *lenp, partial_T **const partialp, if (v != NULL && v->di_tv.v_type == VAR_FUNC) { if (v->di_tv.vval.v_string == NULL) { // just in case *lenp = 0; - return (char_u *)""; + return ""; } *lenp = (int)strlen(v->di_tv.vval.v_string); - return (char_u *)v->di_tv.vval.v_string; + return v->di_tv.vval.v_string; } if (v != NULL && v->di_tv.v_type == VAR_PARTIAL) { @@ -405,31 +405,31 @@ char_u *deref_func_name(const char *name, int *lenp, partial_T **const partialp, if (pt == NULL) { // just in case *lenp = 0; - return (char_u *)""; + return ""; } if (partialp != NULL) { *partialp = pt; } char *s = partial_name(pt); *lenp = (int)strlen(s); - return (char_u *)s; + return s; } - return (char_u *)name; + return (char *)name; } /// Give an error message with a function name. Handle things. /// /// @param ermsg must be passed without translation (use N_() instead of _()). /// @param name function name -void emsg_funcname(char *ermsg, const char_u *name) +void emsg_funcname(char *ermsg, const char *name) { - char_u *p; + char *p; - if (*name == K_SPECIAL) { - p = (char_u *)concat_str("", (char *)name + 3); + if ((uint8_t)(*name) == K_SPECIAL) { + p = concat_str("", name + 3); } else { - p = (char_u *)name; + p = (char *)name; } semsg(_(ermsg), p); @@ -447,7 +447,7 @@ void emsg_funcname(char *ermsg, const char_u *name) /// @param funcexe various values /// /// @return OK or FAIL. -int get_func_tv(const char_u *name, int len, typval_T *rettv, char **arg, funcexe_T *funcexe) +int get_func_tv(const char *name, int len, typval_T *rettv, char **arg, funcexe_T *funcexe) { char *argp; int ret = OK; @@ -491,7 +491,7 @@ int get_func_tv(const char_u *name, int len, typval_T *rettv, char **arg, funcex ((typval_T **)funcargs.ga_data)[funcargs.ga_len++] = &argvars[i]; } } - ret = call_func((char *)name, len, rettv, argcount, argvars, funcexe); + ret = call_func(name, len, rettv, argcount, argvars, funcexe); funcargs.ga_len -= i; } else if (!aborting()) { @@ -593,7 +593,7 @@ ufunc_T *find_func(const char_u *name) /// Copy the function name of "fp" to buffer "buf". /// "buf" must be able to hold the function name plus three bytes. /// Takes care of script-local function names. -static void cat_func_name(char_u *buf, ufunc_T *fp) +static void cat_func_name(char *buf, ufunc_T *fp) { if ((uint8_t)fp->uf_name[0] == K_SPECIAL) { STRCPY(buf, ""); @@ -1439,28 +1439,25 @@ static void user_func_error(int error, const char_u *name) { switch (error) { case FCERR_UNKNOWN: - emsg_funcname(N_("E117: Unknown function: %s"), name); + emsg_funcname(N_("E117: Unknown function: %s"), (char *)name); break; case FCERR_NOTMETHOD: - emsg_funcname(N_("E276: Cannot use function as a method: %s"), name); + emsg_funcname(N_("E276: Cannot use function as a method: %s"), (char *)name); break; case FCERR_DELETED: - emsg_funcname(N_("E933: Function was deleted: %s"), name); + emsg_funcname(N_("E933: Function was deleted: %s"), (char *)name); break; case FCERR_TOOMANY: - emsg_funcname(_(e_toomanyarg), name); + emsg_funcname(_(e_toomanyarg), (char *)name); break; case FCERR_TOOFEW: - emsg_funcname(N_("E119: Not enough arguments for function: %s"), - name); + emsg_funcname(N_("E119: Not enough arguments for function: %s"), (char *)name); break; case FCERR_SCRIPT: - emsg_funcname(N_("E120: Using not in a script context: %s"), - name); + emsg_funcname(N_("E120: Using not in a script context: %s"), (char *)name); break; case FCERR_DICT: - emsg_funcname(N_("E725: Calling dict function without Dictionary: %s"), - name); + emsg_funcname(N_("E725: Calling dict function without Dictionary: %s"), (char *)name); break; } } @@ -1652,9 +1649,9 @@ theend: return ret; } -char_u *printable_func_name(ufunc_T *fp) +char *printable_func_name(ufunc_T *fp) { - return fp->uf_name_exp != NULL ? fp->uf_name_exp : (char_u *)fp->uf_name; + return fp->uf_name_exp != NULL ? (char *)fp->uf_name_exp : fp->uf_name; } /// List the head of the function: "name(arg1, arg2)". @@ -1730,8 +1727,8 @@ char_u *trans_function_name(char **pp, bool skip, int flags, funcdict_T *fdp, pa FUNC_ATTR_NONNULL_ARG(1) { char *name = NULL; - const char_u *start; - const char_u *end; + const char *start; + const char *end; int lead; int len; lval_T lv; @@ -1739,7 +1736,7 @@ char_u *trans_function_name(char **pp, bool skip, int flags, funcdict_T *fdp, pa if (fdp != NULL) { CLEAR_POINTER(fdp); } - start = (char_u *)(*pp); + start = *pp; // Check for hard coded : already translated function ID (from a user // command). @@ -1752,14 +1749,14 @@ char_u *trans_function_name(char **pp, bool skip, int flags, funcdict_T *fdp, pa // A name starting with "" or "" is local to a script. But // don't skip over "s:", get_lval() needs it for "s:dict.func". - lead = eval_fname_script((const char *)start); + lead = eval_fname_script(start); if (lead > 2) { start += lead; } // Note that TFN_ flags use the same values as GLV_ flags. - end = (char_u *)get_lval((char *)start, NULL, &lv, false, skip, flags | GLV_READ_ONLY, - lead > 2 ? 0 : FNE_CHECK_START); + end = get_lval((char *)start, NULL, &lv, false, skip, flags | GLV_READ_ONLY, + lead > 2 ? 0 : FNE_CHECK_START); if (end == start) { if (!skip) { emsg(_("E129: Function name required")); @@ -1783,7 +1780,7 @@ char_u *trans_function_name(char **pp, bool skip, int flags, funcdict_T *fdp, pa if (lv.ll_tv != NULL) { if (fdp != NULL) { fdp->fd_dict = lv.ll_dict; - fdp->fd_newkey = (char_u *)lv.ll_newkey; + fdp->fd_newkey = lv.ll_newkey; lv.ll_newkey = NULL; fdp->fd_di = lv.ll_di; } @@ -1793,7 +1790,7 @@ char_u *trans_function_name(char **pp, bool skip, int flags, funcdict_T *fdp, pa } else if (lv.ll_tv->v_type == VAR_PARTIAL && lv.ll_tv->vval.v_partial != NULL) { if (is_luafunc(lv.ll_tv->vval.v_partial) && *end == '.') { - len = check_luafunc_name((const char *)end + 1, true); + len = check_luafunc_name(end + 1, true); if (len == 0) { semsg(e_invexpr2, "v:lua"); goto theend; @@ -1830,15 +1827,14 @@ char_u *trans_function_name(char **pp, bool skip, int flags, funcdict_T *fdp, pa // Check if the name is a Funcref. If so, use the value. if (lv.ll_exp_name != NULL) { len = (int)strlen(lv.ll_exp_name); - name = (char *)deref_func_name(lv.ll_exp_name, &len, partial, - flags & TFN_NO_AUTOLOAD); + name = deref_func_name(lv.ll_exp_name, &len, partial, + flags & TFN_NO_AUTOLOAD); if ((const char *)name == lv.ll_exp_name) { name = NULL; } } else if (!(flags & TFN_NO_DEREF)) { - len = (int)(end - (char_u *)(*pp)); - name = (char *)deref_func_name((const char *)(*pp), &len, partial, - flags & TFN_NO_AUTOLOAD); + len = (int)(end - *pp); + name = deref_func_name(*pp, &len, partial, flags & TFN_NO_AUTOLOAD); if (name == *pp) { name = NULL; } @@ -1873,7 +1869,7 @@ char_u *trans_function_name(char **pp, bool skip, int flags, funcdict_T *fdp, pa lv.ll_name += 2; lv.ll_name_len -= 2; } - len = (int)((const char *)end - lv.ll_name); + len = (int)(end - lv.ll_name); } size_t sid_buf_len = 0; @@ -1904,7 +1900,7 @@ char_u *trans_function_name(char **pp, bool skip, int flags, funcdict_T *fdp, pa } if (!skip && !(flags & TFN_QUIET) && !(flags & TFN_NO_DEREF)) { - char_u *cp = xmemrchr(lv.ll_name, ':', lv.ll_name_len); + char *cp = xmemrchr(lv.ll_name, ':', lv.ll_name_len); if (cp != NULL && cp < end) { semsg(_("E884: Function name cannot contain a colon: %s"), start); @@ -2162,7 +2158,7 @@ void ex_function(exarg_T *eap) msg_puts(eap->forceit ? "endfunction" : " endfunction"); } } else { - emsg_funcname(N_("E123: Undefined function: %s"), (char_u *)name); + emsg_funcname(N_("E123: Undefined function: %s"), name); } } goto ret_free; @@ -2182,8 +2178,8 @@ void ex_function(exarg_T *eap) } p = skipwhite(p + 1); - ga_init(&newargs, (int)sizeof(char_u *), 3); - ga_init(&newlines, (int)sizeof(char_u *), 3); + ga_init(&newargs, (int)sizeof(char *), 3); + ga_init(&newlines, (int)sizeof(char *), 3); if (!eap->skip) { // Check the name of the function. Unless it's a dictionary function @@ -2191,7 +2187,7 @@ void ex_function(exarg_T *eap) if (name != NULL) { arg = name; } else { - arg = (char *)fudi.fd_newkey; + arg = fudi.fd_newkey; } if (arg != NULL && (fudi.fd_di == NULL || !tv_is_func(fudi.fd_di->di_tv))) { int j = ((uint8_t)(*arg) == K_SPECIAL) ? 3 : 0; @@ -2199,7 +2195,7 @@ void ex_function(exarg_T *eap) j++; } if (arg[j] != NUL) { - emsg_funcname((char *)e_invarg2, (char_u *)arg); + emsg_funcname((char *)e_invarg2, arg); } } // Disallow using the g: dict. @@ -2235,7 +2231,7 @@ void ex_function(exarg_T *eap) p += 7; if (current_funccal == NULL) { emsg_funcname(N_("E932: Closure function should not be at top level: %s"), - name == NULL ? (char_u *)"" : (char_u *)name); + name == NULL ? "" : name); goto erret; } } else { @@ -2260,7 +2256,7 @@ void ex_function(exarg_T *eap) if (fudi.fd_dict != NULL && fudi.fd_newkey == NULL) { emsg(_(e_funcdict)); } else if (name != NULL && find_func((char_u *)name) != NULL) { - emsg_funcname(e_funcexts, (char_u *)name); + emsg_funcname(e_funcexts, name); } } @@ -2509,8 +2505,7 @@ void ex_function(exarg_T *eap) if (fudi.fd_dict == NULL) { v = find_var((const char *)name, strlen(name), &ht, false); if (v != NULL && v->di_tv.v_type == VAR_FUNC) { - emsg_funcname(N_("E707: Function name conflicts with variable: %s"), - (char_u *)name); + emsg_funcname(N_("E707: Function name conflicts with variable: %s"), name); goto erret; } @@ -2521,12 +2516,11 @@ void ex_function(exarg_T *eap) if (!eap->forceit && (fp->uf_script_ctx.sc_sid != current_sctx.sc_sid || fp->uf_script_ctx.sc_seq == current_sctx.sc_seq)) { - emsg_funcname(e_funcexts, (char_u *)name); + emsg_funcname(e_funcexts, name); goto erret; } if (fp->uf_calls > 0) { - emsg_funcname(N_("E127: Cannot redefine function %s: It is in use"), - (char_u *)name); + emsg_funcname(N_("E127: Cannot redefine function %s: It is in use"), name); goto erret; } if (fp->uf_refcount > 1) { @@ -2577,13 +2571,13 @@ void ex_function(exarg_T *eap) if (fp == NULL) { if (fudi.fd_dict == NULL && vim_strchr(name, AUTOLOAD_CHAR) != NULL) { int slen, plen; - char_u *scriptname; + char *scriptname; // Check that the autoload name matches the script name. int j = FAIL; if (SOURCING_NAME != NULL) { - scriptname = (char_u *)autoload_name((const char *)name, strlen(name)); - p = vim_strchr((char *)scriptname, '/'); + scriptname = autoload_name(name, strlen(name)); + p = vim_strchr(scriptname, '/'); plen = (int)strlen(p); slen = (int)strlen(SOURCING_NAME); if (slen > plen && path_fnamecmp(p, SOURCING_NAME + slen - plen) == 0) { @@ -2706,7 +2700,7 @@ bool translated_function_exists(const char *name) /// @return true if it exists, false otherwise. bool function_exists(const char *const name, bool no_deref) { - const char_u *nm = (const char_u *)name; + const char *nm = name; bool n = false; int flag = TFN_INT | TFN_QUIET | TFN_NO_AUTOLOAD; @@ -2714,7 +2708,7 @@ bool function_exists(const char *const name, bool no_deref) flag |= TFN_NO_DEREF; } char *const p = (char *)trans_function_name((char **)&nm, false, flag, NULL, NULL); - nm = (char_u *)skipwhite((char *)nm); + nm = skipwhite(nm); // Only accept "funcname", "funcname ", "funcname (..." and // "funcname(...", not "funcname!...". @@ -2758,7 +2752,7 @@ char *get_user_func_name(expand_T *xp, int idx) return (char *)fp->uf_name; // Prevent overflow. } - cat_func_name((char_u *)IObuff, fp); + cat_func_name(IObuff, fp); if (xp->xp_context != EXPAND_USER_FUNC) { STRCAT(IObuff, "("); if (!fp->uf_varargs && GA_EMPTY(&fp->uf_args)) { @@ -2774,12 +2768,12 @@ char *get_user_func_name(expand_T *xp, int idx) void ex_delfunction(exarg_T *eap) { ufunc_T *fp = NULL; - char_u *p; + char *p; char_u *name; funcdict_T fudi; - p = (char_u *)eap->arg; - name = trans_function_name((char **)&p, eap->skip, 0, &fudi, NULL); + p = eap->arg; + name = trans_function_name(&p, eap->skip, 0, &fudi, NULL); xfree(fudi.fd_newkey); if (name == NULL) { if (fudi.fd_dict != NULL && !eap->skip) { @@ -2787,12 +2781,12 @@ void ex_delfunction(exarg_T *eap) } return; } - if (!ends_excmd(*skipwhite((char *)p))) { + if (!ends_excmd(*skipwhite(p))) { xfree(name); semsg(_(e_trailing_arg), p); return; } - eap->nextcmd = check_nextcmd((char *)p); + eap->nextcmd = check_nextcmd(p); if (eap->nextcmd != NULL) { *p = NUL; } @@ -3043,7 +3037,7 @@ void ex_call(exarg_T *eap) // contents. For VAR_PARTIAL get its partial, unless we already have one // from trans_function_name(). len = (int)strlen(tofree); - name = (char *)deref_func_name(tofree, &len, partial != NULL ? NULL : &partial, false); + name = deref_func_name(tofree, &len, partial != NULL ? NULL : &partial, false); // Skip white space to allow ":call func ()". Not good, but required for // backward compatibility. @@ -3077,7 +3071,7 @@ void ex_call(exarg_T *eap) funcexe.fe_evaluate = true; funcexe.fe_partial = partial; funcexe.fe_selfdict = fudi.fd_dict; - if (get_func_tv((char_u *)name, -1, &rettv, &arg, &funcexe) == FAIL) { + if (get_func_tv(name, -1, &rettv, &arg, &funcexe) == FAIL) { failed = true; break; } diff --git a/src/nvim/eval/userfunc.h b/src/nvim/eval/userfunc.h index 1255f86103..c8583f232c 100644 --- a/src/nvim/eval/userfunc.h +++ b/src/nvim/eval/userfunc.h @@ -36,7 +36,7 @@ struct funccal_entry; /// Structure used by trans_function_name() typedef struct { dict_T *fd_dict; ///< Dictionary used. - char_u *fd_newkey; ///< New key in "dict" in allocated memory. + char *fd_newkey; ///< New key in "dict" in allocated memory. dictitem_T *fd_di; ///< Dictionary item used. } funcdict_T; diff --git a/src/nvim/eval/vars.c b/src/nvim/eval/vars.c index 62138221e6..463313efd8 100644 --- a/src/nvim/eval/vars.c +++ b/src/nvim/eval/vars.c @@ -1112,7 +1112,7 @@ int get_var_tv(const char *name, int len, typval_T *rettv, dictitem_T **dip, boo /// NULL when it doesn't exist. /// /// @see tv_get_string() for how long the pointer remains valid. -char_u *get_var_value(const char *const name) +char *get_var_value(const char *const name) { dictitem_T *v; @@ -1120,7 +1120,7 @@ char_u *get_var_value(const char *const name) if (v == NULL) { return NULL; } - return (char_u *)tv_get_string(&v->di_tv); + return (char *)tv_get_string(&v->di_tv); } /// Clean up a list of internal variables. diff --git a/src/nvim/eval/window.c b/src/nvim/eval/window.c index 50b25378e4..4bcbc13534 100644 --- a/src/nvim/eval/window.c +++ b/src/nvim/eval/window.c @@ -766,7 +766,7 @@ void f_winnr(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) /// "winrestcmd()" function void f_winrestcmd(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) { - char_u buf[50]; + char buf[50]; garray_T ga; ga_init(&ga, (int)sizeof(char), 70); @@ -775,12 +775,12 @@ void f_winrestcmd(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) for (int i = 0; i < 2; i++) { int winnr = 1; FOR_ALL_WINDOWS_IN_TAB(wp, curtab) { - snprintf((char *)buf, sizeof(buf), "%dresize %d|", winnr, + snprintf(buf, sizeof(buf), "%dresize %d|", winnr, wp->w_height); - ga_concat(&ga, (char *)buf); - snprintf((char *)buf, sizeof(buf), "vert %dresize %d|", winnr, + ga_concat(&ga, buf); + snprintf(buf, sizeof(buf), "vert %dresize %d|", winnr, wp->w_width); - ga_concat(&ga, (char *)buf); + ga_concat(&ga, buf); winnr++; } } diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c index 55d0651930..413a488283 100644 --- a/src/nvim/ex_cmds.c +++ b/src/nvim/ex_cmds.c @@ -1025,7 +1025,7 @@ void do_bang(int addr_count, exarg_T *eap, bool forceit, bool do_in, bool do_out // If % or # appears in the command, it must have been escaped. // Reescape them, so that redoing them does not substitute them by the // buffername. - char *cmd = (char *)vim_strsave_escaped((char_u *)prevcmd, (char_u *)"%#"); + char *cmd = vim_strsave_escaped(prevcmd, "%#"); AppendToRedobuffLit(cmd, -1); xfree(cmd); diff --git a/src/nvim/ex_cmds2.c b/src/nvim/ex_cmds2.c index 7020747cf6..d08823bc30 100644 --- a/src/nvim/ex_cmds2.c +++ b/src/nvim/ex_cmds2.c @@ -721,7 +721,7 @@ void ex_compiler(exarg_T *eap) // plugin will then skip the settings. Afterwards set // "b:current_compiler" and restore "current_compiler". // Explicitly prepend "g:" to make it work in a function. - old_cur_comp = (char *)get_var_value("g:current_compiler"); + old_cur_comp = get_var_value("g:current_compiler"); if (old_cur_comp != NULL) { old_cur_comp = xstrdup(old_cur_comp); } @@ -743,7 +743,7 @@ void ex_compiler(exarg_T *eap) do_cmdline_cmd(":delcommand CompilerSet"); // Set "b:current_compiler" from "current_compiler". - p = (char *)get_var_value("g:current_compiler"); + p = get_var_value("g:current_compiler"); if (p != NULL) { set_internal_string_var("b:current_compiler", p); } diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index e847f74289..8d70dcce9a 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -3802,7 +3802,7 @@ int expand_filename(exarg_T *eap, char **cmdlinep, char **errormsgp) for (l = repl; *l; l++) { if (vim_strchr((char *)ESCAPE_CHARS, *l) != NULL) { - l = (char *)vim_strsave_escaped((char_u *)repl, ESCAPE_CHARS); + l = vim_strsave_escaped(repl, (char *)ESCAPE_CHARS); xfree(repl); repl = l; break; @@ -3817,7 +3817,7 @@ int expand_filename(exarg_T *eap, char **cmdlinep, char **errormsgp) && strpbrk(repl, "!") != NULL) { char *l; - l = (char *)vim_strsave_escaped((char_u *)repl, (char_u *)"!"); + l = vim_strsave_escaped(repl, "!"); xfree(repl); repl = l; } @@ -7263,7 +7263,7 @@ static void ex_terminal(exarg_T *eap) char ex_cmd[1024]; if (*eap->arg != NUL) { // Run {cmd} in 'shell'. - char *name = (char *)vim_strsave_escaped((char_u *)eap->arg, (char_u *)"\"\\"); + char *name = vim_strsave_escaped(eap->arg, "\"\\"); snprintf(ex_cmd, sizeof(ex_cmd), ":enew%s | call termopen(\"%s\")", eap->forceit ? "!" : "", name); diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 93c5d24c0d..eeb983fc21 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -3964,18 +3964,16 @@ char *vim_strsave_fnameescape(const char *const fname, const int what) char *p = (char *)vim_strsave_escaped((const char_u *)fname, (const char_u *)buf); #else -# define PATH_ESC_CHARS ((char_u *)" \t\n*?[{`$\\%#'\"|!<") -# define SHELL_ESC_CHARS ((char_u *)" \t\n*?[{`$\\%#'\"|!<>();&") -# define BUFFER_ESC_CHARS ((char_u *)" \t\n*?[`$\\%#'\"|!<") - char *p = - (char *)vim_strsave_escaped((const char_u *)fname, - what == VSE_SHELL ? SHELL_ESC_CHARS - : what == VSE_BUFFER ? BUFFER_ESC_CHARS : PATH_ESC_CHARS); +# define PATH_ESC_CHARS " \t\n*?[{`$\\%#'\"|!<" +# define SHELL_ESC_CHARS " \t\n*?[{`$\\%#'\"|!<>();&" +# define BUFFER_ESC_CHARS " \t\n*?[`$\\%#'\"|!<" + char *p = vim_strsave_escaped(fname, + what == VSE_SHELL ? SHELL_ESC_CHARS : what == + VSE_BUFFER ? BUFFER_ESC_CHARS : PATH_ESC_CHARS); if (what == VSE_SHELL && csh_like_shell()) { // For csh and similar shells need to put two backslashes before '!'. // One is taken by Vim, one by the shell. - char *s = (char *)vim_strsave_escaped((const char_u *)p, - (const char_u *)"!"); + char *s = vim_strsave_escaped(p, "!"); xfree(p); p = s; } diff --git a/src/nvim/file_search.c b/src/nvim/file_search.c index 5c5839cb08..fe46e457d5 100644 --- a/src/nvim/file_search.c +++ b/src/nvim/file_search.c @@ -347,7 +347,7 @@ void *vim_findfile_init(char *path, char *filename, char *stopdirs, int level, i } size_t dircount = 1; - search_ctx->ffsc_stopdirs_v = xmalloc(sizeof(char_u *)); + search_ctx->ffsc_stopdirs_v = xmalloc(sizeof(char *)); do { char *helper; @@ -355,7 +355,7 @@ void *vim_findfile_init(char *path, char *filename, char *stopdirs, int level, i helper = walker; ptr = xrealloc(search_ctx->ffsc_stopdirs_v, - (dircount + 1) * sizeof(char_u *)); + (dircount + 1) * sizeof(char *)); search_ctx->ffsc_stopdirs_v = ptr; walker = vim_strchr(walker, ';'); if (walker) { @@ -447,11 +447,11 @@ void *vim_findfile_init(char *path, char *filename, char *stopdirs, int level, i add_pathsep(ff_expand_buffer); { size_t eb_len = strlen(ff_expand_buffer); - char_u *buf = xmalloc(eb_len + strlen(search_ctx->ffsc_fix_path) + 1); + char *buf = xmalloc(eb_len + strlen(search_ctx->ffsc_fix_path) + 1); STRCPY(buf, ff_expand_buffer); STRCPY(buf + eb_len, search_ctx->ffsc_fix_path); - if (os_isdir((char *)buf)) { + if (os_isdir(buf)) { STRCAT(ff_expand_buffer, search_ctx->ffsc_fix_path); add_pathsep(ff_expand_buffer); } else { @@ -555,7 +555,7 @@ char_u *vim_findfile(void *search_ctx_arg) { char *file_path; char *rest_of_wildcards; - char_u *path_end = NULL; + char *path_end = NULL; ff_stack_T *stackp = NULL; size_t len; char *p; @@ -574,7 +574,7 @@ char_u *vim_findfile(void *search_ctx_arg) // store the end of the start dir -- needed for upward search if (search_ctx->ffsc_start_dir != NULL) { - path_end = (char_u *)&search_ctx->ffsc_start_dir[strlen(search_ctx->ffsc_start_dir)]; + path_end = &search_ctx->ffsc_start_dir[strlen(search_ctx->ffsc_start_dir)]; } // upward search loop @@ -886,16 +886,16 @@ char_u *vim_findfile(void *search_ctx_arg) // is the last starting directory in the stop list? if (ff_path_in_stoplist(search_ctx->ffsc_start_dir, - (int)(path_end - (char_u *)search_ctx->ffsc_start_dir), + (int)(path_end - search_ctx->ffsc_start_dir), search_ctx->ffsc_stopdirs_v) == true) { break; } // cut of last dir - while (path_end > (char_u *)search_ctx->ffsc_start_dir && vim_ispathsep(*path_end)) { + while (path_end > search_ctx->ffsc_start_dir && vim_ispathsep(*path_end)) { path_end--; } - while (path_end > (char_u *)search_ctx->ffsc_start_dir && !vim_ispathsep(path_end[-1])) { + while (path_end > search_ctx->ffsc_start_dir && !vim_ispathsep(path_end[-1])) { path_end--; } *path_end = 0; @@ -1025,7 +1025,7 @@ static ff_visited_list_hdr_T *ff_get_visited_list(char *filename, /// - char by char comparison is OK /// - the only differences are in the counters behind a '**', so /// '**\20' is equal to '**\24' -static bool ff_wc_equal(char_u *s1, char_u *s2) +static bool ff_wc_equal(char *s1, char *s2) { int i, j; int c1 = NUL; @@ -1042,8 +1042,8 @@ static bool ff_wc_equal(char_u *s1, char_u *s2) } for (i = 0, j = 0; s1[i] != NUL && s2[j] != NUL;) { - c1 = utf_ptr2char((char *)s1 + i); - c2 = utf_ptr2char((char *)s2 + j); + c1 = utf_ptr2char(s1 + i); + c2 = utf_ptr2char(s2 + j); if ((p_fic ? mb_tolower(c1) != mb_tolower(c2) : c1 != c2) && (prev1 != '*' || prev2 != '*')) { @@ -1052,8 +1052,8 @@ static bool ff_wc_equal(char_u *s1, char_u *s2) prev2 = prev1; prev1 = c1; - i += utfc_ptr2len((char *)s1 + i); - j += utfc_ptr2len((char *)s2 + j); + i += utfc_ptr2len(s1 + i); + j += utfc_ptr2len(s2 + j); } return s1[i] == s2[j]; } @@ -1086,7 +1086,7 @@ static int ff_check_visited(ff_visited_T **visited_list, char *fname, char *wc_p || (!url && vp->file_id_valid && os_fileid_equal(&(vp->file_id), &file_id))) { // are the wildcard parts equal - if (ff_wc_equal((char_u *)vp->ffv_wc_path, (char_u *)wc_path)) { + if (ff_wc_equal(vp->ffv_wc_path, wc_path)) { // already visited return FAIL; } @@ -1453,7 +1453,7 @@ char *find_file_in_path_option(char *ptr, size_t len, int options, int first, ch did_findfile_init = false; } else { - char_u *r_ptr; + char *r_ptr; if (dir == NULL || *dir == NUL) { // We searched all paths of the option, now we can free the search context. @@ -1469,9 +1469,9 @@ char *find_file_in_path_option(char *ptr, size_t len, int options, int first, ch copy_option_part(&dir, buf, MAXPATHL, " ,"); // get the stopdir string - r_ptr = vim_findfile_stopdir((char_u *)buf); + r_ptr = (char *)vim_findfile_stopdir((char_u *)buf); fdip_search_ctx = vim_findfile_init(buf, ff_file_to_find, - (char *)r_ptr, 100, false, find_what, + r_ptr, 100, false, find_what, fdip_search_ctx, false, rel_fname); if (fdip_search_ctx != NULL) { did_findfile_init = true; diff --git a/src/nvim/highlight_group.c b/src/nvim/highlight_group.c index 59ffff40a6..404835c4a9 100644 --- a/src/nvim/highlight_group.c +++ b/src/nvim/highlight_group.c @@ -601,7 +601,7 @@ void init_highlight(bool both, bool reset) // Try finding the color scheme file. Used when a color file was loaded // and 'background' or 't_Co' is changed. - char *p = (char *)get_var_value("g:colors_name"); + char *p = get_var_value("g:colors_name"); if (p != NULL) { // Value of g:colors_name could be freed in load_colors() and make // p invalid, so copy it. diff --git a/src/nvim/insexpand.c b/src/nvim/insexpand.c index f2ee299211..fcf64d6ae7 100644 --- a/src/nvim/insexpand.c +++ b/src/nvim/insexpand.c @@ -1327,7 +1327,7 @@ static void ins_compl_dictionaries(char_u *dict_start, char_u *pat, int flags, i // to only match at the start of a line. Otherwise just match the // pattern. Also need to double backslashes. if (ctrl_x_mode_line_or_eval()) { - char *pat_esc = (char *)vim_strsave_escaped(pat, (char_u *)"\\"); + char *pat_esc = vim_strsave_escaped((char *)pat, "\\"); size_t len = strlen(pat_esc) + 10; ptr = xmalloc(len); diff --git a/src/nvim/keycodes.c b/src/nvim/keycodes.c index 71086a76e5..36b65d6213 100644 --- a/src/nvim/keycodes.c +++ b/src/nvim/keycodes.c @@ -960,10 +960,10 @@ char *replace_termcodes(const char *const from, const size_t from_len, char **co // If "mapleader" or "maplocalleader" isn't set use a backslash. if (end - src >= 7 && STRNICMP(src, "", 8) == 0) { len = 8; - p = (char *)get_var_value("g:mapleader"); + p = get_var_value("g:mapleader"); } else if (end - src >= 12 && STRNICMP(src, "", 13) == 0) { len = 13; - p = (char *)get_var_value("g:maplocalleader"); + p = get_var_value("g:maplocalleader"); } else { len = 0; p = NULL; diff --git a/src/nvim/main.c b/src/nvim/main.c index d27d8c75d2..237ffef9ea 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -242,10 +242,10 @@ int main(int argc, char **argv) argv0 = argv[0]; - char_u *fname = NULL; // file name from command line + char *fname = NULL; // file name from command line mparm_T params; // various parameters passed between // main() and other functions. - char_u *cwd = NULL; // current working dir on startup + char *cwd = NULL; // current working dir on startup time_init(); // Many variables are in `params` so that we can pass them around easily. @@ -551,7 +551,7 @@ int main(int argc, char **argv) // Need to jump to the tag before executing the '-c command'. // Makes "vim -c '/return' -t main" work. - handle_tag((char_u *)params.tagname); + handle_tag(params.tagname); // Execute any "+", "-c" and "-S" arguments. if (params.n_commands > 0) { @@ -1206,7 +1206,7 @@ static void command_line_scan(mparm_T *parmp) break; case 'w': // "-w{number}" set window height // "-w {scriptout}" write to script - if (ascii_isdigit(((char_u *)argv[0])[argv_idx])) { + if (ascii_isdigit((argv[0])[argv_idx])) { n = get_number_arg(argv[0], &argv_idx, 10); set_option_value_give_err("window", n, NULL, 0); break; @@ -1347,7 +1347,7 @@ scripterror: case 'w': // "-w {nr}" 'window' value // "-w {scriptout}" append to script file - if (ascii_isdigit(*((char_u *)argv[0]))) { + if (ascii_isdigit(*(argv[0]))) { argv_idx = 0; n = get_number_arg(argv[0], &argv_idx, 10); set_option_value_give_err("window", n, NULL, 0); @@ -1480,9 +1480,9 @@ static void init_path(const char *exename) } /// Get filename from command line, if any. -static char_u *get_fname(mparm_T *parmp, char_u *cwd) +static char *get_fname(mparm_T *parmp, char *cwd) { - return (char_u *)alist_name(&GARGLIST[0]); + return alist_name(&GARGLIST[0]); } // Decide about window layout for diff mode after reading vimrc. @@ -1516,7 +1516,7 @@ static void handle_quickfix(mparm_T *paramp) // Need to jump to the tag before executing the '-c command'. // Makes "vim -c '/return' -t main" work. -static void handle_tag(char_u *tagname) +static void handle_tag(char *tagname) { if (tagname != NULL) { swap_exists_did_quit = false; @@ -1704,7 +1704,7 @@ static void create_windows(mparm_T *parmp) /// If opened more than one window, start editing files in the other /// windows. make_windows() has already opened the windows. -static void edit_buffers(mparm_T *parmp, char_u *cwd) +static void edit_buffers(mparm_T *parmp, char *cwd) { int arg_idx; // index in argument list int i; @@ -1725,7 +1725,7 @@ static void edit_buffers(mparm_T *parmp, char_u *cwd) arg_idx = 1; for (i = 1; i < parmp->window_count; i++) { if (cwd != NULL) { - os_chdir((char *)cwd); + os_chdir(cwd); } // When w_arg_idx is -1 remove the window (see create_windows()). if (curwin->w_arg_idx == -1) { @@ -1944,13 +1944,13 @@ static bool do_user_initialization(void) return do_exrc; } - char_u *init_lua_path = (char_u *)stdpaths_user_conf_subpath("init.lua"); - char_u *user_vimrc = (char_u *)stdpaths_user_conf_subpath("init.vim"); + char *init_lua_path = stdpaths_user_conf_subpath("init.lua"); + char *user_vimrc = stdpaths_user_conf_subpath("init.vim"); // init.lua - if (os_path_exists((char *)init_lua_path) - && do_source((char *)init_lua_path, true, DOSO_VIMRC)) { - if (os_path_exists((char *)user_vimrc)) { + if (os_path_exists(init_lua_path) + && do_source(init_lua_path, true, DOSO_VIMRC)) { + if (os_path_exists(user_vimrc)) { semsg(_("E5422: Conflicting configs: \"%s\" \"%s\""), init_lua_path, user_vimrc); } @@ -1963,10 +1963,10 @@ static bool do_user_initialization(void) xfree(init_lua_path); // init.vim - if (do_source((char *)user_vimrc, true, DOSO_VIMRC) != FAIL) { + if (do_source(user_vimrc, true, DOSO_VIMRC) != FAIL) { do_exrc = p_exrc; if (do_exrc) { - do_exrc = (path_full_compare(VIMRC_FILE, (char *)user_vimrc, false, true) != kEqualFiles); + do_exrc = (path_full_compare(VIMRC_FILE, user_vimrc, false, true) != kEqualFiles); } xfree(user_vimrc); return do_exrc; diff --git a/src/nvim/mapping.c b/src/nvim/mapping.c index 757855c350..fa8521306f 100644 --- a/src/nvim/mapping.c +++ b/src/nvim/mapping.c @@ -297,10 +297,10 @@ static void set_maparg_rhs(const char *const orig_rhs, const size_t orig_rhs_len if (rhs_lua == LUA_NOREF) { mapargs->orig_rhs_len = orig_rhs_len; - mapargs->orig_rhs = xcalloc(mapargs->orig_rhs_len + 1, sizeof(char_u)); + mapargs->orig_rhs = xcalloc(mapargs->orig_rhs_len + 1, sizeof(char)); xstrlcpy(mapargs->orig_rhs, orig_rhs, mapargs->orig_rhs_len + 1); if (STRICMP(orig_rhs, "") == 0) { // "" means nothing - mapargs->rhs = xcalloc(1, sizeof(char_u)); // single NUL-char + mapargs->rhs = xcalloc(1, sizeof(char)); // single NUL-char mapargs->rhs_len = 0; mapargs->rhs_is_noop = true; } else { @@ -316,7 +316,7 @@ static void set_maparg_rhs(const char *const orig_rhs, const size_t orig_rhs_len } else { char tmp_buf[64]; // orig_rhs is not used for Lua mappings, but still needs to be a string. - mapargs->orig_rhs = xcalloc(1, sizeof(char_u)); + mapargs->orig_rhs = xcalloc(1, sizeof(char)); mapargs->orig_rhs_len = 0; // stores ref_no in map_str mapargs->rhs_len = (size_t)vim_snprintf(S_LEN(tmp_buf), "%c%c%c%d\r", K_SPECIAL, @@ -344,53 +344,53 @@ static void set_maparg_rhs(const char *const orig_rhs, const size_t orig_rhs_len /// @param[out] mapargs MapArguments struct holding all extracted argument /// values. /// @return 0 on success, 1 if invalid arguments are detected. -static int str_to_mapargs(const char_u *strargs, bool is_unmap, MapArguments *mapargs) +static int str_to_mapargs(const char *strargs, bool is_unmap, MapArguments *mapargs) { - const char *to_parse = (char *)strargs; - to_parse = skipwhite((char *)to_parse); + const char *to_parse = strargs; + to_parse = skipwhite(to_parse); CLEAR_POINTER(mapargs); // Accept , , , ,