diff options
author | Dundar Goc <gocdundar@gmail.com> | 2022-05-01 11:18:17 +0200 |
---|---|---|
committer | Dundar Goc <gocdundar@gmail.com> | 2022-05-03 10:33:40 +0200 |
commit | b9bdd0f61e5e7365c07aadbc3f796556b6d85fdf (patch) | |
tree | 807bb0bcb4a551285e7c1f739b1b201d49d58261 | |
parent | 46734cf7c1e5abe8e452354db6914364bfe89f0d (diff) | |
download | rneovim-b9bdd0f61e5e7365c07aadbc3f796556b6d85fdf.tar.gz rneovim-b9bdd0f61e5e7365c07aadbc3f796556b6d85fdf.tar.bz2 rneovim-b9bdd0f61e5e7365c07aadbc3f796556b6d85fdf.zip |
refactor: replace char_u variables and functions with char
Work on https://github.com/neovim/neovim/issues/459
-rw-r--r-- | src/nvim/api/vimscript.c | 4 | ||||
-rw-r--r-- | src/nvim/autocmd.c | 4 | ||||
-rw-r--r-- | src/nvim/buffer.c | 8 | ||||
-rw-r--r-- | src/nvim/debugger.c | 2 | ||||
-rw-r--r-- | src/nvim/edit.c | 4 | ||||
-rw-r--r-- | src/nvim/eval.c | 964 | ||||
-rw-r--r-- | src/nvim/eval.h | 4 | ||||
-rw-r--r-- | src/nvim/eval/funcs.c | 26 | ||||
-rw-r--r-- | src/nvim/eval/typval_encode.c.h | 3 | ||||
-rw-r--r-- | src/nvim/eval/userfunc.c | 38 | ||||
-rw-r--r-- | src/nvim/ex_cmds2.c | 4 | ||||
-rw-r--r-- | src/nvim/ex_docmd.c | 22 | ||||
-rw-r--r-- | src/nvim/ex_eval.c | 12 | ||||
-rw-r--r-- | src/nvim/ex_getln.c | 6 | ||||
-rw-r--r-- | src/nvim/fold.c | 6 | ||||
-rw-r--r-- | src/nvim/getchar.c | 2 | ||||
-rw-r--r-- | src/nvim/if_cscope.c | 4 | ||||
-rw-r--r-- | src/nvim/indent.c | 2 | ||||
-rw-r--r-- | src/nvim/message.c | 4 | ||||
-rw-r--r-- | src/nvim/ops.c | 6 | ||||
-rw-r--r-- | src/nvim/os/env.c | 6 | ||||
-rw-r--r-- | src/nvim/path.c | 6 | ||||
-rw-r--r-- | src/nvim/quickfix.c | 6 | ||||
-rw-r--r-- | src/nvim/regexp.c | 4 | ||||
-rw-r--r-- | src/nvim/runtime.c | 2 | ||||
-rw-r--r-- | src/nvim/screen.c | 2 | ||||
-rw-r--r-- | src/nvim/spell.c | 2 | ||||
-rw-r--r-- | src/nvim/syntax.c | 4 | ||||
-rw-r--r-- | src/nvim/tag.c | 2 | ||||
-rw-r--r-- | src/nvim/testing.c | 2 |
30 files changed, 574 insertions, 587 deletions
diff --git a/src/nvim/api/vimscript.c b/src/nvim/api/vimscript.c index 4123674fe7..40ac0b8b64 100644 --- a/src/nvim/api/vimscript.c +++ b/src/nvim/api/vimscript.c @@ -131,7 +131,7 @@ Object nvim_eval(String expr, Error *err) try_start(); typval_T rettv; - int ok = eval0((char_u *)expr.data, &rettv, NULL, true); + int ok = eval0(expr.data, &rettv, NULL, true); if (!try_end(err)) { if (ok == FAIL) { @@ -246,7 +246,7 @@ Object nvim_call_dict_function(Object dict, String fn, Array args, Error *err) switch (dict.type) { case kObjectTypeString: try_start(); - if (eval0((char_u *)dict.data.string.data, &rettv, NULL, true) == FAIL) { + if (eval0(dict.data.string.data, &rettv, NULL, true) == FAIL) { api_set_error(err, kErrorTypeException, "Failed to evaluate dict expression"); } diff --git a/src/nvim/autocmd.c b/src/nvim/autocmd.c index 9bc0a4fabf..cd726b70b6 100644 --- a/src/nvim/autocmd.c +++ b/src/nvim/autocmd.c @@ -1816,7 +1816,7 @@ bool apply_autocmds_group(event_T event, char_u *fname, char_u *fname_io, bool f // set v:cmdarg (only when there is a matching pattern) save_cmdbang = (long)get_vim_var_nr(VV_CMDBANG); if (eap != NULL) { - save_cmdarg = set_cmdarg(eap, NULL); + save_cmdarg = (char_u *)set_cmdarg(eap, NULL); set_vim_var_nr(VV_CMDBANG, (long)eap->forceit); } else { save_cmdarg = NULL; // avoid gcc warning @@ -1845,7 +1845,7 @@ bool apply_autocmds_group(event_T event, char_u *fname, char_u *fname_io, bool f if (eap != NULL) { - (void)set_cmdarg(NULL, save_cmdarg); + (void)set_cmdarg(NULL, (char *)save_cmdarg); set_vim_var_nr(VV_CMDBANG, save_cmdbang); } // delete from active_apc_list diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c index c70d845c42..14ed9921a0 100644 --- a/src/nvim/buffer.c +++ b/src/nvim/buffer.c @@ -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 = eval_to_string_safe(fmt + 2, NULL, use_sandbox); + usefmt = (char_u *)eval_to_string_safe((char *)fmt + 2, NULL, use_sandbox); if (usefmt == NULL) { usefmt = fmt; } @@ -3878,9 +3878,9 @@ int build_stl_str_hl(win_T *wp, char_u *out, size_t outlen, char_u *fmt, int use // Store the current buffer number as a string variable vim_snprintf(buf_tmp, sizeof(buf_tmp), "%d", curbuf->b_fnum); - set_internal_string_var("g:actual_curbuf", (char_u *)buf_tmp); + set_internal_string_var("g:actual_curbuf", buf_tmp); vim_snprintf((char *)win_tmp, sizeof(win_tmp), "%d", curwin->handle); - set_internal_string_var("g:actual_curwin", win_tmp); + set_internal_string_var("g:actual_curwin", (char *)win_tmp); buf_T *const save_curbuf = curbuf; win_T *const save_curwin = curwin; @@ -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 = (char *)eval_to_string_safe(out_p, &t, use_sandbox); + str = eval_to_string_safe((char *)out_p, (char **)&t, use_sandbox); curwin = save_curwin; curbuf = save_curbuf; diff --git a/src/nvim/debugger.c b/src/nvim/debugger.c index c6fd8aade3..cf062cfbe8 100644 --- a/src/nvim/debugger.c +++ b/src/nvim/debugger.c @@ -461,7 +461,7 @@ static typval_T *eval_expr_no_emsg(struct debuggy *const bp) { // Disable error messages, a bad expression would make Vim unusable. emsg_off++; - typval_T *const tv = eval_expr(bp->dbg_name); + typval_T *const tv = eval_expr((char *)bp->dbg_name); emsg_off--; return tv; } diff --git a/src/nvim/edit.c b/src/nvim/edit.c index a94f7a803a..6a6d433228 100644 --- a/src/nvim/edit.c +++ b/src/nvim/edit.c @@ -4028,7 +4028,7 @@ static void expand_by_function(int type, char_u *base) curbuf_save = curbuf; // Call a function, which returns a list or dict. - if (call_vim_function(funcname, 2, args, &rettv) == OK) { + if (call_vim_function((char *)funcname, 2, args, &rettv) == OK) { switch (rettv.v_type) { case VAR_LIST: matchlist = rettv.vval.v_list; @@ -5311,7 +5311,7 @@ static int ins_complete(int c, bool enable_pum) pos = curwin->w_cursor; curwin_save = curwin; curbuf_save = curbuf; - int col = call_func_retnr(funcname, 2, args); + int col = call_func_retnr((char *)funcname, 2, args); State = save_State; if (curwin_save != curwin || curbuf_save != curbuf) { diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 3023b1e774..b4c3e62ddf 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -73,7 +73,7 @@ static char *e_string_list_or_blob_required = N_("E1098: String, List or Blob re // TODO(ZyX-I): move to eval/executor static char *e_letwrong = N_("E734: Wrong variable type for %s="); -static char_u * const namespace_char = (char_u *)"abglstvw"; +static char * const namespace_char = "abglstvw"; /// Variable used for g: static ScopeDictDictItem globvars_var; @@ -103,7 +103,7 @@ static garray_T ga_scripts = { 0, 0, sizeof(scriptvar_T *), 4, NULL }; static int echo_attr = 0; // attributes used for ":echo" // The names of packages that once were loaded are remembered. -static garray_T ga_loaded = { 0, 0, sizeof(char_u *), 4, NULL }; +static garray_T ga_loaded = { 0, 0, sizeof(char *), 4, NULL }; /* * Info used by a ":for" loop. @@ -115,7 +115,7 @@ typedef struct { list_T *fi_list; // list being used int fi_bi; // index of blob blob_T *fi_blob; // blob being used - char_u *fi_string; // copy of string being used + char *fi_string; // copy of string being used int fi_byte_idx; // byte index in fi_string } forinfo_T; @@ -500,12 +500,12 @@ void eval_clear(void) /// Set an internal variable to a string value. Creates the variable if it does /// not already exist. -void set_internal_string_var(const char *name, char_u *value) +void set_internal_string_var(const char *name, char *value) FUNC_ATTR_NONNULL_ARG(1) { typval_T tv = { .v_type = VAR_STRING, - .vval.v_string = value, + .vval.v_string = (char_u *)value, }; set_var(name, strlen(name), &tv, true); @@ -513,15 +513,15 @@ void set_internal_string_var(const char *name, char_u *value) static lval_T *redir_lval = NULL; static garray_T redir_ga; // Only valid when redir_lval is not NULL. -static char_u *redir_endp = NULL; -static char_u *redir_varname = NULL; +static char *redir_endp = NULL; +static char *redir_varname = NULL; /// Start recording command output to a variable /// /// @param append append to an existing variable /// /// @return OK if successfully completed the setup. FAIL otherwise. -int var_redir_start(char_u *name, int append) +int var_redir_start(char *name, int append) { int save_emsg; int err; @@ -534,7 +534,7 @@ int var_redir_start(char_u *name, int append) } // Make a copy of the name, it is used in redir_lval until redir ends. - redir_varname = vim_strsave(name); + redir_varname = xstrdup(name); redir_lval = xcalloc(1, sizeof(lval_T)); @@ -588,7 +588,7 @@ int var_redir_start(char_u *name, int append) /// :redir => foo /// :let foo /// :redir END -void var_redir_str(char_u *value, int value_len) +void var_redir_str(char *value, int value_len) { int len; @@ -646,7 +646,7 @@ int eval_charconvert(const char *const enc_from, const char *const enc_to, set_vim_var_string(VV_CC_TO, enc_to, -1); set_vim_var_string(VV_FNAME_IN, fname_from, -1); set_vim_var_string(VV_FNAME_OUT, fname_to, -1); - if (eval_to_bool(p_ccv, &err, NULL, false)) { + if (eval_to_bool((char *)p_ccv, &err, NULL, false)) { err = true; } set_vim_var_string(VV_CC_FROM, NULL, -1); @@ -666,7 +666,7 @@ int eval_printexpr(const char *const fname, const char *const args) set_vim_var_string(VV_FNAME_IN, fname, -1); set_vim_var_string(VV_CMDARG, args, -1); - if (eval_to_bool(p_pexpr, &err, NULL, false)) { + if (eval_to_bool((char *)p_pexpr, &err, NULL, false)) { err = true; } set_vim_var_string(VV_FNAME_IN, NULL, -1); @@ -686,7 +686,7 @@ void eval_diff(const char *const origfile, const char *const newfile, const char set_vim_var_string(VV_FNAME_IN, origfile, -1); set_vim_var_string(VV_FNAME_NEW, newfile, -1); set_vim_var_string(VV_FNAME_OUT, outfile, -1); - (void)eval_to_bool(p_dex, &err, NULL, FALSE); + (void)eval_to_bool((char *)p_dex, &err, NULL, false); set_vim_var_string(VV_FNAME_IN, NULL, -1); set_vim_var_string(VV_FNAME_NEW, NULL, -1); set_vim_var_string(VV_FNAME_OUT, NULL, -1); @@ -699,7 +699,7 @@ void eval_patch(const char *const origfile, const char *const difffile, const ch set_vim_var_string(VV_FNAME_IN, origfile, -1); set_vim_var_string(VV_FNAME_DIFF, difffile, -1); set_vim_var_string(VV_FNAME_OUT, outfile, -1); - (void)eval_to_bool(p_pex, &err, NULL, FALSE); + (void)eval_to_bool((char *)p_pex, &err, NULL, false); set_vim_var_string(VV_FNAME_IN, NULL, -1); set_vim_var_string(VV_FNAME_DIFF, NULL, -1); set_vim_var_string(VV_FNAME_OUT, NULL, -1); @@ -711,7 +711,7 @@ void eval_patch(const char *const origfile, const char *const difffile, const ch /// @param skip only parse, don't execute /// /// @return TRUE or FALSE. -int eval_to_bool(char_u *arg, bool *error, char_u **nextcmd, int skip) +int eval_to_bool(char *arg, bool *error, char **nextcmd, int skip) { typval_T tv; bool retval = false; @@ -736,10 +736,10 @@ int eval_to_bool(char_u *arg, bool *error, char_u **nextcmd, int skip) } /// Call eval1() and give an error message if not done at a lower level. -static int eval1_emsg(char_u **arg, typval_T *rettv, bool evaluate) +static int eval1_emsg(char **arg, typval_T *rettv, bool evaluate) FUNC_ATTR_NONNULL_ARG(1, 2) { - const char_u *const start = *arg; + const char *const start = *arg; const int did_emsg_before = did_emsg; const int called_emsg_before = called_emsg; @@ -773,36 +773,36 @@ int eval_expr_typval(const typval_T *expr, typval_T *argv, int argc, typval_T *r funcexe_T funcexe = FUNCEXE_INIT; if (expr->v_type == VAR_FUNC) { - const char_u *const s = expr->vval.v_string; + const char *const s = (char *)expr->vval.v_string; if (s == NULL || *s == NUL) { return FAIL; } funcexe.evaluate = true; - if (call_func(s, -1, rettv, argc, argv, &funcexe) == FAIL) { + if (call_func((char_u *)s, -1, rettv, argc, argv, &funcexe) == FAIL) { return FAIL; } } else if (expr->v_type == VAR_PARTIAL) { partial_T *const partial = expr->vval.v_partial; - const char_u *const s = partial_name(partial); + const char *const s = partial_name(partial); if (s == NULL || *s == NUL) { return FAIL; } funcexe.evaluate = true; funcexe.partial = partial; - if (call_func(s, -1, rettv, argc, argv, &funcexe) == FAIL) { + if (call_func((char_u *)s, -1, rettv, argc, argv, &funcexe) == FAIL) { return FAIL; } } else { char buf[NUMBUFLEN]; - char_u *s = (char_u *)tv_get_string_buf_chk(expr, buf); + char *s = (char *)tv_get_string_buf_chk(expr, buf); if (s == NULL) { return FAIL; } - s = skipwhite(s); + s = (char *)skipwhite((char_u *)s); if (eval1_emsg(&s, rettv, true) == FAIL) { return FAIL; } - if (*skipwhite(s) != NUL) { // check for trailing chars after expr + if (*skipwhite((char_u *)s) != NUL) { // check for trailing chars after expr tv_clear(rettv); semsg(_(e_invexpr2), s); return FAIL; @@ -845,7 +845,7 @@ char *eval_to_string_skip(const char *arg, const char **nextcmd, const bool skip if (skip) { emsg_skip++; } - if (eval0((char_u *)arg, &tv, (char_u **)nextcmd, !skip) == FAIL || skip) { + if (eval0((char *)arg, &tv, (char **)nextcmd, !skip) == FAIL || skip) { retval = NULL; } else { retval = xstrdup(tv_get_string(&tv)); @@ -861,12 +861,12 @@ char *eval_to_string_skip(const char *arg, const char **nextcmd, const bool skip /// Skip over an expression at "*pp". /// /// @return FAIL for an error, OK otherwise. -int skip_expr(char_u **pp) +int skip_expr(char **pp) { typval_T rettv; - *pp = skipwhite(*pp); - return eval1(pp, &rettv, FALSE); + *pp = (char *)skipwhite((char_u *)(*pp)); + return eval1(pp, &rettv, false); } /// Top level evaluation function, returning a string. @@ -875,7 +875,7 @@ int skip_expr(char_u **pp) /// a Float to a String. /// /// @return pointer to allocated memory, or NULL for failure. -char_u *eval_to_string(char_u *arg, char_u **nextcmd, bool convert) +char *eval_to_string(char *arg, char **nextcmd, bool convert) { typval_T tv; char *retval; @@ -904,16 +904,16 @@ char_u *eval_to_string(char_u *arg, char_u **nextcmd, bool convert) tv_clear(&tv); } - return (char_u *)retval; + return retval; } /// Call eval_to_string() without using current local variables and using /// textlock. /// /// @param use_sandbox when TRUE, use the sandbox. -char_u *eval_to_string_safe(char_u *arg, char_u **nextcmd, int use_sandbox) +char *eval_to_string_safe(char *arg, char **nextcmd, int use_sandbox) { - char_u *retval; + char *retval; funccal_entry_T funccal_entry; save_funccal(&funccal_entry); @@ -934,11 +934,11 @@ char_u *eval_to_string_safe(char_u *arg, char_u **nextcmd, int use_sandbox) /// Evaluates "expr" silently. /// /// @return -1 for an error. -varnumber_T eval_to_number(char_u *expr) +varnumber_T eval_to_number(char *expr) { typval_T rettv; varnumber_T retval; - char_u *p = skipwhite(expr); + char *p = (char *)skipwhite((char_u *)expr); ++emsg_off; @@ -957,7 +957,7 @@ varnumber_T eval_to_number(char_u *expr) /// /// @return an allocated typval_T with the result or /// NULL when there is an error. -typval_T *eval_expr(char_u *arg) +typval_T *eval_expr(char *arg) { typval_T *tv = xmalloc(sizeof(*tv)); if (eval0(arg, tv, NULL, true) == FAIL) { @@ -1009,17 +1009,17 @@ void find_win_for_curbuf(void) /// For the "expr:" part of 'spellsuggest'. /// /// @return NULL when there is an error. -list_T *eval_spell_expr(char_u *badword, char_u *expr) +list_T *eval_spell_expr(char *badword, char *expr) { typval_T save_val; typval_T rettv; list_T *list = NULL; - char_u *p = skipwhite(expr); + char *p = (char *)skipwhite((char_u *)expr); // Set "v:val" to the bad word. prepare_vimvar(VV_VAL, &save_val); vimvars[VV_VAL].vv_type = VAR_STRING; - vimvars[VV_VAL].vv_str = badword; + vimvars[VV_VAL].vv_str = (char_u *)badword; if (p_verbose == 0) { ++emsg_off; } @@ -1073,7 +1073,7 @@ int get_spellword(list_T *const list, const char **ret_word) // should have type VAR_UNKNOWN. // // @return OK or FAIL. -int call_vim_function(const char_u *func, int argc, typval_T *argv, typval_T *rettv) +int call_vim_function(const char *func, int argc, typval_T *argv, typval_T *rettv) FUNC_ATTR_NONNULL_ALL { int ret; @@ -1082,7 +1082,7 @@ int call_vim_function(const char_u *func, int argc, typval_T *argv, typval_T *re if (len >= 6 && !memcmp(func, "v:lua.", 6)) { func += 6; - len = check_luafunc_name((const char *)func, false); + len = check_luafunc_name(func, false); if (len == 0) { ret = FAIL; goto fail; @@ -1096,7 +1096,7 @@ int call_vim_function(const char_u *func, int argc, typval_T *argv, typval_T *re funcexe.lastline = curwin->w_cursor.lnum; funcexe.evaluate = true; funcexe.partial = pt; - ret = call_func(func, len, rettv, argc, argv, &funcexe); + ret = call_func((char_u *)func, len, rettv, argc, argv, &funcexe); fail: if (ret == FAIL) { @@ -1112,13 +1112,13 @@ fail: /// @param[in] argv Array with typval_T arguments. /// /// @return -1 when calling function fails, result of function otherwise. -varnumber_T call_func_retnr(const char_u *func, int argc, typval_T *argv) +varnumber_T call_func_retnr(const char *func, int argc, typval_T *argv) FUNC_ATTR_NONNULL_ALL { typval_T rettv; varnumber_T retval; - if (call_vim_function(func, argc, argv, &rettv) == FAIL) { + if (call_vim_function((char *)func, argc, argv, &rettv) == FAIL) { return -1; } retval = tv_get_number_chk(&rettv, NULL); @@ -1138,7 +1138,7 @@ char *call_func_retstr(const char *const func, int argc, typval_T *argv) { typval_T rettv; // All arguments are passed as strings, no conversion to number. - if (call_vim_function((const char_u *)func, argc, argv, &rettv) + if (call_vim_function(func, argc, argv, &rettv) == FAIL) { return NULL; } @@ -1155,13 +1155,13 @@ char *call_func_retstr(const char *const func, int argc, typval_T *argv) /// /// @return [allocated] NULL when calling function fails or return tv is not a /// List, allocated List otherwise. -void *call_func_retlist(const char_u *func, int argc, typval_T *argv) +void *call_func_retlist(const char *func, int argc, typval_T *argv) FUNC_ATTR_NONNULL_ALL { typval_T rettv; // All arguments are passed as strings, no conversion to number. - if (call_vim_function(func, argc, argv, &rettv) == FAIL) { + if (call_vim_function((char *)func, argc, argv, &rettv) == FAIL) { return NULL; } @@ -1212,7 +1212,7 @@ void prof_child_exit(proftime_T *tm) /// Evaluate 'foldexpr'. Returns the foldlevel, and any character preceding /// it in "*cp". Doesn't give error messages. -int eval_foldexpr(char_u *arg, int *cp) +int eval_foldexpr(char *arg, int *cp) { typval_T tv; varnumber_T retval; @@ -1235,11 +1235,11 @@ int eval_foldexpr(char_u *arg, int *cp) } else { // If the result is a string, check if there is a non-digit before // the number. - char_u *s = tv.vval.v_string; + char *s = (char *)tv.vval.v_string; if (!ascii_isdigit(*s) && *s != '-') { - *cp = *s++; + *cp = (char_u)(*s++); } - retval = atol((char *)s); + retval = atol(s); } tv_clear(&tv); } @@ -1273,13 +1273,13 @@ void ex_const(exarg_T *eap) /// indentation in the 'cmd' line) is stripped. /// /// @return a List with {lines} or NULL. -static list_T *heredoc_get(exarg_T *eap, char_u *cmd) +static list_T *heredoc_get(exarg_T *eap, char *cmd) { - char_u *marker; - char_u *p; + char *marker; + char *p; int marker_indent_len = 0; int text_indent_len = 0; - char_u *text_indent = NULL; + char *text_indent = NULL; if (eap->getline == NULL) { emsg(_("E991: cannot use =<< here")); @@ -1287,16 +1287,16 @@ static list_T *heredoc_get(exarg_T *eap, char_u *cmd) } // Check for the optional 'trim' word before the marker - cmd = skipwhite(cmd); + cmd = (char *)skipwhite((char_u *)cmd); if (STRNCMP(cmd, "trim", 4) == 0 && (cmd[4] == NUL || ascii_iswhite(cmd[4]))) { - cmd = skipwhite(cmd + 4); + cmd = (char *)skipwhite((char_u *)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 // the first line after the :let command line. To find the end marker // the indent of the :let command line is trimmed. - p = *eap->cmdlinep; + p = (char *)(*eap->cmdlinep); while (ascii_iswhite(*p)) { p++; marker_indent_len++; @@ -1306,9 +1306,9 @@ static list_T *heredoc_get(exarg_T *eap, char_u *cmd) // The marker is the next word. if (*cmd != NUL && *cmd != '"') { - marker = skipwhite(cmd); - p = skiptowhite(marker); - if (*skipwhite(p) != NUL && *skipwhite(p) != '"') { + marker = (char *)skipwhite((char_u *)cmd); + p = (char *)skiptowhite((char_u *)marker); + if (*skipwhite((char_u *)p) != NUL && *skipwhite((char_u *)p) != '"') { emsg(_(e_trailing)); return NULL; } @@ -1327,7 +1327,7 @@ static list_T *heredoc_get(exarg_T *eap, char_u *cmd) int mi = 0; int ti = 0; - char_u *theline = eap->getline(NUL, eap->cookie, 0, false); + char *theline = (char *)eap->getline(NUL, eap->cookie, 0, false); if (theline == NULL) { semsg(_("E990: Missing end marker '%s'"), marker); break; @@ -1351,7 +1351,7 @@ static list_T *heredoc_get(exarg_T *eap, char_u *cmd) p++; text_indent_len++; } - text_indent = vim_strnsave(theline, text_indent_len); + text_indent = xstrnsave(theline, text_indent_len); } // with "trim": skip the indent matching the first line if (text_indent != NULL) { @@ -1362,7 +1362,7 @@ static list_T *heredoc_get(exarg_T *eap, char_u *cmd) } } - tv_list_append_string(l, (char *)(theline + ti), -1); + tv_list_append_string(l, theline + ti, -1); xfree(theline); } xfree(text_indent); @@ -1389,24 +1389,24 @@ void ex_let(exarg_T *eap) static void ex_let_const(exarg_T *eap, const bool is_const) { - char_u *arg = eap->arg; - char_u *expr = NULL; + char *arg = (char *)eap->arg; + char *expr = NULL; typval_T rettv; int i; int var_count = 0; int semicolon = 0; - char_u op[2]; - char_u *argend; - int first = TRUE; + char op[2]; + char *argend; + int first = true; - argend = (char_u *)skip_var_list(arg, &var_count, &semicolon); + argend = (char *)skip_var_list(arg, &var_count, &semicolon); if (argend == NULL) { return; } if (argend > arg && argend[-1] == '.') { // For var.='str'. argend--; } - expr = skipwhite(argend); + expr = (char *)skipwhite((char_u *)argend); if (*expr != '=' && !((vim_strchr((char_u *)"+-*/%.", *expr) != NULL && expr[1] == '=') || STRNCMP(expr, "..=", 3) == 0)) { // ":let" without "=": list variables @@ -1414,7 +1414,7 @@ static void ex_let_const(exarg_T *eap, const bool is_const) emsg(_(e_invarg)); } else if (!ends_excmd(*arg)) { // ":let var1 var2" - arg = (char_u *)list_arg_vars(eap, (const char *)arg, &first); + arg = (char *)list_arg_vars(eap, (const char *)arg, &first); } else if (!eap->skip) { // ":let" list_glob_vars(&first); @@ -1425,7 +1425,7 @@ static void ex_let_const(exarg_T *eap, const bool is_const) list_func_vars(&first); list_vim_vars(&first); } - eap->nextcmd = check_nextcmd(arg); + eap->nextcmd = check_nextcmd((char_u *)arg); } else if (expr[0] == '=' && expr[1] == '<' && expr[2] == '<') { // HERE document list_T *l = heredoc_get(eap, expr + 3); @@ -1434,8 +1434,8 @@ static void ex_let_const(exarg_T *eap, const bool is_const) if (!eap->skip) { op[0] = '='; op[1] = NUL; - (void)ex_let_vars(eap->arg, &rettv, false, semicolon, var_count, - is_const, op); + (void)ex_let_vars((char *)eap->arg, &rettv, false, semicolon, var_count, + is_const, (char *)op); } tv_clear(&rettv); } @@ -1449,23 +1449,23 @@ static void ex_let_const(exarg_T *eap, const bool is_const) expr++; } } - expr = skipwhite(expr + 2); + expr = (char *)skipwhite((char_u *)expr + 2); } else { - expr = skipwhite(expr + 1); + expr = (char *)skipwhite((char_u *)expr + 1); } if (eap->skip) { ++emsg_skip; } - i = eval0(expr, &rettv, &eap->nextcmd, !eap->skip); + i = eval0(expr, &rettv, (char **)&eap->nextcmd, !eap->skip); if (eap->skip) { if (i != FAIL) { tv_clear(&rettv); } emsg_skip--; } else if (i != FAIL) { - (void)ex_let_vars(eap->arg, &rettv, false, semicolon, var_count, - is_const, op); + (void)ex_let_vars((char *)eap->arg, &rettv, false, semicolon, var_count, + is_const, (char *)op); tv_clear(&rettv); } } @@ -1483,10 +1483,10 @@ static void ex_let_const(exarg_T *eap, const bool is_const) /// @param is_const lock variables for :const /// /// @return OK or FAIL; -static int ex_let_vars(char_u *arg_start, typval_T *tv, int copy, int semicolon, int var_count, - int is_const, char_u *op) +static int ex_let_vars(char *arg_start, typval_T *tv, int copy, int semicolon, int var_count, + int is_const, char *op) { - char_u *arg = arg_start; + char *arg = arg_start; typval_T ltv; if (*arg != '[') { @@ -1522,16 +1522,15 @@ static int ex_let_vars(char_u *arg_start, typval_T *tv, int copy, int semicolon, listitem_T *item = tv_list_first(l); size_t rest_len = tv_list_len(l); while (*arg != ']') { - arg = skipwhite(arg + 1); - arg = ex_let_one(arg, TV_LIST_ITEM_TV(item), true, is_const, - (const char_u *)",;]", op); + arg = (char *)skipwhite((char_u *)arg + 1); + arg = ex_let_one(arg, TV_LIST_ITEM_TV(item), true, is_const, ",;]", op); if (arg == NULL) { return FAIL; } rest_len--; item = TV_LIST_ITEM_NEXT(l, item); - arg = skipwhite(arg); + arg = (char *)skipwhite((char_u *)arg); if (*arg == ';') { /* Put the rest of the list (may be empty) in the var after ';'. * Create a new list for this. */ @@ -1546,8 +1545,7 @@ static int ex_let_vars(char_u *arg_start, typval_T *tv, int copy, int semicolon, ltv.vval.v_list = rest_list; tv_list_ref(rest_list); - arg = ex_let_one(skipwhite(arg + 1), <v, false, is_const, (char_u *)"]", - op); + arg = ex_let_one((char *)skipwhite((char_u *)arg + 1), <v, false, is_const, "]", op); tv_clear(<v); if (arg == NULL) { return FAIL; @@ -1568,24 +1566,24 @@ static int ex_let_vars(char_u *arg_start, typval_T *tv, int copy, int semicolon, /// for "[var, var; var]" set "semicolon". /// /// @return NULL for an error. -static const char_u *skip_var_list(const char_u *arg, int *var_count, int *semicolon) +static const char *skip_var_list(const char *arg, int *var_count, int *semicolon) { - const char_u *p; - const char_u *s; + const char *p; + const char *s; if (*arg == '[') { // "[var, var]": find the matching ']'. p = arg; for (;;) { - p = skipwhite(p + 1); // skip whites after '[', ';' or ',' - s = skip_var_one(p); + p = (char *)skipwhite((char_u *)p + 1); // skip whites after '[', ';' or ',' + s = skip_var_one((char *)p); if (s == p) { semsg(_(e_invarg2), p); return NULL; } ++*var_count; - p = skipwhite(s); + p = (char *)skipwhite((char_u *)s); if (*p == ']') { break; } else if (*p == ';') { @@ -1601,19 +1599,19 @@ static const char_u *skip_var_list(const char_u *arg, int *var_count, int *semic } return p + 1; } else { - return skip_var_one(arg); + return skip_var_one((char *)arg); } } /// Skip one (assignable) variable name, including @r, $VAR, &option, d.key, /// l[idx]. -static const char_u *skip_var_one(const char_u *arg) +static const char *skip_var_one(const char *arg) { if (*arg == '@' && arg[1] != NUL) { return arg + 2; } - return find_name_end(*arg == '$' || *arg == '&' ? arg + 1 : arg, - NULL, NULL, FNE_INCL_BR | FNE_CHECK_START); + return (char *)find_name_end(*arg == '$' || *arg == '&' ? arg + 1 : arg, + NULL, NULL, FNE_INCL_BR | FNE_CHECK_START); } /// List variables for hashtab "ht" with prefix "prefix". @@ -1696,8 +1694,7 @@ static const char *list_arg_vars(exarg_T *eap, const char *arg, int *first) while (!ends_excmd(*arg) && !got_int) { if (error || eap->skip) { - arg = (const char *)find_name_end((char_u *)arg, NULL, NULL, - FNE_INCL_BR | FNE_CHECK_START); + arg = find_name_end(arg, NULL, NULL, FNE_INCL_BR | FNE_CHECK_START); if (!ascii_iswhite(*arg) && !ends_excmd(*arg)) { emsg_severe = true; emsg(_(e_trailing)); @@ -1727,9 +1724,7 @@ static const char *list_arg_vars(exarg_T *eap, const char *arg, int *first) } else { // handle d.key, l[idx], f(expr) const char *const arg_subsc = arg; - if (handle_subscript(&arg, &tv, true, true, (const char_u *)name, - (const char_u **)&name) - == FAIL) { + if (handle_subscript(&arg, &tv, true, true, name, &name) == FAIL) { error = true; } else { if (arg == arg_subsc && len == 2 && name[1] == ':') { @@ -1790,14 +1785,14 @@ static const char *list_arg_vars(exarg_T *eap, const char *arg, int *first) /// /// @return a pointer to the char just after the var name or NULL in case of /// error. -static char_u *ex_let_one(char_u *arg, typval_T *const tv, const bool copy, const bool is_const, - const char_u *const endchars, const char_u *const op) +static char *ex_let_one(char *arg, typval_T *const tv, const bool copy, const bool is_const, + const char *const endchars, const char *const op) FUNC_ATTR_NONNULL_ARG(1, 2) FUNC_ATTR_WARN_UNUSED_RESULT { - char_u *arg_end = NULL; + char *arg_end = NULL; int len; int opt_flags; - char_u *tofree = NULL; + char *tofree = NULL; /* * ":let $VAR = expr": Set environment variable. @@ -1809,15 +1804,15 @@ static char_u *ex_let_one(char_u *arg, typval_T *const tv, const bool copy, cons } // Find the end of the name. arg++; - char *name = (char *)arg; - len = get_env_len((const char_u **)&arg); + char *name = arg; + len = get_env_len((const char **)&arg); if (len == 0) { semsg(_(e_invarg2), name - 1); } else { if (op != NULL && vim_strchr((char_u *)"+-*/%", *op) != NULL) { semsg(_(e_letwrong), op); } else if (endchars != NULL - && vim_strchr(endchars, *skipwhite(arg)) == NULL) { + && vim_strchr((char_u *)endchars, *skipwhite((char_u *)arg)) == NULL) { emsg(_(e_letunexp)); } else if (!check_secure()) { const char c1 = name[len]; @@ -1827,7 +1822,7 @@ static char_u *ex_let_one(char_u *arg, typval_T *const tv, const bool copy, cons char *s = vim_getenv(name); if (s != NULL) { - tofree = concat_str((const char_u *)s, (const char_u *)p); + tofree = (char *)concat_str((const char_u *)s, (const char_u *)p); p = (const char *)tofree; xfree(s); } @@ -1860,7 +1855,7 @@ static char_u *ex_let_one(char_u *arg, typval_T *const tv, const bool copy, cons char *const p = (char *)find_option_end((const char **)&arg, &opt_flags); if (p == NULL || (endchars != NULL - && vim_strchr(endchars, *skipwhite((const char_u *)p)) == NULL)) { + && vim_strchr((char_u *)endchars, *skipwhite((const char_u *)p)) == NULL)) { emsg(_(e_letunexp)); } else { int opt_type; @@ -1876,7 +1871,7 @@ static char_u *ex_let_one(char_u *arg, typval_T *const tv, const bool copy, cons s = tv_get_string_chk(tv); // != NULL if number or string. } if (s != NULL && op != NULL && *op != '=') { - opt_type = get_option_value((char *)arg, &numval, (char_u **)&stringval, + opt_type = get_option_value(arg, &numval, (char_u **)&stringval, opt_flags); if ((opt_type == 1 && *op == '.') || (opt_type == 0 && *op != '.')) { @@ -1908,7 +1903,7 @@ static char_u *ex_let_one(char_u *arg, typval_T *const tv, const bool copy, cons if (s != NULL || tv->v_type == VAR_BOOL || tv->v_type == VAR_SPECIAL) { set_option_value((const char *)arg, n, s, opt_flags); - arg_end = (char_u *)p; + arg_end = p; } *p = c1; xfree(stringval); @@ -1923,17 +1918,17 @@ static char_u *ex_let_one(char_u *arg, typval_T *const tv, const bool copy, cons if (op != NULL && vim_strchr((char_u *)"+-*/%", *op) != NULL) { semsg(_(e_letwrong), op); } else if (endchars != NULL - && vim_strchr(endchars, *skipwhite(arg + 1)) == NULL) { + && vim_strchr((char_u *)endchars, *skipwhite((char_u *)arg + 1)) == NULL) { emsg(_(e_letunexp)); } else { - char_u *s; + char *s; - char_u *ptofree = NULL; + char *ptofree = NULL; const char *p = tv_get_string_chk(tv); if (p != NULL && op != NULL && *op == '.') { s = get_reg_contents(*arg == '@' ? '"' : *arg, kGRegExprSrc); if (s != NULL) { - ptofree = concat_str(s, (const char_u *)p); + ptofree = (char *)concat_str((char_u *)s, (const char_u *)p); p = (const char *)ptofree; xfree(s); } @@ -1953,12 +1948,12 @@ static char_u *ex_let_one(char_u *arg, typval_T *const tv, const bool copy, cons else if (eval_isnamec1(*arg) || *arg == '{') { lval_T lv; - char_u *const p = get_lval(arg, tv, &lv, false, false, 0, FNE_CHECK_START); + 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(endchars, *skipwhite(p)) == NULL) { + if (endchars != NULL && vim_strchr((char_u *)endchars, *skipwhite((char_u *)p)) == NULL) { emsg(_(e_letunexp)); } else { - set_var_lval(&lv, p, tv, copy, is_const, (const char *)op); + set_var_lval(&lv, p, tv, copy, is_const, op); arg_end = p; } } @@ -1995,8 +1990,8 @@ static char_u *ex_let_one(char_u *arg, typval_T *const tv, const bool copy, cons /// /// @return A pointer to just after the name, including indexes. Returns NULL /// for a parsing error, but it is still needed to free items in lp. -char_u *get_lval(char_u *const name, typval_T *const rettv, lval_T *const lp, const bool unlet, - const bool skip, const int flags, const int fne_flags) +char *get_lval(char *const name, typval_T *const rettv, lval_T *const lp, const bool unlet, + const bool skip, const int flags, const int fne_flags) FUNC_ATTR_NONNULL_ARG(1, 3) { dictitem_T *v; @@ -2013,17 +2008,16 @@ char_u *get_lval(char_u *const name, typval_T *const rettv, lval_T *const lp, co if (skip) { // When skipping just find the end of the name. lp->ll_name = (const char *)name; - return (char_u *)find_name_end((const char_u *)name, NULL, NULL, - FNE_INCL_BR | fne_flags); + return (char *)find_name_end(name, NULL, NULL, + FNE_INCL_BR | fne_flags); } // Find the end of the name. - char_u *expr_start; - char_u *expr_end; - char_u *p = (char_u *)find_name_end(name, - (const char_u **)&expr_start, - (const char_u **)&expr_end, - fne_flags); + char *expr_start; + char *expr_end; + char *p = (char *)find_name_end(name, (const char **)&expr_start, + (const char **)&expr_end, + fne_flags); if (expr_start != NULL) { // Don't expand the name when we already know there is an error. if (unlet && !ascii_iswhite(*p) && !ends_excmd(*p) @@ -2032,8 +2026,7 @@ char_u *get_lval(char_u *const name, typval_T *const rettv, lval_T *const lp, co return NULL; } - lp->ll_exp_name = (char *)make_expanded_name(name, expr_start, expr_end, - p); + lp->ll_exp_name = make_expanded_name(name, expr_start, expr_end, p); lp->ll_name = lp->ll_exp_name; if (lp->ll_exp_name == NULL) { // Report an invalid expression in braces, unless the @@ -2092,7 +2085,7 @@ char_u *get_lval(char_u *const name, typval_T *const rettv, lval_T *const lp, co } int len = -1; - char_u *key = NULL; + char *key = NULL; if (*p == '.') { key = p + 1; for (len = 0; ASCII_ISALNUM(key[len]) || key[len] == '_'; len++) {} @@ -2105,7 +2098,7 @@ char_u *get_lval(char_u *const name, typval_T *const rettv, lval_T *const lp, co p = key + len; } else { // Get the index [expr] or the first index [expr: ]. - p = skipwhite(p + 1); + p = (char *)skipwhite((char_u *)p + 1); if (*p == ':') { empty1 = true; } else { @@ -2118,7 +2111,7 @@ char_u *get_lval(char_u *const name, typval_T *const rettv, lval_T *const lp, co tv_clear(&var1); return NULL; } - p = skipwhite(p); + p = (char *)skipwhite((char_u *)p); } // Optionally get the second index [ :expr]. @@ -2139,7 +2132,7 @@ char_u *get_lval(char_u *const name, typval_T *const rettv, lval_T *const lp, co tv_clear(&var1); return NULL; } - p = skipwhite(p + 1); + p = (char *)skipwhite((char_u *)p + 1); if (*p == ']') { lp->ll_empty2 = true; } else { @@ -2176,7 +2169,7 @@ char_u *get_lval(char_u *const name, typval_T *const rettv, lval_T *const lp, co if (lp->ll_tv->v_type == VAR_DICT) { if (len == -1) { // "[key]": get key from "var1" - key = (char_u *)tv_get_string(&var1); // is number or string + key = (char *)tv_get_string(&var1); // is number or string } lp->ll_list = NULL; lp->ll_dict = lp->ll_tv->vval.v_dict; @@ -2190,7 +2183,7 @@ char_u *get_lval(char_u *const name, typval_T *const rettv, lval_T *const lp, co int wrong; if (len != -1) { - prevval = key[len]; + prevval = (char_u)key[len]; key[len] = NUL; } else { prevval = 0; // Avoid compiler warning. @@ -2232,9 +2225,9 @@ char_u *get_lval(char_u *const name, typval_T *const rettv, lval_T *const lp, co return NULL; } if (len == -1) { - lp->ll_newkey = vim_strsave(key); + lp->ll_newkey = xstrdup(key); } else { - lp->ll_newkey = vim_strnsave(key, len); + lp->ll_newkey = xstrnsave(key, len); } tv_clear(&var1); break; @@ -2361,7 +2354,7 @@ void clear_lval(lval_T *lp) /// @param endp points to just after the parsed name. /// @param op NULL, "+" for "+=", "-" for "-=", "*" for "*=", "/" for "/=", /// "%" for "%=", "." for ".=" or "=" for "=". -static void set_var_lval(lval_T *lp, char_u *endp, typval_T *rettv, int copy, const bool is_const, +static void set_var_lval(lval_T *lp, char *endp, typval_T *rettv, int copy, const bool is_const, const char *op) { int cc; @@ -2369,7 +2362,7 @@ static void set_var_lval(lval_T *lp, char_u *endp, typval_T *rettv, int copy, co dictitem_T *di; if (lp->ll_tv == NULL) { - cc = *endp; + cc = (char_u)(*endp); *endp = NUL; if (lp->ll_blob != NULL) { if (op != NULL && *op != '=') { @@ -2398,7 +2391,7 @@ static void set_var_lval(lval_T *lp, char_u *endp, typval_T *rettv, int copy, co } } else { bool error = false; - const char_u val = tv_get_number_chk(rettv, &error); + const char val = tv_get_number_chk(rettv, &error); if (!error) { garray_T *const gap = &lp->ll_blob->bv_ga; @@ -2551,7 +2544,7 @@ notify: if (watched) { if (oldtv.v_type == VAR_UNKNOWN) { assert(lp->ll_newkey != NULL); - tv_dict_watcher_notify(dict, (char *)lp->ll_newkey, lp->ll_tv, NULL); + tv_dict_watcher_notify(dict, lp->ll_newkey, lp->ll_tv, NULL); } else { dictitem_T *di_ = lp->ll_di; assert(di_->di_key != NULL); @@ -2570,21 +2563,21 @@ notify: /// @param[out] *errp set to TRUE for an error, FALSE otherwise; /// /// @return a pointer that holds the info. Null when there is an error. -void *eval_for_line(const char_u *arg, bool *errp, char_u **nextcmdp, int skip) +void *eval_for_line(const char *arg, bool *errp, char **nextcmdp, int skip) { forinfo_T *fi = xcalloc(1, sizeof(forinfo_T)); - const char_u *expr; + const char *expr; typval_T tv; list_T *l; *errp = true; // Default: there is an error. - expr = skip_var_list(arg, &fi->fi_varcount, &fi->fi_semicolon); + expr = skip_var_list((char *)arg, &fi->fi_varcount, &fi->fi_semicolon); if (expr == NULL) { return fi; } - expr = skipwhite(expr); + expr = (char *)skipwhite((char_u *)expr); if (expr[0] != 'i' || expr[1] != 'n' || !ascii_iswhite(expr[2])) { emsg(_("E690: Missing \"in\" after :for")); return fi; @@ -2593,7 +2586,7 @@ void *eval_for_line(const char_u *arg, bool *errp, char_u **nextcmdp, int skip) if (skip) { ++emsg_skip; } - if (eval0(skipwhite(expr + 2), &tv, nextcmdp, !skip) == OK) { + if (eval0((char *)skipwhite((char_u *)expr + 2), &tv, nextcmdp, !skip) == OK) { *errp = false; if (!skip) { if (tv.v_type == VAR_LIST) { @@ -2621,10 +2614,10 @@ void *eval_for_line(const char_u *arg, bool *errp, char_u **nextcmdp, int skip) tv_clear(&tv); } else if (tv.v_type == VAR_STRING) { fi->fi_byte_idx = 0; - fi->fi_string = tv.vval.v_string; + fi->fi_string = (char *)tv.vval.v_string; tv.vval.v_string = NULL; if (fi->fi_string == NULL) { - fi->fi_string = vim_strsave((char_u *)""); + fi->fi_string = xstrdup(""); } } else { emsg(_(e_string_list_or_blob_required)); @@ -2646,7 +2639,7 @@ void *eval_for_line(const char_u *arg, bool *errp, char_u **nextcmdp, int skip) /// /// @return true when a valid item was found, false when at end of list or /// something wrong. -bool next_for_item(void *fi_void, char_u *arg) +bool next_for_item(void *fi_void, char *arg) { forinfo_T *fi = (forinfo_T *)fi_void; @@ -2659,19 +2652,18 @@ bool next_for_item(void *fi_void, char_u *arg) tv.v_lock = VAR_FIXED; tv.vval.v_number = tv_blob_get(fi->fi_blob, fi->fi_bi); fi->fi_bi++; - return ex_let_vars(arg, &tv, true, - fi->fi_semicolon, fi->fi_varcount, false, NULL) == OK; + return ex_let_vars(arg, &tv, true, fi->fi_semicolon, fi->fi_varcount, false, NULL) == OK; } if (fi->fi_string != NULL) { - const int len = utfc_ptr2len(fi->fi_string + fi->fi_byte_idx); + const int len = utfc_ptr2len((char_u *)fi->fi_string + fi->fi_byte_idx); if (len == 0) { return false; } typval_T tv; tv.v_type = VAR_STRING; tv.v_lock = VAR_FIXED; - tv.vval.v_string = vim_strnsave(fi->fi_string + fi->fi_byte_idx, len); + tv.vval.v_string = vim_strnsave((char_u *)fi->fi_string + fi->fi_byte_idx, len); fi->fi_byte_idx += len; const int result = ex_let_vars(arg, &tv, true, fi->fi_semicolon, fi->fi_varcount, false, NULL) == OK; @@ -2711,19 +2703,19 @@ void free_for_info(void *fi_void) } -void set_context_for_expression(expand_T *xp, char_u *arg, cmdidx_T cmdidx) +void set_context_for_expression(expand_T *xp, char *arg, cmdidx_T cmdidx) FUNC_ATTR_NONNULL_ALL { int got_eq = FALSE; int c; - char_u *p; + char *p; if (cmdidx == CMD_let || cmdidx == CMD_const) { xp->xp_context = EXPAND_USER_VARS; - if (strpbrk((char *)arg, "\"'+-*/%.=!?~|&$([<>,#") == NULL) { + if (strpbrk(arg, "\"'+-*/%.=!?~|&$([<>,#") == NULL) { // ":let var1 var2 ...": find last space. for (p = arg + STRLEN(arg); p >= arg;) { - xp->xp_pattern = p; + xp->xp_pattern = (char_u *)p; MB_PTR_BACK(arg, p); if (ascii_iswhite(*p)) { break; @@ -2735,7 +2727,7 @@ void set_context_for_expression(expand_T *xp, char_u *arg, cmdidx_T cmdidx) xp->xp_context = cmdidx == CMD_call ? EXPAND_FUNCTIONS : EXPAND_EXPRESSION; } - while ((xp->xp_pattern = (char_u *)strpbrk((char *)arg, "\"'+-*/%.=!?~|&$([<>,#")) != NULL) { + while ((xp->xp_pattern = (char_u *)strpbrk(arg, "\"'+-*/%.=!?~|&$([<>,#")) != NULL) { c = *xp->xp_pattern; if (c == '&') { c = xp->xp_pattern[1]; @@ -2791,9 +2783,9 @@ void set_context_for_expression(expand_T *xp, char_u *arg, cmdidx_T cmdidx) // anyway. xp->xp_context = EXPAND_EXPRESSION; } - arg = xp->xp_pattern; + arg = (char *)xp->xp_pattern; if (*arg != NUL) { - while ((c = *++arg) != NUL && (c == ' ' || c == '\t')) {} + while ((c = (char_u)(*++arg)) != NUL && (c == ' ' || c == '\t')) {} } } @@ -2804,22 +2796,22 @@ void set_context_for_expression(expand_T *xp, char_u *arg, cmdidx_T cmdidx) || cmdidx == CMD_echomsg) && xp->xp_context == EXPAND_EXPRESSION) { for (;;) { - char_u *const n = skiptowhite(arg); + char *const n = (char *)skiptowhite((char_u *)arg); - if (n == arg || ascii_iswhite_or_nul(*skipwhite(n))) { + if (n == arg || ascii_iswhite_or_nul(*skipwhite((char_u *)n))) { break; } - arg = skipwhite(n); + arg = (char *)skipwhite((char_u *)n); } } - xp->xp_pattern = arg; + xp->xp_pattern = (char_u *)arg; } /// ":unlet[!] var1 ... " command. void ex_unlet(exarg_T *eap) { - ex_unletlock(eap, eap->arg, 0, do_unlet_var); + ex_unletlock(eap, (char *)eap->arg, 0, do_unlet_var); } // TODO(ZyX-I): move to eval/ex_cmds @@ -2827,14 +2819,14 @@ void ex_unlet(exarg_T *eap) /// ":lockvar" and ":unlockvar" commands void ex_lockvar(exarg_T *eap) { - char_u *arg = eap->arg; + char *arg = (char *)eap->arg; int deep = 2; if (eap->forceit) { deep = -1; } else if (ascii_isdigit(*arg)) { - deep = getdigits_int(&arg, false, -1); - arg = skipwhite(arg); + deep = getdigits_int((char_u **)&arg, false, -1); + arg = (char *)skipwhite((char_u *)arg); } ex_unletlock(eap, arg, deep, do_lock_var); @@ -2851,11 +2843,11 @@ void ex_lockvar(exarg_T *eap) /// @param[in] deep Levels to (un)lock for :(un)lockvar, -1 to (un)lock /// everything. /// @param[in] callback Appropriate handler for the command. -static void ex_unletlock(exarg_T *eap, char_u *argstart, int deep, ex_unletlock_callback callback) +static void ex_unletlock(exarg_T *eap, char *argstart, int deep, ex_unletlock_callback callback) FUNC_ATTR_NONNULL_ALL { - char_u *arg = argstart; - char_u *name_end; + char *arg = argstart; + char *name_end; bool error = false; lval_T lv; @@ -2864,7 +2856,7 @@ static void ex_unletlock(exarg_T *eap, char_u *argstart, int deep, ex_unletlock_ lv.ll_name = (const char *)arg; lv.ll_tv = NULL; arg++; - if (get_env_len((const char_u **)&arg) == 0) { + if (get_env_len((const char **)&arg) == 0) { semsg(_(e_invarg2), arg - 1); return; } @@ -2899,10 +2891,10 @@ static void ex_unletlock(exarg_T *eap, char_u *argstart, int deep, ex_unletlock_ clear_lval(&lv); } } - arg = skipwhite(name_end); + arg = (char *)skipwhite((char_u *)name_end); } while (!ends_excmd(*arg)); - eap->nextcmd = check_nextcmd(arg); + eap->nextcmd = check_nextcmd((char_u *)arg); } // TODO(ZyX-I): move to eval/ex_cmds @@ -2915,7 +2907,7 @@ static void ex_unletlock(exarg_T *eap, char_u *argstart, int deep, ex_unletlock_ /// @param[in] deep Unused. /// /// @return OK on success, or FAIL on failure. -static int do_unlet_var(lval_T *lp, char_u *name_end, exarg_T *eap, int deep FUNC_ATTR_UNUSED) +static int do_unlet_var(lval_T *lp, char *name_end, exarg_T *eap, int deep FUNC_ATTR_UNUSED) FUNC_ATTR_NONNULL_ALL { int forceit = eap->forceit; @@ -2923,7 +2915,7 @@ static int do_unlet_var(lval_T *lp, char_u *name_end, exarg_T *eap, int deep FUN int cc; if (lp->ll_tv == NULL) { - cc = *name_end; + cc = (char_u)(*name_end); *name_end = NUL; // Environment variable, normal name or expanded name. @@ -3081,7 +3073,7 @@ int do_unlet(const char *const name, const size_t name_len, const bool forceit) /// @param[in] deep Levels to (un)lock, -1 to (un)lock everything. /// /// @return OK on success, or FAIL on failure. -static int do_lock_var(lval_T *lp, char_u *name_end FUNC_ATTR_UNUSED, exarg_T *eap, int deep) +static int do_lock_var(lval_T *lp, char *name_end FUNC_ATTR_UNUSED, exarg_T *eap, int deep) FUNC_ATTR_NONNULL_ARG(1, 3) { bool lock = eap->cmdidx == CMD_lockvar; @@ -3156,11 +3148,11 @@ void del_menutrans_vars(void) */ -static char_u *varnamebuf = NULL; +static char *varnamebuf = NULL; static size_t varnamebuflen = 0; /// Function to concatenate a prefix and a variable name. -char_u *cat_prefix_varname(int prefix, const char_u *name) +char *cat_prefix_varname(int prefix, const char *name) FUNC_ATTR_NONNULL_ALL { size_t len = STRLEN(name) + 3; @@ -3204,7 +3196,7 @@ char_u *get_user_var_name(expand_T *xp, int idx) ++hi; } if (STRNCMP("g:", xp->xp_pattern, 2) == 0) { - return cat_prefix_varname('g', hi->hi_key); + return (char_u *)cat_prefix_varname('g', (char *)hi->hi_key); } return hi->hi_key; } @@ -3220,7 +3212,7 @@ char_u *get_user_var_name(expand_T *xp, int idx) while (HASHITEM_EMPTY(hi)) { ++hi; } - return cat_prefix_varname('b', hi->hi_key); + return (char_u *)cat_prefix_varname('b', (char *)hi->hi_key); } // w: variables @@ -3234,7 +3226,7 @@ char_u *get_user_var_name(expand_T *xp, int idx) while (HASHITEM_EMPTY(hi)) { ++hi; } - return cat_prefix_varname('w', hi->hi_key); + return (char_u *)cat_prefix_varname('w', (char *)hi->hi_key); } // t: variables @@ -3248,12 +3240,12 @@ char_u *get_user_var_name(expand_T *xp, int idx) while (HASHITEM_EMPTY(hi)) { ++hi; } - return cat_prefix_varname('t', hi->hi_key); + return (char_u *)cat_prefix_varname('t', (char *)hi->hi_key); } // v: variables if (vidx < ARRAY_SIZE(vimvars)) { - return cat_prefix_varname('v', (char_u *)vimvars[vidx++].vv_name); + return (char_u *)cat_prefix_varname('v', vimvars[vidx++].vv_name); } XFREE_CLEAR(varnamebuf); @@ -3266,21 +3258,21 @@ char_u *get_user_var_name(expand_T *xp, int idx) /// Does not use 'cpo' and always uses 'magic'. /// /// @return TRUE if "pat" matches "text". -int pattern_match(char_u *pat, char_u *text, bool ic) +int pattern_match(char *pat, char *text, bool ic) { int matches = 0; regmatch_T regmatch; // avoid 'l' flag in 'cpoptions' - char_u *save_cpo = p_cpo; + char *save_cpo = (char *)p_cpo; p_cpo = (char_u *)""; - regmatch.regprog = vim_regcomp(pat, RE_MAGIC + RE_STRING); + regmatch.regprog = vim_regcomp((char_u *)pat, RE_MAGIC + RE_STRING); if (regmatch.regprog != NULL) { regmatch.rm_ic = ic; - matches = vim_regexec_nl(®match, text, (colnr_T)0); + matches = vim_regexec_nl(®match, (char_u *)text, (colnr_T)0); vim_regfree(regmatch.regprog); } - p_cpo = save_cpo; + p_cpo = (char_u *)save_cpo; return matches; } @@ -3291,11 +3283,11 @@ int pattern_match(char_u *pat, char_u *text, bool ic) /// @param basetv "expr" for "expr->name(arg)" /// /// @return OK or FAIL. -static int eval_func(char_u **const arg, char_u *const name, const int name_len, - typval_T *const rettv, const bool evaluate, typval_T *const basetv) +static int eval_func(char **const arg, char *const name, const int name_len, typval_T *const rettv, + const bool evaluate, typval_T *const basetv) FUNC_ATTR_NONNULL_ARG(1, 2, 4) { - char_u *s = name; + char *s = name; int len = name_len; if (!evaluate) { @@ -3305,7 +3297,7 @@ static int eval_func(char_u **const arg, char_u *const name, const int name_len, // If "s" is the name of a variable of type VAR_FUNC // use its contents. partial_T *partial; - s = deref_func_name((const char *)s, &len, &partial, !evaluate); + s = (char *)deref_func_name((const char *)s, &len, &partial, !evaluate); // Need to make a copy, in case evaluating the arguments makes // the name invalid. @@ -3318,7 +3310,7 @@ static int eval_func(char_u **const arg, char_u *const name, const int name_len, funcexe.evaluate = evaluate; funcexe.partial = partial; funcexe.basetv = basetv; - int ret = get_func_tv(s, len, rettv, arg, &funcexe); + int ret = get_func_tv((char_u *)s, len, rettv, (char_u **)arg, &funcexe); xfree(s); @@ -3356,14 +3348,14 @@ static int eval_func(char_u **const arg, char_u *const name, const int name_len, /// Note: "rettv.v_lock" is not set. /// /// @return OK or FAIL. -int eval0(char_u *arg, typval_T *rettv, char_u **nextcmd, int evaluate) +int eval0(char *arg, typval_T *rettv, char **nextcmd, int evaluate) { int ret; - char_u *p; + char *p; const int did_emsg_before = did_emsg; const int called_emsg_before = called_emsg; - p = skipwhite(arg); + p = (char *)skipwhite((char_u *)arg); ret = eval1(&p, rettv, evaluate); if (ret == FAIL || !ends_excmd(*p)) { if (ret != FAIL) { @@ -3380,7 +3372,7 @@ int eval0(char_u *arg, typval_T *rettv, char_u **nextcmd, int evaluate) ret = FAIL; } if (nextcmd != NULL) { - *nextcmd = check_nextcmd(p); + *nextcmd = (char *)check_nextcmd((char_u *)p); } return ret; @@ -3397,7 +3389,7 @@ int eval0(char_u *arg, typval_T *rettv, char_u **nextcmd, int evaluate) /// Note: "rettv.v_lock" is not set. /// /// @return OK or FAIL. -int eval1(char_u **arg, typval_T *rettv, int evaluate) +int eval1(char **arg, typval_T *rettv, int evaluate) { int result; typval_T var2; @@ -3426,7 +3418,7 @@ int eval1(char_u **arg, typval_T *rettv, int evaluate) /* * Get the second variable. */ - *arg = skipwhite(*arg + 1); + *arg = (char *)skipwhite((char_u *)(*arg) + 1); if (eval1(arg, rettv, evaluate && result) == FAIL) { // recursive! return FAIL; } @@ -3445,7 +3437,7 @@ int eval1(char_u **arg, typval_T *rettv, int evaluate) /* * Get the third variable. */ - *arg = skipwhite(*arg + 1); + *arg = (char *)skipwhite((char_u *)(*arg) + 1); if (eval1(arg, &var2, evaluate && !result) == FAIL) { // Recursive! if (evaluate && result) { tv_clear(rettv); @@ -3469,7 +3461,7 @@ int eval1(char_u **arg, typval_T *rettv, int evaluate) /// "arg" is advanced to the next non-white after the recognized expression. /// /// @return OK or FAIL. -static int eval2(char_u **arg, typval_T *rettv, int evaluate) +static int eval2(char **arg, typval_T *rettv, int evaluate) { typval_T var2; long result; @@ -3503,7 +3495,7 @@ static int eval2(char_u **arg, typval_T *rettv, int evaluate) /* * Get the second variable. */ - *arg = skipwhite(*arg + 2); + *arg = (char *)skipwhite((char_u *)(*arg) + 2); if (eval3(arg, &var2, evaluate && !result) == FAIL) { return FAIL; } @@ -3538,7 +3530,7 @@ static int eval2(char_u **arg, typval_T *rettv, int evaluate) /// `arg` is advanced to the next non-white after the recognized expression. /// /// @return OK or FAIL. -static int eval3(char_u **arg, typval_T *rettv, int evaluate) +static int eval3(char **arg, typval_T *rettv, int evaluate) { typval_T var2; long result; @@ -3572,7 +3564,7 @@ static int eval3(char_u **arg, typval_T *rettv, int evaluate) /* * Get the second variable. */ - *arg = skipwhite(*arg + 2); + *arg = (char *)skipwhite((char_u *)(*arg) + 2); if (eval4(arg, &var2, evaluate && result) == FAIL) { return FAIL; } @@ -3616,10 +3608,10 @@ static int eval3(char_u **arg, typval_T *rettv, int evaluate) /// "arg" is advanced to the next non-white after the recognized expression. /// /// @return OK or FAIL. -static int eval4(char_u **arg, typval_T *rettv, int evaluate) +static int eval4(char **arg, typval_T *rettv, int evaluate) { typval_T var2; - char_u *p; + char *p; exprtype_T type = EXPR_UNKNOWN; int len = 2; bool ic; @@ -3691,7 +3683,7 @@ static int eval4(char_u **arg, typval_T *rettv, int evaluate) } // Get the second variable. - *arg = skipwhite(p + len); + *arg = (char *)skipwhite((char_u *)p + len); if (eval5(arg, &var2, evaluate) == FAIL) { tv_clear(rettv); return FAIL; @@ -3719,14 +3711,14 @@ static int eval4(char_u **arg, typval_T *rettv, int evaluate) /// `arg` is advanced to the next non-white after the recognized expression. /// /// @return OK or FAIL. -static int eval5(char_u **arg, typval_T *rettv, int evaluate) +static int eval5(char **arg, typval_T *rettv, int evaluate) { typval_T var2; typval_T var3; int op; varnumber_T n1, n2; float_T f1 = 0, f2 = 0; - char_u *p; + char *p; /* * Get the first variable. @@ -3739,7 +3731,7 @@ static int eval5(char_u **arg, typval_T *rettv, int evaluate) * Repeat computing, until no '+', '-' or '.' is following. */ for (;;) { - op = **arg; + op = (char_u)(**arg); if (op != '+' && op != '-' && op != '.') { break; } @@ -3765,7 +3757,7 @@ static int eval5(char_u **arg, typval_T *rettv, int evaluate) if (op == '.' && *(*arg + 1) == '.') { // ..string concatenation (*arg)++; } - *arg = skipwhite(*arg + 1); + *arg = (char *)skipwhite((char_u *)(*arg) + 1); if (eval6(arg, &var2, evaluate, op == '.') == FAIL) { tv_clear(rettv); return FAIL; @@ -3786,10 +3778,10 @@ static int eval5(char_u **arg, typval_T *rettv, int evaluate) tv_clear(&var2); return FAIL; } - p = concat_str((const char_u *)s1, (const char_u *)s2); + p = (char *)concat_str((const char_u *)s1, (const char_u *)s2); tv_clear(rettv); rettv->v_type = VAR_STRING; - rettv->vval.v_string = p; + rettv->vval.v_string = (char_u *)p; } else if (op == '+' && rettv->v_type == VAR_BLOB && var2.v_type == VAR_BLOB) { const blob_T *const b1 = rettv->vval.v_blob; @@ -3893,7 +3885,7 @@ static int eval5(char_u **arg, typval_T *rettv, int evaluate) /// @param[in] want_string True if "." is string_concatenation, otherwise /// float /// @return OK or FAIL. -static int eval6(char_u **arg, typval_T *rettv, int evaluate, int want_string) +static int eval6(char **arg, typval_T *rettv, int evaluate, int want_string) FUNC_ATTR_NO_SANITIZE_UNDEFINED { typval_T var2; @@ -3914,7 +3906,7 @@ static int eval6(char_u **arg, typval_T *rettv, int evaluate, int want_string) * Repeat computing, until no '*', '/' or '%' is following. */ for (;;) { - op = **arg; + op = (char_u)(**arg); if (op != '*' && op != '/' && op != '%') { break; } @@ -3938,8 +3930,8 @@ static int eval6(char_u **arg, typval_T *rettv, int evaluate, int want_string) /* * Get the second variable. */ - *arg = skipwhite(*arg + 1); - if (eval7(arg, &var2, evaluate, FALSE) == FAIL) { + *arg = (char *)skipwhite((char_u *)(*arg) + 1); + if (eval7(arg, &var2, evaluate, false) == FAIL) { return FAIL; } @@ -4034,14 +4026,14 @@ static int eval6(char_u **arg, typval_T *rettv, int evaluate, int want_string) /// @param want_string after "." operator /// /// @return OK or FAIL. -static int eval7(char_u **arg, typval_T *rettv, int evaluate, int want_string) +static int eval7(char **arg, typval_T *rettv, int evaluate, int want_string) { varnumber_T n; int len; - char_u *s; - const char_u *start_leader, *end_leader; + char *s; + const char *start_leader, *end_leader; int ret = OK; - char_u *alias; + char *alias; // Initialise variable so that tv_clear() can't mistake this for a // string and free a string that isn't there. @@ -4050,7 +4042,7 @@ static int eval7(char_u **arg, typval_T *rettv, int evaluate, int want_string) // Skip '!', '-' and '+' characters. They are handled later. start_leader = *arg; while (**arg == '!' || **arg == '-' || **arg == '+') { - *arg = skipwhite(*arg + 1); + *arg = (char *)skipwhite((char_u *)(*arg) + 1); } end_leader = *arg; @@ -4066,7 +4058,7 @@ static int eval7(char_u **arg, typval_T *rettv, int evaluate, int want_string) case '7': case '8': case '9': { - char_u *p = skipdigits(*arg + 1); + char *p = (char *)skipdigits((char_u *)(*arg) + 1); int get_float = false; // We accept a float when the format matches @@ -4076,7 +4068,7 @@ static int eval7(char_u **arg, typval_T *rettv, int evaluate, int want_string) // ":let vers = 1.2.3" doesn't fail. if (!want_string && p[0] == '.' && ascii_isdigit(p[1])) { get_float = true; - p = skipdigits(p + 2); + p = (char *)skipdigits((char_u *)p + 2); if (*p == 'e' || *p == 'E') { ++p; if (*p == '-' || *p == '+') { @@ -4085,7 +4077,7 @@ static int eval7(char_u **arg, typval_T *rettv, int evaluate, int want_string) if (!ascii_isdigit(*p)) { get_float = false; } else { - p = skipdigits(p + 1); + p = (char *)skipdigits((char_u *)p + 1); } } if (ASCII_ISALPHA(*p) || *p == '.') { @@ -4095,7 +4087,7 @@ static int eval7(char_u **arg, typval_T *rettv, int evaluate, int want_string) if (get_float) { float_T f; - *arg += string2float((char *)*arg, &f); + *arg += string2float(*arg, &f); if (evaluate) { rettv->v_type = VAR_FLOAT; rettv->vval.v_float = f; @@ -4106,7 +4098,7 @@ static int eval7(char_u **arg, typval_T *rettv, int evaluate, int want_string) if (evaluate) { blob = tv_blob_alloc(); } - char_u *bp; + char *bp; for (bp = *arg + 2; ascii_isxdigit(bp[0]); bp += 2) { if (!ascii_isxdigit(bp[1])) { if (blob != NULL) { @@ -4131,7 +4123,7 @@ static int eval7(char_u **arg, typval_T *rettv, int evaluate, int want_string) *arg = bp; } else { // decimal, hex or octal number - vim_str2nr(*arg, NULL, &len, STR2NR_ALL, &n, NULL, 0, true); + vim_str2nr((char_u *)(*arg), NULL, &len, STR2NR_ALL, &n, NULL, 0, true); if (len == 0) { semsg(_(e_invexpr2), *arg); ret = FAIL; @@ -4174,7 +4166,7 @@ static int eval7(char_u **arg, typval_T *rettv, int evaluate, int want_string) // Lambda: {arg, arg -> expr} // Dictionary: {'key': val, 'key': val} case '{': - ret = get_lambda_tv(arg, rettv, evaluate); + ret = get_lambda_tv((char_u **)arg, rettv, evaluate); if (ret == NOTDONE) { ret = dict_get_tv(arg, rettv, evaluate, false); } @@ -4203,7 +4195,7 @@ static int eval7(char_u **arg, typval_T *rettv, int evaluate, int want_string) // nested expression: (expression). case '(': - *arg = skipwhite(*arg + 1); + *arg = (char *)skipwhite((char_u *)(*arg) + 1); ret = eval1(arg, rettv, evaluate); // recursive! if (**arg == ')') { ++*arg; @@ -4223,7 +4215,7 @@ static int eval7(char_u **arg, typval_T *rettv, int evaluate, int want_string) // Must be a variable or function name. // Can also be a curly-braces kind of name: {expr}. s = *arg; - len = get_name_len((const char **)arg, (char **)&alias, evaluate, true); + len = get_name_len((const char **)arg, &alias, evaluate, true); if (alias != NULL) { s = alias; } @@ -4243,18 +4235,18 @@ static int eval7(char_u **arg, typval_T *rettv, int evaluate, int want_string) xfree(alias); } - *arg = skipwhite(*arg); + *arg = (char *)skipwhite((char_u *)(*arg)); // Handle following '[', '(' and '.' for expr[expr], expr.name, // expr(expr), expr->name(expr) if (ret == OK) { ret = handle_subscript((const char **)arg, rettv, evaluate, true, - start_leader, &end_leader); + (char *)start_leader, &end_leader); } // Apply logical NOT and unary '-', from right to left, ignore '+'. if (ret == OK && evaluate && end_leader > start_leader) { - ret = eval7_leader(rettv, start_leader, &end_leader); + ret = eval7_leader(rettv, (char *)start_leader, &end_leader); } return ret; } @@ -4263,11 +4255,11 @@ static int eval7(char_u **arg, typval_T *rettv, int evaluate, int want_string) /// Adjusts "end_leaderp" until it is at "start_leader". /// /// @return OK on success, FAIL on failure. -static int eval7_leader(typval_T *const rettv, const char_u *const start_leader, - const char_u **const end_leaderp) +static int eval7_leader(typval_T *const rettv, const char *const start_leader, + const char **const end_leaderp) FUNC_ATTR_NONNULL_ALL { - const char_u *end_leader = *end_leaderp; + const char *end_leader = (char *)(*end_leaderp); int ret = OK; bool error = false; varnumber_T val = 0; @@ -4317,14 +4309,14 @@ static int eval7_leader(typval_T *const rettv, const char_u *const start_leader, /// to the name of the Lua function to call (after the /// "v:lua." prefix). /// @return OK on success, FAIL on failure. -static int call_func_rettv(char_u **const arg, typval_T *const rettv, const bool evaluate, +static int call_func_rettv(char **const arg, typval_T *const rettv, const bool evaluate, dict_T *const selfdict, typval_T *const basetv, - const char_u *const lua_funcname) + const char *const lua_funcname) FUNC_ATTR_NONNULL_ARG(1, 2) { partial_T *pt = NULL; typval_T functv; - const char_u *funcname; + const char *funcname; bool is_lua = false; // need to copy the funcref so that we can clear rettv @@ -4338,10 +4330,10 @@ static int call_func_rettv(char_u **const arg, typval_T *const rettv, const bool is_lua = is_luafunc(pt); funcname = is_lua ? lua_funcname : partial_name(pt); } else { - funcname = functv.vval.v_string; + funcname = (char *)functv.vval.v_string; } } else { - funcname = (char_u *)""; + funcname = ""; } funcexe_T funcexe = FUNCEXE_INIT; @@ -4351,8 +4343,8 @@ static int call_func_rettv(char_u **const arg, typval_T *const rettv, const bool funcexe.partial = pt; funcexe.selfdict = selfdict; funcexe.basetv = basetv; - const int ret = get_func_tv(funcname, is_lua ? *arg - funcname : -1, rettv, - arg, &funcexe); + const int ret = get_func_tv((char_u *)funcname, is_lua ? *arg - funcname : -1, rettv, + (char_u **)arg, &funcexe); // Clear the funcref afterwards, so that deleting it while // evaluating the arguments is possible (see test55). @@ -4371,7 +4363,7 @@ static int call_func_rettv(char_u **const arg, typval_T *const rettv, const bool /// @return FAIL or OK. /// /// @note "*arg" is advanced to after the ')'. -static int eval_lambda(char_u **const arg, typval_T *const rettv, const bool evaluate, +static int eval_lambda(char **const arg, typval_T *const rettv, const bool evaluate, const bool verbose) FUNC_ATTR_NONNULL_ALL { @@ -4380,12 +4372,12 @@ static int eval_lambda(char_u **const arg, typval_T *const rettv, const bool eva typval_T base = *rettv; rettv->v_type = VAR_UNKNOWN; - int ret = get_lambda_tv(arg, rettv, evaluate); + int ret = get_lambda_tv((char_u **)arg, rettv, evaluate); if (ret != OK) { return FAIL; } else if (**arg != '(') { if (verbose) { - if (*skipwhite(*arg) == '(') { + if (*skipwhite((char_u *)(*arg)) == '(') { emsg(_(e_nowhitespace)); } else { semsg(_(e_missingparen), "lambda"); @@ -4411,7 +4403,7 @@ static int eval_lambda(char_u **const arg, typval_T *const rettv, const bool eva /// @param *arg points to the '-'. /// /// @return FAIL or OK. "*arg" is advanced to after the ')'. -static int eval_method(char_u **const arg, typval_T *const rettv, const bool evaluate, +static int eval_method(char **const arg, typval_T *const rettv, const bool evaluate, const bool verbose) FUNC_ATTR_NONNULL_ALL { @@ -4422,16 +4414,16 @@ static int eval_method(char_u **const arg, typval_T *const rettv, const bool eva // Locate the method name. int len; - char_u *name = *arg; - char_u *lua_funcname = NULL; + char *name = *arg; + char *lua_funcname = NULL; if (STRNCMP(name, "v:lua.", 6) == 0) { lua_funcname = name + 6; - *arg = (char_u *)skip_luafunc_name((const char *)lua_funcname); - *arg = skipwhite(*arg); // to detect trailing whitespace later + *arg = (char *)skip_luafunc_name((const char *)lua_funcname); + *arg = (char *)skipwhite((char_u *)(*arg)); // to detect trailing whitespace later len = *arg - lua_funcname; } else { - char_u *alias; - len = get_name_len((const char **)arg, (char **)&alias, evaluate, true); + char *alias; + len = get_name_len((const char **)arg, &alias, evaluate, true); if (alias != NULL) { name = alias; } @@ -4487,14 +4479,14 @@ static int eval_method(char_u **const arg, typval_T *const rettv, const bool eva /// @param verbose give error messages /// /// @returns FAIL or OK. "*arg" is advanced to after the ']'. -static int eval_index(char_u **arg, typval_T *rettv, int evaluate, int verbose) +static int eval_index(char **arg, typval_T *rettv, int evaluate, int verbose) { bool empty1 = false; bool empty2 = false; long n1, n2 = 0; ptrdiff_t len = -1; int range = false; - char_u *key = NULL; + char *key = NULL; switch (rettv->v_type) { case VAR_FUNC: @@ -4538,14 +4530,14 @@ static int eval_index(char_u **arg, typval_T *rettv, int evaluate, int verbose) if (len == 0) { return FAIL; } - *arg = skipwhite(key + len); + *arg = (char *)skipwhite((char_u *)key + len); } else { /* * something[idx] * * Get the (first) variable from inside the []. */ - *arg = skipwhite(*arg + 1); + *arg = (char *)skipwhite((char_u *)(*arg) + 1); if (**arg == ':') { empty1 = true; } else if (eval1(arg, &var1, evaluate) == FAIL) { // Recursive! @@ -4560,8 +4552,8 @@ static int eval_index(char_u **arg, typval_T *rettv, int evaluate, int verbose) * Get the second variable from inside the [:]. */ if (**arg == ':') { - range = TRUE; - *arg = skipwhite(*arg + 1); + range = true; + *arg = (char *)skipwhite((char_u *)(*arg) + 1); if (**arg == ']') { empty2 = true; } else if (eval1(arg, &var2, evaluate) == FAIL) { // Recursive! @@ -4590,7 +4582,7 @@ static int eval_index(char_u **arg, typval_T *rettv, int evaluate, int verbose) } return FAIL; } - *arg = skipwhite(*arg + 1); // skip the ']' + *arg = (char *)skipwhite((char_u *)(*arg) + 1); // skip the ']' } if (evaluate) { @@ -4748,7 +4740,7 @@ static int eval_index(char_u **arg, typval_T *rettv, int evaluate, int verbose) } if (len == -1) { - key = (char_u *)tv_get_string_chk(&var1); + key = (char *)tv_get_string_chk(&var1); if (key == NULL) { tv_clear(&var1); return FAIL; @@ -4800,7 +4792,7 @@ int get_option_tv(const char **const arg, typval_T *const rettv, const bool eval FUNC_ATTR_NONNULL_ARG(1) { long numval; - char_u *stringval; + char *stringval; int opt_type; bool working = (**arg == '+'); // has("+option") int ret = OK; @@ -4823,7 +4815,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 : &stringval, opt_flags); + rettv == NULL ? NULL : (char_u **)&stringval, opt_flags); if (opt_type == -3) { // invalid name if (rettv != NULL) { @@ -4842,7 +4834,7 @@ int get_option_tv(const char **const arg, typval_T *const rettv, const bool eval rettv->vval.v_number = numval; } else { // string option rettv->v_type = VAR_STRING; - rettv->vval.v_string = stringval; + rettv->vval.v_string = (char_u *)stringval; } } else if (working && (opt_type == -2 || opt_type == -1)) { ret = FAIL; @@ -4857,9 +4849,9 @@ int get_option_tv(const char **const arg, typval_T *const rettv, const bool eval /// Allocate a variable for a string constant. /// /// @return OK or FAIL. -static int get_string_tv(char_u **arg, typval_T *rettv, int evaluate) +static int get_string_tv(char **arg, typval_T *rettv, int evaluate) { - char_u *p; + char *p; unsigned int extra = 0; /* @@ -4893,9 +4885,9 @@ static int get_string_tv(char_u **arg, typval_T *rettv, int evaluate) * characters. */ const int len = (int)(p - *arg + extra); - char_u *name = xmalloc(len); + char *name = xmalloc(len); rettv->v_type = VAR_STRING; - rettv->vval.v_string = name; + rettv->vval.v_string = (char_u *)name; for (p = *arg + 1; *p != NUL && *p != '"';) { if (*p == '\\') { @@ -4937,7 +4929,7 @@ static int get_string_tv(char_u **arg, typval_T *rettv, int evaluate) // For "\u" store the number according to // 'encoding'. if (c != 'X') { - name += utf_char2bytes(nr, name); + name += utf_char2bytes(nr, (char_u *)name); } else { *name++ = nr; } @@ -4970,10 +4962,10 @@ static int get_string_tv(char_u **arg, typval_T *rettv, int evaluate) if (p[1] != '*') { flags |= FSK_SIMPLIFY; } - extra = trans_special((const char_u **)&p, STRLEN(p), name, flags, false, NULL); + extra = trans_special((const char_u **)&p, STRLEN(p), (char_u *)name, flags, false, NULL); if (extra != 0) { name += extra; - if (name >= rettv->vval.v_string + len) { + if ((char_u *)name >= rettv->vval.v_string + len) { iemsg("get_string_tv() used more space than allocated"); } break; @@ -4982,11 +4974,11 @@ static int get_string_tv(char_u **arg, typval_T *rettv, int evaluate) FALLTHROUGH; default: - mb_copy_char((const char_u **)&p, &name); + mb_copy_char((const char_u **)&p, (char_u **)&name); break; } } else { - mb_copy_char((const char_u **)&p, &name); + mb_copy_char((const char_u **)&p, (char_u **)&name); } } *name = NUL; @@ -5001,10 +4993,10 @@ static int get_string_tv(char_u **arg, typval_T *rettv, int evaluate) /// Allocate a variable for a 'str''ing' constant. /// /// @return OK or FAIL. -static int get_lit_string_tv(char_u **arg, typval_T *rettv, int evaluate) +static int get_lit_string_tv(char **arg, typval_T *rettv, int evaluate) { - char_u *p; - char_u *str; + char *p; + char *str; int reduce = 0; /* @@ -5036,7 +5028,7 @@ static int get_lit_string_tv(char_u **arg, typval_T *rettv, int evaluate) */ str = xmalloc((p - *arg) - reduce); rettv->v_type = VAR_STRING; - rettv->vval.v_string = str; + rettv->vval.v_string = (char_u *)str; for (p = *arg + 1; *p != NUL;) { if (*p == '\'') { @@ -5045,7 +5037,7 @@ static int get_lit_string_tv(char_u **arg, typval_T *rettv, int evaluate) } ++p; } - mb_copy_char((const char_u **)&p, &str); + mb_copy_char((const char_u **)&p, (char_u **)&str); } *str = NUL; *arg = p + 1; @@ -5054,13 +5046,13 @@ static int get_lit_string_tv(char_u **arg, typval_T *rettv, int evaluate) } /// @return the function name of the partial. -char_u *partial_name(partial_T *pt) +char *partial_name(partial_T *pt) FUNC_ATTR_PURE { if (pt->pt_name != NULL) { - return pt->pt_name; + return (char *)pt->pt_name; } - return pt->pt_func->uf_name; + return (char *)pt->pt_func->uf_name; } // TODO(ZyX-I): Move to eval/typval.h @@ -5095,7 +5087,7 @@ void partial_unref(partial_T *pt) /// Allocate a variable for a List and fill it from "*arg". /// /// @return OK or FAIL. -static int get_list_tv(char_u **arg, typval_T *rettv, int evaluate) +static int get_list_tv(char **arg, typval_T *rettv, int evaluate) { list_T *l = NULL; @@ -5103,7 +5095,7 @@ static int get_list_tv(char_u **arg, typval_T *rettv, int evaluate) l = tv_list_alloc(kListLenShouldKnow); } - *arg = skipwhite(*arg + 1); + *arg = (char *)skipwhite((char_u *)(*arg) + 1); while (**arg != ']' && **arg != NUL) { typval_T tv; if (eval1(arg, &tv, evaluate) == FAIL) { // Recursive! @@ -5121,7 +5113,7 @@ static int get_list_tv(char_u **arg, typval_T *rettv, int evaluate) semsg(_("E696: Missing comma in List: %s"), *arg); goto failret; } - *arg = skipwhite(*arg + 1); + *arg = (char *)skipwhite((char_u *)(*arg) + 1); } if (**arg != ']') { @@ -5133,7 +5125,7 @@ failret: return FAIL; } - *arg = skipwhite(*arg + 1); + *arg = (char *)skipwhite((char_u *)(*arg) + 1); if (evaluate) { tv_list_set_ret(rettv, l); } @@ -5150,12 +5142,12 @@ bool func_equal(typval_T *tv1, typval_T *tv2, bool ic) // empty and NULL function name considered the same s1 = tv1->v_type == VAR_FUNC ? tv1->vval.v_string - : partial_name(tv1->vval.v_partial); + : (char_u *)partial_name(tv1->vval.v_partial); if (s1 != NULL && *s1 == NUL) { s1 = NULL; } s2 = tv2->v_type == VAR_FUNC ? tv2->vval.v_string - : partial_name(tv2->vval.v_partial); + : (char_u *)partial_name(tv2->vval.v_partial); if (s2 != NULL && *s2 == NUL) { s2 = NULL; } @@ -5698,19 +5690,19 @@ static inline bool set_ref_dict(dict_T *dict, int copyID) /// Get the key for *{key: val} into "tv" and advance "arg". /// /// @return FAIL when there is no valid key. -static int get_literal_key(char_u **arg, typval_T *tv) +static int get_literal_key(char **arg, typval_T *tv) FUNC_ATTR_NONNULL_ALL { - char_u *p; + char *p; if (!ASCII_ISALNUM(**arg) && **arg != '_' && **arg != '-') { return FAIL; } for (p = *arg; ASCII_ISALNUM(*p) || *p == '_' || *p == '-'; p++) {} tv->v_type = VAR_STRING; - tv->vval.v_string = vim_strnsave(*arg, p - *arg); + tv->vval.v_string = vim_strnsave((char_u *)(*arg), p - *arg); - *arg = skipwhite(p); + *arg = (char *)skipwhite((char_u *)p); return OK; } @@ -5718,14 +5710,14 @@ static int get_literal_key(char_u **arg, typval_T *tv) /// "literal" is true for *{key: val} /// /// @return OK or FAIL. Returns NOTDONE for {expr}. -static int dict_get_tv(char_u **arg, typval_T *rettv, int evaluate, bool literal) +static int dict_get_tv(char **arg, typval_T *rettv, int evaluate, bool literal) { dict_T *d = NULL; typval_T tvkey; typval_T tv; - char_u *key = NULL; + char *key = NULL; dictitem_T *item; - char_u *start = skipwhite(*arg + 1); + char *start = (char *)skipwhite((char_u *)(*arg) + 1); char buf[NUMBUFLEN]; /* @@ -5739,7 +5731,7 @@ static int dict_get_tv(char_u **arg, typval_T *rettv, int evaluate, bool literal if (eval1(&start, &tv, false) == FAIL) { // recursive! return FAIL; } - if (*skipwhite(start) == '}') { + if (*skipwhite((char_u *)start) == '}') { return NOTDONE; } } @@ -5750,7 +5742,7 @@ static int dict_get_tv(char_u **arg, typval_T *rettv, int evaluate, bool literal tvkey.v_type = VAR_UNKNOWN; tv.v_type = VAR_UNKNOWN; - *arg = skipwhite(*arg + 1); + *arg = (char *)skipwhite((char_u *)(*arg) + 1); while (**arg != '}' && **arg != NUL) { if ((literal ? get_literal_key(arg, &tvkey) @@ -5763,7 +5755,7 @@ static int dict_get_tv(char_u **arg, typval_T *rettv, int evaluate, bool literal goto failret; } if (evaluate) { - key = (char_u *)tv_get_string_buf_chk(&tvkey, buf); + key = (char *)tv_get_string_buf_chk(&tvkey, buf); if (key == NULL) { // "key" is NULL when tv_get_string_buf_chk() gave an errmsg tv_clear(&tvkey); @@ -5771,7 +5763,7 @@ static int dict_get_tv(char_u **arg, typval_T *rettv, int evaluate, bool literal } } - *arg = skipwhite(*arg + 1); + *arg = (char *)skipwhite((char_u *)(*arg) + 1); if (eval1(arg, &tv, evaluate) == FAIL) { // Recursive! if (evaluate) { tv_clear(&tvkey); @@ -5802,7 +5794,7 @@ static int dict_get_tv(char_u **arg, typval_T *rettv, int evaluate, bool literal semsg(_("E722: Missing comma in Dictionary: %s"), *arg); goto failret; } - *arg = skipwhite(*arg + 1); + *arg = (char *)skipwhite((char_u *)(*arg) + 1); } if (**arg != '}') { @@ -5814,7 +5806,7 @@ failret: return FAIL; } - *arg = skipwhite(*arg + 1); + *arg = (char *)skipwhite((char_u *)(*arg) + 1); if (evaluate) { tv_dict_set_ret(rettv, d); } @@ -5860,37 +5852,37 @@ size_t string2float(const char *const text, float_T *const ret_value) /// @param arg Points to the '$'. It is advanced to after the name. /// /// @return FAIL if the name is invalid. -static int get_env_tv(char_u **arg, typval_T *rettv, int evaluate) +static int get_env_tv(char **arg, typval_T *rettv, int evaluate) { - char_u *name; - char_u *string = NULL; + char *name; + char *string = NULL; int len; int cc; ++*arg; name = *arg; - len = get_env_len((const char_u **)arg); + len = get_env_len((const char **)arg); if (evaluate) { if (len == 0) { return FAIL; // Invalid empty name. } - cc = name[len]; + cc = (char_u)name[len]; name[len] = NUL; // First try vim_getenv(), fast for normal environment vars. - string = (char_u *)vim_getenv((char *)name); + string = vim_getenv(name); if (string == NULL || *string == NUL) { xfree(string); // Next try expanding things like $VIM and ${HOME}. - string = expand_env_save(name - 1); + string = (char *)expand_env_save((char_u *)name - 1); if (string != NULL && *string == '$') { XFREE_CLEAR(string); } } name[len] = cc; rettv->v_type = VAR_STRING; - rettv->vval.v_string = string; + rettv->vval.v_string = (char_u *)string; } return OK; @@ -5948,7 +5940,7 @@ void filter_map(typval_T *argvars, typval_T *rettv, int map) blob_T *b = NULL; int rem = false; int todo; - char_u *ermsg = (char_u *)(map ? "map()" : "filter()"); + char *ermsg = map ? "map()" : "filter()"; const char *const arg_errmsg = (map ? N_("map() argument") : N_("filter() argument")); @@ -6050,7 +6042,7 @@ void filter_map(typval_T *argvars, typval_T *rettv, int map) tv_blob_set(b, i, tv.vval.v_number); } } else if (rem) { - char_u *const p = (char_u *)argvars[0].vval.v_blob->bv_ga.ga_data; + char *const p = argvars[0].vval.v_blob->bv_ga.ga_data; memmove(p + i, p + i + 1, (size_t)b->bv_ga.ga_len - i - 1); b->bv_ga.ga_len--; i--; @@ -6131,15 +6123,15 @@ theend: void common_function(typval_T *argvars, typval_T *rettv, bool is_funcref, FunPtr fptr) { - char_u *s; - char_u *name; + char *s; + char *name; bool use_string = false; partial_T *arg_pt = NULL; - char_u *trans_name = NULL; + char *trans_name = NULL; if (argvars[0].v_type == VAR_FUNC) { // function(MyFunc, [arg], dict) - s = argvars[0].vval.v_string; + s = (char *)argvars[0].vval.v_string; } else if (argvars[0].v_type == VAR_PARTIAL && argvars[0].vval.v_partial != NULL) { // function(dict.MyFunc, [arg]) @@ -6148,15 +6140,15 @@ void common_function(typval_T *argvars, typval_T *rettv, bool is_funcref, FunPtr // TODO(bfredl): do the entire nlua_is_table_from_lua dance } else { // function('MyFunc', [arg], dict) - s = (char_u *)tv_get_string(&argvars[0]); + s = (char *)tv_get_string(&argvars[0]); use_string = true; } - if ((use_string && vim_strchr(s, AUTOLOAD_CHAR) == NULL) || is_funcref) { + if ((use_string && vim_strchr((char_u *)s, AUTOLOAD_CHAR) == NULL) || is_funcref) { name = s; - trans_name = trans_function_name(&name, false, - TFN_INT | TFN_QUIET | TFN_NO_AUTOLOAD - | TFN_NO_DEREF, NULL, NULL); + trans_name = (char *)trans_function_name((char_u **)&name, false, + TFN_INT | TFN_QUIET | TFN_NO_AUTOLOAD + | TFN_NO_DEREF, NULL, NULL); if (*name != NUL) { s = NULL; } @@ -6169,7 +6161,7 @@ void common_function(typval_T *argvars, typval_T *rettv, bool is_funcref, FunPtr // Don't check an autoload name for existence here. } else if (trans_name != NULL && (is_funcref - ? find_func(trans_name) == NULL + ? find_func((char_u *)trans_name) == NULL : !translated_function_exists((const char *)trans_name))) { semsg(_("E700: Unknown function: %s"), s); } else { @@ -6190,7 +6182,7 @@ void common_function(typval_T *argvars, typval_T *rettv, bool is_funcref, FunPtr STRCPY(name, sid_buf); STRCAT(name, s + off); } else { - name = vim_strsave(s); + name = xstrdup(s); } if (argvars[1].v_type != VAR_UNKNOWN) { @@ -6226,7 +6218,7 @@ void common_function(typval_T *argvars, typval_T *rettv, bool is_funcref, FunPtr if (tv_list_len(list) == 0) { arg_idx = 0; } else if (tv_list_len(list) > MAX_FUNC_ARGS) { - emsg_funcname((char *)e_toomanyarg, s); + emsg_funcname((char *)e_toomanyarg, (char_u *)s); xfree(name); goto theend; } @@ -6275,12 +6267,12 @@ void common_function(typval_T *argvars, typval_T *rettv, bool is_funcref, FunPtr func_ptr_ref(pt->pt_func); xfree(name); } else if (is_funcref) { - pt->pt_func = find_func(trans_name); + pt->pt_func = find_func((char_u *)trans_name); func_ptr_ref(pt->pt_func); xfree(name); } else { - pt->pt_name = name; - func_ref(name); + pt->pt_name = (char_u *)name; + func_ref((char_u *)name); } rettv->v_type = VAR_PARTIAL; @@ -6288,8 +6280,8 @@ void common_function(typval_T *argvars, typval_T *rettv, bool is_funcref, FunPtr } else { // result is a VAR_FUNC rettv->v_type = VAR_FUNC; - rettv->vval.v_string = name; - func_ref(name); + rettv->vval.v_string = (char_u *)name; + func_ref((char_u *)name); } } theend: @@ -6863,10 +6855,10 @@ void mapblock_fill_dict(dict_T *const dict, const mapblock_T *const mp, long buf void return_register(int regname, typval_T *rettv) { - char_u buf[2] = { regname, 0 }; + char buf[2] = { regname, 0 }; rettv->v_type = VAR_STRING; - rettv->vval.v_string = vim_strsave(buf); + rettv->vval.v_string = vim_strsave((char_u *)buf); } void screenchar_adjust_grid(ScreenGrid **grid, int *row, int *col) @@ -7201,23 +7193,23 @@ bool callback_from_typval(Callback *const callback, typval_T *const arg) && ascii_isdigit(*arg->vval.v_string)) { r = FAIL; } else if (arg->v_type == VAR_FUNC || arg->v_type == VAR_STRING) { - char_u *name = arg->vval.v_string; + char *name = (char *)arg->vval.v_string; if (name == NULL) { r = FAIL; } else if (*name == NUL) { callback->type = kCallbackNone; callback->data.funcref = NULL; } else { - func_ref(name); - callback->data.funcref = vim_strsave(name); + func_ref((char_u *)name); + callback->data.funcref = vim_strsave((char_u *)name); callback->type = kCallbackFuncref; } } else if (nlua_is_table_from_lua(arg)) { // TODO(tjdvries): UnifiedCallback - char_u *name = nlua_register_table_as_callable(arg); + char *name = (char *)nlua_register_table_as_callable(arg); if (name != NULL) { - callback->data.funcref = vim_strsave(name); + callback->data.funcref = vim_strsave((char_u *)name); callback->type = kCallbackFuncref; } else { r = FAIL; @@ -7242,12 +7234,12 @@ bool callback_call(Callback *const callback, const int argcount_in, typval_T *co FUNC_ATTR_NONNULL_ALL { partial_T *partial; - char_u *name; + char *name; Array args = ARRAY_DICT_INIT; Object rv; switch (callback->type) { case kCallbackFuncref: - name = callback->data.funcref; + name = (char *)callback->data.funcref; partial = NULL; break; @@ -7278,7 +7270,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(name, -1, rettv, argcount_in, argvars_in, &funcexe); + return call_func((char_u *)name, -1, rettv, argcount_in, argvars_in, &funcexe); } static bool set_ref_in_callback(Callback *callback, int copyID, ht_stack_T **ht_stack, @@ -7615,7 +7607,7 @@ char *save_tv_as_string(typval_T *tv, ptrdiff_t *const len, bool endnl) buf_T *buf = buflist_findnr(tv->vval.v_number); if (buf) { for (linenr_T lnum = 1; lnum <= buf->b_ml.ml_line_count; lnum++) { - for (char_u *p = ml_get_buf(buf, lnum, false); *p != NUL; p++) { + for (char *p = (char *)ml_get_buf(buf, lnum, false); *p != NUL; p++) { *len += 1; } *len += 1; @@ -7633,7 +7625,7 @@ char *save_tv_as_string(typval_T *tv, ptrdiff_t *const len, bool endnl) char *ret = xmalloc(*len + 1); char *end = ret; for (linenr_T lnum = 1; lnum <= buf->b_ml.ml_line_count; lnum++) { - for (char_u *p = ml_get_buf(buf, lnum, false); *p != NUL; p++) { + for (char *p = (char *)ml_get_buf(buf, lnum, false); *p != NUL; p++) { *end++ = (*p == '\n') ? NUL : *p; } *end++ = '\n'; @@ -7682,17 +7674,17 @@ int buf_byteidx_to_charidx(buf_T *buf, int lnum, int byteidx) lnum = buf->b_ml.ml_line_count; } - char_u *str = ml_get_buf(buf, lnum, false); + char *str = (char *)ml_get_buf(buf, lnum, false); if (*str == NUL) { return 0; } // count the number of characters - char_u *t = str; + char *t = str; int count; for (count = 0; *t != NUL && t <= str + byteidx; count++) { - t += utfc_ptr2len(t); + t += utfc_ptr2len((char_u *)t); } // In insert mode, when the cursor is at the end of a non-empty line, @@ -7720,12 +7712,12 @@ int buf_charidx_to_byteidx(buf_T *buf, int lnum, int charidx) lnum = buf->b_ml.ml_line_count; } - char_u *str = ml_get_buf(buf, lnum, false); + char *str = (char *)ml_get_buf(buf, lnum, false); // Convert the character offset to a byte offset - char_u *t = str; + char *t = str; while (*t != NUL && --charidx > 0) { - t += utfc_ptr2len(t); + t += utfc_ptr2len((char_u *)t); } return t - str; @@ -7938,11 +7930,11 @@ int list2fpos(typval_T *arg, pos_T *posp, int *fnump, colnr_T *curswantp, bool c /// Advance "arg" to the first character after the name. /// /// @return 0 for error. -static int get_env_len(const char_u **arg) +static int get_env_len(const char **arg) { int len; - const char_u *p; + const char *p; for (p = *arg; vim_isIDc(*p); p++) {} if (p == *arg) { // No name found. return 0; @@ -7970,7 +7962,7 @@ int get_id_len(const char **const arg) // slice "[n:]". Also "xx:" is not a namespace. len = (int)(p - *arg); if (len > 1 - || (len == 1 && vim_strchr(namespace_char, **arg) == NULL)) { + || (len == 1 && vim_strchr((char_u *)namespace_char, **arg) == NULL)) { break; } } @@ -8013,12 +8005,10 @@ int get_name_len(const char **const arg, char **alias, bool evaluate, bool verbo } // Find the end of the name; check for {} construction. - char_u *expr_start; - char_u *expr_end; - const char *p = (const char *)find_name_end((char_u *)(*arg), - (const char_u **)&expr_start, - (const char_u **)&expr_end, - len > 0 ? 0 : FNE_CHECK_START); + char *expr_start; + char *expr_end; + const char *p = find_name_end((*arg), (const char **)&expr_start, (const char **)&expr_end, + len > 0 ? 0 : FNE_CHECK_START); if (expr_start != NULL) { if (!evaluate) { len += (int)(p - *arg); @@ -8030,12 +8020,11 @@ int get_name_len(const char **const arg, char **alias, bool evaluate, bool verbo * Include any <SID> etc in the expanded string: * Thus the -len here. */ - char_u *temp_string = make_expanded_name((char_u *)(*arg) - len, expr_start, - expr_end, (char_u *)p); + char *temp_string = make_expanded_name(*arg - len, expr_start, expr_end, (char *)p); if (temp_string == NULL) { return -1; } - *alias = (char *)temp_string; + *alias = temp_string; *arg = (const char *)skipwhite((const char_u *)p); return (int)STRLEN(temp_string); } @@ -8059,8 +8048,8 @@ int get_name_len(const char **const arg, char **alias, bool evaluate, bool verbo /// /// @return a pointer to just after the name. Equal to "arg" if there is no /// valid name. -const char_u *find_name_end(const char_u *arg, const char_u **expr_start, const char_u **expr_end, - int flags) +const char *find_name_end(const char *arg, const char **expr_start, const char **expr_end, + int flags) { int mb_nest = 0; int br_nest = 0; @@ -8076,7 +8065,7 @@ const char_u *find_name_end(const char_u *arg, const char_u **expr_start, const return arg; } - const char_u *p; + const char *p; for (p = arg; *p != NUL && (eval_isnamec(*p) || *p == '{' @@ -8104,7 +8093,7 @@ const char_u *find_name_end(const char_u *arg, const char_u **expr_start, const // slice "[n:]". Also "xx:" is not a namespace. But {ns}: is. len = (int)(p - arg); if ((len > 1 && p[-1] != '}') - || (len == 1 && vim_strchr(namespace_char, *arg) == NULL)) { + || (len == 1 && vim_strchr((char_u *)namespace_char, *arg) == NULL)) { break; } } @@ -8146,13 +8135,13 @@ const char_u *find_name_end(const char_u *arg, const char_u **expr_start, const /// /// @return a new allocated string, which the caller must free or /// NULL for failure. -static char_u *make_expanded_name(const char_u *in_start, char_u *expr_start, char_u *expr_end, - char_u *in_end) +static char *make_expanded_name(const char *in_start, char *expr_start, char *expr_end, + char *in_end) { - char_u c1; - char_u *retval = NULL; - char_u *temp_result; - char_u *nextcmd = NULL; + char c1; + char *retval = NULL; + char *temp_result; + char *nextcmd = NULL; if (expr_end == NULL || in_end == NULL) { return NULL; @@ -8177,9 +8166,9 @@ static char_u *make_expanded_name(const char_u *in_start, char_u *expr_start, ch *expr_end = '}'; if (retval != NULL) { - temp_result = (char_u *)find_name_end(retval, - (const char_u **)&expr_start, - (const char_u **)&expr_end, 0); + temp_result = (char *)find_name_end(retval, + (const char **)&expr_start, + (const char **)&expr_end, 0); if (expr_start != NULL) { // Further expansion! temp_result = make_expanded_name(retval, expr_start, @@ -8379,13 +8368,13 @@ void set_reg_var(int c) /// Otherwise, restore the value to "oldval" and return NULL. /// Must always be called in pairs to save and restore v:exception! Does not /// take care of memory allocations. -char_u *v_exception(char_u *oldval) +char *v_exception(char *oldval) { if (oldval == NULL) { - return vimvars[VV_EXCEPTION].vv_str; + return (char *)vimvars[VV_EXCEPTION].vv_str; } - vimvars[VV_EXCEPTION].vv_str = oldval; + vimvars[VV_EXCEPTION].vv_str = (char_u *)oldval; return NULL; } @@ -8393,13 +8382,13 @@ char_u *v_exception(char_u *oldval) /// Otherwise, restore the value to "oldval" and return NULL. /// Must always be called in pairs to save and restore v:throwpoint! Does not /// take care of memory allocations. -char_u *v_throwpoint(char_u *oldval) +char *v_throwpoint(char *oldval) { if (oldval == NULL) { - return vimvars[VV_THROWPOINT].vv_str; + return (char *)vimvars[VV_THROWPOINT].vv_str; } - vimvars[VV_THROWPOINT].vv_str = oldval; + vimvars[VV_THROWPOINT].vv_str = (char_u *)oldval; return NULL; } @@ -8407,12 +8396,12 @@ char_u *v_throwpoint(char_u *oldval) /// If "eap" != NULL, use "eap" to generate the value and return the old value. /// If "oldarg" != NULL, restore the value to "oldarg" and return NULL. /// Must always be called in pairs! -char_u *set_cmdarg(exarg_T *eap, char_u *oldarg) +char *set_cmdarg(exarg_T *eap, char *oldarg) { - char_u *oldval = vimvars[VV_CMDARG].vv_str; + char *oldval = (char *)vimvars[VV_CMDARG].vv_str; if (eap == NULL) { xfree(oldval); - vimvars[VV_CMDARG].vv_str = oldarg; + vimvars[VV_CMDARG].vv_str = (char_u *)oldarg; return NULL; } @@ -8438,12 +8427,12 @@ char_u *set_cmdarg(exarg_T *eap, char_u *oldarg) } const size_t newval_len = len + 1; - char_u *newval = xmalloc(newval_len); + char *newval = xmalloc(newval_len); if (eap->force_bin == FORCE_BIN) { - snprintf((char *)newval, newval_len, " ++bin"); + snprintf(newval, newval_len, " ++bin"); } else if (eap->force_bin == FORCE_NOBIN) { - snprintf((char *)newval, newval_len, " ++nobin"); + snprintf(newval, newval_len, " ++nobin"); } else { *newval = NUL; } @@ -8453,12 +8442,12 @@ char_u *set_cmdarg(exarg_T *eap, char_u *oldarg) } if (eap->force_ff != 0) { - snprintf((char *)newval + STRLEN(newval), newval_len, " ++ff=%s", + snprintf(newval + STRLEN(newval), newval_len, " ++ff=%s", eap->force_ff == 'u' ? "unix" : eap->force_ff == 'd' ? "dos" : "mac"); } if (eap->force_enc != 0) { - snprintf((char *)newval + STRLEN(newval), newval_len, " ++enc=%s", + snprintf(newval + STRLEN(newval), newval_len, " ++enc=%s", eap->cmd + eap->force_enc); } if (eap->bad_char == BAD_KEEP) { @@ -8466,10 +8455,10 @@ char_u *set_cmdarg(exarg_T *eap, char_u *oldarg) } else if (eap->bad_char == BAD_DROP) { STRCPY(newval + STRLEN(newval), " ++bad=drop"); } else if (eap->bad_char != 0) { - snprintf((char *)newval + STRLEN(newval), newval_len, " ++bad=%c", + snprintf(newval + STRLEN(newval), newval_len, " ++bad=%c", eap->bad_char); } - vimvars[VV_CMDARG].vv_str = newval; + vimvars[VV_CMDARG].vv_str = (char_u *)newval; return oldval; } @@ -8576,11 +8565,11 @@ int check_luafunc_name(const char *const str, const bool paren) /// @param start_leader start of '!' and '-' prefixes /// @param end_leaderp end of '!' and '-' prefixes int handle_subscript(const char **const arg, typval_T *rettv, int evaluate, int verbose, - const char_u *const start_leader, const char_u **const end_leaderp) + const char *const start_leader, const char **const end_leaderp) { int ret = OK; dict_T *selfdict = NULL; - const char_u *lua_funcname = NULL; + const char *lua_funcname = NULL; if (tv_is_luafunc(rettv)) { if (**arg != '.') { @@ -8589,7 +8578,7 @@ int handle_subscript(const char **const arg, typval_T *rettv, int evaluate, int } else { (*arg)++; - lua_funcname = (char_u *)(*arg); + lua_funcname = *arg; const int len = check_luafunc_name(*arg, true); if (len == 0) { tv_clear(rettv); @@ -8606,8 +8595,7 @@ int handle_subscript(const char **const arg, typval_T *rettv, int evaluate, int && !ascii_iswhite(*(*arg - 1))) || (**arg == '-' && (*arg)[1] == '>'))) { if (**arg == '(') { - ret = call_func_rettv((char_u **)arg, rettv, evaluate, selfdict, NULL, - lua_funcname); + ret = call_func_rettv((char **)arg, rettv, evaluate, selfdict, NULL, lua_funcname); // Stop the expression evaluation when immediately aborting on // error, or when an interrupt occurred or an exception was thrown @@ -8624,15 +8612,15 @@ int handle_subscript(const char **const arg, typval_T *rettv, int evaluate, int // Expression "-1.0->method()" applies the leader "-" before // applying ->. if (evaluate && *end_leaderp > start_leader) { - ret = eval7_leader(rettv, start_leader, end_leaderp); + ret = eval7_leader(rettv, (char *)start_leader, end_leaderp); } if (ret == OK) { if ((*arg)[2] == '{') { // expr->{lambda}() - ret = eval_lambda((char_u **)arg, rettv, evaluate, verbose); + ret = eval_lambda((char **)arg, rettv, evaluate, verbose); } else { // expr->name() - ret = eval_method((char_u **)arg, rettv, evaluate, verbose); + ret = eval_method((char **)arg, rettv, evaluate, verbose); } } } else { // **arg == '[' || **arg == '.' @@ -8645,7 +8633,7 @@ int handle_subscript(const char **const arg, typval_T *rettv, int evaluate, int } else { selfdict = NULL; } - if (eval_index((char_u **)arg, rettv, evaluate, verbose) == FAIL) { + if (eval_index((char **)arg, rettv, evaluate, verbose) == FAIL) { tv_clear(rettv); ret = FAIL; } @@ -8849,8 +8837,8 @@ static hashtab_T *find_var_ht_dict(const char *name, const size_t name_len, cons bool should_free; // should_free is ignored as script_sctx will be resolved to a fnmae // & new_script_item will consume it. - char_u *sc_name = get_scriptname(last_set, &should_free); - new_script_item(sc_name, ¤t_sctx.sc_sid); + char *sc_name = (char *)get_scriptname(last_set, &should_free); + new_script_item((char_u *)sc_name, ¤t_sctx.sc_sid); } } if (current_sctx.sc_sid == SID_STR || current_sctx.sc_sid == SID_LUA) { @@ -9434,7 +9422,7 @@ int var_item_copy(const vimconv_T *const conv, typval_T *const from, typval_T *c /// ":echon expr1 ..." print each argument plain. void ex_echo(exarg_T *eap) { - char_u *arg = eap->arg; + char *arg = (char *)eap->arg; typval_T rettv; bool atstart = true; bool need_clear = true; @@ -9450,7 +9438,7 @@ void ex_echo(exarg_T *eap) need_clr_eos = true; { - char_u *p = arg; + char *p = arg; if (eval1(&arg, &rettv, !eap->skip) == FAIL) { // Report the invalid expression unless the expression evaluation // has been cancelled due to an aborting error, an interrupt, or an @@ -9488,9 +9476,9 @@ void ex_echo(exarg_T *eap) xfree(tofree); } tv_clear(&rettv); - arg = skipwhite(arg); + arg = (char *)skipwhite((char_u *)arg); } - eap->nextcmd = check_nextcmd(arg); + eap->nextcmd = check_nextcmd((char_u *)arg); if (eap->skip) { emsg_skip--; @@ -9518,7 +9506,7 @@ void ex_echohl(exarg_T *eap) /// echo commands void ex_execute(exarg_T *eap) { - char_u *arg = eap->arg; + char *arg = (char *)eap->arg; typval_T rettv; int ret = OK; garray_T ga; @@ -9554,7 +9542,7 @@ void ex_execute(exarg_T *eap) } tv_clear(&rettv); - arg = skipwhite(arg); + arg = (char *)skipwhite((char_u *)arg); } if (ret != FAIL && ga.ga_data != NULL) { @@ -9588,7 +9576,7 @@ void ex_execute(exarg_T *eap) --emsg_skip; } - eap->nextcmd = check_nextcmd(arg); + eap->nextcmd = check_nextcmd((char_u *)arg); } /// Skip over the name of an option: "&option", "&g:option" or "&l:option". @@ -9693,7 +9681,7 @@ void func_dump_profile(FILE *fd) .script_ctx = fp->uf_script_ctx, .channel_id = 0, }; - char_u *p = get_scriptname(last_set, &should_free); + char *p = (char *)get_scriptname(last_set, &should_free); fprintf(fd, " Defined: %s:%" PRIdLINENR "\n", p, fp->uf_script_ctx.sc_lnum); if (should_free) { @@ -9924,10 +9912,10 @@ void func_line_end(void *cookie) } } -static var_flavour_T var_flavour(char_u *varname) +static var_flavour_T var_flavour(char *varname) FUNC_ATTR_PURE { - char_u *p = varname; + char *p = varname; if (ASCII_ISUPPER(*p)) { while (*(++p)) { @@ -9964,7 +9952,7 @@ const void *var_shada_iter(const void *const iter, const char **const name, typv hi = globvarht.ht_array; while ((size_t)(hi - hifirst) < hinum && (HASHITEM_EMPTY(hi) - || !(var_flavour(hi->hi_key) & flavour))) { + || !(var_flavour((char *)hi->hi_key) & flavour))) { hi++; } if ((size_t)(hi - hifirst) == hinum) { @@ -9976,7 +9964,7 @@ const void *var_shada_iter(const void *const iter, const char **const name, typv *name = (char *)TV_DICT_HI2DI(hi)->di_key; tv_copy(&TV_DICT_HI2DI(hi)->di_tv, rettv); while ((size_t)(++hi - hifirst) < hinum) { - if (!HASHITEM_EMPTY(hi) && (var_flavour(hi->hi_key) & flavour)) { + if (!HASHITEM_EMPTY(hi) && (var_flavour((char *)hi->hi_key) & flavour)) { return hi; } } @@ -9997,12 +9985,12 @@ int store_session_globals(FILE *fd) TV_DICT_ITER(&globvardict, this_var, { if ((this_var->di_tv.v_type == VAR_NUMBER || this_var->di_tv.v_type == VAR_STRING) - && var_flavour(this_var->di_key) == VAR_FLAVOUR_SESSION) { + && 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_u *const p = vim_strsave_escaped((const char_u *)tv_get_string(&this_var->di_tv), - (const char_u *)"\\\"\n\r"); - for (char_u *t = p; *t != NUL; t++) { + char *const p = (char *)vim_strsave_escaped((const char_u *)tv_get_string(&this_var->di_tv), + (const char_u *)"\\\"\n\r"); + for (char *t = p; *t != NUL; t++) { if (*t == '\n') { *t = 'n'; } else if (*t == '\r') { @@ -10022,7 +10010,7 @@ int store_session_globals(FILE *fd) } xfree(p); } else if (this_var->di_tv.v_type == VAR_FLOAT - && var_flavour(this_var->di_key) == VAR_FLAVOUR_SESSION) { + && var_flavour((char *)this_var->di_key) == VAR_FLAVOUR_SESSION) { float_T f = this_var->di_tv.vval.v_float; int sign = ' '; @@ -10057,10 +10045,10 @@ void option_last_set_msg(LastSet last_set) { if (last_set.script_ctx.sc_sid != 0) { bool should_free; - char_u *p = get_scriptname(last_set, &should_free); + char *p = (char *)get_scriptname(last_set, &should_free); verbose_enter(); msg_puts(_("\n\tLast set from ")); - msg_puts((char *)p); + msg_puts(p); if (last_set.script_ctx.sc_lnum > 0) { msg_puts(_(line_msg)); msg_outnum((long)last_set.script_ctx.sc_lnum); @@ -10096,13 +10084,13 @@ void reset_v_option_vars(void) /// @param fnamep file name so far /// @param bufp buffer for allocated file name or NULL /// @param fnamelen length of fnamep -int modify_fname(char_u *src, bool tilde_file, size_t *usedlen, char_u **fnamep, char_u **bufp, +int modify_fname(char *src, bool tilde_file, size_t *usedlen, char **fnamep, char **bufp, size_t *fnamelen) { int valid = 0; - char_u *tail; - char_u *s, *p, *pbuf; - char_u dirname[MAXPATHL]; + char *tail; + char *s, *p, *pbuf; + char dirname[MAXPATHL]; int c; bool has_fullname = false; bool has_homerelative = false; @@ -10125,7 +10113,7 @@ repeat: || (*fnamep)[1] == NUL) #endif && !(tilde_file && (*fnamep)[1] == NUL)) { - *fnamep = expand_env_save(*fnamep); + *fnamep = (char *)expand_env_save((char_u *)(*fnamep)); xfree(*bufp); // free any allocated file name *bufp = *fnamep; if (*fnamep == NULL) { @@ -10146,8 +10134,8 @@ repeat: } // FullName_save() is slow, don't use it when not needed. - if (*p != NUL || !vim_isAbsName(*fnamep)) { - *fnamep = (char_u *)FullName_save((char *)(*fnamep), *p != NUL); + if (*p != NUL || !vim_isAbsName((char_u *)(*fnamep))) { + *fnamep = FullName_save((*fnamep), *p != NUL); xfree(*bufp); // free any allocated file name *bufp = *fnamep; if (*fnamep == NULL) { @@ -10156,15 +10144,15 @@ repeat: } // Append a path separator to a directory. - if (os_isdir(*fnamep)) { + if (os_isdir((char_u *)(*fnamep))) { // Make room for one or two extra characters. - *fnamep = vim_strnsave(*fnamep, STRLEN(*fnamep) + 2); + *fnamep = xstrnsave(*fnamep, STRLEN(*fnamep) + 2); xfree(*bufp); // free any allocated file name *bufp = *fnamep; if (*fnamep == NULL) { return -1; } - add_pathsep((char *)*fnamep); + add_pathsep(*fnamep); } } @@ -10172,7 +10160,7 @@ repeat: // ":~" - path relative to the home directory // ":8" - shortname path - postponed till after while (src[*usedlen] == ':' - && ((c = src[*usedlen + 1]) == '.' || c == '~' || c == '8')) { + && ((c = (char_u)src[*usedlen + 1]) == '.' || c == '~' || c == '8')) { *usedlen += 2; if (c == '8') { continue; @@ -10181,9 +10169,9 @@ repeat: // Need full path first (use expand_env() to remove a "~/") if (!has_fullname && !has_homerelative) { if (**fnamep == '~') { - p = pbuf = expand_env_save(*fnamep); + p = pbuf = (char *)expand_env_save((char_u *)(*fnamep)); } else { - p = pbuf = (char_u *)FullName_save((char *)*fnamep, FALSE); + p = pbuf = FullName_save(*fnamep, false); } } else { p = *fnamep; @@ -10193,10 +10181,10 @@ repeat: if (p != NULL) { if (c == '.') { - os_dirname(dirname, MAXPATHL); + os_dirname((char_u *)dirname, MAXPATHL); if (has_homerelative) { - s = vim_strsave(dirname); - home_replace(NULL, s, dirname, MAXPATHL, true); + s = xstrdup(dirname); + home_replace(NULL, (char_u *)s, (char_u *)dirname, MAXPATHL, true); xfree(s); } size_t namelen = STRLEN(dirname); @@ -10219,10 +10207,10 @@ repeat: } } } else { - home_replace(NULL, p, dirname, MAXPATHL, true); + home_replace(NULL, (char_u *)p, (char_u *)dirname, MAXPATHL, true); // Only replace it when it starts with '~' if (*dirname == '~') { - s = vim_strsave(dirname); + s = xstrdup(dirname); *fnamep = s; xfree(*bufp); *bufp = s; @@ -10233,7 +10221,7 @@ repeat: } } - tail = path_tail(*fnamep); + tail = (char *)path_tail((char_u *)(*fnamep)); *fnamelen = STRLEN(*fnamep); // ":h" - head, remove "/file_name", can be repeated @@ -10241,18 +10229,18 @@ repeat: while (src[*usedlen] == ':' && src[*usedlen + 1] == 'h') { valid |= VALID_HEAD; *usedlen += 2; - s = get_past_head(*fnamep); - while (tail > s && after_pathsep((char *)s, (char *)tail)) { + s = (char *)get_past_head((char_u *)(*fnamep)); + while (tail > s && after_pathsep(s, tail)) { MB_PTR_BACK(*fnamep, tail); } *fnamelen = (size_t)(tail - *fnamep); if (*fnamelen == 0) { // Result is empty. Turn it into "." to make ":cd %:h" work. xfree(*bufp); - *bufp = *fnamep = tail = vim_strsave((char_u *)"."); + *bufp = *fnamep = tail = xstrdup("."); *fnamelen = 1; } else { - while (tail > s && !after_pathsep((char *)s, (char *)tail)) { + while (tail > s && !after_pathsep(s, tail)) { MB_PTR_BACK(*fnamep, tail); } } @@ -10281,9 +10269,9 @@ repeat: */ const bool is_second_e = *fnamep > tail; if (src[*usedlen + 1] == 'e' && is_second_e) { - s = *fnamep - 2; + s = (*fnamep) - 2; } else { - s = *fnamep + *fnamelen - 1; + s = (*fnamep) + *fnamelen - 1; } for (; s > tail; s--) { @@ -10294,7 +10282,7 @@ repeat: if (src[*usedlen + 1] == 'e') { if (s > tail || (0 && is_second_e && s == tail)) { // we stopped at a '.' (so anchor to &'.' + 1) - char_u *newstart = s + 1; + char *newstart = s + 1; size_t distance_stepped_back = *fnamep - newstart; *fnamelen += distance_stepped_back; *fnamep = newstart; @@ -10317,7 +10305,7 @@ repeat: // "path/to/this.file.ext" :r:r:r // ^ ^------------- tail // +--------------------- *fnamep - if (s > MAX(tail, *fnamep)) { + if (s > MAX(tail, (char *)(*fnamep))) { *fnamelen = (size_t)(s - *fnamep); } } @@ -10330,28 +10318,28 @@ repeat: && (src[*usedlen + 1] == 's' || (src[*usedlen + 1] == 'g' && src[*usedlen + 2] == 's'))) { int sep; - char_u *flags; - int didit = FALSE; + char *flags; + int didit = false; - flags = (char_u *)""; + flags = ""; s = src + *usedlen + 2; if (src[*usedlen + 1] == 'g') { - flags = (char_u *)"g"; - ++s; + flags = "g"; + s++; } - sep = *s++; + sep = (char_u)(*s++); if (sep) { // find end of pattern - p = vim_strchr(s, sep); + p = (char *)vim_strchr((char_u *)s, sep); if (p != NULL) { - char_u *const pat = vim_strnsave(s, p - s); + char *const pat = xstrnsave(s, p - s); s = p + 1; // find end of substitution - p = vim_strchr(s, sep); + p = (char *)vim_strchr((char_u *)s, sep); if (p != NULL) { - char_u *const sub = vim_strnsave(s, p - s); - char_u *const str = vim_strnsave(*fnamep, *fnamelen); + char *const sub = xstrnsave(s, p - s); + char *const str = xstrnsave(*fnamep, *fnamelen); *usedlen = (size_t)(p + 1 - src); s = do_string_sub(str, pat, sub, NULL, flags); *fnamep = s; @@ -10373,11 +10361,11 @@ repeat: if (src[*usedlen] == ':' && src[*usedlen + 1] == 'S') { // vim_strsave_shellescape() needs a NUL terminated string. - c = (*fnamep)[*fnamelen]; + c = (char_u)(*fnamep)[*fnamelen]; if (c != NUL) { (*fnamep)[*fnamelen] = NUL; } - p = vim_strsave_shellescape(*fnamep, false, false); + p = (char *)vim_strsave_shellescape((char_u *)(*fnamep), false, false); if (c != NUL) { (*fnamep)[*fnamelen] = c; } @@ -10395,19 +10383,19 @@ repeat: /// "flags" can be "g" to do a global substitute. /// /// @return an allocated string, NULL for error. -char_u *do_string_sub(char_u *str, char_u *pat, char_u *sub, typval_T *expr, char_u *flags) +char *do_string_sub(char *str, char *pat, char *sub, typval_T *expr, char *flags) { int sublen; regmatch_T regmatch; int do_all; - char_u *tail; - char_u *end; + char *tail; + char *end; garray_T ga; - char_u *save_cpo; - char_u *zero_width = NULL; + char *save_cpo; + char *zero_width = NULL; // Make 'cpoptions' empty, so that the 'l' flag doesn't work here - save_cpo = p_cpo; + save_cpo = (char *)p_cpo; p_cpo = empty_option; ga_init(&ga, 1, 200); @@ -10415,22 +10403,22 @@ char_u *do_string_sub(char_u *str, char_u *pat, char_u *sub, typval_T *expr, cha do_all = (flags[0] == 'g'); regmatch.rm_ic = p_ic; - regmatch.regprog = vim_regcomp(pat, RE_MAGIC + RE_STRING); + regmatch.regprog = vim_regcomp((char_u *)pat, RE_MAGIC + RE_STRING); if (regmatch.regprog != NULL) { tail = str; end = str + STRLEN(str); - while (vim_regexec_nl(®match, str, (colnr_T)(tail - str))) { + while (vim_regexec_nl(®match, (char_u *)str, (colnr_T)(tail - str))) { // Skip empty match except for first match. if (regmatch.startp[0] == regmatch.endp[0]) { - if (zero_width == regmatch.startp[0]) { + if ((char_u *)zero_width == regmatch.startp[0]) { // avoid getting stuck on a match with an empty string - int i = utfc_ptr2len(tail); + int i = utfc_ptr2len((char_u *)tail); memmove((char_u *)ga.ga_data + ga.ga_len, tail, (size_t)i); ga.ga_len += i; tail += i; continue; } - zero_width = regmatch.startp[0]; + zero_width = (char *)regmatch.startp[0]; } // Get some space for a temporary buffer to do the substitution @@ -10438,18 +10426,18 @@ char_u *do_string_sub(char_u *str, char_u *pat, char_u *sub, typval_T *expr, cha // - The text up to where the match is. // - The substituted text. // - The text after the match. - sublen = vim_regsub(®match, sub, expr, tail, false, true, false); + sublen = vim_regsub(®match, (char_u *)sub, expr, (char_u *)tail, false, true, false); ga_grow(&ga, (int)((end - tail) + sublen - (regmatch.endp[0] - regmatch.startp[0]))); // copy the text up to where the match is - int i = (int)(regmatch.startp[0] - tail); + int i = (int)(regmatch.startp[0] - (char_u *)tail); memmove((char_u *)ga.ga_data + ga.ga_len, tail, (size_t)i); // add the substituted text - (void)vim_regsub(®match, sub, expr, (char_u *)ga.ga_data + (void)vim_regsub(®match, (char_u *)sub, expr, (char_u *)ga.ga_data + ga.ga_len + i, true, true, false); ga.ga_len += i + sublen - 1; - tail = regmatch.endp[0]; + tail = (char *)regmatch.endp[0]; if (*tail == NUL) { break; } @@ -10465,13 +10453,13 @@ char_u *do_string_sub(char_u *str, char_u *pat, char_u *sub, typval_T *expr, cha vim_regfree(regmatch.regprog); } - char_u *ret = vim_strsave(ga.ga_data == NULL ? str : (char_u *)ga.ga_data); + char *ret = xstrdup(ga.ga_data == NULL ? str : ga.ga_data); ga_clear(&ga); if (p_cpo == empty_option) { - p_cpo = save_cpo; + p_cpo = (char_u *)save_cpo; } else { // Darn, evaluating {sub} expression or {expr} changed the value. - free_string_option(save_cpo); + free_string_option((char_u *)save_cpo); } return ret; @@ -10703,8 +10691,8 @@ void invoke_prompt_callback(void) { typval_T rettv; typval_T argv[2]; - char_u *text; - char_u *prompt; + char *text; + char *prompt; linenr_T lnum = curbuf->b_ml.ml_line_count; // Add a new line for the prompt before invoking the callback, so that @@ -10716,13 +10704,13 @@ void invoke_prompt_callback(void) if (curbuf->b_prompt_callback.type == kCallbackNone) { return; } - text = ml_get(lnum); - prompt = prompt_text(); + text = (char *)ml_get(lnum); + prompt = (char *)prompt_text(); if (STRLEN(text) >= STRLEN(prompt)) { text += STRLEN(prompt); } argv[0].v_type = VAR_STRING; - argv[0].vval.v_string = vim_strsave(text); + argv[0].vval.v_string = vim_strsave((char_u *)text); argv[1].v_type = VAR_UNKNOWN; callback_call(&curbuf->b_prompt_callback, 1, argv, &rettv); @@ -10942,7 +10930,7 @@ int typval_compare(typval_T *typ1, typval_T *typ2, exprtype_T type, bool ic) case EXPR_MATCH: case EXPR_NOMATCH: - n1 = pattern_match((char_u *)s2, (char_u *)s1, ic); + n1 = pattern_match((char *)s2, (char *)s1, ic); if (type == EXPR_NOMATCH) { n1 = !n1; } @@ -10983,9 +10971,7 @@ bool var_exists(const char *var) n = get_var_tv(name, len, &tv, NULL, false, true) == OK; if (n) { // Handle d.key, l[idx], f(expr). - n = handle_subscript(&var, &tv, true, false, (const char_u *)name, - (const char_u **)&name) - == OK; + n = handle_subscript(&var, &tv, true, false, name, &name) == OK; if (n) { tv_clear(&tv); } diff --git a/src/nvim/eval.h b/src/nvim/eval.h index 83e9c6370d..53f19b8736 100644 --- a/src/nvim/eval.h +++ b/src/nvim/eval.h @@ -62,7 +62,7 @@ typedef struct lval_S { long ll_n2; ///< Second index for list range. dict_T *ll_dict; ///< The Dictionary or NULL. dictitem_T *ll_di; ///< The dictitem or NULL. - char_u *ll_newkey; ///< New key for Dict in allocated memory or NULL. + char *ll_newkey; ///< New key for Dict in allocated memory or NULL. blob_T *ll_blob; ///< The Blob or NULL. } lval_T; @@ -266,7 +266,7 @@ typedef enum { kDictListItems, ///< List dictionary contents: [keys, values]. } DictListType; -typedef int (*ex_unletlock_callback)(lval_T *, char_u *, exarg_T *, int); +typedef int (*ex_unletlock_callback)(lval_T *, char *, exarg_T *, int); // Used for checking if local variables or arguments used in a lambda. extern bool *eval_lavars_used; diff --git a/src/nvim/eval/funcs.c b/src/nvim/eval/funcs.c index c6993d2ff8..88059ff21e 100644 --- a/src/nvim/eval/funcs.c +++ b/src/nvim/eval/funcs.c @@ -129,7 +129,7 @@ char_u *get_function_name(expand_T *xp, int idx) if (name != NULL) { if (*name != NUL && *name != '<' && STRNCMP("g:", xp->xp_pattern, 2) == 0) { - return cat_prefix_varname('g', name); + return (char_u *)cat_prefix_varname('g', (char *)name); } return name; } @@ -772,7 +772,7 @@ static void f_call(typval_T *argvars, typval_T *rettv, FunPtr fptr) func = argvars[0].vval.v_string; } else if (argvars[0].v_type == VAR_PARTIAL) { partial = argvars[0].vval.v_partial; - func = partial_name(partial); + func = (char_u *)partial_name(partial); } else if (nlua_is_table_from_lua(&argvars[0])) { // TODO(tjdevries): UnifiedCallback func = nlua_register_table_as_callable(&argvars[0]); @@ -1896,7 +1896,7 @@ static void f_eval(typval_T *argvars, typval_T *rettv, FunPtr fptr) } const char *const expr_start = s; - if (s == NULL || eval1((char_u **)&s, rettv, true) == FAIL) { + if (s == NULL || eval1((char **)&s, rettv, true) == FAIL) { if (expr_start != NULL && !aborting()) { semsg(_(e_invexpr2), expr_start); } @@ -2489,8 +2489,8 @@ static void f_fnamemodify(typval_T *argvars, typval_T *rettv, FunPtr fptr) len = strlen(fname); if (*mods != NUL) { size_t usedlen = 0; - (void)modify_fname((char_u *)mods, false, &usedlen, - (char_u **)&fname, &fbuf, &len); + (void)modify_fname((char *)mods, false, &usedlen, + (char **)&fname, (char **)&fbuf, &len); } } @@ -4886,11 +4886,11 @@ static void f_islocked(typval_T *argvars, typval_T *rettv, FunPtr fptr) dictitem_T *di; rettv->vval.v_number = -1; - const char_u *const end = get_lval((char_u *)tv_get_string(&argvars[0]), - NULL, - &lv, false, false, - GLV_NO_AUTOLOAD|GLV_READ_ONLY, - FNE_CHECK_START); + const char_u *const end = (char_u *)get_lval((char *)tv_get_string(&argvars[0]), + NULL, + &lv, false, false, + GLV_NO_AUTOLOAD|GLV_READ_ONLY, + FNE_CHECK_START); if (end != NULL && lv.ll_name != NULL) { if (*end != NUL) { emsg(_(e_trailing)); @@ -7506,7 +7506,7 @@ static void f_reduce(typval_T *argvars, typval_T *rettv, FunPtr fptr) func_name = argvars[1].vval.v_string; } else if (argvars[1].v_type == VAR_PARTIAL) { partial = argvars[1].vval.v_partial; - func_name = partial_name(partial); + func_name = (char_u *)partial_name(partial); } else { func_name = (const char_u *)tv_get_string(&argvars[1]); } @@ -10303,8 +10303,8 @@ static void f_substitute(typval_T *argvars, typval_T *rettv, FunPtr fptr) || flg == NULL) { rettv->vval.v_string = NULL; } else { - rettv->vval.v_string = do_string_sub((char_u *)str, (char_u *)pat, - (char_u *)sub, expr, (char_u *)flg); + rettv->vval.v_string = (char_u *)do_string_sub((char *)str, (char *)pat, + (char *)sub, expr, (char *)flg); } } diff --git a/src/nvim/eval/typval_encode.c.h b/src/nvim/eval/typval_encode.c.h index ece51cb046..42b0544ef9 100644 --- a/src/nvim/eval/typval_encode.c.h +++ b/src/nvim/eval/typval_encode.c.h @@ -343,8 +343,7 @@ static int _TYPVAL_ENCODE_CONVERT_ONE_VALUE( case VAR_PARTIAL: { partial_T *const pt = tv->vval.v_partial; (void)pt; - TYPVAL_ENCODE_CONV_FUNC_START( // -V547 - tv, (pt == NULL ? NULL : partial_name(pt))); + TYPVAL_ENCODE_CONV_FUNC_START(tv, (pt == NULL ? NULL : (char_u *)partial_name(pt))); // -V547 _mp_push(*mpstack, ((MPConvStackVal) { // -V779 .type = kMPConvPartial, .tv = tv, diff --git a/src/nvim/eval/userfunc.c b/src/nvim/eval/userfunc.c index 8b47468aad..0a35e6655f 100644 --- a/src/nvim/eval/userfunc.c +++ b/src/nvim/eval/userfunc.c @@ -132,7 +132,7 @@ static int get_function_args(char_u **argp, char_u endchar, garray_T *newargs, i p = skipwhite(p) + 1; p = skipwhite(p); char_u *expr = p; - if (eval1(&p, &rettv, false) != FAIL) { + if (eval1((char **)&p, &rettv, false) != FAIL) { ga_grow(default_args, 1); // trim trailing whitespace @@ -253,7 +253,7 @@ 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); s = *arg; - ret = skip_expr(arg); + ret = skip_expr((char **)arg); if (ret == FAIL) { goto errret; } @@ -372,7 +372,7 @@ char_u *deref_func_name(const char *name, int *lenp, partial_T **const partialp, if (partialp != NULL) { *partialp = pt; } - char_u *s = partial_name(pt); + char_u *s = (char_u *)partial_name(pt); *lenp = (int)STRLEN(s); return s; } @@ -426,7 +426,7 @@ int get_func_tv(const char_u *name, int len, typval_T *rettv, char_u **arg, func if (*argp == ')' || *argp == ',' || *argp == NUL) { break; } - if (eval1(&argp, &argvars[argcount], funcexe->evaluate) == FAIL) { + if (eval1((char **)&argp, &argvars[argcount], funcexe->evaluate) == FAIL) { ret = FAIL; break; } @@ -941,7 +941,7 @@ void call_user_func(ufunc_T *fp, int argcount, typval_T *argvars, typval_T *rett default_expr = ((char_u **)(fp->uf_def_args.ga_data)) [ai + fp->uf_def_args.ga_len]; - if (eval1(&default_expr, &def_rettv, true) == FAIL) { + if (eval1((char **)&default_expr, &def_rettv, true) == FAIL) { default_arg_err = true; break; } @@ -1103,7 +1103,7 @@ void call_user_func(ufunc_T *fp, int argcount, typval_T *argvars, typval_T *rett // A Lambda always has the command "return {expr}". It is much faster // to evaluate {expr} directly. ex_nesting_level++; - (void)eval1(&p, rettv, true); + (void)eval1((char **)&p, rettv, true); ex_nesting_level--; } else { // call do_cmdline() to execute the lines @@ -1150,18 +1150,18 @@ void call_user_func(ufunc_T *fp, int argcount, typval_T *argvars, typval_T *rett smsg(_("%s returning #%" PRId64 ""), sourcing_name, (int64_t)fc->rettv->vval.v_number); } else { - char_u buf[MSG_BUF_LEN]; + char buf[MSG_BUF_LEN]; // The value may be very long. Skip the middle part, so that we // have some idea how it starts and ends. smsg() would always // truncate it at the end. Don't want errors such as E724 here. emsg_off++; - char_u *s = (char_u *)encode_tv2string(fc->rettv, NULL); - char_u *tofree = s; + char *s = encode_tv2string(fc->rettv, NULL); + char *tofree = s; emsg_off--; if (s != NULL) { - if (vim_strsize(s) > MSG_BUF_CLEN) { - trunc_string(s, buf, MSG_BUF_CLEN, MSG_BUF_LEN); + if (vim_strsize((char_u *)s) > MSG_BUF_CLEN) { + trunc_string((char_u *)s, (char_u *)buf, MSG_BUF_CLEN, MSG_BUF_LEN); s = buf; } smsg(_("%s returning %s"), sourcing_name, s); @@ -1724,8 +1724,8 @@ char_u *trans_function_name(char_u **pp, bool skip, int flags, funcdict_T *fdp, } // Note that TFN_ flags use the same values as GLV_ flags. - end = get_lval((char_u *)start, NULL, &lv, false, skip, flags | GLV_READ_ONLY, - lead > 2 ? 0 : FNE_CHECK_START); + end = (char_u *)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")); @@ -1743,7 +1743,7 @@ char_u *trans_function_name(char_u **pp, bool skip, int flags, funcdict_T *fdp, semsg(_(e_invarg2), start); } } else { - *pp = (char_u *)find_name_end(start, NULL, NULL, FNE_INCL_BR); + *pp = (char_u *)find_name_end((char *)start, NULL, NULL, FNE_INCL_BR); } goto theend; } @@ -1751,7 +1751,7 @@ char_u *trans_function_name(char_u **pp, bool skip, int flags, funcdict_T *fdp, if (lv.ll_tv != NULL) { if (fdp != NULL) { fdp->fd_dict = lv.ll_dict; - fdp->fd_newkey = lv.ll_newkey; + fdp->fd_newkey = (char_u *)lv.ll_newkey; lv.ll_newkey = NULL; fdp->fd_di = lv.ll_di; } @@ -1770,7 +1770,7 @@ char_u *trans_function_name(char_u **pp, bool skip, int flags, funcdict_T *fdp, memcpy(name, end + 1, (size_t)len); *pp = (char_u *)end + 1 + len; } else { - name = vim_strsave(partial_name(lv.ll_tv->vval.v_partial)); + name = vim_strsave((char_u *)partial_name(lv.ll_tv->vval.v_partial)); *pp = (char_u *)end; } if (partial != NULL) { @@ -2873,7 +2873,7 @@ void ex_return(exarg_T *eap) eap->nextcmd = NULL; if ((*arg != NUL && *arg != '|' && *arg != '\n') - && eval0(arg, &rettv, &eap->nextcmd, !eap->skip) != FAIL) { + && eval0((char *)arg, &rettv, (char **)&eap->nextcmd, !eap->skip) != FAIL) { if (!eap->skip) { returning = do_return(eap, false, true, &rettv); } else { @@ -2926,7 +2926,7 @@ void ex_call(exarg_T *eap) // instead to skip to any following command, e.g. for: // :if 0 | call dict.foo().bar() | endif. emsg_skip++; - if (eval0(eap->arg, &rettv, &eap->nextcmd, false) != FAIL) { + if (eval0((char *)eap->arg, &rettv, (char **)&eap->nextcmd, false) != FAIL) { tv_clear(&rettv); } emsg_skip--; @@ -2995,7 +2995,7 @@ void ex_call(exarg_T *eap) // Handle a function returning a Funcref, Dictionary or List. if (handle_subscript((const char **)&arg, &rettv, true, true, - (const char_u *)name, (const char_u **)&name) + (const char *)name, (const char **)&name) == FAIL) { failed = true; break; diff --git a/src/nvim/ex_cmds2.c b/src/nvim/ex_cmds2.c index c439b29cf6..edbd850cd0 100644 --- a/src/nvim/ex_cmds2.c +++ b/src/nvim/ex_cmds2.c @@ -1627,14 +1627,14 @@ void ex_compiler(exarg_T *eap) // Set "b:current_compiler" from "current_compiler". p = get_var_value("g:current_compiler"); if (p != NULL) { - set_internal_string_var("b:current_compiler", p); + set_internal_string_var("b:current_compiler", (char *)p); } // Restore "current_compiler" for ":compiler {name}". if (!eap->forceit) { if (old_cur_comp != NULL) { set_internal_string_var("g:current_compiler", - old_cur_comp); + (char *)old_cur_comp); xfree(old_cur_comp); } else { do_unlet(S_LEN("g:current_compiler"), true); diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index b2a71b386b..4aa2ef6ae0 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -152,8 +152,8 @@ static void save_dbg_stuff(struct dbg_stuff *dsp) dsp->trylevel = trylevel; trylevel = 0; dsp->force_abort = force_abort; force_abort = FALSE; dsp->caught_stack = caught_stack; caught_stack = NULL; - dsp->vv_exception = (char *)v_exception(NULL); - dsp->vv_throwpoint = (char *)v_throwpoint(NULL); + dsp->vv_exception = v_exception(NULL); + dsp->vv_throwpoint = v_throwpoint(NULL); // Necessary for debugging an inactive ":catch", ":finally", ":endtry". dsp->did_emsg = did_emsg; did_emsg = false; @@ -169,8 +169,8 @@ static void restore_dbg_stuff(struct dbg_stuff *dsp) trylevel = dsp->trylevel; force_abort = dsp->force_abort; caught_stack = dsp->caught_stack; - (void)v_exception((char_u *)dsp->vv_exception); - (void)v_throwpoint((char_u *)dsp->vv_throwpoint); + (void)v_exception(dsp->vv_exception); + (void)v_throwpoint(dsp->vv_throwpoint); did_emsg = dsp->did_emsg; got_int = dsp->got_int; need_rethrow = dsp->need_rethrow; @@ -3701,7 +3701,7 @@ const char *set_one_cmd_context(expand_T *xp, const char *buff) case CMD_lexpr: case CMD_laddexpr: case CMD_lgetexpr: - set_context_for_expression(xp, (char_u *)arg, ea.cmdidx); + set_context_for_expression(xp, (char *)arg, ea.cmdidx); break; case CMD_unlet: @@ -4591,7 +4591,7 @@ int expand_filename(exarg_T *eap, char_u **cmdlinep, char **errormsgp) // Skip over `=expr`, wildcards in it are not expanded. if (p[0] == '`' && p[1] == '=') { p += 2; - (void)skip_expr((char_u **)&p); + (void)skip_expr(&p); if (*p == '`') { ++p; } @@ -4806,7 +4806,7 @@ void separate_nextcmd(exarg_T *eap) } else if (p[0] == '`' && p[1] == '=' && (eap->argt & EX_XFILE)) { // Skip over `=expr` when wildcards are expanded. p += 2; - (void)skip_expr((char_u **)&p); + (void)skip_expr(&p); if (*p == NUL) { // stop at NUL after CTRL-V break; } @@ -6669,7 +6669,7 @@ static void ex_colorscheme(exarg_T *eap) char *p = NULL; emsg_off++; - p = (char *)eval_to_string((char_u *)expr, NULL, false); + p = eval_to_string(expr, NULL, false); emsg_off--; xfree(expr); @@ -8527,7 +8527,7 @@ static void ex_redir(exarg_T *eap) append = FALSE; } - if (var_redir_start(skipwhite((char_u *)arg), append) == OK) { + if (var_redir_start((char *)skipwhite((char_u *)arg), append) == OK) { redir_vname = 1; } } else { // TODO(vim): redirect to a buffer @@ -9383,8 +9383,8 @@ char_u *eval_vars(char_u *src, char_u *srcstart, size_t *usedlen, linenr_T *lnum resultlen = (size_t)(s - result); } } else if (!skip_mod) { - valid |= modify_fname(src, tilde_file, usedlen, (char_u **)&result, - (char_u **)&resultbuf, &resultlen); + valid |= modify_fname((char *)src, tilde_file, usedlen, &result, + &resultbuf, &resultlen); if (result == NULL) { *errormsg = ""; return NULL; diff --git a/src/nvim/ex_eval.c b/src/nvim/ex_eval.c index f91371d3ad..570ae0d85e 100644 --- a/src/nvim/ex_eval.c +++ b/src/nvim/ex_eval.c @@ -801,7 +801,7 @@ void ex_eval(exarg_T *eap) { typval_T tv; - if (eval0(eap->arg, &tv, &eap->nextcmd, !eap->skip) == OK) { + if (eval0((char *)eap->arg, &tv, (char **)&eap->nextcmd, !eap->skip) == OK) { tv_clear(&tv); } } @@ -822,7 +822,7 @@ void ex_if(exarg_T *eap) skip = CHECK_SKIP; bool error; - result = eval_to_bool(eap->arg, &error, &eap->nextcmd, skip); + result = eval_to_bool((char *)eap->arg, &error, (char **)&eap->nextcmd, skip); if (!skip && !error) { if (result) { @@ -911,7 +911,7 @@ void ex_else(exarg_T *eap) if (eap->cmdidx == CMD_elseif) { bool error; - result = eval_to_bool(eap->arg, &error, &eap->nextcmd, skip); + result = eval_to_bool((char *)eap->arg, &error, (char **)&eap->nextcmd, skip); // When throwing error exceptions, we want to throw always the first // of several errors in a row. This is what actually happens when // a conditional error was detected above and there is another failure @@ -962,7 +962,7 @@ void ex_while(exarg_T *eap) /* * ":while bool-expr" */ - result = eval_to_bool(eap->arg, &error, &eap->nextcmd, skip); + result = eval_to_bool((char *)eap->arg, &error, (char **)&eap->nextcmd, skip); } else { void *fi; @@ -976,13 +976,13 @@ void ex_while(exarg_T *eap) error = FALSE; } else { // Evaluate the argument and get the info in a structure. - fi = eval_for_line(eap->arg, &error, &eap->nextcmd, skip); + fi = eval_for_line((char *)eap->arg, &error, (char **)&eap->nextcmd, skip); cstack->cs_forinfo[cstack->cs_idx] = fi; } // use the element at the start of the list and advance if (!error && fi != NULL && !skip) { - result = next_for_item(fi, eap->arg); + result = next_for_item(fi, (char *)eap->arg); } else { result = FALSE; } diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index cd8ade33c8..8a37c5bc93 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -335,10 +335,10 @@ static void get_healthcheck_cb(char_u *path, void *cookie) pattern = ".*[\\/]\\([^\\/]*\\)\\.vim$"; } - res = do_string_sub(path, (char_u *)pattern, (char_u *)sub, NULL, (char_u *)"g"); + res = (char_u *)do_string_sub((char *)path, pattern, sub, NULL, "g"); if (hcookie->is_lua && res != NULL) { // Replace slashes with dots as represented by the healthcheck plugin. - char_u *ares = do_string_sub(res, (char_u *)"[\\/]", (char_u *)".", NULL, (char_u *)"g"); + char_u *ares = (char_u *)do_string_sub((char *)res, "[\\/]", ".", NULL, "g"); xfree(res); res = ares; } @@ -4715,7 +4715,7 @@ void set_cmd_context(expand_T *xp, char_u *str, int len, int col, int use_ccline if (use_ccline && ccline.cmdfirstc == '=') { // pass CMD_SIZE because there is no real command - set_context_for_expression(xp, str, CMD_SIZE); + set_context_for_expression(xp, (char *)str, CMD_SIZE); } else if (use_ccline && ccline.input_fn) { xp->xp_context = ccline.xp_context; xp->xp_pattern = ccline.cmdbuff; diff --git a/src/nvim/fold.c b/src/nvim/fold.c index ef2987d1ab..af7288e103 100644 --- a/src/nvim/fold.c +++ b/src/nvim/fold.c @@ -1774,7 +1774,9 @@ char_u *get_foldtext(win_T *wp, linenr_T lnum, linenr_T lnume, foldinfo_T foldin curbuf = wp->w_buffer; emsg_silent++; // handle exceptions, but don't display errors - text = eval_to_string_safe(wp->w_p_fdt, NULL, was_set_insecurely(wp, "foldtext", OPT_LOCAL)); + text = + (char_u *)eval_to_string_safe((char *)wp->w_p_fdt, NULL, + was_set_insecurely(wp, "foldtext", OPT_LOCAL)); emsg_silent--; if (text == NULL || did_emsg) { @@ -2962,7 +2964,7 @@ static void foldlevelExpr(fline_T *flp) // KeyTyped may be reset to 0 when calling a function which invokes // do_cmdline(). To make 'foldopen' work correctly restore KeyTyped. const bool save_keytyped = KeyTyped; - const int n = eval_foldexpr(flp->wp->w_p_fde, &c); + const int n = eval_foldexpr((char *)flp->wp->w_p_fde, &c); KeyTyped = save_keytyped; switch (c) { diff --git a/src/nvim/getchar.c b/src/nvim/getchar.c index 6dd6c51e8f..539f6e3a1f 100644 --- a/src/nvim/getchar.c +++ b/src/nvim/getchar.c @@ -4275,7 +4275,7 @@ static char_u *eval_map_expr(mapblock_T *mp, int c) api_clear_error(&err); } } else { - p = eval_to_string(expr, NULL, false); + p = (char_u *)eval_to_string((char *)expr, NULL, false); xfree(expr); } textlock--; diff --git a/src/nvim/if_cscope.c b/src/nvim/if_cscope.c index 2f34c8f27b..55af044658 100644 --- a/src/nvim/if_cscope.c +++ b/src/nvim/if_cscope.c @@ -429,8 +429,8 @@ static int cs_add_common(char *arg1, char *arg2, char *flags) expand_env((char_u *)arg1, (char_u *)fname, MAXPATHL); size_t len = STRLEN(fname); fbuf = (char_u *)fname; - (void)modify_fname((char_u *)":p", false, &usedlen, - (char_u **)&fname, &fbuf, &len); + (void)modify_fname(":p", false, &usedlen, + &fname, (char **)&fbuf, &len); if (fname == NULL) { goto add_err; } diff --git a/src/nvim/indent.c b/src/nvim/indent.c index 2659c2c175..67a2d4aac7 100644 --- a/src/nvim/indent.c +++ b/src/nvim/indent.c @@ -548,7 +548,7 @@ int get_expr_indent(void) // Need to make a copy, the 'indentexpr' option could be changed while // evaluating it. char_u *inde_copy = vim_strsave(curbuf->b_p_inde); - indent = (int)eval_to_number(inde_copy); + indent = (int)eval_to_number((char *)inde_copy); xfree(inde_copy); if (use_sandbox) { diff --git a/src/nvim/message.c b/src/nvim/message.c index 66df3f8a6f..e5e661c708 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -3195,7 +3195,7 @@ static void redir_write(const char *const str, const ptrdiff_t maxlen) if (redir_reg) { write_reg_contents(redir_reg, (char_u *)" ", 1, true); } else if (redir_vname) { - var_redir_str((char_u *)" ", -1); + var_redir_str(" ", -1); } else if (redir_fd != NULL) { fputs(" ", redir_fd); } @@ -3214,7 +3214,7 @@ static void redir_write(const char *const str, const ptrdiff_t maxlen) write_reg_contents(redir_reg, s, len, true); } if (redir_vname) { - var_redir_str((char_u *)s, maxlen); + var_redir_str((char *)s, maxlen); } // Write and adjust the current column. diff --git a/src/nvim/ops.c b/src/nvim/ops.c index 36e773a82d..f0b328dd5f 100644 --- a/src/nvim/ops.c +++ b/src/nvim/ops.c @@ -774,7 +774,7 @@ char_u *get_expr_line(void) } nested++; - rv = eval_to_string(expr_copy, NULL, true); + rv = (char_u *)eval_to_string((char *)expr_copy, NULL, true); nested--; xfree(expr_copy); return rv; @@ -4441,7 +4441,7 @@ int fex_format(linenr_T lnum, long count, int c) if (use_sandbox) { sandbox++; } - r = (int)eval_to_number(fex); + r = (int)eval_to_number((char *)fex); if (use_sandbox) { sandbox--; } @@ -6192,7 +6192,7 @@ static void op_function(const oparg_T *oap) // Reset finish_op so that mode() returns the right value. finish_op = false; - (void)call_func_retnr(p_opfunc, 1, argv); + (void)call_func_retnr((char *)p_opfunc, 1, argv); virtual_op = save_virtual_op; finish_op = save_finish_op; diff --git a/src/nvim/os/env.c b/src/nvim/os/env.c index bf9e455c38..7a79272c56 100644 --- a/src/nvim/os/env.c +++ b/src/nvim/os/env.c @@ -587,7 +587,7 @@ void expand_env_esc(char_u *restrict srcp, char_u *restrict dst, int dstlen, boo if (src[0] == '`' && src[1] == '=') { var = src; src += 2; - (void)skip_expr(&src); + (void)skip_expr((char **)&src); if (*src == '`') { src++; } @@ -1072,8 +1072,8 @@ size_t home_replace(const buf_T *const buf, const char_u *src, char_u *const dst size_t usedlen = 0; size_t flen = strlen(homedir_env_mod); char_u *fbuf = NULL; - (void)modify_fname((char_u *)":p", false, &usedlen, - (char_u **)&homedir_env_mod, &fbuf, &flen); + (void)modify_fname(":p", false, &usedlen, + &homedir_env_mod, (char **)&fbuf, &flen); flen = strlen(homedir_env_mod); assert(homedir_env_mod != homedir_env); if (vim_ispathsep(homedir_env_mod[flen - 1])) { diff --git a/src/nvim/path.c b/src/nvim/path.c index 0ecdba468a..bf394ec9ab 100644 --- a/src/nvim/path.c +++ b/src/nvim/path.c @@ -1383,7 +1383,7 @@ static int expand_backtick(garray_T *gap, char_u *pat, int flags) char_u *cmd = vim_strnsave(pat + 1, STRLEN(pat) - 2); if (*cmd == '=') { // `={expr}`: Expand expression - buffer = eval_to_string(cmd + 1, &p, true); + buffer = (char_u *)eval_to_string((char *)cmd + 1, (char **)&p, true); } else { buffer = get_cmd_output(cmd, NULL, (flags & EW_SILENT) ? kShellOptSilent : 0, NULL); } @@ -1678,8 +1678,8 @@ void simplify_filename(char_u *filename) static char *eval_includeexpr(const char *const ptr, const size_t len) { set_vim_var_string(VV_FNAME, ptr, (ptrdiff_t)len); - char *res = (char *)eval_to_string_safe(curbuf->b_p_inex, NULL, - was_set_insecurely(curwin, "includeexpr", OPT_LOCAL)); + char *res = eval_to_string_safe((char *)curbuf->b_p_inex, NULL, + was_set_insecurely(curwin, "includeexpr", OPT_LOCAL)); set_vim_var_string(VV_FNAME, NULL, 0); return res; } diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c index 7c64b0aa0b..f13fd11fd3 100644 --- a/src/nvim/quickfix.c +++ b/src/nvim/quickfix.c @@ -3726,7 +3726,7 @@ static int qf_open_new_cwindow(qf_info_T *qi, int height) static void qf_set_title_var(qf_list_T *qfl) { if (qfl->qf_title != NULL) { - set_internal_string_var("w:quickfix_title", (char_u *)qfl->qf_title); + set_internal_string_var("w:quickfix_title", qfl->qf_title); } } @@ -3929,7 +3929,7 @@ bool qf_process_qftf_option(void) if (*p_qftf == '{') { // Lambda expression - tv = eval_expr(p_qftf); + tv = eval_expr((char *)p_qftf); if (tv == NULL) { return false; } @@ -7035,7 +7035,7 @@ void ex_cexpr(exarg_T *eap) // Evaluate the expression. When the result is a string or a list we can // use it to fill the errorlist. typval_T tv; - if (eval0(eap->arg, &tv, &eap->nextcmd, true) != FAIL) { + if (eval0((char *)eap->arg, &tv, (char **)&eap->nextcmd, true) != FAIL) { if ((tv.v_type == VAR_STRING && tv.vval.v_string != NULL) || tv.v_type == VAR_LIST) { incr_quickfix_busy(); diff --git a/src/nvim/regexp.c b/src/nvim/regexp.c index a98250f6e8..ef75f681b4 100644 --- a/src/nvim/regexp.c +++ b/src/nvim/regexp.c @@ -1790,7 +1790,7 @@ static int vim_regsub_both(char_u *source, typval_T *expr, char_u *dest, } else if (expr->v_type == VAR_PARTIAL) { partial_T *partial = expr->vval.v_partial; - s = partial_name(partial); + s = (char_u *)partial_name(partial); funcexe.partial = partial; call_func(s, -1, &rettv, 1, argv, &funcexe); } @@ -1810,7 +1810,7 @@ static int vim_regsub_both(char_u *source, typval_T *expr, char_u *dest, } tv_clear(&rettv); } else { - eval_result = eval_to_string(source + 2, NULL, true); + eval_result = (char_u *)eval_to_string((char *)source + 2, NULL, true); } if (eval_result != NULL) { diff --git a/src/nvim/runtime.c b/src/nvim/runtime.c index 970072a53c..3f21fae995 100644 --- a/src/nvim/runtime.c +++ b/src/nvim/runtime.c @@ -826,7 +826,7 @@ static int load_pack_plugin(bool opt, char_u *fname) // If runtime/filetype.vim wasn't loaded yet, the scripts will be // found when it loads. - if (opt && eval_to_number(cmd) > 0) { + if (opt && eval_to_number((char *)cmd) > 0) { do_cmdline_cmd("augroup filetypedetect"); vim_snprintf((char *)pat, len, ftpat, ffname); source_all_matches(pat); diff --git a/src/nvim/screen.c b/src/nvim/screen.c index 81c8830b84..58abc1599a 100644 --- a/src/nvim/screen.c +++ b/src/nvim/screen.c @@ -5392,7 +5392,7 @@ bool get_keymap_str(win_T *wp, char_u *fmt, char_u *buf, int len) curwin = wp; STRCPY(buf, "b:keymap_name"); // must be writable emsg_skip++; - s = p = eval_to_string(buf, NULL, false); + s = p = (char_u *)eval_to_string((char *)buf, NULL, false); emsg_skip--; curbuf = old_curbuf; curwin = old_curwin; diff --git a/src/nvim/spell.c b/src/nvim/spell.c index 754d9dcb48..3e3cfd906b 100644 --- a/src/nvim/spell.c +++ b/src/nvim/spell.c @@ -3372,7 +3372,7 @@ static void spell_suggest_expr(suginfo_T *su, char_u *expr) // The work is split up in a few parts to avoid having to export // suginfo_T. // First evaluate the expression and get the resulting list. - list_T *const list = eval_spell_expr(su->su_badword, expr); + list_T *const list = eval_spell_expr((char *)su->su_badword, (char *)expr); if (list != NULL) { // Loop over the items in the list. TV_LIST_ITER(list, li, { diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c index 3be7dfe477..4ba89319e7 100644 --- a/src/nvim/syntax.c +++ b/src/nvim/syntax.c @@ -5674,14 +5674,14 @@ void ex_ownsyntax(exarg_T *eap) // Move value of b:current_syntax to w:current_syntax. new_value = get_var_value("b:current_syntax"); if (new_value != NULL) { - set_internal_string_var("w:current_syntax", new_value); + set_internal_string_var("w:current_syntax", (char *)new_value); } // Restore value of b:current_syntax. if (old_value == NULL) { do_unlet(S_LEN("b:current_syntax"), true); } else { - set_internal_string_var("b:current_syntax", old_value); + set_internal_string_var("b:current_syntax", (char *)old_value); xfree(old_value); } } diff --git a/src/nvim/tag.c b/src/nvim/tag.c index 40d65c2542..7598cdbd73 100644 --- a/src/nvim/tag.c +++ b/src/nvim/tag.c @@ -1182,7 +1182,7 @@ static int find_tagfunc_tags(char_u *pat, garray_T *ga, int *match_count, int fl flags & TAG_REGEXP ? "r": ""); save_pos = curwin->w_cursor; - result = call_vim_function(curbuf->b_p_tfu, 3, args, &rettv); + result = call_vim_function((char *)curbuf->b_p_tfu, 3, args, &rettv); curwin->w_cursor = save_pos; // restore the cursor position d->dv_refcount--; diff --git a/src/nvim/testing.c b/src/nvim/testing.c index f0b84c0eab..07e1fe424b 100644 --- a/src/nvim/testing.c +++ b/src/nvim/testing.c @@ -178,7 +178,7 @@ static int assert_match_common(typval_T *argvars, assert_type_T atype) if (pat == NULL || text == NULL) { emsg(_(e_invarg)); - } else if (pattern_match((char_u *)pat, (char_u *)text, false) + } else if (pattern_match((char *)pat, (char *)text, false) != (atype == ASSERT_MATCH)) { garray_T ga; prepare_assert_error(&ga); |