aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDundar Goc <gocdundar@gmail.com>2022-05-04 18:27:22 +0200
committerDundar Goc <gocdundar@gmail.com>2022-05-05 18:10:46 +0200
commit9a671e6a24243a5ff2879599d91ab5aec8b4e77d (patch)
tree703693c3591ed6b8881ed965f7f2ed2394a29ce6 /src
parent82c7a82c3585100e73e154c49e3e002b7dc35437 (diff)
downloadrneovim-9a671e6a24243a5ff2879599d91ab5aec8b4e77d.tar.gz
rneovim-9a671e6a24243a5ff2879599d91ab5aec8b4e77d.tar.bz2
rneovim-9a671e6a24243a5ff2879599d91ab5aec8b4e77d.zip
refactor: replace char_u variables and functions with char
Work on https://github.com/neovim/neovim/issues/459
Diffstat (limited to 'src')
-rw-r--r--src/nvim/api/autocmd.c2
-rw-r--r--src/nvim/api/buffer.c8
-rw-r--r--src/nvim/api/extmark.c4
-rw-r--r--src/nvim/api/private/converter.c5
-rw-r--r--src/nvim/api/private/helpers.c28
-rw-r--r--src/nvim/api/vim.c2
-rw-r--r--src/nvim/change.c18
-rw-r--r--src/nvim/channel.c4
-rw-r--r--src/nvim/cursor.c4
-rw-r--r--src/nvim/diff.c2
-rw-r--r--src/nvim/digraph.c2
-rw-r--r--src/nvim/edit.c12
-rw-r--r--src/nvim/eval.c113
-rw-r--r--src/nvim/eval/decode.c3
-rw-r--r--src/nvim/eval/encode.c15
-rw-r--r--src/nvim/eval/executor.c2
-rw-r--r--src/nvim/eval/funcs.c232
-rw-r--r--src/nvim/eval/typval.c24
-rw-r--r--src/nvim/eval/typval.h22
-rw-r--r--src/nvim/eval/typval_encode.c.h2
-rw-r--r--src/nvim/eval/userfunc.c10
-rw-r--r--src/nvim/ex_cmds.c24
-rw-r--r--src/nvim/ex_cmds2.c351
-rw-r--r--src/nvim/ex_cmds_defs.h2
-rw-r--r--src/nvim/ex_docmd.c19
-rw-r--r--src/nvim/ex_getln.c12
-rw-r--r--src/nvim/fileio.c8
-rw-r--r--src/nvim/generators/gen_ex_cmds.lua2
-rw-r--r--src/nvim/getchar.c30
-rw-r--r--src/nvim/indent.c2
-rw-r--r--src/nvim/lua/converter.c2
-rw-r--r--src/nvim/lua/executor.c8
-rw-r--r--src/nvim/mbyte.c4
-rw-r--r--src/nvim/memline.c39
-rw-r--r--src/nvim/message.c2
-rw-r--r--src/nvim/normal.c24
-rw-r--r--src/nvim/ops.c34
-rw-r--r--src/nvim/os/shell.c4
-rw-r--r--src/nvim/popupmnu.c4
-rw-r--r--src/nvim/quickfix.c8
-rw-r--r--src/nvim/regexp.c4
-rw-r--r--src/nvim/screen.c8
-rw-r--r--src/nvim/search.c4
-rw-r--r--src/nvim/spell.c10
-rw-r--r--src/nvim/tag.c12
-rw-r--r--src/nvim/terminal.c8
-rw-r--r--src/nvim/undo.c6
47 files changed, 569 insertions, 576 deletions
diff --git a/src/nvim/api/autocmd.c b/src/nvim/api/autocmd.c
index 010c03e505..6f262ebfa0 100644
--- a/src/nvim/api/autocmd.c
+++ b/src/nvim/api/autocmd.c
@@ -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,
diff --git a/src/nvim/api/buffer.c b/src/nvim/api/buffer.c
index b4d4265a37..45dadae1dd 100644
--- a/src/nvim/api/buffer.c
+++ b/src/nvim/api/buffer.c
@@ -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;
}
diff --git a/src/nvim/api/extmark.c b/src/nvim/api/extmark.c
index fa6923e6d5..bbc1ee9d71 100644
--- a/src/nvim/api/extmark.c
+++ b/src/nvim/api/extmark.c
@@ -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;
}
diff --git a/src/nvim/api/private/converter.c b/src/nvim/api/private/converter.c
index a26383ec7d..8724ef4432 100644
--- a/src/nvim/api/private/converter.c
+++ b/src/nvim/api/private/converter.c
@@ -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;
}
diff --git a/src/nvim/api/private/helpers.c b/src/nvim/api/private/helpers.c
index a89a254f20..9f894d5533 100644
--- a/src/nvim/api/private/helpers.c
+++ b/src/nvim/api/private/helpers.c
@@ -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, " ");
diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c
index 2323b8db47..7f4fafa71b 100644
--- a/src/nvim/api/vim.c
+++ b/src/nvim/api/vim.c
@@ -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'.
diff --git a/src/nvim/change.c b/src/nvim/change.c
index c751507955..2d5ece8880 100644
--- a/src/nvim/change.c
+++ b/src/nvim/change.c
@@ -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);
diff --git a/src/nvim/channel.c b/src/nvim/channel.c
index cc76c6cf2d..6278f84190 100644
--- a/src/nvim/channel.c
+++ b/src/nvim/channel.c
@@ -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;
diff --git a/src/nvim/cursor.c b/src/nvim/cursor.c
index d924119fdf..87835ec50a 100644
--- a/src/nvim/cursor.c
+++ b/src/nvim/cursor.c
@@ -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;
diff --git a/src/nvim/diff.c b/src/nvim/diff.c
index 52ae1bc819..6b606f50a1 100644
--- a/src/nvim/diff.c
+++ b/src/nvim/diff.c
@@ -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)) {
diff --git a/src/nvim/digraph.c b/src/nvim/digraph.c
index 02851b235f..7d95cf5184 100644
--- a/src/nvim/digraph.c
+++ b/src/nvim/digraph.c
@@ -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
diff --git a/src/nvim/edit.c b/src/nvim/edit.c
index f2c3f64790..593c395661 100644
--- a/src/nvim/edit.c
+++ b/src/nvim/edit.c
@@ -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 {
diff --git a/src/nvim/eval.c b/src/nvim/eval.c
index 7f99d81bb4..d910b47c57 100644
--- a/src/nvim/eval.c
+++ b/src/nvim/eval.c
@@ -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