mirror of
https://github.com/neovim/neovim.git
synced 2025-01-01 17:23:36 -07:00
refactor: replace char_u variables and functions with char
Work on https://github.com/neovim/neovim/issues/459
This commit is contained in:
parent
82c7a82c35
commit
9a671e6a24
@ -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,
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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, " ");
|
||||
|
@ -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'.
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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)) {
|
||||
|
@ -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
|
||||
|
@ -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 {
|
||||
|
111
src/nvim/eval.c
111
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
|
||||
|
||||
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, ¤t_sctx.sc_sid);
|
||||
new_script_item(sc_name, ¤t_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,
|
||||
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);
|
||||
|
@ -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)) },
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -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"));
|
||||
|
@ -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: {
|
||||
|
@ -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,7 +2151,7 @@ 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,
|
||||
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);
|
||||
@ -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, ®len);
|
||||
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,7 +4065,8 @@ 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,
|
||||
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,
|
||||
@ -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,7 +5940,7 @@ 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],
|
||||
rettv->vval.v_string = xmemdupz((const char *)regmatch.startp[0],
|
||||
(size_t)(regmatch.endp[0] -
|
||||
regmatch.startp[0]));
|
||||
}
|
||||
@ -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,8 +9136,8 @@ 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,
|
||||
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,7 +10310,7 @@ 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,
|
||||
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
|
||||
|
@ -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;
|
||||
|
@ -77,7 +77,7 @@ typedef enum {
|
||||
|
||||
typedef struct {
|
||||
union {
|
||||
char_u *funcref;
|
||||
char *funcref;
|
||||
partial_T *partial;
|
||||
LuaRef luaref;
|
||||
} data;
|
||||
@ -140,7 +140,7 @@ typedef struct {
|
||||
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.
|
||||
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.
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ typedef struct sn_prl_S {
|
||||
/// sourcing can be done recursively.
|
||||
struct source_cookie {
|
||||
FILE *fp; ///< opened file for sourcing
|
||||
char_u *nextline; ///< if not NULL: line that was read ahead
|
||||
char *nextline; ///< if not NULL: line that was read ahead
|
||||
linenr_T sourcing_lnum; ///< line number of the source file
|
||||
int finished; ///< ":finish" used
|
||||
#if defined(USE_CRNL)
|
||||
@ -78,7 +78,7 @@ struct source_cookie {
|
||||
bool error; ///< true if LF found after CR-LF
|
||||
#endif
|
||||
linenr_T breakpoint; ///< next line with breakpoint or zero
|
||||
char_u *fname; ///< name of sourced file
|
||||
char *fname; ///< name of sourced file
|
||||
int dbg_tick; ///< debug_tick when breakpoint was set
|
||||
int level; ///< top nesting level of sourced file
|
||||
vimconv_T conv; ///< type of conversion
|
||||
@ -90,23 +90,23 @@ struct source_cookie {
|
||||
# include "ex_cmds2.c.generated.h"
|
||||
#endif
|
||||
|
||||
static char_u *profile_fname = NULL;
|
||||
static char *profile_fname = NULL;
|
||||
|
||||
/// ":profile cmd args"
|
||||
void ex_profile(exarg_T *eap)
|
||||
{
|
||||
static proftime_T pause_time;
|
||||
|
||||
char_u *e;
|
||||
char *e;
|
||||
int len;
|
||||
|
||||
e = skiptowhite((char_u *)eap->arg);
|
||||
len = (int)(e - (char_u *)eap->arg);
|
||||
e = skipwhite(e);
|
||||
e = (char *)skiptowhite((char_u *)eap->arg);
|
||||
len = (int)(e - eap->arg);
|
||||
e = (char *)skipwhite((char_u *)e);
|
||||
|
||||
if (len == 5 && STRNCMP(eap->arg, "start", 5) == 0 && *e != NUL) {
|
||||
xfree(profile_fname);
|
||||
profile_fname = expand_env_save_opt(e, true);
|
||||
profile_fname = (char *)expand_env_save_opt((char_u *)e, true);
|
||||
do_profiling = PROF_YES;
|
||||
profile_set_wait(profile_zero());
|
||||
set_vim_var_nr(VV_PROFILING, 1L);
|
||||
@ -241,7 +241,7 @@ void profile_dump(void)
|
||||
FILE *fd;
|
||||
|
||||
if (profile_fname != NULL) {
|
||||
fd = os_fopen((char *)profile_fname, "w");
|
||||
fd = os_fopen(profile_fname, "w");
|
||||
if (fd == NULL) {
|
||||
semsg(_(e_notopen), profile_fname);
|
||||
} else {
|
||||
@ -545,7 +545,7 @@ bool check_changed(buf_T *buf, int flags)
|
||||
/// @param checkall may abandon all changed buffers
|
||||
void dialog_changed(buf_T *buf, bool checkall)
|
||||
{
|
||||
char_u buff[DIALOG_MSG_SIZE];
|
||||
char buff[DIALOG_MSG_SIZE];
|
||||
int ret;
|
||||
// Init ea pseudo-structure, this is needed for the check_overwrite()
|
||||
// function.
|
||||
@ -556,9 +556,9 @@ void dialog_changed(buf_T *buf, bool checkall)
|
||||
|
||||
dialog_msg((char *)buff, _("Save changes to \"%s\"?"), (char *)buf->b_fname);
|
||||
if (checkall) {
|
||||
ret = vim_dialog_yesnoallcancel(VIM_QUESTION, NULL, buff, 1);
|
||||
ret = vim_dialog_yesnoallcancel(VIM_QUESTION, NULL, (char_u *)buff, 1);
|
||||
} else {
|
||||
ret = vim_dialog_yesnocancel(VIM_QUESTION, NULL, buff, 1);
|
||||
ret = vim_dialog_yesnocancel(VIM_QUESTION, NULL, (char_u *)buff, 1);
|
||||
}
|
||||
|
||||
if (ret == VIM_YES) {
|
||||
@ -608,12 +608,12 @@ void dialog_changed(buf_T *buf, bool checkall)
|
||||
/// @return bool Whether to close the buffer or not.
|
||||
bool dialog_close_terminal(buf_T *buf)
|
||||
{
|
||||
char_u buff[DIALOG_MSG_SIZE];
|
||||
char buff[DIALOG_MSG_SIZE];
|
||||
|
||||
dialog_msg((char *)buff, _("Close \"%s\"?"),
|
||||
dialog_msg(buff, _("Close \"%s\"?"),
|
||||
(buf->b_fname != NULL) ? (char *)buf->b_fname : "?");
|
||||
|
||||
int ret = vim_dialog_yesnocancel(VIM_QUESTION, NULL, buff, 1);
|
||||
int ret = vim_dialog_yesnocancel(VIM_QUESTION, NULL, (char_u *)buff, 1);
|
||||
|
||||
return ret == VIM_YES;
|
||||
}
|
||||
@ -812,16 +812,16 @@ int buf_write_all(buf_T *buf, int forceit)
|
||||
/// Changes the argument in-place, puts a NUL after it. Backticks remain.
|
||||
///
|
||||
/// @return a pointer to the start of the next argument.
|
||||
static char_u *do_one_arg(char_u *str)
|
||||
static char *do_one_arg(char *str)
|
||||
{
|
||||
char_u *p;
|
||||
char *p;
|
||||
bool inbacktick;
|
||||
|
||||
inbacktick = false;
|
||||
for (p = str; *str; str++) {
|
||||
// When the backslash is used for escaping the special meaning of a
|
||||
// character we need to keep it until wildcard expansion.
|
||||
if (rem_backslash(str)) {
|
||||
if (rem_backslash((char_u *)str)) {
|
||||
*p++ = *str++;
|
||||
*p++ = *str;
|
||||
} else {
|
||||
@ -835,7 +835,7 @@ static char_u *do_one_arg(char_u *str)
|
||||
*p++ = *str;
|
||||
}
|
||||
}
|
||||
str = skipwhite(str);
|
||||
str = (char *)skipwhite((char_u *)str);
|
||||
*p = NUL;
|
||||
|
||||
return str;
|
||||
@ -843,11 +843,11 @@ static char_u *do_one_arg(char_u *str)
|
||||
|
||||
/// Separate the arguments in "str" and return a list of pointers in the
|
||||
/// growarray "gap".
|
||||
static void get_arglist(garray_T *gap, char_u *str, int escaped)
|
||||
static void get_arglist(garray_T *gap, char *str, int escaped)
|
||||
{
|
||||
ga_init(gap, (int)sizeof(char_u *), 20);
|
||||
while (*str != NUL) {
|
||||
GA_APPEND(char_u *, gap, str);
|
||||
GA_APPEND(char *, gap, str);
|
||||
|
||||
// If str is escaped, don't handle backslashes or spaces
|
||||
if (!escaped) {
|
||||
@ -868,7 +868,7 @@ int get_arglist_exp(char_u *str, int *fcountp, char_u ***fnamesp, bool wig)
|
||||
garray_T ga;
|
||||
int i;
|
||||
|
||||
get_arglist(&ga, str, true);
|
||||
get_arglist(&ga, (char *)str, true);
|
||||
|
||||
if (wig) {
|
||||
i = expand_wildcards(ga.ga_len, (char_u **)ga.ga_data,
|
||||
@ -893,13 +893,13 @@ int get_arglist_exp(char_u *str, int *fcountp, char_u ***fnamesp, bool wig)
|
||||
/// @param will_edit will edit added argument
|
||||
///
|
||||
/// @return FAIL for failure, OK otherwise.
|
||||
static int do_arglist(char_u *str, int what, int after, bool will_edit)
|
||||
static int do_arglist(char *str, int what, int after, bool will_edit)
|
||||
FUNC_ATTR_NONNULL_ALL
|
||||
{
|
||||
garray_T new_ga;
|
||||
int exp_count;
|
||||
char_u **exp_files;
|
||||
char_u *p;
|
||||
char **exp_files;
|
||||
char *p;
|
||||
int match;
|
||||
int arg_escaped = true;
|
||||
|
||||
@ -908,7 +908,7 @@ static int do_arglist(char_u *str, int what, int after, bool will_edit)
|
||||
if (curbuf->b_ffname == NULL) {
|
||||
return FAIL;
|
||||
}
|
||||
str = curbuf->b_fname;
|
||||
str = (char *)curbuf->b_fname;
|
||||
arg_escaped = false;
|
||||
}
|
||||
|
||||
@ -923,12 +923,12 @@ static int do_arglist(char_u *str, int what, int after, bool will_edit)
|
||||
// argument list.
|
||||
regmatch.rm_ic = p_fic; // ignore case when 'fileignorecase' is set
|
||||
for (int i = 0; i < new_ga.ga_len && !got_int; i++) {
|
||||
p = ((char_u **)new_ga.ga_data)[i];
|
||||
p = file_pat_to_reg_pat(p, NULL, NULL, false);
|
||||
p = ((char **)new_ga.ga_data)[i];
|
||||
p = (char *)file_pat_to_reg_pat((char_u *)p, NULL, NULL, false);
|
||||
if (p == NULL) {
|
||||
break;
|
||||
}
|
||||
regmatch.regprog = vim_regcomp(p, p_magic ? RE_MAGIC : 0);
|
||||
regmatch.regprog = vim_regcomp((char_u *)p, p_magic ? RE_MAGIC : 0);
|
||||
if (regmatch.regprog == NULL) {
|
||||
xfree(p);
|
||||
break;
|
||||
@ -959,7 +959,7 @@ static int do_arglist(char_u *str, int what, int after, bool will_edit)
|
||||
ga_clear(&new_ga);
|
||||
} else {
|
||||
int i = expand_wildcards(new_ga.ga_len, (char_u **)new_ga.ga_data,
|
||||
&exp_count, &exp_files,
|
||||
&exp_count, (char_u ***)&exp_files,
|
||||
EW_DIR|EW_FILE|EW_ADDSLASH|EW_NOTFOUND);
|
||||
ga_clear(&new_ga);
|
||||
if (i == FAIL || exp_count == 0) {
|
||||
@ -972,7 +972,7 @@ static int do_arglist(char_u *str, int what, int after, bool will_edit)
|
||||
xfree(exp_files);
|
||||
} else {
|
||||
assert(what == AL_SET);
|
||||
alist_set(ALIST(curwin), exp_count, (char **)exp_files, will_edit, NULL, 0);
|
||||
alist_set(ALIST(curwin), exp_count, exp_files, will_edit, NULL, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1052,14 +1052,14 @@ void ex_args(exarg_T *eap)
|
||||
} else if (eap->cmdidx == CMD_args) {
|
||||
// ":args": list arguments.
|
||||
if (ARGCOUNT > 0) {
|
||||
char_u **items = xmalloc(sizeof(char_u *) * (size_t)ARGCOUNT);
|
||||
char **items = xmalloc(sizeof(char_u *) * (size_t)ARGCOUNT);
|
||||
// Overwrite the command, for a short list there is no scrolling
|
||||
// required and no wait_return().
|
||||
gotocmdline(true);
|
||||
for (int i = 0; i < ARGCOUNT; i++) {
|
||||
items[i] = alist_name(&ARGLIST[i]);
|
||||
items[i] = (char *)alist_name(&ARGLIST[i]);
|
||||
}
|
||||
list_in_columns(items, ARGCOUNT, curwin->w_arg_idx);
|
||||
list_in_columns((char_u **)items, ARGCOUNT, curwin->w_arg_idx);
|
||||
xfree(items);
|
||||
}
|
||||
} else if (eap->cmdidx == CMD_arglocal) {
|
||||
@ -1119,7 +1119,7 @@ void ex_argument(exarg_T *eap)
|
||||
void do_argfile(exarg_T *eap, int argn)
|
||||
{
|
||||
int other;
|
||||
char_u *p;
|
||||
char *p;
|
||||
int old_arg_idx = curwin->w_arg_idx;
|
||||
|
||||
if (argn < 0 || argn >= ARGCOUNT) {
|
||||
@ -1144,8 +1144,8 @@ void do_argfile(exarg_T *eap, int argn)
|
||||
// the same buffer
|
||||
other = true;
|
||||
if (buf_hide(curbuf)) {
|
||||
p = (char_u *)fix_fname((char *)alist_name(&ARGLIST[argn]));
|
||||
other = otherfile(p);
|
||||
p = fix_fname((char *)alist_name(&ARGLIST[argn]));
|
||||
other = otherfile((char_u *)p);
|
||||
xfree(p);
|
||||
}
|
||||
if ((!buf_hide(curbuf) || !other)
|
||||
@ -1191,7 +1191,7 @@ void ex_next(exarg_T *eap)
|
||||
| (eap->forceit ? CCGD_FORCEIT : 0)
|
||||
| CCGD_EXCMD)) {
|
||||
if (*eap->arg != NUL) { // redefine file list
|
||||
if (do_arglist((char_u *)eap->arg, AL_SET, 0, true) == FAIL) {
|
||||
if (do_arglist(eap->arg, AL_SET, 0, true) == FAIL) {
|
||||
return;
|
||||
}
|
||||
i = 0;
|
||||
@ -1209,7 +1209,7 @@ void ex_argedit(exarg_T *eap)
|
||||
// Whether curbuf will be reused, curbuf->b_ffname will be set.
|
||||
bool curbuf_is_reusable = curbuf_reusable();
|
||||
|
||||
if (do_arglist((char_u *)eap->arg, AL_ADD, i, true) == FAIL) {
|
||||
if (do_arglist(eap->arg, AL_ADD, i, true) == FAIL) {
|
||||
return;
|
||||
}
|
||||
maketitle();
|
||||
@ -1228,7 +1228,7 @@ void ex_argedit(exarg_T *eap)
|
||||
/// ":argadd"
|
||||
void ex_argadd(exarg_T *eap)
|
||||
{
|
||||
do_arglist((char_u *)eap->arg, AL_ADD,
|
||||
do_arglist(eap->arg, AL_ADD,
|
||||
eap->addr_count > 0 ? (int)eap->line2 : curwin->w_arg_idx + 1,
|
||||
false);
|
||||
maketitle();
|
||||
@ -1277,7 +1277,7 @@ void ex_argdelete(exarg_T *eap)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
do_arglist((char_u *)eap->arg, AL_DEL, 0, false);
|
||||
do_arglist(eap->arg, AL_DEL, 0, false);
|
||||
}
|
||||
maketitle();
|
||||
}
|
||||
@ -1289,13 +1289,13 @@ void ex_listdo(exarg_T *eap)
|
||||
win_T *wp;
|
||||
tabpage_T *tp;
|
||||
int next_fnum = 0;
|
||||
char_u *save_ei = NULL;
|
||||
char_u *p_shm_save;
|
||||
char *save_ei = NULL;
|
||||
char *p_shm_save;
|
||||
|
||||
if (eap->cmdidx != CMD_windo && eap->cmdidx != CMD_tabdo) {
|
||||
// Don't do syntax HL autocommands. Skipping the syntax file is a
|
||||
// great speed improvement.
|
||||
save_ei = (char_u *)au_event_disable(",Syntax");
|
||||
save_ei = au_event_disable(",Syntax");
|
||||
|
||||
FOR_ALL_BUFFERS(buf) {
|
||||
buf->b_flags &= ~BF_SYN_SET;
|
||||
@ -1381,10 +1381,10 @@ void ex_listdo(exarg_T *eap)
|
||||
if (curwin->w_arg_idx != i || !editing_arg_idx(curwin)) {
|
||||
// Clear 'shm' to avoid that the file message overwrites
|
||||
// any output from the command.
|
||||
p_shm_save = vim_strsave(p_shm);
|
||||
p_shm_save = (char *)vim_strsave(p_shm);
|
||||
set_option_value("shm", 0L, "", 0);
|
||||
do_argfile(eap, i);
|
||||
set_option_value("shm", 0L, (char *)p_shm_save, 0);
|
||||
set_option_value("shm", 0L, p_shm_save, 0);
|
||||
xfree(p_shm_save);
|
||||
}
|
||||
if (curwin->w_arg_idx != i) {
|
||||
@ -1450,10 +1450,10 @@ void ex_listdo(exarg_T *eap)
|
||||
|
||||
// Go to the next buffer. Clear 'shm' to avoid that the file
|
||||
// message overwrites any output from the command.
|
||||
p_shm_save = vim_strsave(p_shm);
|
||||
p_shm_save = (char *)vim_strsave(p_shm);
|
||||
set_option_value("shm", 0L, "", 0);
|
||||
goto_buffer(eap, DOBUF_FIRST, FORWARD, next_fnum);
|
||||
set_option_value("shm", 0L, (char *)p_shm_save, 0);
|
||||
set_option_value("shm", 0L, p_shm_save, 0);
|
||||
xfree(p_shm_save);
|
||||
|
||||
// If autocommands took us elsewhere, quit here.
|
||||
@ -1473,10 +1473,10 @@ void ex_listdo(exarg_T *eap)
|
||||
|
||||
// Clear 'shm' to avoid that the file message overwrites
|
||||
// any output from the command.
|
||||
p_shm_save = vim_strsave(p_shm);
|
||||
p_shm_save = (char *)vim_strsave(p_shm);
|
||||
set_option_value("shm", 0L, "", 0);
|
||||
ex_cnext(eap);
|
||||
set_option_value("shm", 0L, (char *)p_shm_save, 0);
|
||||
set_option_value("shm", 0L, p_shm_save, 0);
|
||||
xfree(p_shm_save);
|
||||
|
||||
// If jumping to the next quickfix entry fails, quit here.
|
||||
@ -1508,7 +1508,7 @@ void ex_listdo(exarg_T *eap)
|
||||
buf_T *bnext;
|
||||
aco_save_T aco;
|
||||
|
||||
au_event_restore((char *)save_ei);
|
||||
au_event_restore(save_ei);
|
||||
|
||||
for (buf_T *buf = firstbuf; buf != NULL; buf = bnext) {
|
||||
bnext = buf->b_next;
|
||||
@ -1540,7 +1540,7 @@ void ex_listdo(exarg_T *eap)
|
||||
///
|
||||
/// @param after: where to add: 0 = before first one
|
||||
/// @param will_edit will edit adding argument
|
||||
static void alist_add_list(int count, char_u **files, int after, bool will_edit)
|
||||
static void alist_add_list(int count, char **files, int after, bool will_edit)
|
||||
FUNC_ATTR_NONNULL_ALL
|
||||
{
|
||||
int old_argcount = ARGCOUNT;
|
||||
@ -1558,8 +1558,8 @@ static void alist_add_list(int count, char_u **files, int after, bool will_edit)
|
||||
}
|
||||
for (int i = 0; i < count; i++) {
|
||||
const int flags = BLN_LISTED | (will_edit ? BLN_CURBUF : 0);
|
||||
ARGLIST[after + i].ae_fname = files[i];
|
||||
ARGLIST[after + i].ae_fnum = buflist_add(files[i], flags);
|
||||
ARGLIST[after + i].ae_fname = (char_u *)files[i];
|
||||
ARGLIST[after + i].ae_fnum = buflist_add((char_u *)files[i], flags);
|
||||
}
|
||||
ALIST(curwin)->al_ga.ga_len += count;
|
||||
if (old_argcount > 0 && curwin->w_arg_idx >= after) {
|
||||
@ -1582,9 +1582,9 @@ char_u *get_arglist_name(expand_T *xp FUNC_ATTR_UNUSED, int idx)
|
||||
/// ":compiler[!] {name}"
|
||||
void ex_compiler(exarg_T *eap)
|
||||
{
|
||||
char_u *buf;
|
||||
char_u *old_cur_comp = NULL;
|
||||
char_u *p;
|
||||
char *buf;
|
||||
char *old_cur_comp = NULL;
|
||||
char *p;
|
||||
|
||||
if (*eap->arg == NUL) {
|
||||
// List all compiler scripts.
|
||||
@ -1603,20 +1603,20 @@ void ex_compiler(exarg_T *eap)
|
||||
// plugin will then skip the settings. Afterwards set
|
||||
// "b:current_compiler" and restore "current_compiler".
|
||||
// Explicitly prepend "g:" to make it work in a function.
|
||||
old_cur_comp = get_var_value("g:current_compiler");
|
||||
old_cur_comp = (char *)get_var_value("g:current_compiler");
|
||||
if (old_cur_comp != NULL) {
|
||||
old_cur_comp = vim_strsave(old_cur_comp);
|
||||
old_cur_comp = xstrdup(old_cur_comp);
|
||||
}
|
||||
do_cmdline_cmd("command -nargs=* -keepscript CompilerSet setlocal <args>");
|
||||
}
|
||||
do_unlet(S_LEN("g:current_compiler"), true);
|
||||
do_unlet(S_LEN("b:current_compiler"), true);
|
||||
|
||||
snprintf((char *)buf, bufsize, "compiler/%s.vim", eap->arg);
|
||||
if (source_runtime((char *)buf, DIP_ALL) == FAIL) {
|
||||
snprintf(buf, bufsize, "compiler/%s.vim", eap->arg);
|
||||
if (source_runtime(buf, DIP_ALL) == FAIL) {
|
||||
// Try lua compiler
|
||||
snprintf((char *)buf, bufsize, "compiler/%s.lua", eap->arg);
|
||||
if (source_runtime((char *)buf, DIP_ALL) == FAIL) {
|
||||
snprintf(buf, bufsize, "compiler/%s.lua", eap->arg);
|
||||
if (source_runtime(buf, DIP_ALL) == FAIL) {
|
||||
semsg(_("E666: compiler not supported: %s"), eap->arg);
|
||||
}
|
||||
}
|
||||
@ -1625,16 +1625,15 @@ void ex_compiler(exarg_T *eap)
|
||||
do_cmdline_cmd(":delcommand CompilerSet");
|
||||
|
||||
// Set "b:current_compiler" from "current_compiler".
|
||||
p = get_var_value("g:current_compiler");
|
||||
p = (char *)get_var_value("g:current_compiler");
|
||||
if (p != NULL) {
|
||||
set_internal_string_var("b:current_compiler", (char *)p);
|
||||
set_internal_string_var("b:current_compiler", p);
|
||||
}
|
||||
|
||||
// Restore "current_compiler" for ":compiler {name}".
|
||||
if (!eap->forceit) {
|
||||
if (old_cur_comp != NULL) {
|
||||
set_internal_string_var("g:current_compiler",
|
||||
(char *)old_cur_comp);
|
||||
set_internal_string_var("g:current_compiler", old_cur_comp);
|
||||
xfree(old_cur_comp);
|
||||
} else {
|
||||
do_unlet(S_LEN("g:current_compiler"), true);
|
||||
@ -1651,16 +1650,16 @@ void ex_options(exarg_T *eap)
|
||||
os_setenv("OPTWIN_CMD",
|
||||
cmdmod.tab ? "tab" :
|
||||
(cmdmod.split & WSP_VERT) ? "vert" : "", 1);
|
||||
cmd_source((char_u *)SYS_OPTWIN_FILE, NULL);
|
||||
cmd_source(SYS_OPTWIN_FILE, NULL);
|
||||
}
|
||||
|
||||
/// ":source [{fname}]"
|
||||
void ex_source(exarg_T *eap)
|
||||
{
|
||||
cmd_source((char_u *)eap->arg, eap);
|
||||
cmd_source(eap->arg, eap);
|
||||
}
|
||||
|
||||
static void cmd_source(char_u *fname, exarg_T *eap)
|
||||
static void cmd_source(char *fname, exarg_T *eap)
|
||||
{
|
||||
if (eap != NULL && *fname == NUL) {
|
||||
cmd_source_buffer(eap);
|
||||
@ -1672,11 +1671,11 @@ static void cmd_source(char_u *fname, exarg_T *eap)
|
||||
// - after ":argdo", ":windo" or ":bufdo"
|
||||
// - another command follows
|
||||
// - inside a loop
|
||||
openscript(fname, global_busy || listcmd_busy || eap->nextcmd != NULL
|
||||
openscript((char_u *)fname, global_busy || listcmd_busy || eap->nextcmd != NULL
|
||||
|| eap->cstack->cs_idx >= 0);
|
||||
|
||||
// ":source" read ex commands
|
||||
} else if (do_source((char *)fname, false, DOSO_NONE) == FAIL) {
|
||||
} else if (do_source(fname, false, DOSO_NONE) == FAIL) {
|
||||
semsg(_(e_notopen), fname);
|
||||
}
|
||||
}
|
||||
@ -1697,8 +1696,8 @@ static bool concat_continued_line(garray_T *const ga, const int init_growsize,
|
||||
const char_u *const p, size_t len)
|
||||
FUNC_ATTR_NONNULL_ALL
|
||||
{
|
||||
const char_u *const line = skipwhite_len(p, len);
|
||||
len -= (size_t)(line - p);
|
||||
const char *const line = (char *)skipwhite_len(p, len);
|
||||
len -= (size_t)((char_u *)line - p);
|
||||
// Skip lines starting with '\" ', concat lines starting with '\'
|
||||
if (len >= 3 && STRNCMP(line, "\"\\ ", 3) == 0) {
|
||||
return true;
|
||||
@ -1708,7 +1707,7 @@ static bool concat_continued_line(garray_T *const ga, const int init_growsize,
|
||||
if (ga->ga_len > init_growsize) {
|
||||
ga_set_growsize(ga, MIN(ga->ga_len, 8000));
|
||||
}
|
||||
ga_concat_len(ga, (const char *)line + 1, len - 1);
|
||||
ga_concat_len(ga, line + 1, len - 1);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -1758,7 +1757,7 @@ static FILE *fopen_noinh_readbin(char *filename)
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
char_u *buf;
|
||||
char *buf;
|
||||
size_t offset;
|
||||
} GetStrLineCookie;
|
||||
|
||||
@ -1773,19 +1772,19 @@ static char_u *get_str_line(int c, void *cookie, int indent, bool do_concat)
|
||||
if (STRLEN(p->buf) <= p->offset) {
|
||||
return NULL;
|
||||
}
|
||||
const char_u *line = p->buf + p->offset;
|
||||
const char_u *eol = skip_to_newline(line);
|
||||
const char *line = p->buf + p->offset;
|
||||
const char *eol = (char *)skip_to_newline((char_u *)line);
|
||||
garray_T ga;
|
||||
ga_init(&ga, sizeof(char_u), 400);
|
||||
ga_concat_len(&ga, (const char *)line, (size_t)(eol - line));
|
||||
ga_concat_len(&ga, line, (size_t)(eol - line));
|
||||
if (do_concat && vim_strchr(p_cpo, CPO_CONCAT) == NULL) {
|
||||
while (eol[0] != NUL) {
|
||||
line = eol + 1;
|
||||
const char_u *const next_eol = skip_to_newline(line);
|
||||
if (!concat_continued_line(&ga, 400, line, (size_t)(next_eol - line))) {
|
||||
const char_u *const next_eol = skip_to_newline((char_u *)line);
|
||||
if (!concat_continued_line(&ga, 400, (char_u *)line, (size_t)(next_eol - (char_u *)line))) {
|
||||
break;
|
||||
}
|
||||
eol = next_eol;
|
||||
eol = (char *)next_eol;
|
||||
}
|
||||
}
|
||||
ga_append(&ga, NUL);
|
||||
@ -1799,7 +1798,7 @@ static char_u *get_str_line(int c, void *cookie, int indent, bool do_concat)
|
||||
/// @param[out] sid_out SID of the new item.
|
||||
///
|
||||
/// @return pointer to the created script item.
|
||||
scriptitem_T *new_script_item(char_u *const name, scid_T *const sid_out)
|
||||
scriptitem_T *new_script_item(char *const name, scid_T *const sid_out)
|
||||
{
|
||||
static scid_T last_current_SID = 0;
|
||||
const scid_T sid = ++last_current_SID;
|
||||
@ -1812,23 +1811,23 @@ scriptitem_T *new_script_item(char_u *const name, scid_T *const sid_out)
|
||||
SCRIPT_ITEM(script_items.ga_len).sn_name = NULL;
|
||||
SCRIPT_ITEM(script_items.ga_len).sn_prof_on = false;
|
||||
}
|
||||
SCRIPT_ITEM(sid).sn_name = name;
|
||||
SCRIPT_ITEM(sid).sn_name = (char_u *)name;
|
||||
new_script_vars(sid); // Allocate the local script variables to use for this script.
|
||||
return &SCRIPT_ITEM(sid);
|
||||
}
|
||||
|
||||
static int source_using_linegetter(void *cookie, LineGetter fgetline, const char *traceback_name)
|
||||
{
|
||||
char_u *save_sourcing_name = sourcing_name;
|
||||
char *save_sourcing_name = (char *)sourcing_name;
|
||||
linenr_T save_sourcing_lnum = sourcing_lnum;
|
||||
char_u sourcing_name_buf[256];
|
||||
char sourcing_name_buf[256];
|
||||
if (save_sourcing_name == NULL) {
|
||||
sourcing_name = (char_u *)traceback_name;
|
||||
} else {
|
||||
snprintf((char *)sourcing_name_buf, sizeof(sourcing_name_buf),
|
||||
"%s called at %s:%" PRIdLINENR, traceback_name, save_sourcing_name,
|
||||
save_sourcing_lnum);
|
||||
sourcing_name = sourcing_name_buf; // -V507 reassigned below, before return.
|
||||
sourcing_name = (char_u *)sourcing_name_buf; // -V507 reassigned below, before return.
|
||||
}
|
||||
sourcing_lnum = 0;
|
||||
|
||||
@ -1843,7 +1842,7 @@ static int source_using_linegetter(void *cookie, LineGetter fgetline, const char
|
||||
int retval = do_cmdline(NULL, fgetline, cookie,
|
||||
DOCMD_VERBOSE | DOCMD_NOWAIT | DOCMD_REPEAT);
|
||||
sourcing_lnum = save_sourcing_lnum;
|
||||
sourcing_name = save_sourcing_name;
|
||||
sourcing_name = (char_u *)save_sourcing_name;
|
||||
current_sctx = save_current_sctx;
|
||||
restore_funccal();
|
||||
return retval;
|
||||
@ -1889,7 +1888,7 @@ static void cmd_source_buffer(const exarg_T *const eap)
|
||||
int do_source_str(const char *cmd, const char *traceback_name)
|
||||
{
|
||||
GetStrLineCookie cookie = {
|
||||
.buf = (char_u *)cmd,
|
||||
.buf = (char *)cmd,
|
||||
.offset = 0,
|
||||
};
|
||||
return source_using_linegetter((void *)&cookie, get_str_line, traceback_name);
|
||||
@ -1910,55 +1909,55 @@ int do_source_str(const char *cmd, const char *traceback_name)
|
||||
int do_source(char *fname, int check_other, int is_vimrc)
|
||||
{
|
||||
struct source_cookie cookie;
|
||||
char_u *save_sourcing_name;
|
||||
char *save_sourcing_name;
|
||||
linenr_T save_sourcing_lnum;
|
||||
char_u *p;
|
||||
char_u *fname_exp;
|
||||
char_u *firstline = NULL;
|
||||
char *p;
|
||||
char *fname_exp;
|
||||
uint8_t *firstline = NULL;
|
||||
int retval = FAIL;
|
||||
int save_debug_break_level = debug_break_level;
|
||||
scriptitem_T *si = NULL;
|
||||
proftime_T wait_start;
|
||||
bool trigger_source_post = false;
|
||||
|
||||
p = expand_env_save((char_u *)fname);
|
||||
p = (char *)expand_env_save((char_u *)fname);
|
||||
if (p == NULL) {
|
||||
return retval;
|
||||
}
|
||||
fname_exp = (char_u *)fix_fname((char *)p);
|
||||
fname_exp = fix_fname(p);
|
||||
xfree(p);
|
||||
if (fname_exp == NULL) {
|
||||
return retval;
|
||||
}
|
||||
if (os_isdir(fname_exp)) {
|
||||
if (os_isdir((char_u *)fname_exp)) {
|
||||
smsg(_("Cannot source a directory: \"%s\""), fname);
|
||||
goto theend;
|
||||
}
|
||||
|
||||
// Apply SourceCmd autocommands, they should get the file and source it.
|
||||
if (has_autocmd(EVENT_SOURCECMD, fname_exp, NULL)
|
||||
&& apply_autocmds(EVENT_SOURCECMD, fname_exp, fname_exp,
|
||||
if (has_autocmd(EVENT_SOURCECMD, (char_u *)fname_exp, NULL)
|
||||
&& apply_autocmds(EVENT_SOURCECMD, (char_u *)fname_exp, (char_u *)fname_exp,
|
||||
false, curbuf)) {
|
||||
retval = aborting() ? FAIL : OK;
|
||||
if (retval == OK) {
|
||||
// Apply SourcePost autocommands.
|
||||
apply_autocmds(EVENT_SOURCEPOST, fname_exp, fname_exp, false, curbuf);
|
||||
apply_autocmds(EVENT_SOURCEPOST, (char_u *)fname_exp, (char_u *)fname_exp, false, curbuf);
|
||||
}
|
||||
goto theend;
|
||||
}
|
||||
|
||||
// Apply SourcePre autocommands, they may get the file.
|
||||
apply_autocmds(EVENT_SOURCEPRE, fname_exp, fname_exp, false, curbuf);
|
||||
apply_autocmds(EVENT_SOURCEPRE, (char_u *)fname_exp, (char_u *)fname_exp, false, curbuf);
|
||||
|
||||
cookie.fp = fopen_noinh_readbin((char *)fname_exp);
|
||||
cookie.fp = fopen_noinh_readbin(fname_exp);
|
||||
if (cookie.fp == NULL && check_other) {
|
||||
// Try again, replacing file name ".vimrc" by "_vimrc" or vice versa,
|
||||
// and ".exrc" by "_exrc" or vice versa.
|
||||
p = path_tail(fname_exp);
|
||||
p = (char *)path_tail((char_u *)fname_exp);
|
||||
if ((*p == '.' || *p == '_')
|
||||
&& (STRICMP(p + 1, "nvimrc") == 0 || STRICMP(p + 1, "exrc") == 0)) {
|
||||
*p = (*p == '_') ? '.' : '_';
|
||||
cookie.fp = fopen_noinh_readbin((char *)fname_exp);
|
||||
cookie.fp = fopen_noinh_readbin(fname_exp);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1990,7 +1989,7 @@ int do_source(char *fname, int check_other, int is_vimrc)
|
||||
verbose_leave();
|
||||
}
|
||||
if (is_vimrc == DOSO_VIMRC) {
|
||||
vimrc_found((char *)fname_exp, "MYVIMRC");
|
||||
vimrc_found(fname_exp, "MYVIMRC");
|
||||
}
|
||||
|
||||
#ifdef USE_CRNL
|
||||
@ -2008,15 +2007,15 @@ int do_source(char *fname, int check_other, int is_vimrc)
|
||||
cookie.finished = false;
|
||||
|
||||
// Check if this script has a breakpoint.
|
||||
cookie.breakpoint = dbg_find_breakpoint(true, fname_exp, (linenr_T)0);
|
||||
cookie.breakpoint = dbg_find_breakpoint(true, (char_u *)fname_exp, (linenr_T)0);
|
||||
cookie.fname = fname_exp;
|
||||
cookie.dbg_tick = debug_tick;
|
||||
|
||||
cookie.level = ex_nesting_level;
|
||||
|
||||
// Keep the sourcing name/lnum, for recursive calls.
|
||||
save_sourcing_name = sourcing_name;
|
||||
sourcing_name = fname_exp;
|
||||
save_sourcing_name = (char *)sourcing_name;
|
||||
sourcing_name = (char_u *)fname_exp;
|
||||
save_sourcing_lnum = sourcing_lnum;
|
||||
sourcing_lnum = 0;
|
||||
|
||||
@ -2040,7 +2039,7 @@ int do_source(char *fname, int check_other, int is_vimrc)
|
||||
save_funccal(&funccalp_entry);
|
||||
|
||||
const sctx_T save_current_sctx = current_sctx;
|
||||
si = get_current_script_id(fname_exp, ¤t_sctx);
|
||||
si = get_current_script_id((char_u *)fname_exp, ¤t_sctx);
|
||||
|
||||
if (l_do_profiling == PROF_YES) {
|
||||
bool forceit = false;
|
||||
@ -2065,12 +2064,12 @@ int do_source(char *fname, int check_other, int is_vimrc)
|
||||
&& firstline[1] == 0xbb && firstline[2] == 0xbf) {
|
||||
// Found BOM; setup conversion, skip over BOM and recode the line.
|
||||
convert_setup(&cookie.conv, (char_u *)"utf-8", p_enc);
|
||||
p = string_convert(&cookie.conv, firstline + 3, NULL);
|
||||
p = (char *)string_convert(&cookie.conv, (char_u *)firstline + 3, NULL);
|
||||
if (p == NULL) {
|
||||
p = vim_strsave(firstline + 3);
|
||||
p = xstrdup((char *)firstline + 3);
|
||||
}
|
||||
xfree(firstline);
|
||||
firstline = p;
|
||||
firstline = (uint8_t *)p;
|
||||
}
|
||||
|
||||
if (path_with_extension((const char *)fname_exp, "lua")) {
|
||||
@ -2105,7 +2104,7 @@ int do_source(char *fname, int check_other, int is_vimrc)
|
||||
if (got_int) {
|
||||
emsg(_(e_interr));
|
||||
}
|
||||
sourcing_name = save_sourcing_name;
|
||||
sourcing_name = (char_u *)save_sourcing_name;
|
||||
sourcing_lnum = save_sourcing_lnum;
|
||||
if (p_verbose > 1) {
|
||||
verbose_enter();
|
||||
@ -2144,7 +2143,7 @@ int do_source(char *fname, int check_other, int is_vimrc)
|
||||
convert_setup(&cookie.conv, NULL, NULL);
|
||||
|
||||
if (trigger_source_post) {
|
||||
apply_autocmds(EVENT_SOURCEPOST, fname_exp, fname_exp, false, curbuf);
|
||||
apply_autocmds(EVENT_SOURCEPOST, (char_u *)fname_exp, (char_u *)fname_exp, false, curbuf);
|
||||
}
|
||||
|
||||
theend:
|
||||
@ -2183,7 +2182,7 @@ scriptitem_T *get_current_script_id(char_u *fname, sctx_T *ret_sctx)
|
||||
}
|
||||
}
|
||||
if (script_sctx.sc_sid == 0) {
|
||||
si = new_script_item(vim_strsave(fname), &script_sctx.sc_sid);
|
||||
si = new_script_item((char *)vim_strsave(fname), &script_sctx.sc_sid);
|
||||
if (file_id_ok) {
|
||||
si->file_id_valid = true;
|
||||
si->file_id = file_id;
|
||||
@ -2266,7 +2265,7 @@ char_u *get_scriptname(LastSet last_set, bool *should_free)
|
||||
case SID_STR:
|
||||
return (char_u *)_("anonymous :source");
|
||||
default: {
|
||||
char_u *const sname = SCRIPT_ITEM(last_set.script_ctx.sc_sid).sn_name;
|
||||
char *const sname = (char *)SCRIPT_ITEM(last_set.script_ctx.sc_sid).sn_name;
|
||||
if (sname == NULL) {
|
||||
snprintf((char *)IObuff, IOSIZE, _("anonymous :source (script id %d)"),
|
||||
last_set.script_ctx.sc_sid);
|
||||
@ -2274,7 +2273,7 @@ char_u *get_scriptname(LastSet last_set, bool *should_free)
|
||||
}
|
||||
|
||||
*should_free = true;
|
||||
return home_replace_save(NULL, sname);
|
||||
return home_replace_save(NULL, (char_u *)sname);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2306,12 +2305,12 @@ linenr_T get_sourced_lnum(LineGetter fgetline, void *cookie)
|
||||
char_u *getsourceline(int c, void *cookie, int indent, bool do_concat)
|
||||
{
|
||||
struct source_cookie *sp = (struct source_cookie *)cookie;
|
||||
char_u *line;
|
||||
char_u *p;
|
||||
char *line;
|
||||
char *p;
|
||||
|
||||
// If breakpoints have been added/deleted need to check for it.
|
||||
if (sp->dbg_tick < debug_tick) {
|
||||
sp->breakpoint = dbg_find_breakpoint(true, sp->fname, sourcing_lnum);
|
||||
sp->breakpoint = dbg_find_breakpoint(true, (char_u *)sp->fname, sourcing_lnum);
|
||||
sp->dbg_tick = debug_tick;
|
||||
}
|
||||
if (do_profiling == PROF_YES) {
|
||||
@ -2346,14 +2345,14 @@ char_u *getsourceline(int c, void *cookie, int indent, bool do_concat)
|
||||
// Also check for a comment in between continuation lines: "\ .
|
||||
sp->nextline = get_one_sourceline(sp);
|
||||
if (sp->nextline != NULL
|
||||
&& (*(p = skipwhite(sp->nextline)) == '\\'
|
||||
&& (*(p = (char *)skipwhite((char_u *)sp->nextline)) == '\\'
|
||||
|| (p[0] == '"' && p[1] == '\\' && p[2] == ' '))) {
|
||||
garray_T ga;
|
||||
|
||||
ga_init(&ga, (int)sizeof(char_u), 400);
|
||||
ga_concat(&ga, (char *)line);
|
||||
ga_concat(&ga, line);
|
||||
while (sp->nextline != NULL
|
||||
&& concat_continued_line(&ga, 400, sp->nextline,
|
||||
&& concat_continued_line(&ga, 400, (char_u *)sp->nextline,
|
||||
STRLEN(sp->nextline))) {
|
||||
xfree(sp->nextline);
|
||||
sp->nextline = get_one_sourceline(sp);
|
||||
@ -2365,10 +2364,10 @@ char_u *getsourceline(int c, void *cookie, int indent, bool do_concat)
|
||||
}
|
||||
|
||||
if (line != NULL && sp->conv.vc_type != CONV_NONE) {
|
||||
char_u *s;
|
||||
char *s;
|
||||
|
||||
// Convert the encoding of the script line.
|
||||
s = string_convert(&sp->conv, line, NULL);
|
||||
s = (char *)string_convert(&sp->conv, (char_u *)line, NULL);
|
||||
if (s != NULL) {
|
||||
xfree(line);
|
||||
line = s;
|
||||
@ -2377,21 +2376,21 @@ char_u *getsourceline(int c, void *cookie, int indent, bool do_concat)
|
||||
|
||||
// Did we encounter a breakpoint?
|
||||
if (sp->breakpoint != 0 && sp->breakpoint <= sourcing_lnum) {
|
||||
dbg_breakpoint(sp->fname, sourcing_lnum);
|
||||
dbg_breakpoint((char_u *)sp->fname, sourcing_lnum);
|
||||
// Find next breakpoint.
|
||||
sp->breakpoint = dbg_find_breakpoint(true, sp->fname, sourcing_lnum);
|
||||
sp->breakpoint = dbg_find_breakpoint(true, (char_u *)sp->fname, sourcing_lnum);
|
||||
sp->dbg_tick = debug_tick;
|
||||
}
|
||||
|
||||
return line;
|
||||
return (char_u *)line;
|
||||
}
|
||||
|
||||
static char_u *get_one_sourceline(struct source_cookie *sp)
|
||||
static char *get_one_sourceline(struct source_cookie *sp)
|
||||
{
|
||||
garray_T ga;
|
||||
int len;
|
||||
int c;
|
||||
char_u *buf;
|
||||
char *buf;
|
||||
#ifdef USE_CRNL
|
||||
int has_cr; // CR-LF found
|
||||
#endif
|
||||
@ -2405,11 +2404,11 @@ static char_u *get_one_sourceline(struct source_cookie *sp)
|
||||
for (;;) {
|
||||
// make room to read at least 120 (more) characters
|
||||
ga_grow(&ga, 120);
|
||||
buf = (char_u *)ga.ga_data;
|
||||
buf = ga.ga_data;
|
||||
|
||||
retry:
|
||||
errno = 0;
|
||||
if (fgets((char *)buf + ga.ga_len, ga.ga_maxlen - ga.ga_len,
|
||||
if (fgets(buf + ga.ga_len, ga.ga_maxlen - ga.ga_len,
|
||||
sp->fp) == NULL) {
|
||||
if (errno == EINTR) {
|
||||
goto retry;
|
||||
@ -2481,7 +2480,7 @@ retry:
|
||||
}
|
||||
|
||||
if (have_read) {
|
||||
return (char_u *)ga.ga_data;
|
||||
return ga.ga_data;
|
||||
}
|
||||
|
||||
xfree(ga.ga_data);
|
||||
@ -2567,7 +2566,7 @@ void script_line_end(void)
|
||||
void ex_scriptencoding(exarg_T *eap)
|
||||
{
|
||||
struct source_cookie *sp;
|
||||
char_u *name;
|
||||
char *name;
|
||||
|
||||
if (!getline_equal(eap->getline, eap->cookie, getsourceline)) {
|
||||
emsg(_("E167: :scriptencoding used outside of a sourced file"));
|
||||
@ -2575,16 +2574,16 @@ void ex_scriptencoding(exarg_T *eap)
|
||||
}
|
||||
|
||||
if (*eap->arg != NUL) {
|
||||
name = enc_canonize((char_u *)eap->arg);
|
||||
name = (char *)enc_canonize((char_u *)eap->arg);
|
||||
} else {
|
||||
name = (char_u *)eap->arg;
|
||||
name = eap->arg;
|
||||
}
|
||||
|
||||
// Setup for conversion from the specified encoding to 'encoding'.
|
||||
sp = (struct source_cookie *)getline_cookie(eap->getline, eap->cookie);
|
||||
convert_setup(&sp->conv, name, p_enc);
|
||||
convert_setup(&sp->conv, (char_u *)name, p_enc);
|
||||
|
||||
if (name != (char_u *)eap->arg) {
|
||||
if (name != eap->arg) {
|
||||
xfree(name);
|
||||
}
|
||||
}
|
||||
@ -2703,21 +2702,21 @@ char *get_mess_lang(void)
|
||||
// Complicated #if; matches with where get_mess_env() is used below.
|
||||
#ifdef HAVE_WORKING_LIBINTL
|
||||
/// Get the language used for messages from the environment.
|
||||
static char_u *get_mess_env(void)
|
||||
static char *get_mess_env(void)
|
||||
{
|
||||
char_u *p;
|
||||
char *p;
|
||||
|
||||
p = (char_u *)os_getenv("LC_ALL");
|
||||
p = (char *)os_getenv("LC_ALL");
|
||||
if (p == NULL) {
|
||||
p = (char_u *)os_getenv("LC_MESSAGES");
|
||||
p = (char *)os_getenv("LC_MESSAGES");
|
||||
if (p == NULL) {
|
||||
p = (char_u *)os_getenv("LANG");
|
||||
p = (char *)os_getenv("LANG");
|
||||
if (p != NULL && ascii_isdigit(*p)) {
|
||||
p = NULL; // ignore something like "1043"
|
||||
}
|
||||
# ifdef HAVE_GET_LOCALE_VAL
|
||||
if (p == NULL) {
|
||||
p = (char_u *)get_locale_val(LC_CTYPE);
|
||||
p = get_locale_val(LC_CTYPE);
|
||||
}
|
||||
# endif
|
||||
}
|
||||
@ -2745,7 +2744,7 @@ void set_lang_var(void)
|
||||
// When LC_MESSAGES isn't defined use the value from $LC_MESSAGES, fall
|
||||
// back to LC_CTYPE if it's empty.
|
||||
#ifdef HAVE_WORKING_LIBINTL
|
||||
loc = (char *)get_mess_env();
|
||||
loc = get_mess_env();
|
||||
#elif defined(LC_MESSAGES)
|
||||
loc = get_locale_val(LC_MESSAGES);
|
||||
#else
|
||||
@ -2776,8 +2775,8 @@ void set_lang_var(void)
|
||||
void ex_language(exarg_T *eap)
|
||||
{
|
||||
char *loc;
|
||||
char_u *p;
|
||||
char_u *name;
|
||||
char *p;
|
||||
char *name;
|
||||
int what = LC_ALL;
|
||||
char *whatstr = "";
|
||||
# ifdef LC_MESSAGES
|
||||
@ -2786,28 +2785,28 @@ void ex_language(exarg_T *eap)
|
||||
# define VIM_LC_MESSAGES 6789
|
||||
# endif
|
||||
|
||||
name = (char_u *)eap->arg;
|
||||
name = eap->arg;
|
||||
|
||||
// Check for "messages {name}", "ctype {name}" or "time {name}" argument.
|
||||
// Allow abbreviation, but require at least 3 characters to avoid
|
||||
// confusion with a two letter language name "me" or "ct".
|
||||
p = skiptowhite((char_u *)eap->arg);
|
||||
if ((*p == NUL || ascii_iswhite(*p)) && p - (char_u *)eap->arg >= 3) {
|
||||
if (STRNICMP(eap->arg, "messages", p - (char_u *)eap->arg) == 0) {
|
||||
p = (char *)skiptowhite((char_u *)eap->arg);
|
||||
if ((*p == NUL || ascii_iswhite(*p)) && p - eap->arg >= 3) {
|
||||
if (STRNICMP(eap->arg, "messages", p - eap->arg) == 0) {
|
||||
what = VIM_LC_MESSAGES;
|
||||
name = skipwhite(p);
|
||||
name = (char *)skipwhite((char_u *)p);
|
||||
whatstr = "messages ";
|
||||
} else if (STRNICMP(eap->arg, "ctype", p - (char_u *)eap->arg) == 0) {
|
||||
} else if (STRNICMP(eap->arg, "ctype", p - eap->arg) == 0) {
|
||||
what = LC_CTYPE;
|
||||
name = skipwhite(p);
|
||||
name = (char *)skipwhite((char_u *)p);
|
||||
whatstr = "ctype ";
|
||||
} else if (STRNICMP(eap->arg, "time", p - (char_u *)eap->arg) == 0) {
|
||||
} else if (STRNICMP(eap->arg, "time", p - eap->arg) == 0) {
|
||||
what = LC_TIME;
|
||||
name = skipwhite(p);
|
||||
name = (char *)skipwhite((char_u *)p);
|
||||
whatstr = "time ";
|
||||
} else if (STRNICMP(eap->arg, "collate", p - (char_u *)eap->arg) == 0) {
|
||||
} else if (STRNICMP(eap->arg, "collate", p - eap->arg) == 0) {
|
||||
what = LC_COLLATE;
|
||||
name = skipwhite(p);
|
||||
name = (char *)skipwhite((char_u *)p);
|
||||
whatstr = "collate ";
|
||||
}
|
||||
}
|
||||
@ -2818,12 +2817,12 @@ void ex_language(exarg_T *eap)
|
||||
p = get_mess_env();
|
||||
} else {
|
||||
# endif
|
||||
p = (char_u *)setlocale(what, NULL);
|
||||
p = setlocale(what, NULL);
|
||||
# ifdef HAVE_WORKING_LIBINTL
|
||||
}
|
||||
# endif
|
||||
if (p == NULL || *p == NUL) {
|
||||
p = (char_u *)"Unknown";
|
||||
p = "Unknown";
|
||||
}
|
||||
smsg(_("Current %slanguage: \"%s\""), whatstr, p);
|
||||
} else {
|
||||
@ -2832,7 +2831,7 @@ void ex_language(exarg_T *eap)
|
||||
loc = "";
|
||||
} else {
|
||||
# endif
|
||||
loc = setlocale(what, (char *)name);
|
||||
loc = setlocale(what, name);
|
||||
# ifdef LC_NUMERIC
|
||||
// Make sure strtod() uses a decimal point, not a comma.
|
||||
setlocale(LC_NUMERIC, "C");
|
||||
@ -2857,14 +2856,14 @@ void ex_language(exarg_T *eap)
|
||||
// Tell gettext() what to translate to. It apparently doesn't
|
||||
// use the currently effective locale.
|
||||
if (what == LC_ALL) {
|
||||
os_setenv("LANG", (char *)name, 1);
|
||||
os_setenv("LANG", name, 1);
|
||||
|
||||
// Clear $LANGUAGE because GNU gettext uses it.
|
||||
os_setenv("LANGUAGE", "", 1);
|
||||
}
|
||||
if (what != LC_CTYPE) {
|
||||
os_setenv("LC_MESSAGES", (char *)name, 1);
|
||||
set_helplang_default((char *)name);
|
||||
os_setenv("LC_MESSAGES", name, 1);
|
||||
set_helplang_default(name);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2876,7 +2875,7 @@ void ex_language(exarg_T *eap)
|
||||
}
|
||||
|
||||
|
||||
static char_u **locales = NULL; // Array of all available locales
|
||||
static char **locales = NULL; // Array of all available locales
|
||||
|
||||
# ifndef WIN32
|
||||
static bool did_init_locales = false;
|
||||
@ -2884,15 +2883,15 @@ static bool did_init_locales = false;
|
||||
/// @return an array of strings for all available locales + NULL for the
|
||||
/// last element or,
|
||||
/// NULL in case of error.
|
||||
static char_u **find_locales(void)
|
||||
static char **find_locales(void)
|
||||
{
|
||||
garray_T locales_ga;
|
||||
char_u *loc;
|
||||
char *loc;
|
||||
char *saveptr = NULL;
|
||||
|
||||
// Find all available locales by running command "locale -a". If this
|
||||
// doesn't work we won't have completion.
|
||||
char_u *locale_a = get_cmd_output((char_u *)"locale -a", NULL,
|
||||
char *locale_a = (char *)get_cmd_output((char_u *)"locale -a", NULL,
|
||||
kShellOptSilent, NULL);
|
||||
if (locale_a == NULL) {
|
||||
return NULL;
|
||||
@ -2901,18 +2900,18 @@ static char_u **find_locales(void)
|
||||
|
||||
// Transform locale_a string where each locale is separated by "\n"
|
||||
// into an array of locale strings.
|
||||
loc = (char_u *)os_strtok((char *)locale_a, "\n", &saveptr);
|
||||
loc = os_strtok(locale_a, "\n", &saveptr);
|
||||
|
||||
while (loc != NULL) {
|
||||
loc = vim_strsave(loc);
|
||||
GA_APPEND(char_u *, &locales_ga, loc);
|
||||
loc = (char_u *)os_strtok(NULL, "\n", &saveptr);
|
||||
loc = xstrdup(loc);
|
||||
GA_APPEND(char *, &locales_ga, loc);
|
||||
loc = os_strtok(NULL, "\n", &saveptr);
|
||||
}
|
||||
xfree(locale_a);
|
||||
// Guarantee that .ga_data is NULL terminated
|
||||
ga_grow(&locales_ga, 1);
|
||||
((char_u **)locales_ga.ga_data)[locales_ga.ga_len] = NULL;
|
||||
return (char_u **)locales_ga.ga_data;
|
||||
return locales_ga.ga_data;
|
||||
}
|
||||
# endif
|
||||
|
||||
@ -2962,7 +2961,7 @@ char_u *get_lang_arg(expand_T *xp, int idx)
|
||||
if (locales == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
return locales[idx - 4];
|
||||
return (char_u *)locales[idx - 4];
|
||||
}
|
||||
|
||||
/// Function given to ExpandGeneric() to obtain the available locales.
|
||||
@ -2972,7 +2971,7 @@ char_u *get_locales(expand_T *xp, int idx)
|
||||
if (locales == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
return locales[idx];
|
||||
return (char_u *)locales[idx];
|
||||
}
|
||||
|
||||
#endif
|
||||
@ -3036,7 +3035,7 @@ void ex_drop(exarg_T *eap)
|
||||
// and mostly only one file is dropped.
|
||||
// This also ignores wildcards, since it is very unlikely the user is
|
||||
// editing a file name with a wildcard character.
|
||||
do_arglist((char_u *)eap->arg, AL_SET, 0, false);
|
||||
do_arglist(eap->arg, AL_SET, 0, false);
|
||||
|
||||
// Expanding wildcards may result in an empty argument list. E.g. when
|
||||
// editing "foo.pyc" and ".pyc" is in 'wildignore'. Assume that we
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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();
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
@ -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,12 +2874,14 @@ 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,
|
||||
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,
|
||||
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));
|
||||
@ -2899,7 +2901,7 @@ 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,
|
||||
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.
|
||||
@ -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);
|
||||
|
@ -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,
|
||||
|
@ -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: {
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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,7 +1132,7 @@ void ml_recover(bool checkext)
|
||||
*/
|
||||
if (line_count != dp->db_line_count) {
|
||||
ml_append(lnum++,
|
||||
(char_u *)_("??? from here until ???END lines"
|
||||
_("??? from here until ???END lines"
|
||||
" may have been inserted/deleted"),
|
||||
(colnr_T)0, true);
|
||||
error++;
|
||||
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -1747,7 +1747,7 @@ 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
|
||||
.v_string = (which_button == MOUSE_LEFT
|
||||
? "l"
|
||||
: (which_button == MOUSE_RIGHT
|
||||
? "r"
|
||||
@ -1760,11 +1760,11 @@ 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[]) {
|
||||
(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
|
||||
}
|
||||
},
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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.
|
||||
|
@ -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);
|
||||
|
@ -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)
|
||||
|
@ -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"
|
||||
|
@ -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++;
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user