refactor: replace char_u variables and functions with char

Work on https://github.com/neovim/neovim/issues/459
This commit is contained in:
Dundar Goc 2022-05-04 18:27:22 +02:00
parent 82c7a82c35
commit 9a671e6a24
47 changed files with 569 additions and 576 deletions

View File

@ -460,7 +460,7 @@ Integer nvim_create_autocmd(uint64_t channel_id, Object event, Dict(create_autoc
cb.data.luaref = api_new_luaref(callback->data.luaref);
} else if (callback->type == kObjectTypeString) {
cb.type = kCallbackFuncref;
cb.data.funcref = (char_u *)string_to_cstr(callback->data.string);
cb.data.funcref = string_to_cstr(callback->data.string);
} else {
api_set_error(err,
kErrorTypeException,

View File

@ -452,7 +452,7 @@ void nvim_buf_set_lines(uint64_t channel_id, Buffer buffer, Integer start, Integ
goto end;
}
if (ml_replace((linenr_T)lnum, (char_u *)lines[i], false) == FAIL) {
if (ml_replace((linenr_T)lnum, lines[i], false) == FAIL) {
api_set_error(err, kErrorTypeException, "Failed to replace line");
goto end;
}
@ -472,7 +472,7 @@ void nvim_buf_set_lines(uint64_t channel_id, Buffer buffer, Integer start, Integ
goto end;
}
if (ml_append((linenr_T)lnum, (char_u *)lines[i], 0, false) == FAIL) {
if (ml_append((linenr_T)lnum, lines[i], 0, false) == FAIL) {
api_set_error(err, kErrorTypeException, "Failed to insert line");
goto end;
}
@ -692,7 +692,7 @@ void nvim_buf_set_text(uint64_t channel_id, Buffer buffer, Integer start_row, In
goto end;
}
if (ml_replace((linenr_T)lnum, (char_u *)lines[i], false) == FAIL) {
if (ml_replace((linenr_T)lnum, lines[i], false) == FAIL) {
api_set_error(err, kErrorTypeException, "Failed to replace line");
goto end;
}
@ -710,7 +710,7 @@ void nvim_buf_set_text(uint64_t channel_id, Buffer buffer, Integer start_row, In
goto end;
}
if (ml_append((linenr_T)lnum, (char_u *)lines[i], 0, false) == FAIL) {
if (ml_append((linenr_T)lnum, lines[i], 0, false) == FAIL) {
api_set_error(err, kErrorTypeException, "Failed to insert line");
goto end;
}

View File

@ -688,8 +688,8 @@ Integer nvim_buf_set_extmark(Buffer buffer, Integer ns_id, Integer line, Integer
}
if (opts->sign_text.type == kObjectTypeString) {
if (!init_sign_text(&decor.sign_text,
(char_u *)opts->sign_text.data.string.data)) {
if (!init_sign_text((char **)&decor.sign_text,
opts->sign_text.data.string.data)) {
api_set_error(err, kErrorTypeValidation, "sign_text is not a valid value");
goto error;
}

View File

@ -353,9 +353,10 @@ bool object_to_vim(Object obj, typval_T *tv, Error *err)
case kObjectTypeLuaRef: {
LuaCFunctionState *state = xmalloc(sizeof(LuaCFunctionState));
state->lua_callable.func_ref = api_new_luaref(obj.data.luaref);
char_u *name = register_cfunc(&nlua_CFunction_func_call, &nlua_CFunction_func_free, state);
char *name =
(char *)register_cfunc(&nlua_CFunction_func_call, &nlua_CFunction_func_free, state);
tv->v_type = VAR_FUNC;
tv->vval.v_string = vim_strsave(name);
tv->vval.v_string = xstrdup(name);
break;
}

View File

@ -634,8 +634,8 @@ void modify_keymap(uint64_t channel_id, Buffer buffer, bool is_unmap, String mod
}
parsed_args.buffer = !global;
set_maparg_lhs_rhs((char_u *)lhs.data, lhs.size,
(char_u *)rhs.data, rhs.size, lua_funcref,
set_maparg_lhs_rhs(lhs.data, lhs.size,
rhs.data, rhs.size, lua_funcref,
CPO_TO_CPO_FLAGS, &parsed_args);
if (opts != NULL && opts->desc.type == kObjectTypeString) {
parsed_args.desc = string_to_cstr(opts->desc.data.string);
@ -652,16 +652,16 @@ void modify_keymap(uint64_t channel_id, Buffer buffer, bool is_unmap, String mod
goto fail_and_free;
}
int mode_val; // integer value of the mapping mode, to be passed to do_map()
char_u *p = (char_u *)((mode.size) ? mode.data : "m");
char *p = (mode.size) ? mode.data : "m";
if (STRNCMP(p, "!", 2) == 0) {
mode_val = get_map_mode(&p, true); // mapmode-ic
mode_val = get_map_mode((char_u **)&p, true); // mapmode-ic
} else {
mode_val = get_map_mode(&p, false);
mode_val = get_map_mode((char_u **)&p, false);
if ((mode_val == VISUAL + SELECTMODE + NORMAL + OP_PENDING)
&& mode.size > 0) {
// get_map_mode() treats unrecognized mode shortnames as ":map".
// This is an error unless the given shortname was empty string "".
api_set_error(err, kErrorTypeValidation, "Invalid mode shortname: \"%s\"", (char *)p);
api_set_error(err, kErrorTypeValidation, "Invalid mode shortname: \"%s\"", p);
goto fail_and_free;
}
}
@ -1269,7 +1269,7 @@ VirtText parse_virt_text(Array chunks, Error *err, int *width)
}
char *text = transstr(str.size > 0 ? str.data : "", false); // allocates
w += (int)mb_string2cells((char_u *)text);
w += (int)mb_string2cells(text);
kv_push(virt_text, ((VirtTextChunk){ .text = text, .hl_id = hl_id }));
}
@ -1658,19 +1658,19 @@ sctx_T api_set_sctx(uint64_t channel_id)
// adapted from sign.c:sign_define_init_text.
// TODO(lewis6991): Consider merging
int init_sign_text(char_u **sign_text, char_u *text)
int init_sign_text(char **sign_text, char *text)
{
char_u *s;
char *s;
char_u *endp = text + (int)STRLEN(text);
char *endp = text + (int)STRLEN(text);
// Count cells and check for non-printable chars
int cells = 0;
for (s = text; s < endp; s += utfc_ptr2len(s)) {
if (!vim_isprintc(utf_ptr2char(s))) {
for (s = text; s < endp; s += utfc_ptr2len((char_u *)s)) {
if (!vim_isprintc(utf_ptr2char((char_u *)s))) {
break;
}
cells += utf_ptr2cells(s);
cells += utf_ptr2cells((char_u *)s);
}
// Currently must be empty, one or two display cells
if (s != endp || cells > 2) {
@ -1683,7 +1683,7 @@ int init_sign_text(char_u **sign_text, char_u *text)
// Allocate one byte more if we need to pad up
// with a space.
size_t len = (size_t)(endp - text + ((cells == 1) ? 1 : 0));
*sign_text = vim_strnsave(text, len);
*sign_text = xstrnsave(text, len);
if (cells == 1) {
STRCPY(*sign_text + len - 1, " ");

View File

@ -474,7 +474,7 @@ Integer nvim_strwidth(String text, Error *err)
return 0;
}
return (Integer)mb_string2cells((char_u *)text.data);
return (Integer)mb_string2cells(text.data);
}
/// Gets the paths contained in 'runtimepath'.

View File

@ -645,7 +645,7 @@ void ins_char_bytes(char_u *buf, size_t charlen)
}
// Replace the line in the buffer.
ml_replace(lnum, newp, false);
ml_replace(lnum, (char *)newp, false);
// mark the buffer as changed and prepare for displaying
inserted_bytes(lnum, (colnr_T)col, (int)oldlen, (int)newlen);
@ -689,7 +689,7 @@ void ins_str(char_u *s)
int bytes = oldlen - col + 1;
assert(bytes >= 0);
memmove(newp + col + newlen, oldp + col, (size_t)bytes);
ml_replace(lnum, newp, false);
ml_replace(lnum, (char *)newp, false);
inserted_bytes(lnum, col, 0, newlen);
curwin->w_cursor.col += newlen;
}
@ -801,7 +801,7 @@ int del_bytes(colnr_T count, bool fixpos_arg, bool use_delcombine)
}
memmove(newp + col, oldp + col + count, (size_t)movelen);
if (!was_alloced) {
ml_replace(lnum, newp, false);
ml_replace(lnum, (char *)newp, false);
}
// mark the buffer as changed and prepare for displaying
@ -914,7 +914,7 @@ int copy_indent(int size, char_u *src)
memmove(p, get_cursor_line_ptr(), (size_t)line_len);
// Replace the line
ml_replace(curwin->w_cursor.lnum, line, false);
ml_replace(curwin->w_cursor.lnum, (char *)line, false);
// Put the cursor after the indent.
curwin->w_cursor.col = ind_len;
@ -1612,7 +1612,7 @@ int open_line(int dir, int flags, int second_line_indent, bool *did_do_comment)
curwin->w_cursor.lnum--;
}
if (!(State & VREPLACE_FLAG) || old_cursor.lnum >= orig_line_count) {
if (ml_append(curwin->w_cursor.lnum, p_extra, (colnr_T)0, false) == FAIL) {
if (ml_append(curwin->w_cursor.lnum, (char *)p_extra, (colnr_T)0, false) == FAIL) {
goto theend;
}
// Postpone calling changed_lines(), because it would mess up folding
@ -1634,7 +1634,7 @@ int open_line(int dir, int flags, int second_line_indent, bool *did_do_comment)
(void)u_save_cursor(); // errors are ignored!
vr_lines_changed++;
}
ml_replace(curwin->w_cursor.lnum, p_extra, true);
ml_replace(curwin->w_cursor.lnum, (char *)p_extra, true);
changed_bytes(curwin->w_cursor.lnum, 0);
// TODO(vigoux): extmark_splice_cols here??
curwin->w_cursor.lnum--;
@ -1700,7 +1700,7 @@ int open_line(int dir, int flags, int second_line_indent, bool *did_do_comment)
if (trunc_line && !(flags & OPENLINE_KEEPTRAIL)) {
truncate_spaces(saved_line);
}
ml_replace(curwin->w_cursor.lnum, saved_line, false);
ml_replace(curwin->w_cursor.lnum, (char *)saved_line, false);
int new_len = (int)STRLEN(saved_line);
@ -1785,7 +1785,7 @@ int open_line(int dir, int flags, int second_line_indent, bool *did_do_comment)
p_extra = vim_strsave(get_cursor_line_ptr());
// Put back original line
ml_replace(curwin->w_cursor.lnum, next_line, false);
ml_replace(curwin->w_cursor.lnum, (char *)next_line, false);
// Insert new stuff into line again
curwin->w_cursor.col = 0;
@ -1818,7 +1818,7 @@ void truncate_line(int fixpos)
} else {
newp = vim_strnsave(ml_get(lnum), (size_t)col);
}
ml_replace(lnum, newp, false);
ml_replace(lnum, (char *)newp, false);
// mark the buffer as changed and prepare for displaying
changed_bytes(lnum, curwin->w_cursor.col);

View File

@ -739,13 +739,13 @@ static void channel_callback_call(Channel *chan, CallbackReader *reader)
tv_list_ref(argv[1].vval.v_list);
ga_clear(&reader->buffer);
cb = &reader->cb;
argv[2].vval.v_string = (char_u *)reader->type;
argv[2].vval.v_string = (char *)reader->type;
} else {
argv[1].v_type = VAR_NUMBER;
argv[1].v_lock = VAR_UNLOCKED;
argv[1].vval.v_number = chan->exit_status;
cb = &chan->on_exit;
argv[2].vval.v_string = (char_u *)"exit";
argv[2].vval.v_string = "exit";
}
argv[2].v_type = VAR_STRING;

View File

@ -171,7 +171,7 @@ static int coladvance2(pos_T *pos, bool addspaces, bool finetune, colnr_T wcol_a
memcpy(newline, line, (size_t)idx);
memset(newline + idx, ' ', (size_t)correct);
ml_replace(pos->lnum, newline, false);
ml_replace(pos->lnum, (char *)newline, false);
inserted_bytes(pos->lnum, (colnr_T)idx, 0, correct);
idx += correct;
col = wcol;
@ -197,7 +197,7 @@ static int coladvance2(pos_T *pos, bool addspaces, bool finetune, colnr_T wcol_a
STRICT_SUB(n, 1, &n, size_t);
memcpy(newline + idx + csize, line + idx + 1, n);
ml_replace(pos->lnum, newline, false);
ml_replace(pos->lnum, (char *)newline, false);
inserted_bytes(pos->lnum, idx, 1, csize);
idx += (csize - 1 + correct);
col += correct;

View File

@ -2706,7 +2706,7 @@ void ex_diffgetput(exarg_T *eap)
break;
}
p = vim_strsave(ml_get_buf(curtab->tp_diffbuf[idx_from], nr, false));
ml_append(lnum + i - 1, p, 0, false);
ml_append(lnum + i - 1, (char *)p, 0, false);
xfree(p);
added++;
if (buf_empty && (curbuf->b_ml.ml_line_count == 2)) {

View File

@ -1934,7 +1934,7 @@ void f_digraph_get(typval_T *argvars, typval_T *rettv, FunPtr fptr)
char_u buf[NUMBUFLEN];
buf[utf_char2bytes(code, buf)] = NUL;
rettv->vval.v_string = vim_strsave(buf);
rettv->vval.v_string = (char *)vim_strsave(buf);
}
/// "digraph_getlist()" function

View File

@ -1685,9 +1685,9 @@ static void init_prompt(int cmdchar_todo)
if (STRNCMP(text, prompt, STRLEN(prompt)) != 0) {
// prompt is missing, insert it or append a line with it
if (*text == NUL) {
ml_replace(curbuf->b_ml.ml_line_count, prompt, true);
ml_replace(curbuf->b_ml.ml_line_count, (char *)prompt, true);
} else {
ml_append(curbuf->b_ml.ml_line_count, prompt, 0, false);
ml_append(curbuf->b_ml.ml_line_count, (char *)prompt, 0, false);
}
curwin->w_cursor.lnum = curbuf->b_ml.ml_line_count;
coladvance(MAXCOL);
@ -1985,7 +1985,7 @@ void change_indent(int type, int amount, int round, int replaced, int call_chang
int new_col = curwin->w_cursor.col;
// Put back original line
ml_replace(curwin->w_cursor.lnum, orig_line, false);
ml_replace(curwin->w_cursor.lnum, (char *)orig_line, false);
curwin->w_cursor.col = orig_col;
curbuf_splice_pending++;
@ -4021,7 +4021,7 @@ static void expand_by_function(int type, char_u *base)
args[1].v_type = VAR_STRING;
args[2].v_type = VAR_UNKNOWN;
args[0].vval.v_number = 0;
args[1].vval.v_string = base != NULL ? base : (char_u *)"";
args[1].vval.v_string = base != NULL ? (char *)base : "";
pos = curwin->w_cursor;
curwin_save = curwin;
@ -5306,7 +5306,7 @@ static int ins_complete(int c, bool enable_pum)
args[1].v_type = VAR_STRING;
args[2].v_type = VAR_UNKNOWN;
args[0].vval.v_number = 1;
args[1].vval.v_string = (char_u *)"";
args[1].vval.v_string = "";
pos = curwin->w_cursor;
curwin_save = curwin;
@ -6478,7 +6478,7 @@ void auto_format(bool trailblank, bool prev_line)
pnew = vim_strnsave(new, len + 2);
pnew[len] = ' ';
pnew[len + 1] = NUL;
ml_replace(curwin->w_cursor.lnum, pnew, false);
ml_replace(curwin->w_cursor.lnum, (char *)pnew, false);
// remove the space later
did_add_space = true;
} else {

View File

@ -505,7 +505,7 @@ void set_internal_string_var(const char *name, char *value)
{
typval_T tv = {
.v_type = VAR_STRING,
.vval.v_string = (char_u *)value,
.vval.v_string = value,
};
set_var(name, strlen(name), &tv, true);
@ -563,7 +563,7 @@ int var_redir_start(char *name, int append)
save_emsg = did_emsg;
did_emsg = FALSE;
tv.v_type = VAR_STRING;
tv.vval.v_string = (char_u *)"";
tv.vval.v_string = "";
if (append) {
set_var_lval(redir_lval, redir_endp, &tv, true, false, ".");
} else {
@ -773,7 +773,7 @@ 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 *const s = (char *)expr->vval.v_string;
const char *const s = expr->vval.v_string;
if (s == NULL || *s == NUL) {
return FAIL;
}
@ -1019,7 +1019,7 @@ list_T *eval_spell_expr(char *badword, char *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 = (char_u *)badword;
vimvars[VV_VAL].vv_str = badword;
if (p_verbose == 0) {
++emsg_off;
}
@ -1235,7 +1235,7 @@ int eval_foldexpr(char *arg, int *cp)
} else {
// If the result is a string, check if there is a non-digit before
// the number.
char *s = (char *)tv.vval.v_string;
char *s = tv.vval.v_string;
if (!ascii_isdigit(*s) && *s != '-') {
*cp = (char_u)(*s++);
}
@ -2614,7 +2614,7 @@ void *eval_for_line(const char *arg, bool *errp, char **nextcmdp, int skip)
tv_clear(&tv);
} else if (tv.v_type == VAR_STRING) {
fi->fi_byte_idx = 0;
fi->fi_string = (char *)tv.vval.v_string;
fi->fi_string = tv.vval.v_string;
tv.vval.v_string = NULL;
if (fi->fi_string == NULL) {
fi->fi_string = xstrdup("");
@ -2663,7 +2663,7 @@ bool next_for_item(void *fi_void, char *arg)
typval_T tv;
tv.v_type = VAR_STRING;
tv.v_lock = VAR_FIXED;
tv.vval.v_string = vim_strnsave((char_u *)fi->fi_string + fi->fi_byte_idx, len);
tv.vval.v_string = xstrnsave(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;
@ -3318,7 +3318,7 @@ static int eval_func(char **const arg, char *const name, const int name_len, typ
// get_func_tv, but it's needed in handle_subscript() to parse
// what follows. So set it here.
if (rettv->v_type == VAR_UNKNOWN && !evaluate && **arg == '(') {
rettv->vval.v_string = (char_u *)tv_empty_string;
rettv->vval.v_string = (char *)tv_empty_string;
rettv->v_type = VAR_FUNC;
}
@ -3781,7 +3781,7 @@ static int eval5(char **arg, typval_T *rettv, int evaluate)
p = (char *)concat_str((const char_u *)s1, (const char_u *)s2);
tv_clear(rettv);
rettv->v_type = VAR_STRING;
rettv->vval.v_string = (char_u *)p;
rettv->vval.v_string = p;
} else if (op == '+' && rettv->v_type == VAR_BLOB
&& var2.v_type == VAR_BLOB) {
const blob_T *const b1 = rettv->vval.v_blob;
@ -4330,7 +4330,7 @@ static int call_func_rettv(char **const arg, typval_T *const rettv, const bool e
is_lua = is_luafunc(pt);
funcname = is_lua ? lua_funcname : partial_name(pt);
} else {
funcname = (char *)functv.vval.v_string;
funcname = functv.vval.v_string;
}
} else {
funcname = "";
@ -4637,7 +4637,7 @@ static int eval_index(char **arg, typval_T *rettv, int evaluate, int verbose)
}
tv_clear(rettv);
rettv->v_type = VAR_STRING;
rettv->vval.v_string = (char_u *)v;
rettv->vval.v_string = v;
break;
}
case VAR_BLOB:
@ -4834,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 = (char_u *)stringval;
rettv->vval.v_string = stringval;
}
} else if (working && (opt_type == -2 || opt_type == -1)) {
ret = FAIL;
@ -4887,7 +4887,7 @@ static int get_string_tv(char **arg, typval_T *rettv, int evaluate)
const int len = (int)(p - *arg + extra);
char *name = xmalloc(len);
rettv->v_type = VAR_STRING;
rettv->vval.v_string = (char_u *)name;
rettv->vval.v_string = name;
for (p = *arg + 1; *p != NUL && *p != '"';) {
if (*p == '\\') {
@ -4965,7 +4965,7 @@ static int get_string_tv(char **arg, typval_T *rettv, int evaluate)
extra = trans_special((const char_u **)&p, STRLEN(p), (char_u *)name, flags, false, NULL);
if (extra != 0) {
name += extra;
if ((char_u *)name >= rettv->vval.v_string + len) {
if (name >= rettv->vval.v_string + len) {
iemsg("get_string_tv() used more space than allocated");
}
break;
@ -5028,7 +5028,7 @@ static int get_lit_string_tv(char **arg, typval_T *rettv, int evaluate)
*/
str = xmalloc((p - *arg) - reduce);
rettv->v_type = VAR_STRING;
rettv->vval.v_string = (char_u *)str;
rettv->vval.v_string = str;
for (p = *arg + 1; *p != NUL;) {
if (*p == '\'') {
@ -5141,13 +5141,11 @@ bool func_equal(typval_T *tv1, typval_T *tv2, bool ic)
int a1, a2;
// empty and NULL function name considered the same
s1 = tv1->v_type == VAR_FUNC ? tv1->vval.v_string
: (char_u *)partial_name(tv1->vval.v_partial);
s1 = (char_u *)(tv1->v_type == VAR_FUNC ? tv1->vval.v_string : partial_name(tv1->vval.v_partial));
if (s1 != NULL && *s1 == NUL) {
s1 = NULL;
}
s2 = tv2->v_type == VAR_FUNC ? tv2->vval.v_string
: (char_u *)partial_name(tv2->vval.v_partial);
s2 = (char_u *)(tv2->v_type == VAR_FUNC ? tv2->vval.v_string : partial_name(tv2->vval.v_partial));
if (s2 != NULL && *s2 == NUL) {
s2 = NULL;
}
@ -5625,7 +5623,7 @@ bool set_ref_in_item(typval_T *tv, int copyID, ht_stack_T **ht_stack, list_stack
break;
}
case VAR_FUNC:
abort = set_ref_in_func(tv->vval.v_string, NULL, copyID);
abort = set_ref_in_func((char_u *)tv->vval.v_string, NULL, copyID);
break;
case VAR_UNKNOWN:
case VAR_BOOL:
@ -5700,7 +5698,7 @@ static int get_literal_key(char **arg, typval_T *tv)
}
for (p = *arg; ASCII_ISALNUM(*p) || *p == '_' || *p == '-'; p++) {}
tv->v_type = VAR_STRING;
tv->vval.v_string = vim_strnsave((char_u *)(*arg), p - *arg);
tv->vval.v_string = xstrnsave(*arg, p - *arg);
*arg = (char *)skipwhite((char_u *)p);
return OK;
@ -5882,7 +5880,7 @@ static int get_env_tv(char **arg, typval_T *rettv, int evaluate)
}
name[len] = cc;
rettv->v_type = VAR_STRING;
rettv->vval.v_string = (char_u *)string;
rettv->vval.v_string = string;
}
return OK;
@ -6004,7 +6002,7 @@ void filter_map(typval_T *argvars, typval_T *rettv, int map)
break;
}
vimvars[VV_KEY].vv_str = vim_strsave(di->di_key);
vimvars[VV_KEY].vv_str = (char *)vim_strsave(di->di_key);
int r = filter_map_one(&di->di_tv, expr, map, &rem);
tv_clear(&vimvars[VV_KEY].vv_tv);
if (r == FAIL || did_emsg) {
@ -6131,7 +6129,7 @@ void common_function(typval_T *argvars, typval_T *rettv, bool is_funcref, FunPtr
if (argvars[0].v_type == VAR_FUNC) {
// function(MyFunc, [arg], dict)
s = (char *)argvars[0].vval.v_string;
s = argvars[0].vval.v_string;
} else if (argvars[0].v_type == VAR_PARTIAL
&& argvars[0].vval.v_partial != NULL) {
// function(dict.MyFunc, [arg])
@ -6280,7 +6278,7 @@ 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 = (char_u *)name;
rettv->vval.v_string = name;
func_ref((char_u *)name);
}
}
@ -6664,14 +6662,13 @@ void get_user_input(const typval_T *const argvars, typval_T *const rettv, const
const int save_ex_normal_busy = ex_normal_busy;
ex_normal_busy = 0;
rettv->vval.v_string =
(char_u *)getcmdline_prompt(secret ? NUL : '@', p, echo_attr,
xp_type, xp_arg, input_callback);
rettv->vval.v_string = getcmdline_prompt(secret ? NUL : '@', p, echo_attr, xp_type, xp_arg,
input_callback);
ex_normal_busy = save_ex_normal_busy;
callback_free(&input_callback);
if (rettv->vval.v_string == NULL && cancelreturn != NULL) {
rettv->vval.v_string = (char_u *)xstrdup(cancelreturn);
rettv->vval.v_string = xstrdup(cancelreturn);
}
xfree(xp_arg);
@ -6706,7 +6703,7 @@ void dict_list(typval_T *const tv, typval_T *const rettv, const DictListType wha
switch (what) {
case kDictListKeys:
tv_item.v_type = VAR_STRING;
tv_item.vval.v_string = vim_strsave(di->di_key);
tv_item.vval.v_string = (char *)vim_strsave(di->di_key);
break;
case kDictListValues:
tv_copy(&di->di_tv, &tv_item);
@ -6721,7 +6718,7 @@ void dict_list(typval_T *const tv, typval_T *const rettv, const DictListType wha
tv_list_append_owned_tv(sub_l, (typval_T) {
.v_type = VAR_STRING,
.v_lock = VAR_UNLOCKED,
.vval.v_string = (char_u *)xstrdup((const char *)di->di_key),
.vval.v_string = xstrdup((const char *)di->di_key),
});
tv_list_append_tv(sub_l, &di->di_tv);
@ -6858,7 +6855,7 @@ void return_register(int regname, typval_T *rettv)
char buf[2] = { regname, 0 };
rettv->v_type = VAR_STRING;
rettv->vval.v_string = vim_strsave((char_u *)buf);
rettv->vval.v_string = xstrdup(buf);
}
void screenchar_adjust_grid(ScreenGrid **grid, int *row, int *col)
@ -6949,7 +6946,7 @@ void set_buffer_lines(buf_T *buf, linenr_T lnum_arg, bool append, const typval_T
// Existing line, replace it.
int old_len = (int)STRLEN(ml_get(lnum));
if (u_savesub(lnum) == OK
&& ml_replace(lnum, (char_u *)line, true) == OK) {
&& ml_replace(lnum, (char *)line, true) == OK) {
inserted_bytes(lnum, 0, old_len, STRLEN(line));
if (is_curbuf && lnum == curwin->w_cursor.lnum) {
check_cursor_col();
@ -6959,7 +6956,7 @@ void set_buffer_lines(buf_T *buf, linenr_T lnum_arg, bool append, const typval_T
} else if (added > 0 || u_save(lnum - 1, lnum) == OK) {
// append the line.
added++;
if (ml_append(lnum - 1, (char_u *)line, 0, false) == OK) {
if (ml_append(lnum - 1, (char *)line, 0, false) == OK) {
rettv->vval.v_number = 0; // OK
}
}
@ -7143,7 +7140,7 @@ void get_system_output_as_rettv(typval_T *argvars, typval_T *rettv, bool retlist
// return an empty list when there's no output
tv_list_alloc_ret(rettv, 0);
} else {
rettv->vval.v_string = (char_u *)xstrdup("");
rettv->vval.v_string = xstrdup("");
}
return;
}
@ -7175,7 +7172,7 @@ void get_system_output_as_rettv(typval_T *argvars, typval_T *rettv, bool retlist
*d = NUL;
#endif
rettv->vval.v_string = (char_u *)res;
rettv->vval.v_string = res;
}
}
@ -7193,7 +7190,7 @@ 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 *name = (char *)arg->vval.v_string;
char *name = arg->vval.v_string;
if (name == NULL) {
r = FAIL;
} else if (*name == NUL) {
@ -7201,7 +7198,7 @@ bool callback_from_typval(Callback *const callback, typval_T *const arg)
callback->data.funcref = NULL;
} else {
func_ref((char_u *)name);
callback->data.funcref = vim_strsave((char_u *)name);
callback->data.funcref = xstrdup(name);
callback->type = kCallbackFuncref;
}
} else if (nlua_is_table_from_lua(arg)) {
@ -7209,7 +7206,7 @@ bool callback_from_typval(Callback *const callback, typval_T *const arg)
char *name = (char *)nlua_register_table_as_callable(arg);
if (name != NULL) {
callback->data.funcref = vim_strsave((char_u *)name);
callback->data.funcref = xstrdup(name);
callback->type = kCallbackFuncref;
} else {
r = FAIL;
@ -7239,7 +7236,7 @@ bool callback_call(Callback *const callback, const int argcount_in, typval_T *co
Object rv;
switch (callback->type) {
case kCallbackFuncref:
name = (char *)callback->data.funcref;
name = callback->data.funcref;
partial = NULL;
break;
@ -8296,9 +8293,9 @@ void set_vim_var_string(const VimVarIndex idx, const char *const val, const ptrd
if (val == NULL) {
vimvars[idx].vv_str = NULL;
} else if (len == -1) {
vimvars[idx].vv_str = (char_u *)xstrdup(val);
vimvars[idx].vv_str = xstrdup(val);
} else {
vimvars[idx].vv_str = (char_u *)xstrndup(val, (size_t)len);
vimvars[idx].vv_str = xstrndup(val, (size_t)len);
}
}
@ -8371,10 +8368,10 @@ void set_reg_var(int c)
char *v_exception(char *oldval)
{
if (oldval == NULL) {
return (char *)vimvars[VV_EXCEPTION].vv_str;
return vimvars[VV_EXCEPTION].vv_str;
}
vimvars[VV_EXCEPTION].vv_str = (char_u *)oldval;
vimvars[VV_EXCEPTION].vv_str = oldval;
return NULL;
}
@ -8385,10 +8382,10 @@ char *v_exception(char *oldval)
char *v_throwpoint(char *oldval)
{
if (oldval == NULL) {
return (char *)vimvars[VV_THROWPOINT].vv_str;
return vimvars[VV_THROWPOINT].vv_str;
}
vimvars[VV_THROWPOINT].vv_str = (char_u *)oldval;
vimvars[VV_THROWPOINT].vv_str = oldval;
return NULL;
}
@ -8398,10 +8395,10 @@ char *v_throwpoint(char *oldval)
/// Must always be called in pairs!
char *set_cmdarg(exarg_T *eap, char *oldarg)
{
char *oldval = (char *)vimvars[VV_CMDARG].vv_str;
char *oldval = vimvars[VV_CMDARG].vv_str;
if (eap == NULL) {
xfree(oldval);
vimvars[VV_CMDARG].vv_str = (char_u *)oldarg;
vimvars[VV_CMDARG].vv_str = oldarg;
return NULL;
}
@ -8458,7 +8455,7 @@ char *set_cmdarg(exarg_T *eap, char *oldarg)
snprintf(newval + STRLEN(newval), newval_len, " ++bad=%c",
eap->bad_char);
}
vimvars[VV_CMDARG].vv_str = (char_u *)newval;
vimvars[VV_CMDARG].vv_str = newval;
return oldval;
}
@ -8838,7 +8835,7 @@ static hashtab_T *find_var_ht_dict(const char *name, const size_t name_len, cons
// should_free is ignored as script_sctx will be resolved to a fnmae
// & new_script_item will consume it.
char *sc_name = (char *)get_scriptname(last_set, &should_free);
new_script_item((char_u *)sc_name, &current_sctx.sc_sid);
new_script_item(sc_name, &current_sctx.sc_sid);
}
}
if (current_sctx.sc_sid == SID_STR || current_sctx.sc_sid == SID_LUA) {
@ -9112,7 +9109,7 @@ static void set_var_const(const char *name, const size_t name_len, typval_T *con
// Careful: when assigning to v:errmsg and tv_get_string()
// causes an error message the variable will already be set.
if (v->di_tv.vval.v_string == NULL) {
v->di_tv.vval.v_string = (char_u *)xstrdup(val);
v->di_tv.vval.v_string = xstrdup(val);
}
} else {
// Take over the string to avoid an extra alloc/free.
@ -9366,11 +9363,11 @@ int var_item_copy(const vimconv_T *const conv, typval_T *const from, typval_T *c
} else {
to->v_type = VAR_STRING;
to->v_lock = VAR_UNLOCKED;
if ((to->vval.v_string = string_convert((vimconv_T *)conv,
from->vval.v_string,
NULL))
if ((to->vval.v_string = (char *)string_convert((vimconv_T *)conv,
(char_u *)from->vval.v_string,
NULL))
== NULL) {
to->vval.v_string = (char_u *)xstrdup((char *)from->vval.v_string);
to->vval.v_string = xstrdup(from->vval.v_string);
}
}
break;
@ -10560,7 +10557,7 @@ typval_T eval_call_provider(char *provider, char *method, list_T *arguments, boo
provider_call_nesting++;
typval_T argvars[3] = {
{ .v_type = VAR_STRING, .vval.v_string = (char_u *)method,
{ .v_type = VAR_STRING, .vval.v_string = method,
.v_lock = VAR_UNLOCKED },
{ .v_type = VAR_LIST, .vval.v_list = arguments, .v_lock = VAR_UNLOCKED },
{ .v_type = VAR_UNKNOWN }
@ -10697,7 +10694,7 @@ void invoke_prompt_callback(void)
// Add a new line for the prompt before invoking the callback, so that
// text can always be inserted above the last line.
ml_append(lnum, (char_u *)"", 0, false);
ml_append(lnum, "", 0, false);
curwin->w_cursor.lnum = lnum + 1;
curwin->w_cursor.col = 0;
@ -10710,7 +10707,7 @@ void invoke_prompt_callback(void)
text += STRLEN(prompt);
}
argv[0].v_type = VAR_STRING;
argv[0].vval.v_string = vim_strsave((char_u *)text);
argv[0].vval.v_string = xstrdup(text);
argv[1].v_type = VAR_UNKNOWN;
callback_call(&curbuf->b_prompt_callback, 1, argv, &rettv);

View File

@ -290,8 +290,7 @@ typval_T decode_string(const char *const s, const size_t len, const TriState has
return (typval_T) {
.v_type = VAR_STRING,
.v_lock = VAR_UNLOCKED,
.vval = { .v_string = (char_u *)(
(s == NULL || s_allocated) ? (char *)s : xmemdupz(s, len)) },
.vval = { .v_string = ((s == NULL || s_allocated) ? (char *)s : xmemdupz(s, len)) },
};
}
}

View File

@ -67,10 +67,10 @@ int encode_list_write(void *const data, const char *const buf, const size_t len)
line_end = xmemscan(buf, NL, len);
if (line_end != buf) {
const size_t line_length = (size_t)(line_end - buf);
char *str = (char *)TV_LIST_ITEM_TV(li)->vval.v_string;
char *str = TV_LIST_ITEM_TV(li)->vval.v_string;
const size_t li_len = (str == NULL ? 0 : strlen(str));
TV_LIST_ITEM_TV(li)->vval.v_string = xrealloc(str, li_len + line_length + 1);
str = (char *)TV_LIST_ITEM_TV(li)->vval.v_string + li_len;
str = TV_LIST_ITEM_TV(li)->vval.v_string + li_len;
memcpy(str, buf, line_length);
str[line_length] = 0;
memchrsub(str, NUL, NL, line_length);
@ -130,9 +130,10 @@ static int conv_error(const char *const msg, const MPConvStack *const mpstack,
case kMPConvDict: {
typval_T key_tv = {
.v_type = VAR_STRING,
.vval = { .v_string = (v.data.d.hi == NULL
? v.data.d.dict->dv_hashtab.ht_array
: (v.data.d.hi - 1))->hi_key },
.vval = { .v_string =
(char *)(v.data.d.hi ==
NULL ? v.data.d.dict->dv_hashtab.ht_array : (v.data.d.hi -
1))->hi_key },
};
char *const key = encode_tv2string(&key_tv, NULL);
vim_snprintf((char *)IObuff, IOSIZE, key_msg, key);
@ -263,7 +264,7 @@ int encode_read_from_list(ListReaderState *const state, char *const buf, const s
|| TV_LIST_ITEM_TV(state->li)->vval.v_string != NULL);
for (size_t i = state->offset; i < state->li_length && p < buf_end; i++) {
assert(TV_LIST_ITEM_TV(state->li)->vval.v_string != NULL);
const char ch = (char)(TV_LIST_ITEM_TV(state->li)->vval.v_string[state->offset++]);
const char ch = TV_LIST_ITEM_TV(state->li)->vval.v_string[state->offset++];
*p++ = (char)(ch == (char)NL ? (char)NUL : ch);
}
if (p < buf_end) {
@ -869,7 +870,7 @@ char *encode_tv2echo(typval_T *tv, size_t *len)
ga_init(&ga, (int)sizeof(char), 80);
if (tv->v_type == VAR_STRING || tv->v_type == VAR_FUNC) {
if (tv->vval.v_string != NULL) {
ga_concat(&ga, (char *)tv->vval.v_string);
ga_concat(&ga, tv->vval.v_string);
}
} else {
const int eve_ret = encode_vim_to_echo(&ga, tv, N_(":echo argument"));

View File

@ -114,7 +114,7 @@ int eexe_mod_op(typval_T *const tv1, const typval_T *const tv2, const char *cons
numbuf));
tv_clear(tv1);
tv1->v_type = VAR_STRING;
tv1->vval.v_string = (char_u *)s;
tv1->vval.v_string = s;
}
return OK;
case VAR_FLOAT: {

View File

@ -439,7 +439,7 @@ static void f_argv(typval_T *argvars, typval_T *rettv, FunPtr fptr)
rettv->vval.v_string = NULL;
int idx = tv_get_number_chk(&argvars[0], NULL);
if (arglist != NULL && idx >= 0 && idx < argcount) {
rettv->vval.v_string = (char_u *)xstrdup((const char *)alist_name(&arglist[idx]));
rettv->vval.v_string = xstrdup((const char *)alist_name(&arglist[idx]));
} else if (idx == -1) {
get_arglist_as_rettv(arglist, argcount, rettv);
}
@ -484,7 +484,7 @@ static buf_T *find_buffer(typval_T *avar)
if (avar->v_type == VAR_NUMBER) {
buf = buflist_findnr((int)avar->vval.v_number);
} else if (avar->v_type == VAR_STRING && avar->vval.v_string != NULL) {
buf = buflist_findname_exp(avar->vval.v_string);
buf = buflist_findname_exp((char_u *)avar->vval.v_string);
if (buf == NULL) {
/* No full path name match, try a match with a URL or a "nofile"
* buffer, these don't use the full path. */
@ -562,7 +562,7 @@ static void f_bufname(typval_T *argvars, typval_T *rettv, FunPtr fptr)
buf = tv_get_buf_from_arg(&argvars[0]);
}
if (buf != NULL && buf->b_fname != NULL) {
rettv->vval.v_string = (char_u *)xstrdup((char *)buf->b_fname);
rettv->vval.v_string = xstrdup((char *)buf->b_fname);
}
}
@ -641,7 +641,7 @@ static void f_bufwinnr(typval_T *argvars, typval_T *rettv, FunPtr fptr)
/// Get buffer by number or pattern.
buf_T *tv_get_buf(typval_T *tv, int curtab_only)
{
char_u *name = tv->vval.v_string;
char_u *name = (char_u *)tv->vval.v_string;
int save_magic;
char_u *save_cpo;
buf_T *buf;
@ -769,7 +769,7 @@ static void f_call(typval_T *argvars, typval_T *rettv, FunPtr fptr)
partial_T *partial = NULL;
dict_T *selfdict = NULL;
if (argvars[0].v_type == VAR_FUNC) {
func = argvars[0].vval.v_string;
func = (char_u *)argvars[0].vval.v_string;
} else if (argvars[0].v_type == VAR_PARTIAL) {
partial = argvars[0].vval.v_partial;
func = (char_u *)partial_name(partial);
@ -823,7 +823,7 @@ static void f_chanclose(typval_T *argvars, typval_T *rettv, FunPtr fptr)
ChannelPart part = kChannelPartAll;
if (argvars[1].v_type == VAR_STRING) {
char *stream = (char *)argvars[1].vval.v_string;
char *stream = argvars[1].vval.v_string;
if (!strcmp(stream, "stdin")) {
part = kChannelPartStdin;
} else if (!strcmp(stream, "stdout")) {
@ -1008,7 +1008,7 @@ static void f_chdir(typval_T *argvars, typval_T *rettv, FunPtr fptr)
#ifdef BACKSLASH_IN_FILENAME
slash_adjust(cwd);
#endif
rettv->vval.v_string = vim_strsave(cwd);
rettv->vval.v_string = (char *)vim_strsave(cwd);
}
xfree(cwd);
@ -1018,7 +1018,7 @@ static void f_chdir(typval_T *argvars, typval_T *rettv, FunPtr fptr)
scope = kCdScopeTabpage;
}
if (!changedir_func((char *)argvars[0].vval.v_string, scope)) {
if (!changedir_func(argvars[0].vval.v_string, scope)) {
// Directory change failed
XFREE_CLEAR(rettv->vval.v_string);
}
@ -1196,7 +1196,7 @@ static void f_count(typval_T *argvars, typval_T *rettv, FunPtr fptr)
if (argvars[0].v_type == VAR_STRING) {
const char_u *expr = (char_u *)tv_get_string_chk(&argvars[1]);
const char_u *p = argvars[0].vval.v_string;
const char_u *p = (char_u *)argvars[0].vval.v_string;
if (!error && expr != NULL && *expr != NUL && p != NULL) {
if (ic) {
@ -1868,8 +1868,9 @@ static void f_escape(typval_T *argvars, typval_T *rettv, FunPtr fptr)
{
char buf[NUMBUFLEN];
rettv->vval.v_string = vim_strsave_escaped((const char_u *)tv_get_string(&argvars[0]),
(const char_u *)tv_get_string_buf(&argvars[1], buf));
rettv->vval.v_string = (char *)vim_strsave_escaped((const char_u *)tv_get_string(&argvars[0]),
(const char_u *)tv_get_string_buf(&argvars[1],
buf));
rettv->v_type = VAR_STRING;
}
@ -1883,7 +1884,7 @@ static void f_getenv(typval_T *argvars, typval_T *rettv, FunPtr fptr)
rettv->vval.v_special = kSpecialVarNull;
return;
}
rettv->vval.v_string = p;
rettv->vval.v_string = (char *)p;
rettv->v_type = VAR_STRING;
}
@ -2055,7 +2056,7 @@ static void f_exepath(typval_T *argvars, typval_T *rettv, FunPtr fptr)
(void)os_can_exe(tv_get_string(&argvars[0]), &path, true);
rettv->v_type = VAR_STRING;
rettv->vval.v_string = (char_u *)path;
rettv->vval.v_string = path;
}
/// "exists()" function
@ -2134,7 +2135,7 @@ static void f_expand(typval_T *argvars, typval_T *rettv, FunPtr fptr)
}
XFREE_CLEAR(result);
} else {
rettv->vval.v_string = result;
rettv->vval.v_string = (char *)result;
}
} else {
// When the optional second argument is non-zero, don't remove matches
@ -2150,8 +2151,8 @@ static void f_expand(typval_T *argvars, typval_T *rettv, FunPtr fptr)
options += WILD_ICASE;
}
if (rettv->v_type == VAR_STRING) {
rettv->vval.v_string = ExpandOne(&xpc, (char_u *)s, NULL, options,
WILD_ALL);
rettv->vval.v_string = (char *)ExpandOne(&xpc, (char_u *)s, NULL, options,
WILD_ALL);
} else {
ExpandOne(&xpc, (char_u *)s, NULL, options, WILD_ALL_KEEP);
tv_list_alloc_ret(rettv, xpc.xp_numfiles);
@ -2205,7 +2206,7 @@ static void f_expandcmd(typval_T *argvars, typval_T *rettv, FunPtr fptr)
if (errormsg != NULL && *errormsg != NUL) {
emsg(errormsg);
}
rettv->vval.v_string = cmdstr;
rettv->vval.v_string = (char *)cmdstr;
}
@ -2415,7 +2416,7 @@ static void findfilendir(typval_T *argvars, typval_T *rettv, int find_what)
}
if (rettv->v_type == VAR_STRING) {
rettv->vval.v_string = fresult;
rettv->vval.v_string = (char *)fresult;
}
}
@ -2471,7 +2472,7 @@ static void f_fmod(typval_T *argvars, typval_T *rettv, FunPtr fptr)
/// "fnameescape({string})" function
static void f_fnameescape(typval_T *argvars, typval_T *rettv, FunPtr fptr)
{
rettv->vval.v_string = (char_u *)vim_strsave_fnameescape(tv_get_string(&argvars[0]), false);
rettv->vval.v_string = vim_strsave_fnameescape(tv_get_string(&argvars[0]), false);
rettv->v_type = VAR_STRING;
}
@ -2498,7 +2499,7 @@ static void f_fnamemodify(typval_T *argvars, typval_T *rettv, FunPtr fptr)
if (fname == NULL) {
rettv->vval.v_string = NULL;
} else {
rettv->vval.v_string = (char_u *)xmemdupz(fname, len);
rettv->vval.v_string = xmemdupz(fname, len);
}
xfree(fbuf);
}
@ -2593,7 +2594,7 @@ static void f_foldtext(typval_T *argvars, typval_T *rettv, FunPtr fptr)
STRCAT(r, s);
// remove 'foldmarker' and 'commentstring'
foldtext_cleanup(r + len);
rettv->vval.v_string = r;
rettv->vval.v_string = (char *)r;
}
}
@ -2622,7 +2623,7 @@ static void f_foldtextresult(typval_T *argvars, typval_T *rettv, FunPtr fptr)
if (text == buf) {
text = vim_strsave(text);
}
rettv->vval.v_string = text;
rettv->vval.v_string = (char *)text;
}
entered = false;
@ -2704,7 +2705,7 @@ static void f_get(typval_T *argvars, typval_T *rettv, FunPtr fptr)
pt = argvars[0].vval.v_partial;
} else {
memset(&fref_pt, 0, sizeof(fref_pt));
fref_pt.pt_name = argvars[0].vval.v_string;
fref_pt.pt_name = (char_u *)argvars[0].vval.v_string;
pt = &fref_pt;
}
@ -2715,9 +2716,9 @@ static void f_get(typval_T *argvars, typval_T *rettv, FunPtr fptr)
rettv->v_type = (*what == 'f' ? VAR_FUNC : VAR_STRING);
const char *const n = (const char *)partial_name(pt);
assert(n != NULL);
rettv->vval.v_string = (char_u *)xstrdup(n);
rettv->vval.v_string = xstrdup(n);
if (rettv->v_type == VAR_FUNC) {
func_ref(rettv->vval.v_string);
func_ref((char_u *)rettv->vval.v_string);
}
} else if (strcmp(what, "dict") == 0) {
what_is_dict = true;
@ -2846,9 +2847,9 @@ static void get_buffer_lines(buf_T *buf, linenr_T start, linenr_T end, int retli
}
} else {
rettv->v_type = VAR_STRING;
rettv->vval.v_string = ((start >= 1 && start <= buf->b_ml.ml_line_count)
? vim_strsave(ml_get_buf(buf, start, false))
: NULL);
rettv->vval.v_string =
(char *)((start >= 1 && start <= buf->b_ml.ml_line_count)
? vim_strsave(ml_get_buf(buf, start, false)) : NULL);
}
}
@ -3039,7 +3040,7 @@ static void getchar_common(typval_T *argvars, typval_T *rettv)
assert(i < 10);
temp[i++] = NUL;
rettv->v_type = VAR_STRING;
rettv->vval.v_string = vim_strsave(temp);
rettv->vval.v_string = (char *)vim_strsave(temp);
if (is_mouse_key(n)) {
int row = mouse_row;
@ -3091,7 +3092,7 @@ static void f_getcharstr(typval_T *argvars, typval_T *rettv, FunPtr fptr)
assert(i < 7);
temp[i++] = NUL;
rettv->v_type = VAR_STRING;
rettv->vval.v_string = vim_strsave(temp);
rettv->vval.v_string = (char *)vim_strsave(temp);
}
}
@ -3178,7 +3179,7 @@ static void f_getcharsearch(typval_T *argvars, typval_T *rettv, FunPtr fptr)
static void f_getcmdline(typval_T *argvars, typval_T *rettv, FunPtr fptr)
{
rettv->v_type = VAR_STRING;
rettv->vval.v_string = get_cmdline_str();
rettv->vval.v_string = (char *)get_cmdline_str();
}
/// "getcmdpos()" function
@ -3395,7 +3396,7 @@ static void f_getcwd(typval_T *argvars, typval_T *rettv, FunPtr fptr)
STRLCPY(cwd, from, MAXPATHL);
}
rettv->vval.v_string = vim_strsave(cwd);
rettv->vval.v_string = (char *)vim_strsave(cwd);
#ifdef BACKSLASH_IN_FILENAME
slash_adjust(rettv->vval.v_string);
#endif
@ -3427,7 +3428,7 @@ static void f_getfperm(typval_T *argvars, typval_T *rettv, FunPtr fptr)
}
}
rettv->v_type = VAR_STRING;
rettv->vval.v_string = (char_u *)perm;
rettv->vval.v_string = perm;
}
/// "getfsize({fname})" function
@ -3499,7 +3500,7 @@ static void f_getftype(typval_T *argvars, typval_T *rettv, FunPtr fptr)
}
type = vim_strsave((char_u *)t);
}
rettv->vval.v_string = type;
rettv->vval.v_string = (char *)type;
}
/// "getjumplist()" function
@ -3722,7 +3723,7 @@ static void f_getregtype(typval_T *argvars, typval_T *rettv, FunPtr fptr)
MotionType reg_type = get_reg_type(regname, &reglen);
format_reg_type(reg_type, reglen, buf, ARRAY_SIZE(buf));
rettv->vval.v_string = (char_u *)xstrdup(buf);
rettv->vval.v_string = xstrdup(buf);
}
/// "gettabinfo()" function
@ -4064,8 +4065,9 @@ static void f_glob(typval_T *argvars, typval_T *rettv, FunPtr fptr)
options += WILD_ICASE;
}
if (rettv->v_type == VAR_STRING) {
rettv->vval.v_string = ExpandOne(&xpc, (char_u *)tv_get_string(&argvars[0]), NULL, options,
WILD_ALL);
rettv->vval.v_string = (char *)ExpandOne(&xpc, (char_u *)
tv_get_string(&argvars[0]), NULL, options,
WILD_ALL);
} else {
ExpandOne(&xpc, (char_u *)tv_get_string(&argvars[0]), NULL, options,
WILD_ALL_KEEP);
@ -4116,7 +4118,7 @@ static void f_globpath(typval_T *argvars, typval_T *rettv, FunPtr fptr)
globpath((char_u *)tv_get_string(&argvars[0]), (char_u *)file, &ga, flags);
if (rettv->v_type == VAR_STRING) {
rettv->vval.v_string = (char_u *)ga_concat_strings_sep(&ga, "\n");
rettv->vval.v_string = ga_concat_strings_sep(&ga, "\n");
} else {
tv_list_alloc_ret(rettv, ga.ga_len);
for (int i = 0; i < ga.ga_len; i++) {
@ -4137,10 +4139,8 @@ static void f_glob2regpat(typval_T *argvars, typval_T *rettv, FunPtr fptr)
const char *const pat = tv_get_string_chk(&argvars[0]); // NULL on type error
rettv->v_type = VAR_STRING;
rettv->vval.v_string = ((pat == NULL)
? NULL
: file_pat_to_reg_pat((char_u *)pat, NULL, NULL,
false));
rettv->vval.v_string =
(char *)((pat == NULL) ? NULL : file_pat_to_reg_pat((char_u *)pat, NULL, NULL, false));
}
/// "has()" function
@ -4556,7 +4556,7 @@ static void f_histget(typval_T *argvars, typval_T *rettv, FunPtr fptr)
idx = (int)tv_get_number_chk(&argvars[1], NULL);
}
// -1 on type error
rettv->vval.v_string = vim_strsave(get_history_entry(type, idx));
rettv->vval.v_string = (char *)vim_strsave(get_history_entry(type, idx));
}
rettv->v_type = VAR_STRING;
}
@ -4593,7 +4593,7 @@ static void f_hostname(typval_T *argvars, typval_T *rettv, FunPtr fptr)
os_get_hostname(hostname, 256);
rettv->v_type = VAR_STRING;
rettv->vval.v_string = vim_strsave((char_u *)hostname);
rettv->vval.v_string = (char *)vim_strsave((char_u *)hostname);
}
/// iconv() function
@ -4614,9 +4614,9 @@ static void f_iconv(typval_T *argvars, typval_T *rettv, FunPtr fptr)
// If the encodings are equal, no conversion needed.
if (vimconv.vc_type == CONV_NONE) {
rettv->vval.v_string = (char_u *)xstrdup(str);
rettv->vval.v_string = xstrdup(str);
} else {
rettv->vval.v_string = string_convert(&vimconv, (char_u *)str, NULL);
rettv->vval.v_string = (char *)string_convert(&vimconv, (char_u *)str, NULL);
}
convert_setup(&vimconv, NULL, NULL);
@ -4945,8 +4945,7 @@ static void f_id(typval_T *argvars, typval_T *rettv, FunPtr fptr)
const int len = vim_vsnprintf_typval(NULL, 0, "%p", dummy_ap, argvars);
rettv->v_type = VAR_STRING;
rettv->vval.v_string = xmalloc(len + 1);
vim_vsnprintf_typval((char *)rettv->vval.v_string, len + 1, "%p",
dummy_ap, argvars);
vim_vsnprintf_typval(rettv->vval.v_string, len + 1, "%p", dummy_ap, argvars);
}
/// "items(dict)" function
@ -5407,7 +5406,7 @@ static void f_join(typval_T *argvars, typval_T *rettv, FunPtr fptr)
ga_init(&ga, (int)sizeof(char), 80);
tv_list_join(&ga, argvars[0].vval.v_list, sep);
ga_append(&ga, NUL);
rettv->vval.v_string = (char_u *)ga.ga_data;
rettv->vval.v_string = ga.ga_data;
} else {
rettv->vval.v_string = NULL;
}
@ -5451,7 +5450,7 @@ static void f_json_decode(typval_T *argvars, typval_T *rettv, FunPtr fptr)
static void f_json_encode(typval_T *argvars, typval_T *rettv, FunPtr fptr)
{
rettv->v_type = VAR_STRING;
rettv->vval.v_string = (char_u *)encode_tv2json(&argvars[0], NULL);
rettv->vval.v_string = encode_tv2json(&argvars[0], NULL);
}
/// "keys()" function
@ -5518,19 +5517,17 @@ static void libcall_common(typval_T *argvars, typval_T *rettv, int out_type)
return;
}
const char *libname = (char *)argvars[0].vval.v_string;
const char *funcname = (char *)argvars[1].vval.v_string;
const char *libname = argvars[0].vval.v_string;
const char *funcname = argvars[1].vval.v_string;
VarType in_type = argvars[2].v_type;
// input variables
char *str_in = (in_type == VAR_STRING)
? (char *)argvars[2].vval.v_string : NULL;
char *str_in = (in_type == VAR_STRING) ? argvars[2].vval.v_string : NULL;
int int_in = argvars[2].vval.v_number;
// output variables
char **str_out = (out_type == VAR_STRING)
? (char **)&rettv->vval.v_string : NULL;
char **str_out = (out_type == VAR_STRING) ? &rettv->vval.v_string : NULL;
int int_out = 0;
bool success = os_libcall(libname, funcname,
@ -5711,15 +5708,15 @@ static void get_maparg(typval_T *argvars, typval_T *rettv, int exact)
// Return a string.
if (rhs != NULL) {
if (*rhs == NUL) {
rettv->vval.v_string = vim_strsave((char_u *)"<Nop>");
rettv->vval.v_string = xstrdup("<Nop>");
} else {
rettv->vval.v_string = (char_u *)str2special_save((char *)rhs, false, false);
rettv->vval.v_string = str2special_save((char *)rhs, false, false);
}
} else if (rhs_lua != LUA_NOREF) {
size_t msglen = 100;
char *msg = (char *)xmalloc(msglen);
snprintf(msg, msglen, "<Lua function %d>", mp->m_luaref);
rettv->vval.v_string = (char_u *)msg;
rettv->vval.v_string = msg;
}
} else {
tv_dict_alloc_ret(rettv);
@ -5943,9 +5940,9 @@ static void find_some_match(typval_T *const argvars, typval_T *const rettv,
if (l != NULL) {
tv_copy(TV_LIST_ITEM_TV(li), rettv);
} else {
rettv->vval.v_string = (char_u *)xmemdupz((const char *)regmatch.startp[0],
(size_t)(regmatch.endp[0] -
regmatch.startp[0]));
rettv->vval.v_string = xmemdupz((const char *)regmatch.startp[0],
(size_t)(regmatch.endp[0] -
regmatch.startp[0]));
}
break;
case kSomeMatch:
@ -6128,7 +6125,7 @@ static void f_mode(typval_T *argvars, typval_T *rettv, FunPtr fptr)
buf[1] = NUL;
}
rettv->vval.v_string = vim_strsave((char_u *)buf);
rettv->vval.v_string = xstrdup(buf);
rettv->v_type = VAR_STRING;
}
@ -6359,8 +6356,8 @@ static void f_pathshorten(typval_T *argvars, typval_T *rettv, FunPtr fptr)
if (p == NULL) {
rettv->vval.v_string = NULL;
} else {
rettv->vval.v_string = vim_strsave(p);
shorten_dir_len(rettv->vval.v_string, trim_len);
rettv->vval.v_string = (char *)vim_strsave(p);
shorten_dir_len((char_u *)rettv->vval.v_string, trim_len);
}
}
@ -6408,7 +6405,7 @@ static void f_printf(typval_T *argvars, typval_T *rettv, FunPtr fptr)
len = vim_vsnprintf_typval(NULL, 0, fmt, dummy_ap, argvars + 1);
if (!did_emsg) {
char *s = xmalloc(len + 1);
rettv->vval.v_string = (char_u *)s;
rettv->vval.v_string = s;
(void)vim_vsnprintf_typval(s, len + 1, fmt, dummy_ap, argvars + 1);
}
did_emsg |= saved_did_emsg;
@ -6480,7 +6477,7 @@ static void f_prompt_getprompt(typval_T *argvars, typval_T *rettv, FunPtr fptr)
return;
}
rettv->vval.v_string = vim_strsave(buf_prompt_text(buf));
rettv->vval.v_string = (char *)vim_strsave(buf_prompt_text(buf));
}
/// "prompt_setprompt({buffer}, {text})" function
@ -6746,7 +6743,7 @@ static varnumber_T readdir_checkitem(void *context, const char *name)
prepare_vimvar(VV_VAL, &save_val);
set_vim_var_string(VV_VAL, name, -1);
argv[0].v_type = VAR_STRING;
argv[0].vval.v_string = (char_u *)name;
argv[0].vval.v_string = (char *)name;
if (eval_expr_typval(expr, argv, 1, &rettv) == FAIL) {
goto theend;
@ -6881,7 +6878,7 @@ static void f_readfile(typval_T *argvars, typval_T *rettv, FunPtr fptr)
tv_list_append_owned_tv(l, (typval_T) {
.v_type = VAR_STRING,
.v_lock = VAR_UNLOCKED,
.vval.v_string = s,
.vval.v_string = (char *)s,
});
start = p + 1; // Step over newline.
@ -7121,7 +7118,7 @@ static void f_reltimestr(typval_T *argvars, typval_T *rettv, FunPtr fptr)
rettv->v_type = VAR_STRING;
rettv->vval.v_string = NULL;
if (list2proftime(&argvars[0], &tm) == OK) {
rettv->vval.v_string = (char_u *)xstrdup(profile_msg(tm));
rettv->vval.v_string = xstrdup(profile_msg(tm));
}
}
@ -7304,7 +7301,7 @@ static void f_repeat(typval_T *argvars, typval_T *rettv, FunPtr fptr)
memmove(r + i * slen, p, slen);
}
rettv->vval.v_string = (char_u *)r;
rettv->vval.v_string = r;
}
}
@ -7465,7 +7462,7 @@ static void f_resolve(typval_T *argvars, typval_T *rettv, FunPtr fptr)
}
}
rettv->vval.v_string = (char_u *)p;
rettv->vval.v_string = p;
xfree(buf);
}
# else
@ -7474,7 +7471,7 @@ static void f_resolve(typval_T *argvars, typval_T *rettv, FunPtr fptr)
# endif
#endif
simplify_filename(rettv->vval.v_string);
simplify_filename((char_u *)rettv->vval.v_string);
}
/// "reverse({list})" function
@ -7513,7 +7510,7 @@ static void f_reduce(typval_T *argvars, typval_T *rettv, FunPtr fptr)
const char_u *func_name;
partial_T *partial = NULL;
if (argvars[1].v_type == VAR_FUNC) {
func_name = argvars[1].vval.v_string;
func_name = (char_u *)argvars[1].vval.v_string;
} else if (argvars[1].v_type == VAR_PARTIAL) {
partial = argvars[1].vval.v_partial;
func_name = (char_u *)partial_name(partial);
@ -7981,7 +7978,7 @@ static void f_rpcstart(typval_T *argvars, typval_T *rettv, FunPtr fptr)
char **argv = xmalloc(sizeof(char_u *) * argvl);
// Copy program name
argv[0] = xstrdup((char *)argvars[0].vval.v_string);
argv[0] = xstrdup(argvars[0].vval.v_string);
int i = 1;
// Copy arguments to the vector
@ -8148,7 +8145,7 @@ static void f_screenstring(typval_T *argvars, typval_T *rettv, FunPtr fptr)
}
ScreenGrid *grid = &default_grid;
screenchar_adjust_grid(&grid, &row, &col);
rettv->vval.v_string = vim_strsave(grid->chars[grid->line_offset[row] + col]);
rettv->vval.v_string = (char *)vim_strsave(grid->chars[grid->line_offset[row] + col]);
}
/// "search()" function
@ -8517,7 +8514,7 @@ static void f_serverstart(typval_T *argvars, typval_T *rettv, FunPtr fptr)
// "localhost:" will now have a port), return the final value to the user.
size_t n;
char **addrs = server_address_list(&n);
rettv->vval.v_string = (char_u *)addrs[n - 1];
rettv->vval.v_string = addrs[n - 1];
n--;
for (size_t i = 0; i < n; i++) {
@ -8541,7 +8538,7 @@ static void f_serverstop(typval_T *argvars, typval_T *rettv, FunPtr fptr)
rettv->v_type = VAR_NUMBER;
rettv->vval.v_number = 0;
if (argvars[0].vval.v_string) {
bool rv = server_stop((char *)argvars[0].vval.v_string);
bool rv = server_stop(argvars[0].vval.v_string);
rettv->vval.v_number = (rv ? 1 : 0);
}
}
@ -9130,7 +9127,7 @@ static void f_sha256(typval_T *argvars, typval_T *rettv, FunPtr fptr)
const char *hash = sha256_bytes((const uint8_t *)p, strlen(p), NULL, 0);
// make a copy of the hash (sha256_bytes returns a static buffer)
rettv->vval.v_string = (char_u *)xstrdup(hash);
rettv->vval.v_string = xstrdup(hash);
rettv->v_type = VAR_STRING;
}
@ -9139,9 +9136,9 @@ static void f_shellescape(typval_T *argvars, typval_T *rettv, FunPtr fptr)
{
const bool do_special = non_zero_arg(&argvars[1]);
rettv->vval.v_string = vim_strsave_shellescape((const char_u *)tv_get_string(
&argvars[0]), do_special,
do_special);
rettv->vval.v_string =
(char *)vim_strsave_shellescape((const char_u *)tv_get_string(&argvars[0]), do_special,
do_special);
rettv->v_type = VAR_STRING;
}
@ -9167,8 +9164,8 @@ static void f_shiftwidth(typval_T *argvars, typval_T *rettv, FunPtr fptr)
static void f_simplify(typval_T *argvars, typval_T *rettv, FunPtr fptr)
{
const char *const p = tv_get_string(&argvars[0]);
rettv->vval.v_string = (char_u *)xstrdup(p);
simplify_filename(rettv->vval.v_string); // Simplify in place.
rettv->vval.v_string = xstrdup(p);
simplify_filename((char_u *)rettv->vval.v_string); // Simplify in place.
rettv->v_type = VAR_STRING;
}
@ -9279,7 +9276,7 @@ static int item_compare(const void *s1, const void *s2, bool keep_zero)
if (tv2->v_type != VAR_STRING || sortinfo->item_compare_numeric) {
p1 = "'";
} else {
p1 = (char *)tv1->vval.v_string;
p1 = tv1->vval.v_string;
}
} else {
tofree1 = p1 = encode_tv2string(tv1, NULL);
@ -9288,7 +9285,7 @@ static int item_compare(const void *s1, const void *s2, bool keep_zero)
if (tv1->v_type != VAR_STRING || sortinfo->item_compare_numeric) {
p2 = "'";
} else {
p2 = (char *)tv2->vval.v_string;
p2 = tv2->vval.v_string;
}
} else {
tofree2 = p2 = encode_tv2string(tv2, NULL);
@ -9620,7 +9617,7 @@ static void f_soundfold(typval_T *argvars, typval_T *rettv, FunPtr fptr)
{
rettv->v_type = VAR_STRING;
const char *const s = tv_get_string(&argvars[0]);
rettv->vval.v_string = (char_u *)eval_soundfold(s);
rettv->vval.v_string = eval_soundfold(s);
}
/// "spellbadword()" function
@ -9823,11 +9820,11 @@ static void f_stdpath(typval_T *argvars, typval_T *rettv, FunPtr fptr)
}
if (strequal(p, "config")) {
rettv->vval.v_string = (char_u *)get_xdg_home(kXDGConfigHome);
rettv->vval.v_string = get_xdg_home(kXDGConfigHome);
} else if (strequal(p, "data")) {
rettv->vval.v_string = (char_u *)get_xdg_home(kXDGDataHome);
rettv->vval.v_string = get_xdg_home(kXDGDataHome);
} else if (strequal(p, "cache")) {
rettv->vval.v_string = (char_u *)get_xdg_home(kXDGCacheHome);
rettv->vval.v_string = get_xdg_home(kXDGCacheHome);
} else if (strequal(p, "config_dirs")) {
get_xdg_var_list(kXDGConfigDirs, rettv);
} else if (strequal(p, "data_dirs")) {
@ -9925,7 +9922,7 @@ static void f_strftime(typval_T *argvars, typval_T *rettv, FunPtr fptr)
struct tm *curtime_ptr = os_localtime_r(&seconds, &curtime);
// MSVC returns NULL for an invalid value of seconds.
if (curtime_ptr == NULL) {
rettv->vval.v_string = vim_strsave((char_u *)_("(Invalid)"));
rettv->vval.v_string = xstrdup(_("(Invalid)"));
} else {
vimconv_T conv;
char_u *enc;
@ -9948,9 +9945,9 @@ static void f_strftime(typval_T *argvars, typval_T *rettv, FunPtr fptr)
}
convert_setup(&conv, enc, p_enc);
if (conv.vc_type != CONV_NONE) {
rettv->vval.v_string = string_convert(&conv, (char_u *)result_buf, NULL);
rettv->vval.v_string = (char *)string_convert(&conv, (char_u *)result_buf, NULL);
} else {
rettv->vval.v_string = (char_u *)xstrdup(result_buf);
rettv->vval.v_string = xstrdup(result_buf);
}
// Release conversion descriptors.
@ -10023,7 +10020,7 @@ static void f_stridx(typval_T *argvars, typval_T *rettv, FunPtr fptr)
static void f_string(typval_T *argvars, typval_T *rettv, FunPtr fptr)
{
rettv->v_type = VAR_STRING;
rettv->vval.v_string = (char_u *)encode_tv2string(&argvars[0], NULL);
rettv->vval.v_string = encode_tv2string(&argvars[0], NULL);
}
/// "strlen()" function
@ -10073,7 +10070,7 @@ static void f_strwidth(typval_T *argvars, typval_T *rettv, FunPtr fptr)
{
const char *const s = tv_get_string(&argvars[0]);
rettv->vval.v_number = (varnumber_T)mb_string2cells((const char_u *)s);
rettv->vval.v_number = (varnumber_T)mb_string2cells(s);
}
/// "strcharpart()" function
@ -10127,7 +10124,7 @@ static void f_strcharpart(typval_T *argvars, typval_T *rettv, FunPtr fptr)
}
rettv->v_type = VAR_STRING;
rettv->vval.v_string = (char_u *)xstrndup(p + nbyte, (size_t)len);
rettv->vval.v_string = xstrndup(p + nbyte, (size_t)len);
}
/// "strpart()" function
@ -10173,7 +10170,7 @@ static void f_strpart(typval_T *argvars, typval_T *rettv, FunPtr fptr)
}
rettv->v_type = VAR_STRING;
rettv->vval.v_string = (char_u *)xmemdupz(p + n, (size_t)len);
rettv->vval.v_string = xmemdupz(p + n, (size_t)len);
}
/// "strptime({format}, {timestring})" function
@ -10255,7 +10252,7 @@ static void f_strridx(typval_T *argvars, typval_T *rettv, FunPtr fptr)
static void f_strtrans(typval_T *argvars, typval_T *rettv, FunPtr fptr)
{
rettv->v_type = VAR_STRING;
rettv->vval.v_string = (char_u *)transstr(tv_get_string(&argvars[0]), true);
rettv->vval.v_string = transstr(tv_get_string(&argvars[0]), true);
}
/// "submatch()" function
@ -10282,7 +10279,7 @@ static void f_submatch(typval_T *argvars, typval_T *rettv, FunPtr fptr)
if (retList == 0) {
rettv->v_type = VAR_STRING;
rettv->vval.v_string = reg_submatch(no);
rettv->vval.v_string = (char *)reg_submatch(no);
} else {
rettv->v_type = VAR_LIST;
rettv->vval.v_list = reg_submatch_list(no);
@ -10313,8 +10310,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 = (char_u *)do_string_sub((char *)str, (char *)pat,
(char *)sub, expr, (char *)flg);
rettv->vval.v_string = do_string_sub((char *)str, (char *)pat,
(char *)sub, expr, (char *)flg);
}
}
@ -10335,7 +10332,7 @@ static void f_swapname(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|| buf->b_ml.ml_mfp->mf_fname == NULL) {
rettv->vval.v_string = NULL;
} else {
rettv->vval.v_string = vim_strsave(buf->b_ml.ml_mfp->mf_fname);
rettv->vval.v_string = (char *)vim_strsave(buf->b_ml.ml_mfp->mf_fname);
}
}
@ -10431,7 +10428,7 @@ static void f_synIDattr(typval_T *argvars, typval_T *rettv, FunPtr fptr)
}
rettv->v_type = VAR_STRING;
rettv->vval.v_string = (char_u *)(p == NULL ? p : xstrdup(p));
rettv->vval.v_string = (char *)(p == NULL ? p : xstrdup(p));
}
/// "synIDtrans(id)" function
@ -10691,7 +10688,7 @@ static void f_taglist(typval_T *argvars, typval_T *rettv, FunPtr fptr)
static void f_tempname(typval_T *argvars, typval_T *rettv, FunPtr fptr)
{
rettv->v_type = VAR_STRING;
rettv->vval.v_string = vim_tempname();
rettv->vval.v_string = (char *)vim_tempname();
}
/// "termopen(cmd[, cwd])" function
@ -10905,16 +10902,14 @@ static void f_timer_stopall(typval_T *argvars, typval_T *unused, FunPtr fptr)
static void f_tolower(typval_T *argvars, typval_T *rettv, FunPtr fptr)
{
rettv->v_type = VAR_STRING;
rettv->vval.v_string = (char_u *)strcase_save(tv_get_string(&argvars[0]),
false);
rettv->vval.v_string = strcase_save(tv_get_string(&argvars[0]), false);
}
/// "toupper(string)" function
static void f_toupper(typval_T *argvars, typval_T *rettv, FunPtr fptr)
{
rettv->v_type = VAR_STRING;
rettv->vval.v_string = (char_u *)strcase_save(tv_get_string(&argvars[0]),
true);
rettv->vval.v_string = strcase_save(tv_get_string(&argvars[0]), true);
}
/// "tr(string, fromstr, tostr)" function
@ -11076,7 +11071,7 @@ static void f_trim(typval_T *argvars, typval_T *rettv, FunPtr fptr)
}
}
}
rettv->vval.v_string = vim_strnsave(head, tail - head);
rettv->vval.v_string = (char *)vim_strnsave(head, tail - head);
}
/// "type(expr)" function
@ -11124,7 +11119,7 @@ static void f_undofile(typval_T *argvars, typval_T *rettv, FunPtr fptr)
char *ffname = FullName_save(fname, true);
if (ffname != NULL) {
rettv->vval.v_string = (char_u *)u_get_undo_file_name(ffname, false);
rettv->vval.v_string = u_get_undo_file_name(ffname, false);
}
xfree(ffname);
}
@ -11188,7 +11183,7 @@ static void f_visualmode(typval_T *argvars, typval_T *rettv, FunPtr fptr)
rettv->v_type = VAR_STRING;
str[0] = curbuf->b_visual_mode_eval;
str[1] = NUL;
rettv->vval.v_string = vim_strsave(str);
rettv->vval.v_string = (char *)vim_strsave(str);
// A non-zero number or non-empty string argument: reset mode.
if (non_zero_arg(&argvars[0])) {
@ -11227,21 +11222,20 @@ static void f_win_gettype(typval_T *argvars, typval_T *rettv, FunPtr fptr)
if (argvars[0].v_type != VAR_UNKNOWN) {
wp = find_win_by_nr_or_id(&argvars[0]);
if (wp == NULL) {
rettv->vval.v_string = vim_strsave((char_u *)"unknown");
rettv->vval.v_string = (char *)vim_strsave((char_u *)"unknown");
return;
}
}
if (wp == aucmd_win) {
rettv->vval.v_string = vim_strsave((char_u *)"autocmd");
rettv->vval.v_string = xstrdup("autocmd");
} else if (wp->w_p_pvw) {
rettv->vval.v_string = vim_strsave((char_u *)"preview");
rettv->vval.v_string = xstrdup("preview");
} else if (wp->w_floating) {
rettv->vval.v_string = vim_strsave((char_u *)"popup");
rettv->vval.v_string = xstrdup("popup");
} else if (wp == curwin && cmdwin_type != 0) {
rettv->vval.v_string = vim_strsave((char_u *)"command");
rettv->vval.v_string = xstrdup("command");
} else if (bt_quickfix(wp->w_buffer)) {
rettv->vval.v_string = vim_strsave((char_u *)(wp->w_llist_ref != NULL ?
"loclist" : "quickfix"));
rettv->vval.v_string = xstrdup((wp->w_llist_ref != NULL ? "loclist" : "quickfix"));
}
}
@ -11476,7 +11470,7 @@ static void f_winwidth(typval_T *argvars, typval_T *rettv, FunPtr fptr)
static void f_windowsversion(typval_T *argvars, typval_T *rettv, FunPtr fptr)
{
rettv->v_type = VAR_STRING;
rettv->vval.v_string = (char_u *)xstrdup(windowsVersion);
rettv->vval.v_string = xstrdup(windowsVersion);
}
/// "wordcount()" function

View File

@ -565,7 +565,7 @@ void tv_list_append_allocated_string(list_T *const l, char *const str)
tv_list_append_owned_tv(l, (typval_T) {
.v_type = VAR_STRING,
.v_lock = VAR_UNLOCKED,
.vval.v_string = (char_u *)str,
.vval.v_string = str,
});
}
@ -1139,7 +1139,7 @@ void callback_free(Callback *callback)
{
switch (callback->type) {
case kCallbackFuncref:
func_unref(callback->data.funcref);
func_unref((char_u *)callback->data.funcref);
xfree(callback->data.funcref);
break;
case kCallbackPartial:
@ -1167,8 +1167,8 @@ void callback_put(Callback *cb, typval_T *tv)
break;
case kCallbackFuncref:
tv->v_type = VAR_FUNC;
tv->vval.v_string = vim_strsave(cb->data.funcref);
func_ref(cb->data.funcref);
tv->vval.v_string = xstrdup(cb->data.funcref);
func_ref((char_u *)cb->data.funcref);
break;
case kCallbackLua:
// TODO(tjdevries): Unified Callback.
@ -1193,8 +1193,8 @@ void callback_copy(Callback *dest, Callback *src)
dest->data.partial->pt_refcount++;
break;
case kCallbackFuncref:
dest->data.funcref = vim_strsave(src->data.funcref);
func_ref(src->data.funcref);
dest->data.funcref = xstrdup(src->data.funcref);
func_ref((char_u *)src->data.funcref);
break;
case kCallbackLua:
dest->data.luaref = api_new_luaref(src->data.luaref);
@ -1288,7 +1288,7 @@ void tv_dict_watcher_notify(dict_T *const dict, const char *const key, typval_T
argv[0].vval.v_dict = dict;
argv[1].v_type = VAR_STRING;
argv[1].v_lock = VAR_UNLOCKED;
argv[1].vval.v_string = (char_u *)xstrdup(key);
argv[1].vval.v_string = xstrdup(key);
argv[2].v_type = VAR_DICT;
argv[2].v_lock = VAR_UNLOCKED;
argv[2].vval.v_dict = tv_dict_alloc();
@ -1906,7 +1906,7 @@ int tv_dict_add_allocated_str(dict_T *const d, const char *const key, const size
dictitem_T *const item = tv_dict_item_alloc_len(key, key_len);
item->di_tv.v_type = VAR_STRING;
item->di_tv.vval.v_string = (char_u *)val;
item->di_tv.vval.v_string = val;
if (tv_dict_add(d, item) == FAIL) {
tv_dict_item_free(item);
return FAIL;
@ -2532,7 +2532,7 @@ void tv_free(typval_T *tv)
partial_unref(tv->vval.v_partial);
break;
case VAR_FUNC:
func_unref(tv->vval.v_string);
func_unref((char_u *)tv->vval.v_string);
FALLTHROUGH;
case VAR_STRING:
xfree(tv->vval.v_string);
@ -2583,9 +2583,9 @@ void tv_copy(const typval_T *const from, typval_T *const to)
case VAR_STRING:
case VAR_FUNC:
if (from->vval.v_string != NULL) {
to->vval.v_string = vim_strsave(from->vval.v_string);
to->vval.v_string = xstrdup(from->vval.v_string);
if (from->v_type == VAR_FUNC) {
func_ref(to->vval.v_string);
func_ref((char_u *)to->vval.v_string);
}
}
break;
@ -3071,7 +3071,7 @@ varnumber_T tv_get_number_chk(const typval_T *const tv, bool *const ret_error)
case VAR_STRING: {
varnumber_T n = 0;
if (tv->vval.v_string != NULL) {
vim_str2nr(tv->vval.v_string, NULL, NULL, STR2NR_ALL, &n, NULL, 0,
vim_str2nr((char_u *)tv->vval.v_string, NULL, NULL, STR2NR_ALL, &n, NULL, 0,
false);
}
return n;

View File

@ -77,7 +77,7 @@ typedef enum {
typedef struct {
union {
char_u *funcref;
char *funcref;
partial_T *partial;
LuaRef luaref;
} data;
@ -133,19 +133,19 @@ typedef enum {
/// Structure that holds an internal variable value
typedef struct {
VarType v_type; ///< Variable type.
VarLockStatus v_lock; ///< Variable lock status.
VarType v_type; ///< Variable type.
VarLockStatus v_lock; ///< Variable lock status.
union typval_vval_union {
varnumber_T v_number; ///< Number, for VAR_NUMBER.
varnumber_T v_number; ///< Number, for VAR_NUMBER.
BoolVarValue v_bool; ///< Bool value, for VAR_BOOL
SpecialVarValue v_special; ///< Special value, for VAR_SPECIAL.
float_T v_float; ///< Floating-point number, for VAR_FLOAT.
char_u *v_string; ///< String, for VAR_STRING and VAR_FUNC, can be NULL.
list_T *v_list; ///< List for VAR_LIST, can be NULL.
dict_T *v_dict; ///< Dictionary for VAR_DICT, can be NULL.
partial_T *v_partial; ///< Closure: function with args.
blob_T *v_blob; ///< Blob for VAR_BLOB, can be NULL.
} vval; ///< Actual value.
float_T v_float; ///< Floating-point number, for VAR_FLOAT.
char *v_string; ///< String, for VAR_STRING and VAR_FUNC, can be NULL.
list_T *v_list; ///< List for VAR_LIST, can be NULL.
dict_T *v_dict; ///< Dictionary for VAR_DICT, can be NULL.
partial_T *v_partial; ///< Closure: function with args.
blob_T *v_blob; ///< Blob for VAR_BLOB, can be NULL.
} vval; ///< Actual value.
} typval_T;
/// Values for (struct dictvar_S).dv_scope

View File

@ -335,7 +335,7 @@ static int _TYPVAL_ENCODE_CONVERT_ONE_VALUE(
tv_blob_len(tv->vval.v_blob));
break;
case VAR_FUNC:
TYPVAL_ENCODE_CONV_FUNC_START(tv, tv->vval.v_string);
TYPVAL_ENCODE_CONV_FUNC_START(tv, (char_u *)tv->vval.v_string);
TYPVAL_ENCODE_CONV_FUNC_BEFORE_ARGS(tv, 0);
TYPVAL_ENCODE_CONV_FUNC_BEFORE_SELF(tv, -1);
TYPVAL_ENCODE_CONV_FUNC_END(tv);

View File

@ -359,7 +359,7 @@ char_u *deref_func_name(const char *name, int *lenp, partial_T **const partialp,
return (char_u *)"";
}
*lenp = (int)STRLEN(v->di_tv.vval.v_string);
return v->di_tv.vval.v_string;
return (char_u *)v->di_tv.vval.v_string;
}
if (v != NULL && v->di_tv.v_type == VAR_PARTIAL) {
@ -1756,7 +1756,7 @@ char_u *trans_function_name(char_u **pp, bool skip, int flags, funcdict_T *fdp,
fdp->fd_di = lv.ll_di;
}
if (lv.ll_tv->v_type == VAR_FUNC && lv.ll_tv->vval.v_string != NULL) {
name = vim_strsave(lv.ll_tv->vval.v_string);
name = vim_strsave((char_u *)lv.ll_tv->vval.v_string);
*pp = (char_u *)end;
} else if (lv.ll_tv->v_type == VAR_PARTIAL
&& lv.ll_tv->vval.v_partial != NULL) {
@ -2530,7 +2530,7 @@ void ex_function(exarg_T *eap)
tv_clear(&fudi.fd_di->di_tv);
}
fudi.fd_di->di_tv.v_type = VAR_FUNC;
fudi.fd_di->di_tv.vval.v_string = vim_strsave(name);
fudi.fd_di->di_tv.vval.v_string = (char *)vim_strsave(name);
// behave like "dict" was used
flags |= FC_DICT;
@ -3219,7 +3219,7 @@ void make_partial(dict_T *const selfdict, typval_T *const rettv)
fp = rettv->vval.v_partial->pt_func;
} else {
fname = rettv->v_type == VAR_FUNC || rettv->v_type == VAR_STRING
? rettv->vval.v_string
? (char_u *)rettv->vval.v_string
: rettv->vval.v_partial->pt_name;
// Translate "s:func" to the stored function name.
fname = fname_trans_sid(fname, fname_buf, &tofree, &error);
@ -3236,7 +3236,7 @@ void make_partial(dict_T *const selfdict, typval_T *const rettv)
pt->pt_auto = true;
if (rettv->v_type == VAR_FUNC || rettv->v_type == VAR_STRING) {
// Just a function: Take over the function name and use selfdict.
pt->pt_name = rettv->vval.v_string;
pt->pt_name = (char_u *)rettv->vval.v_string;
} else {
partial_T *ret_pt = rettv->vval.v_partial;
int i;

View File

@ -669,7 +669,7 @@ void ex_sort(exarg_T *eap)
// Copy the line into a buffer, it may become invalid in
// ml_append(). And it's needed for "unique".
STRCPY(sortbuf1, s);
if (ml_append(lnum++, (char_u *)sortbuf1, (colnr_T)0, false) == FAIL) {
if (ml_append(lnum++, sortbuf1, (colnr_T)0, false) == FAIL) {
break;
}
new_count += bytelen;
@ -825,7 +825,7 @@ void ex_retab(exarg_T *eap)
for (col = 0; col < len; col++) {
ptr[col] = (col < num_tabs) ? '\t' : ' ';
}
if (ml_replace(lnum, (char_u *)new_line, false) == OK) {
if (ml_replace(lnum, new_line, false) == OK) {
// "new_line" may have been copied
new_line = (char *)curbuf->b_ml.ml_line_ptr;
extmark_splice_cols(curbuf, lnum - 1, 0, (colnr_T)old_len,
@ -947,7 +947,7 @@ int do_move(linenr_T line1, linenr_T line2, linenr_T dest)
}
for (extra = 0, l = line1; l <= line2; l++) {
str = (char *)vim_strsave(ml_get(l + extra));
ml_append(dest + l - line1, (char_u *)str, (colnr_T)0, false);
ml_append(dest + l - line1, str, (colnr_T)0, false);
xfree(str);
if (dest < line1) {
extra++;
@ -1088,7 +1088,7 @@ void ex_copy(linenr_T line1, linenr_T line2, linenr_T n)
// need to use vim_strsave() because the line will be unlocked within
// ml_append()
p = (char *)vim_strsave(ml_get(line1));
ml_append(curwin->w_cursor.lnum, (char_u *)p, (colnr_T)0, false);
ml_append(curwin->w_cursor.lnum, p, (colnr_T)0, false);
xfree(p);
// situation 2: skip already copied lines
@ -3008,7 +3008,7 @@ void ex_append(exarg_T *eap)
}
did_undo = true;
ml_append(lnum, (char_u *)theline, (colnr_T)0, false);
ml_append(lnum, theline, (colnr_T)0, false);
if (empty) {
// there are no marks below the inserted lines
appended_lines(lnum, 1L);
@ -3912,7 +3912,7 @@ static buf_T *do_sub(exarg_T *eap, proftime_T timeout, bool do_buf_event, handle
// before the cursor.
len_change = (int)STRLEN(new_line) - (int)STRLEN(orig_line);
curwin->w_cursor.col += len_change;
ml_replace(lnum, (char_u *)new_line, false);
ml_replace(lnum, new_line, false);
}
search_match_lines = regmatch.endpos[0].lnum
@ -3959,7 +3959,7 @@ static buf_T *do_sub(exarg_T *eap, proftime_T timeout, bool do_buf_event, handle
// restore the line
if (orig_line != NULL) {
ml_replace(lnum, (char_u *)orig_line, false);
ml_replace(lnum, orig_line, false);
}
}
@ -4156,7 +4156,7 @@ static buf_T *do_sub(exarg_T *eap, proftime_T timeout, bool do_buf_event, handle
} else if (*p1 == CAR) {
if (u_inssub(lnum) == OK) { // prepare for undo
*p1 = NUL; // truncate up to the CR
ml_append(lnum - 1, (char_u *)new_start,
ml_append(lnum - 1, new_start,
(colnr_T)(p1 - new_start + 1), false);
mark_adjust(lnum + 1, (linenr_T)MAXLNUM, 1L, 0L, kExtmarkNOOP);
@ -4250,7 +4250,7 @@ skip:
if (u_savesub(lnum) != OK) {
break;
}
ml_replace(lnum, (char_u *)new_start, true);
ml_replace(lnum, new_start, true);
if (nmatch_tl > 0) {
/*
@ -5492,7 +5492,7 @@ void fix_help_buffer(void)
}
convert_setup(&vc, NULL, NULL);
ml_append(lnum, (char_u *)cp, (colnr_T)0, false);
ml_append(lnum, cp, (colnr_T)0, false);
if ((char_u *)cp != IObuff) {
xfree(cp);
}
@ -5998,9 +5998,9 @@ static buf_T *show_sub(exarg_T *eap, pos_T old_cusr, PreviewLines *preview_lines
snprintf(str, line_size, "|%*ld| %s", col_width - 3,
next_linenr, line);
if (linenr_preview == 0) {
ml_replace(1, (char_u *)str, true);
ml_replace(1, str, true);
} else {
ml_append(linenr_preview, (char_u *)str, (colnr_T)line_size, false);
ml_append(linenr_preview, str, (colnr_T)line_size, false);
}
linenr_preview += 1;
}

File diff suppressed because it is too large Load Diff

View File

@ -125,7 +125,7 @@ typedef char_u *(*LineGetter)(int, void *, int, bool);
/// Structure for command definition.
typedef struct cmdname {
char_u *cmd_name; ///< Name of the command.
char *cmd_name; ///< Name of the command.
ex_func_T cmd_func; ///< Function with implementation of this command.
uint32_t cmd_argt; ///< Relevant flags from the declared above.
cmd_addr_T cmd_addr_type; ///< Flag for address type

View File

@ -2187,7 +2187,7 @@ doend:
}
do_errthrow(cstack,
(ea.cmdidx != CMD_SIZE
&& !IS_USER_CMDIDX(ea.cmdidx)) ? (char *)cmdnames[(int)ea.cmdidx].cmd_name : NULL);
&& !IS_USER_CMDIDX(ea.cmdidx)) ? cmdnames[(int)ea.cmdidx].cmd_name : NULL);
undo_cmdmod(&ea, save_msg_scroll);
cmdmod = save_cmdmod;
@ -3079,7 +3079,7 @@ int cmd_exists(const char *const name)
void f_fullcommand(typval_T *argvars, typval_T *rettv, FunPtr fptr)
{
exarg_T ea;
char *name = (char *)argvars[0].vval.v_string;
char *name = argvars[0].vval.v_string;
rettv->v_type = VAR_STRING;
rettv->vval.v_string = NULL;
@ -3099,9 +3099,10 @@ void f_fullcommand(typval_T *argvars, typval_T *rettv, FunPtr fptr)
return;
}
rettv->vval.v_string = vim_strsave(IS_USER_CMDIDX(ea.cmdidx)
? (char_u *)get_user_command_name(ea.useridx, ea.cmdidx)
: cmdnames[ea.cmdidx].cmd_name);
rettv->vval.v_string = (char *)vim_strsave(IS_USER_CMDIDX(ea.cmdidx)
? (char_u *)get_user_command_name(ea.useridx,
ea.cmdidx)
: (char_u *)cmdnames[ea.cmdidx].cmd_name);
}
/// This is all pretty much copied from do_one_cmd(), with all the extra stuff
@ -5315,7 +5316,7 @@ char_u *get_command_name(expand_T *xp, int idx)
if (idx >= CMD_SIZE) {
return (char_u *)expand_user_command_name(idx);
}
return cmdnames[idx].cmd_name;
return (char_u *)cmdnames[idx].cmd_name;
}
/// Check for a valid user command name
@ -9011,7 +9012,7 @@ static void ex_findpat(exarg_T *eap)
static void ex_ptag(exarg_T *eap)
{
g_do_tagpreview = (int)p_pvh; // will be reset to 0 in ex_tag_cmd()
ex_tag_cmd(eap, (char *)cmdnames[eap->cmdidx].cmd_name + 1);
ex_tag_cmd(eap, cmdnames[eap->cmdidx].cmd_name + 1);
}
/// ":pedit"
@ -9041,7 +9042,7 @@ static void ex_stag(exarg_T *eap)
postponed_split = -1;
postponed_split_flags = cmdmod.split;
postponed_split_tab = cmdmod.tab;
ex_tag_cmd(eap, (char *)cmdnames[eap->cmdidx].cmd_name + 1);
ex_tag_cmd(eap, cmdnames[eap->cmdidx].cmd_name + 1);
postponed_split_flags = 0;
postponed_split_tab = 0;
}
@ -9049,7 +9050,7 @@ static void ex_stag(exarg_T *eap)
/// ":tag", ":tselect", ":tjump", ":tnext", etc.
static void ex_tag(exarg_T *eap)
{
ex_tag_cmd(eap, (char *)cmdnames[eap->cmdidx].cmd_name);
ex_tag_cmd(eap, cmdnames[eap->cmdidx].cmd_name);
}
static void ex_tag_cmd(exarg_T *eap, char *name)

View File

@ -2793,7 +2793,7 @@ static bool color_cmdline(CmdlineInfo *colored_ccline)
bool arg_allocated = false;
typval_T arg = {
.v_type = VAR_STRING,
.vval.v_string = colored_ccline->cmdbuff,
.vval.v_string = (char *)colored_ccline->cmdbuff,
};
typval_T tv = { .v_type = VAR_UNKNOWN };
@ -2954,7 +2954,7 @@ color_cmdline_end:
// Note: errors “output” is cached just as well as regular results.
ccline_colors->prompt_id = colored_ccline->prompt_id;
if (arg_allocated) {
ccline_colors->cmdbuff = (char *)arg.vval.v_string;
ccline_colors->cmdbuff = arg.vval.v_string;
} else {
ccline_colors->cmdbuff = xmemdupz((const char *)colored_ccline->cmdbuff,
(size_t)colored_ccline->cmdlen);
@ -5317,8 +5317,8 @@ static void *call_user_expand_func(user_expand_func_T user_expand_func, expand_T
args[1].v_type = VAR_STRING;
args[2].v_type = VAR_NUMBER;
args[3].v_type = VAR_UNKNOWN;
args[0].vval.v_string = pat;
args[1].vval.v_string = (char_u *)xp->xp_line;
args[0].vval.v_string = (char *)pat;
args[1].vval.v_string = xp->xp_line;
args[2].vval.v_number = xp->xp_col;
current_sctx = xp->xp_script_ctx;
@ -6430,7 +6430,7 @@ static int open_cmdwin(void)
i = 0;
}
if (history[histtype][i].hisstr != NULL) {
ml_append(lnum++, history[histtype][i].hisstr, (colnr_T)0, false);
ml_append(lnum++, (char *)history[histtype][i].hisstr, (colnr_T)0, false);
}
} while (i != hisidx[histtype]);
}
@ -6438,7 +6438,7 @@ static int open_cmdwin(void)
// Replace the empty last line with the current command-line and put the
// cursor there.
ml_replace(curbuf->b_ml.ml_line_count, ccline.cmdbuff, true);
ml_replace(curbuf->b_ml.ml_line_count, (char *)ccline.cmdbuff, true);
curwin->w_cursor.lnum = curbuf->b_ml.ml_line_count;
curwin->w_cursor.col = ccline.cmdpos;
changed_line_abv_curs();

View File

@ -1584,7 +1584,7 @@ rewind_retry:
if (skip_count == 0) {
*ptr = NUL; // end of line
len = (colnr_T)(ptr - line_start + 1);
if (ml_append(lnum, line_start, len, newfile) == FAIL) {
if (ml_append(lnum, (char *)line_start, len, newfile) == FAIL) {
error = true;
break;
}
@ -1640,7 +1640,7 @@ rewind_retry:
ff_error = EOL_DOS;
}
}
if (ml_append(lnum, line_start, len, newfile) == FAIL) {
if (ml_append(lnum, (char *)line_start, len, newfile) == FAIL) {
error = true;
break;
}
@ -1688,7 +1688,7 @@ failed:
}
*ptr = NUL;
len = (colnr_T)(ptr - line_start + 1);
if (ml_append(lnum, line_start, len, newfile) == FAIL) {
if (ml_append(lnum, (char *)line_start, len, newfile) == FAIL) {
error = true;
} else {
if (read_undo_file) {
@ -4872,7 +4872,7 @@ static int move_lines(buf_T *frombuf, buf_T *tobuf)
curbuf = tobuf;
for (lnum = 1; lnum <= frombuf->b_ml.ml_line_count; lnum++) {
p = vim_strsave(ml_get_buf(frombuf, lnum, false));
if (ml_append(lnum - 1, p, 0, false) == FAIL) {
if (ml_append(lnum - 1, (char *)p, 0, false) == FAIL) {
xfree(p);
retval = FAIL;
break;

View File

@ -73,7 +73,7 @@ for _, cmd in ipairs(defs) do
enumfile:write(' ' .. enumname .. ',\n')
defsfile:write(string.format([[
[%s] = {
.cmd_name = (char_u *) "%s",
.cmd_name = "%s",
.cmd_func = (ex_func_T)&%s,
.cmd_argt = %uL,
.cmd_addr_type = %s

View File

@ -2856,13 +2856,13 @@ int fix_input_buffer(char_u *buf, int len)
/// @param[in] orig_rhs_len `strlen` of orig_rhs.
/// @param[in] cpo_flags See param docs for @ref replace_termcodes.
/// @param[out] mapargs MapArguments struct holding the replaced strings.
void set_maparg_lhs_rhs(const char_u *const orig_lhs, const size_t orig_lhs_len,
const char_u *const orig_rhs, const size_t orig_rhs_len,
const LuaRef rhs_lua, const int cpo_flags, MapArguments *const mapargs)
void set_maparg_lhs_rhs(const char *const orig_lhs, const size_t orig_lhs_len,
const char *const orig_rhs, const size_t orig_rhs_len, const LuaRef rhs_lua,
const int cpo_flags, MapArguments *const mapargs)
{
char_u *lhs_buf = NULL;
char_u *alt_lhs_buf = NULL;
char_u *rhs_buf = NULL;
char *lhs_buf = NULL;
char *alt_lhs_buf = NULL;
char *rhs_buf = NULL;
// If mapping has been given as ^V<C_UP> say, then replace the term codes
// with the appropriate two bytes. If it is a shifted special key, unshift
@ -2874,13 +2874,15 @@ void set_maparg_lhs_rhs(const char_u *const orig_lhs, const size_t orig_lhs_len,
// If something like <C-H> is simplified to 0x08 then mark it as simplified.
bool did_simplify = false;
const int flags = REPTERM_FROM_PART | REPTERM_DO_LT;
char_u *replaced = replace_termcodes(orig_lhs, orig_lhs_len, &lhs_buf, flags, &did_simplify,
cpo_flags);
char *replaced = (char *)replace_termcodes((char_u *)orig_lhs, orig_lhs_len, (char_u **)&lhs_buf,
flags, &did_simplify,
cpo_flags);
mapargs->lhs_len = STRLEN(replaced);
STRLCPY(mapargs->lhs, replaced, sizeof(mapargs->lhs));
if (did_simplify) {
replaced = replace_termcodes(orig_lhs, orig_lhs_len, &alt_lhs_buf, flags | REPTERM_NO_SIMPLIFY,
NULL, cpo_flags);
replaced = (char *)replace_termcodes((char_u *)orig_lhs, orig_lhs_len, (char_u **)&alt_lhs_buf,
flags | REPTERM_NO_SIMPLIFY,
NULL, cpo_flags);
mapargs->alt_lhs_len = STRLEN(replaced);
STRLCPY(mapargs->alt_lhs, replaced, sizeof(mapargs->alt_lhs));
} else {
@ -2899,8 +2901,8 @@ void set_maparg_lhs_rhs(const char_u *const orig_lhs, const size_t orig_lhs_len,
mapargs->rhs_len = 0;
mapargs->rhs_is_noop = true;
} else {
replaced = replace_termcodes(orig_rhs, orig_rhs_len, &rhs_buf,
REPTERM_DO_LT | REPTERM_NO_SIMPLIFY, NULL, cpo_flags);
replaced = (char *)replace_termcodes((char_u *)orig_rhs, orig_rhs_len, (char_u **)&rhs_buf,
REPTERM_DO_LT | REPTERM_NO_SIMPLIFY, NULL, cpo_flags);
mapargs->rhs_len = STRLEN(replaced);
// XXX: even when orig_rhs is non-empty, replace_termcodes may produce an empty string.
mapargs->rhs_is_noop = orig_rhs[0] != NUL && mapargs->rhs_len == 0;
@ -3027,8 +3029,8 @@ int str_to_mapargs(const char_u *strargs, bool is_unmap, MapArguments *mapargs)
STRLCPY(lhs_to_replace, to_parse, orig_lhs_len + 1);
size_t orig_rhs_len = STRLEN(rhs_start);
set_maparg_lhs_rhs(lhs_to_replace, orig_lhs_len,
rhs_start, orig_rhs_len, LUA_NOREF,
set_maparg_lhs_rhs((char *)lhs_to_replace, orig_lhs_len,
(char *)rhs_start, orig_rhs_len, LUA_NOREF,
CPO_TO_CPO_FLAGS, &parsed_args);
xfree(lhs_to_replace);

View File

@ -353,7 +353,7 @@ int set_indent(int size, int flags)
const colnr_T new_offset = (colnr_T)(s - newline);
// this may free "newline"
ml_replace(curwin->w_cursor.lnum, newline, false);
ml_replace(curwin->w_cursor.lnum, (char *)newline, false);
if (!(flags & SIN_NOMARK)) {
extmark_splice_cols(curbuf,
(int)curwin->w_cursor.lnum - 1,

View File

@ -394,7 +394,7 @@ nlua_pop_typval_table_processing_end:
state);
cur.tv->v_type = VAR_FUNC;
cur.tv->vval.v_string = vim_strsave(name);
cur.tv->vval.v_string = (char *)vim_strsave(name);
break;
}
case LUA_TUSERDATA: {

View File

@ -881,7 +881,7 @@ static int nlua_debug(lua_State *lstate)
{
.v_lock = VAR_FIXED,
.v_type = VAR_STRING,
.vval.v_string = (char_u *)"lua_debug> ",
.vval.v_string = "lua_debug> ",
},
{
.v_type = VAR_UNKNOWN,
@ -1195,8 +1195,8 @@ void nlua_call_user_expand_func(expand_T *xp, typval_T *ret_tv)
lua_State *const lstate = global_lstate;
nlua_pushref(lstate, xp->xp_luaref);
lua_pushstring(lstate, (char *)xp->xp_pattern);
lua_pushstring(lstate, (char *)xp->xp_line);
lua_pushstring(lstate, xp->xp_pattern);
lua_pushstring(lstate, xp->xp_line);
lua_pushinteger(lstate, xp->xp_col);
if (nlua_pcall(lstate, 3, 1)) {
@ -1495,7 +1495,7 @@ void ex_luado(exarg_T *const eap)
new_line_transformed[i] = '\n';
}
}
ml_replace(l, (char_u *)new_line_transformed, false);
ml_replace(l, new_line_transformed, false);
inserted_bytes(l, 0, (int)old_line_len, (int)new_line_len);
}
lua_pop(lstate, 1);

View File

@ -562,11 +562,11 @@ int utf_ptr2cells_len(const char_u *p, int size)
/// @param str The source string, may not be NULL, must be a NUL-terminated
/// string.
/// @return The number of cells occupied by string `str`
size_t mb_string2cells(const char_u *str)
size_t mb_string2cells(const char *str)
{
size_t clen = 0;
for (const char_u *p = str; *p != NUL; p += utfc_ptr2len(p)) {
for (const char_u *p = (char_u *)str; *p != NUL; p += utfc_ptr2len(p)) {
clen += utf_ptr2cells(p);
}

View File

@ -1035,8 +1035,8 @@ void ml_recover(bool checkext)
semsg(_("E309: Unable to read block 1 from %s"), mfp->mf_fname);
goto theend;
}
++error;
ml_append(lnum++, (char_u *)_("???MANY LINES MISSING"),
error++;
ml_append(lnum++, _("???MANY LINES MISSING"),
(colnr_T)0, true);
} else { // there is a block
pp = hp->bh_data;
@ -1047,14 +1047,14 @@ void ml_recover(bool checkext)
line_count -= pp->pb_pointer[i].pe_line_count;
}
if (line_count != 0) {
++error;
ml_append(lnum++, (char_u *)_("???LINE COUNT WRONG"),
error++;
ml_append(lnum++, _("???LINE COUNT WRONG"),
(colnr_T)0, true);
}
}
if (pp->pb_count == 0) {
ml_append(lnum++, (char_u *)_("???EMPTY BLOCK"),
ml_append(lnum++, _("???EMPTY BLOCK"),
(colnr_T)0, true);
error++;
} else if (idx < (int)pp->pb_count) { // go a block deeper
@ -1075,8 +1075,8 @@ void ml_recover(bool checkext)
}
}
if (cannot_open) {
++error;
ml_append(lnum++, (char_u *)_("???LINES MISSING"),
error++;
ml_append(lnum++, _("???LINES MISSING"),
(colnr_T)0, true);
}
++idx; // get same block again for next index
@ -1105,8 +1105,8 @@ void ml_recover(bool checkext)
mfp->mf_fname);
goto theend;
}
++error;
ml_append(lnum++, (char_u *)_("???BLOCK MISSING"),
error++;
ml_append(lnum++, _("???BLOCK MISSING"),
(colnr_T)0, true);
} else {
// it is a data block
@ -1116,8 +1116,7 @@ void ml_recover(bool checkext)
// if wrong, use length in pointer block
if (page_count * mfp->mf_page_size != dp->db_txt_end) {
ml_append(lnum++,
(char_u *)_("??? from here until ???END lines"
" may be messed up"),
_("??? from here until ???END lines" " may be messed up"),
(colnr_T)0, true);
error++;
has_error = true;
@ -1133,8 +1132,8 @@ void ml_recover(bool checkext)
*/
if (line_count != dp->db_line_count) {
ml_append(lnum++,
(char_u *)_("??? from here until ???END lines"
" may have been inserted/deleted"),
_("??? from here until ???END lines"
" may have been inserted/deleted"),
(colnr_T)0, true);
error++;
has_error = true;
@ -1149,10 +1148,10 @@ void ml_recover(bool checkext)
} else {
p = (char_u *)dp + txt_start;
}
ml_append(lnum++, p, (colnr_T)0, true);
ml_append(lnum++, (char *)p, (colnr_T)0, true);
}
if (has_error) {
ml_append(lnum++, (char_u *)_("???END"), (colnr_T)0, true);
ml_append(lnum++, _("???END"), (colnr_T)0, true);
}
}
}
@ -1924,7 +1923,7 @@ int ml_line_alloced(void)
/// @param newfile flag, see above
///
/// @return FAIL for failure, OK otherwise
int ml_append(linenr_T lnum, char_u *line, colnr_T len, bool newfile)
int ml_append(linenr_T lnum, char *line, colnr_T len, bool newfile)
{
// When starting up, we might still need to create the memfile
if (curbuf->b_ml.ml_mfp == NULL && open_buffer(FALSE, NULL, 0) == FAIL) {
@ -1934,7 +1933,7 @@ int ml_append(linenr_T lnum, char_u *line, colnr_T len, bool newfile)
if (curbuf->b_ml.ml_line_lnum != 0) {
ml_flush_line(curbuf);
}
return ml_append_int(curbuf, lnum, line, len, newfile, FALSE);
return ml_append_int(curbuf, lnum, (char_u *)line, len, newfile, false);
}
/// Like ml_append() but for an arbitrary buffer. The buffer must already have
@ -2448,9 +2447,9 @@ void ml_add_deleted_len_buf(buf_T *buf, char_u *ptr, ssize_t len)
}
int ml_replace(linenr_T lnum, char_u *line, bool copy)
int ml_replace(linenr_T lnum, char *line, bool copy)
{
return ml_replace_buf(curbuf, lnum, line, copy);
return ml_replace_buf(curbuf, lnum, (char_u *)line, copy);
}
/// Replace line "lnum", with buffering, in current buffer.
@ -2546,7 +2545,7 @@ static int ml_delete_int(buf_T *buf, linenr_T lnum, bool message)
set_keep_msg(_(no_lines_msg), 0);
}
i = ml_replace((linenr_T)1, (char_u *)"", true);
i = ml_replace((linenr_T)1, "", true);
buf->b_ml.ml_flags |= ML_EMPTY;
return i;

View File

@ -2637,7 +2637,7 @@ static void msg_puts_printf(const char *str, const ptrdiff_t maxlen)
typval_T argv[1];
argv[0].v_type = VAR_STRING;
argv[0].v_lock = VAR_UNLOCKED;
argv[0].vval.v_string = (char_u *)str;
argv[0].vval.v_string = (char *)str;
typval_T rettv = TV_INITIAL_VALUE;
callback_call(&on_print, 1, argv, &rettv);
tv_clear(&rettv);

View File

@ -1747,24 +1747,24 @@ bool do_mouse(oparg_T *oap, int c, int dir, long count, bool fixindent)
.v_lock = VAR_FIXED,
.v_type = VAR_STRING,
.vval = {
.v_string = (char_u *)(which_button == MOUSE_LEFT
? "l"
: (which_button == MOUSE_RIGHT
? "r"
: (which_button == MOUSE_MIDDLE
? "m"
: "?")))
.v_string = (which_button == MOUSE_LEFT
? "l"
: (which_button == MOUSE_RIGHT
? "r"
: (which_button == MOUSE_MIDDLE
? "m"
: "?")))
},
},
{
.v_lock = VAR_FIXED,
.v_type = VAR_STRING,
.vval = {
.v_string = (char_u[]) {
(char_u)(mod_mask & MOD_MASK_SHIFT ? 's' : ' '),
(char_u)(mod_mask & MOD_MASK_CTRL ? 'c' : ' '),
(char_u)(mod_mask & MOD_MASK_ALT ? 'a' : ' '),
(char_u)(mod_mask & MOD_MASK_META ? 'm' : ' '),
.v_string = (char[]) {
(char)(mod_mask & MOD_MASK_SHIFT ? 's' : ' '),
(char)(mod_mask & MOD_MASK_CTRL ? 'c' : ' '),
(char)(mod_mask & MOD_MASK_ALT ? 'a' : ' '),
(char)(mod_mask & MOD_MASK_META ? 'm' : ' '),
NUL
}
},

View File

@ -508,7 +508,7 @@ static void shift_block(oparg_T *oap, int amount)
STRMOVE(newp + verbatim_diff + fill, non_white);
}
// replace the line
ml_replace(curwin->w_cursor.lnum, newp, false);
ml_replace(curwin->w_cursor.lnum, (char *)newp, false);
changed_bytes(curwin->w_cursor.lnum, bd.textcol);
extmark_splice_cols(curbuf, (int)curwin->w_cursor.lnum - 1, startcol,
oldlen, newlen,
@ -614,7 +614,7 @@ static void block_insert(oparg_T *oap, char_u *s, int b_insert, struct block_def
}
STRMOVE(newp + offset, oldp);
ml_replace(lnum, newp, false);
ml_replace(lnum, (char *)newp, false);
extmark_splice_cols(curbuf, (int)lnum - 1, startcol,
skipped, offset - startcol, kExtmarkUndo);
@ -1650,7 +1650,7 @@ int op_delete(oparg_T *oap)
oldp += bd.textcol + bd.textlen;
STRMOVE(newp + bd.textcol + bd.startspaces + bd.endspaces, oldp);
// replace the line
ml_replace(lnum, newp, false);
ml_replace(lnum, (char *)newp, false);
extmark_splice_cols(curbuf, (int)lnum - 1, bd.textcol,
bd.textlen, bd.startspaces + bd.endspaces,
@ -2001,11 +2001,11 @@ static int op_replace(oparg_T *oap, int c)
newrows = 1;
}
// replace the line
ml_replace(curwin->w_cursor.lnum, newp, false);
ml_replace(curwin->w_cursor.lnum, (char *)newp, false);
curbuf_splice_pending++;
linenr_T baselnum = curwin->w_cursor.lnum;
if (after_p != NULL) {
ml_append(curwin->w_cursor.lnum++, after_p, (int)after_p_len, false);
ml_append(curwin->w_cursor.lnum++, (char *)after_p, (int)after_p_len, false);
appended_lines_mark(curwin->w_cursor.lnum, 1L);
oap->end.lnum++;
xfree(after_p);
@ -2597,7 +2597,7 @@ int op_change(oparg_T *oap)
offset += ins_len;
oldp += bd.textcol;
STRMOVE(newp + offset, oldp);
ml_replace(linenr, newp, false);
ml_replace(linenr, (char *)newp, false);
extmark_splice_cols(curbuf, (int)linenr - 1, bd.textcol,
0, vpos.coladd + (int)ins_len, kExtmarkUndo);
}
@ -3185,7 +3185,7 @@ void do_put(int regname, yankreg_T *reg, int dir, long count, int flags)
MB_PTR_ADV(p);
}
ptr = vim_strsave(p);
ml_append(curwin->w_cursor.lnum, ptr, (colnr_T)0, false);
ml_append(curwin->w_cursor.lnum, (char *)ptr, (colnr_T)0, false);
xfree(ptr);
oldp = get_cursor_line_ptr();
@ -3194,7 +3194,7 @@ void do_put(int regname, yankreg_T *reg, int dir, long count, int flags)
MB_PTR_ADV(p);
}
ptr = vim_strnsave(oldp, (size_t)(p - oldp));
ml_replace(curwin->w_cursor.lnum, ptr, false);
ml_replace(curwin->w_cursor.lnum, (char *)ptr, false);
nr_lines++;
dir = FORWARD;
}
@ -3331,7 +3331,7 @@ void do_put(int regname, yankreg_T *reg, int dir, long count, int flags)
// add a new line
if (curwin->w_cursor.lnum > curbuf->b_ml.ml_line_count) {
if (ml_append(curbuf->b_ml.ml_line_count, (char_u *)"",
if (ml_append(curbuf->b_ml.ml_line_count, "",
(colnr_T)1, false) == FAIL) {
break;
}
@ -3425,7 +3425,7 @@ void do_put(int regname, yankreg_T *reg, int dir, long count, int flags)
int columns = (int)oldlen - bd.textcol - delcount + 1;
assert(columns >= 0);
memmove(ptr, oldp + bd.textcol + delcount, (size_t)columns);
ml_replace(curwin->w_cursor.lnum, newp, false);
ml_replace(curwin->w_cursor.lnum, (char *)newp, false);
extmark_splice_cols(curbuf, (int)curwin->w_cursor.lnum - 1, bd.textcol,
delcount, addcount, kExtmarkUndo);
@ -3543,7 +3543,7 @@ void do_put(int regname, yankreg_T *reg, int dir, long count, int flags)
ptr += yanklen;
}
STRMOVE(ptr, oldp + col);
ml_replace(lnum, newp, false);
ml_replace(lnum, (char *)newp, false);
// compute the byte offset for the last character
first_byte_off = utf_head_off(newp, ptr - 1);
@ -3596,7 +3596,7 @@ void do_put(int regname, yankreg_T *reg, int dir, long count, int flags)
STRCPY(newp, y_array[y_size - 1]);
STRCAT(newp, ptr);
// insert second line
ml_append(lnum, newp, (colnr_T)0, false);
ml_append(lnum, (char *)newp, (colnr_T)0, false);
new_lnum++;
xfree(newp);
@ -3606,7 +3606,7 @@ void do_put(int regname, yankreg_T *reg, int dir, long count, int flags)
memmove(newp, oldp, (size_t)col);
// append to first line
memmove(newp + col, y_array[0], (size_t)yanklen + 1);
ml_replace(lnum, newp, false);
ml_replace(lnum, (char *)newp, false);
curwin->w_cursor.lnum = lnum;
i = 1;
@ -3614,7 +3614,7 @@ void do_put(int regname, yankreg_T *reg, int dir, long count, int flags)
for (; i < y_size; i++) {
if ((y_type != kMTCharWise || i < y_size - 1)) {
if (ml_append(lnum, y_array[i], (colnr_T)0, false) == FAIL) {
if (ml_append(lnum, (char *)y_array[i], (colnr_T)0, false) == FAIL) {
goto error;
}
new_lnum++;
@ -4214,7 +4214,7 @@ int do_join(size_t count, int insert_space, int save_undo, int use_formatoptions
currsize = (int)STRLEN(curr);
}
ml_replace(curwin->w_cursor.lnum, newp, false);
ml_replace(curwin->w_cursor.lnum, (char *)newp, false);
if (setmark && !cmdmod.lockmarks) {
// Set the '] mark.
@ -6179,7 +6179,7 @@ static void op_function(const oparg_T *oap)
argv[0].v_type = VAR_STRING;
argv[1].v_type = VAR_UNKNOWN;
argv[0].vval.v_string =
(char_u *)(((const char *const[]) {
(char *)(((const char *const[]) {
[kMTBlockWise] = "block",
[kMTLineWise] = "line",
[kMTCharWise] = "char",
@ -7090,7 +7090,7 @@ static bool get_clipboard(int name, yankreg_T **target, bool quiet)
if (TV_LIST_ITEM_TV(tv_list_last(res))->v_type != VAR_STRING) {
goto err;
}
char_u *regtype = TV_LIST_ITEM_TV(tv_list_last(res))->vval.v_string;
char_u *regtype = (char_u *)TV_LIST_ITEM_TV(tv_list_last(res))->vval.v_string;
if (regtype == NULL || STRLEN(regtype) > 1) {
goto err;
}

View File

@ -1253,7 +1253,7 @@ static size_t write_output(char *output, size_t remaining, bool eof)
if (output[off] == NL) {
// Insert the line
output[off] = NUL;
ml_append(curwin->w_cursor.lnum++, (char_u *)output, (int)off + 1,
ml_append(curwin->w_cursor.lnum++, output, (int)off + 1,
false);
size_t skip = off + 1;
output += skip;
@ -1272,7 +1272,7 @@ static size_t write_output(char *output, size_t remaining, bool eof)
if (eof) {
if (remaining) {
// append unfinished line
ml_append(curwin->w_cursor.lnum++, (char_u *)output, 0, false);
ml_append(curwin->w_cursor.lnum++, output, 0, false);
// remember that the NL was missing
curbuf->b_no_eol_lnum = curwin->w_cursor.lnum;
output += remaining;

View File

@ -750,11 +750,11 @@ static int pum_set_selected(int n, int repeat)
for (p = pum_array[pum_selected].pum_info; *p != NUL;) {
e = vim_strchr(p, '\n');
if (e == NULL) {
ml_append(lnum++, p, 0, false);
ml_append(lnum++, (char *)p, 0, false);
break;
} else {
*e = NUL;
ml_append(lnum++, p, (int)(e - p + 1), false);
ml_append(lnum++, (char *)p, (int)(e - p + 1), false);
*e = '\n';
p = e + 1;
}

View File

@ -1029,7 +1029,7 @@ static int qf_setup_state(qfstate_T *pstate, char *restrict enc, const char *res
if (tv != NULL) {
if (tv->v_type == VAR_STRING) {
pstate->p_str = (char *)tv->vval.v_string;
pstate->p_str = tv->vval.v_string;
} else if (tv->v_type == VAR_LIST) {
pstate->p_li = tv_list_first(tv->vval.v_list);
}
@ -3937,7 +3937,7 @@ bool qf_process_qftf_option(void)
// treat everything else as a function name string
tv = xcalloc(1, sizeof(*tv));
tv->v_type = VAR_STRING;
tv->vval.v_string = vim_strsave(p_qftf);
tv->vval.v_string = (char *)vim_strsave(p_qftf);
}
if (!callback_from_typval(&cb, tv)) {
@ -5977,7 +5977,7 @@ static int qf_get_list_from_lines(dict_T *what, dictitem_T *di, dict_T *retdict)
|| efm_di->di_tv.vval.v_string == NULL) {
return FAIL;
}
errorformat = (char *)efm_di->di_tv.vval.v_string;
errorformat = efm_di->di_tv.vval.v_string;
}
list_T *l = tv_list_alloc(kListLenMayKnow);
@ -6602,7 +6602,7 @@ static int qf_setprop_items_from_lines(qf_info_T *qi, int qf_idx, const dict_T *
|| efm_di->di_tv.vval.v_string == NULL) {
return FAIL;
}
errorformat = (char *)efm_di->di_tv.vval.v_string;
errorformat = efm_di->di_tv.vval.v_string;
}
// Only a List value is supported

View File

@ -1629,7 +1629,7 @@ static int fill_submatch_list(int argc FUNC_ATTR_UNUSED, typval_T *argv,
s = vim_strnsave(s, rsm.sm_match->endp[i] - s);
}
TV_LIST_ITEM_TV(li)->v_type = VAR_STRING;
TV_LIST_ITEM_TV(li)->vval.v_string = s;
TV_LIST_ITEM_TV(li)->vval.v_string = (char *)s;
li = TV_LIST_ITEM_NEXT(argv->vval.v_list, li);
}
return argskip + 1;
@ -1785,7 +1785,7 @@ static int vim_regsub_both(char_u *source, typval_T *expr, char_u *dest,
funcexe.argv_func = fill_submatch_list;
funcexe.evaluate = true;
if (expr->v_type == VAR_FUNC) {
s = expr->vval.v_string;
s = (char_u *)expr->vval.v_string;
call_func(s, -1, &rettv, 1, argv, &funcexe);
} else if (expr->v_type == VAR_PARTIAL) {
partial_T *partial = expr->vval.v_partial;

View File

@ -1983,7 +1983,7 @@ static inline void provider_err_virt_text(linenr_T lnum, char *err)
kv_push(err_decor.virt_text,
((VirtTextChunk){ .text = provider_err,
.hl_id = hl_err }));
err_decor.virt_text_width = mb_string2cells((char_u *)err);
err_decor.virt_text_width = mb_string2cells(err);
decor_add_ephemeral(lnum - 1, 0, lnum - 1, 0, &err_decor, 0, 0);
}
@ -4513,10 +4513,10 @@ static void get_sign_display_info(bool nrcol, win_T *wp, linenr_T lnum, sign_att
// TODO(oni-link): Is sign text already extended to
// full cell width?
assert((size_t)win_signcol_width(wp) >= mb_string2cells(*pp_extra));
assert((size_t)win_signcol_width(wp) >= mb_string2cells((char *)(*pp_extra)));
// symbol(s) bytes + (filling spaces) (one byte each)
*n_extrap = symbol_blen +
(win_signcol_width(wp) - mb_string2cells(*pp_extra));
(win_signcol_width(wp) - mb_string2cells((char *)(*pp_extra)));
assert(extra_size > (size_t)symbol_blen);
memset(extra, ' ', extra_size);
@ -5229,7 +5229,7 @@ static void win_redr_status(win_T *wp)
int clen = 0, i;
// Count total number of display cells.
clen = (int)mb_string2cells(p);
clen = (int)mb_string2cells((char *)p);
// Find first character that will fit.
// Going from start to end is much faster for DBCS.

View File

@ -5120,7 +5120,7 @@ static void fuzzy_match_in_list(list_T *const l, char_u *const str, const bool m
rettv.v_type = VAR_UNKNOWN;
const typval_T *const tv = TV_LIST_ITEM_TV(li);
if (tv->v_type == VAR_STRING) { // list of strings
itemstr = tv->vval.v_string;
itemstr = (char_u *)tv->vval.v_string;
} else if (tv->v_type == VAR_DICT && (key != NULL || item_cb->type != kCallbackNone)) {
// For a dict, either use the specified key to lookup the string or
// use the specified callback function to get the string.
@ -5136,7 +5136,7 @@ static void fuzzy_match_in_list(list_T *const l, char_u *const str, const bool m
argv[1].v_type = VAR_UNKNOWN;
if (callback_call(item_cb, 1, argv, &rettv)) {
if (rettv.v_type == VAR_STRING) {
itemstr = rettv.vval.v_string;
itemstr = (char_u *)rettv.vval.v_string;
}
}
tv_dict_unref(tv->vval.v_dict);

View File

@ -3063,7 +3063,7 @@ void spell_suggest(int count)
AppendCharToRedobuff(ESC);
// "p" may be freed here
ml_replace(curwin->w_cursor.lnum, p, false);
ml_replace(curwin->w_cursor.lnum, (char *)p, false);
curwin->w_cursor.col = c;
inserted_bytes(curwin->w_cursor.lnum, c, stp->st_orglen, stp->st_wordlen);
@ -3177,7 +3177,7 @@ void ex_spellrepall(exarg_T *eap)
memmove(p, line, curwin->w_cursor.col);
STRCPY(p + curwin->w_cursor.col, repl_to);
STRCAT(p, line + curwin->w_cursor.col + STRLEN(repl_from));
ml_replace(curwin->w_cursor.lnum, p, false);
ml_replace(curwin->w_cursor.lnum, (char *)p, false);
changed_bytes(curwin->w_cursor.lnum, curwin->w_cursor.col);
if (curwin->w_cursor.lnum != prev_lnum) {
@ -6964,7 +6964,7 @@ void spell_dump_compl(char_u *pat, int ic, Direction *dir, int dumpflags_arg)
if (do_region && region_names != NULL) {
if (pat == NULL) {
vim_snprintf((char *)IObuff, IOSIZE, "/regions=%s", region_names);
ml_append(lnum++, IObuff, (colnr_T)0, false);
ml_append(lnum++, (char *)IObuff, (colnr_T)0, false);
}
} else {
do_region = false;
@ -6980,7 +6980,7 @@ void spell_dump_compl(char_u *pat, int ic, Direction *dir, int dumpflags_arg)
if (pat == NULL) {
vim_snprintf((char *)IObuff, IOSIZE, "# file: %s", slang->sl_fname);
ml_append(lnum++, IObuff, (colnr_T)0, false);
ml_append(lnum++, (char *)IObuff, (colnr_T)0, false);
}
// When matching with a pattern and there are no prefixes only use
@ -7151,7 +7151,7 @@ static void dump_word(slang_T *slang, char_u *word, char_u *pat, Direction *dir,
}
}
ml_append(lnum, p, (colnr_T)0, false);
ml_append(lnum, (char *)p, (colnr_T)0, false);
} else if (((dumpflags & DUMPFLAG_ICASE)
? mb_strnicmp(p, pat, STRLEN(pat)) == 0
: STRNCMP(p, pat, STRLEN(pat)) == 0)

View File

@ -1156,9 +1156,9 @@ static int find_tagfunc_tags(char_u *pat, garray_T *ga, int *match_count, int fl
}
args[0].v_type = VAR_STRING;
args[0].vval.v_string = pat;
args[0].vval.v_string = (char *)pat;
args[1].v_type = VAR_STRING;
args[1].vval.v_string = flagString;
args[1].vval.v_string = (char *)flagString;
// create 'info' dict argument
dict_T *const d = tv_dict_alloc_lock(VAR_FIXED);
@ -1229,20 +1229,20 @@ static int find_tagfunc_tags(char_u *pat, garray_T *ga, int *match_count, int fl
len += STRLEN(tv->vval.v_string) + 1; // Space for "\tVALUE"
if (!STRCMP(dict_key, "name")) {
res_name = tv->vval.v_string;
res_name = (char_u *)tv->vval.v_string;
continue;
}
if (!STRCMP(dict_key, "filename")) {
res_fname = tv->vval.v_string;
res_fname = (char_u *)tv->vval.v_string;
continue;
}
if (!STRCMP(dict_key, "cmd")) {
res_cmd = tv->vval.v_string;
res_cmd = (char_u *)tv->vval.v_string;
continue;
}
has_extra = 1;
if (!STRCMP(dict_key, "kind")) {
res_kind = tv->vval.v_string;
res_kind = (char_u *)tv->vval.v_string;
continue;
}
// Other elements will be stored as "\tKEY:VALUE"

View File

@ -1533,7 +1533,7 @@ static void refresh_scrollback(Terminal *term, buf_T *buf)
int row_offset = term->sb_pending;
while (term->sb_pending > 0 && buf->b_ml.ml_line_count < height) {
fetch_row(term, term->sb_pending - row_offset - 1, width);
ml_append(0, (uint8_t *)term->textbuf, 0, false);
ml_append(0, term->textbuf, 0, false);
appended_lines(0, 1);
term->sb_pending--;
}
@ -1551,7 +1551,7 @@ static void refresh_scrollback(Terminal *term, buf_T *buf)
}
fetch_row(term, -term->sb_pending - row_offset, width);
int buf_index = (int)buf->b_ml.ml_line_count - height;
ml_append(buf_index, (uint8_t *)term->textbuf, 0, false);
ml_append(buf_index, term->textbuf, 0, false);
appended_lines(buf_index, 1);
term->sb_pending--;
}
@ -1591,10 +1591,10 @@ static void refresh_screen(Terminal *term, buf_T *buf)
fetch_row(term, r, width);
if (linenr <= buf->b_ml.ml_line_count) {
ml_replace(linenr, (uint8_t *)term->textbuf, true);
ml_replace(linenr, term->textbuf, true);
changed++;
} else {
ml_append(linenr - 1, (uint8_t *)term->textbuf, 0, false);
ml_append(linenr - 1, term->textbuf, 0, false);
added++;
}
}

View File

@ -2395,9 +2395,9 @@ static void u_undoredo(int undo, bool do_buf_event)
* should get rid of, by replacing it with the new line
*/
if (empty_buffer && lnum == 0) {
ml_replace((linenr_T)1, uep->ue_array[i], true);
ml_replace((linenr_T)1, (char *)uep->ue_array[i], true);
} else {
ml_append(lnum, uep->ue_array[i], (colnr_T)0, false);
ml_append(lnum, (char *)uep->ue_array[i], (colnr_T)0, false);
}
xfree(uep->ue_array[i]);
}
@ -3108,7 +3108,7 @@ void u_undoline(void)
}
oldp = u_save_line(curbuf->b_u_line_lnum);
ml_replace(curbuf->b_u_line_lnum, curbuf->b_u_line_ptr, true);
ml_replace(curbuf->b_u_line_lnum, (char *)curbuf->b_u_line_ptr, true);
changed_bytes(curbuf->b_u_line_lnum, 0);
extmark_splice_cols(curbuf, (int)curbuf->b_u_line_lnum - 1, 0, (colnr_T)STRLEN(oldp),
(colnr_T)STRLEN(curbuf->b_u_line_ptr), kExtmarkUndo);