aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/nvim/api/autocmd.c46
-rw-r--r--src/nvim/api/extmark.c14
-rw-r--r--src/nvim/api/keysets.lua1
-rw-r--r--src/nvim/api/ui.h1
-rw-r--r--src/nvim/api/ui_events.in.h4
-rw-r--r--src/nvim/api/vim.c202
-rw-r--r--src/nvim/api/vimscript.c229
-rw-r--r--src/nvim/autocmd.c252
-rw-r--r--src/nvim/autocmd.h19
-rw-r--r--src/nvim/buffer.c28
-rw-r--r--src/nvim/cursor_shape.c28
-rw-r--r--src/nvim/debugger.c8
-rw-r--r--src/nvim/decoration.c36
-rw-r--r--src/nvim/decoration.h5
-rw-r--r--src/nvim/diff.c26
-rw-r--r--src/nvim/edit.c2
-rw-r--r--src/nvim/eval.c46
-rw-r--r--src/nvim/eval.h2
-rw-r--r--src/nvim/eval/funcs.c23
-rw-r--r--src/nvim/eval/typval.c2
-rw-r--r--src/nvim/eval/userfunc.c32
-rw-r--r--src/nvim/ex_cmds.c58
-rw-r--r--src/nvim/ex_cmds2.c50
-rw-r--r--src/nvim/ex_cmds_defs.h24
-rw-r--r--src/nvim/ex_docmd.c471
-rw-r--r--src/nvim/ex_eval.c59
-rw-r--r--src/nvim/ex_eval.h2
-rw-r--r--src/nvim/ex_getln.c88
-rw-r--r--src/nvim/extmark.c3
-rw-r--r--src/nvim/fileio.c2
-rw-r--r--src/nvim/getchar.c2
-rw-r--r--src/nvim/hardcopy.c6
-rw-r--r--src/nvim/highlight_group.c15
-rw-r--r--src/nvim/if_cscope.c32
-rw-r--r--src/nvim/lua/executor.c2
-rw-r--r--src/nvim/lua/treesitter.c17
-rw-r--r--src/nvim/main.c12
-rw-r--r--src/nvim/main.h6
-rw-r--r--src/nvim/mark.c10
-rw-r--r--src/nvim/mark_defs.h2
-rw-r--r--src/nvim/match.c10
-rw-r--r--src/nvim/menu.c10
-rw-r--r--src/nvim/message.c2
-rw-r--r--src/nvim/move.c4
-rw-r--r--src/nvim/msgpack_rpc/server.c49
-rw-r--r--src/nvim/ops.c2
-rw-r--r--src/nvim/option.c21
-rw-r--r--src/nvim/path.c2
-rw-r--r--src/nvim/quickfix.c38
-rw-r--r--src/nvim/runtime.c2
-rw-r--r--src/nvim/screen.c47
-rw-r--r--src/nvim/shada.c10
-rw-r--r--src/nvim/sign.c8
-rw-r--r--src/nvim/spellfile.c4
-rw-r--r--src/nvim/syntax.c86
-rw-r--r--src/nvim/terminal.c12
-rw-r--r--src/nvim/terminal.h2
57 files changed, 1148 insertions, 1028 deletions
diff --git a/src/nvim/api/autocmd.c b/src/nvim/api/autocmd.c
index 0db9a63e7a..010c03e505 100644
--- a/src/nvim/api/autocmd.c
+++ b/src/nvim/api/autocmd.c
@@ -23,9 +23,9 @@
// Copy string or array of strings into an empty array.
// Get the event number, unless it is an error. Then goto `goto_name`.
#define GET_ONE_EVENT(event_nr, event_str, goto_name) \
- char_u *__next_ev; \
+ char *__next_ev; \
event_T event_nr = \
- event_name2nr((char_u *)event_str.data.string.data, &__next_ev); \
+ event_name2nr(event_str.data.string.data, &__next_ev); \
if (event_nr >= NUM_EVENTS) { \
api_set_error(err, kErrorTypeValidation, "unexpected event"); \
goto goto_name; \
@@ -78,8 +78,8 @@ Array nvim_get_autocmds(Dict(get_autocmds) *opts, Error *err)
// TODO(tjdevries): Would be cool to add nvim_get_autocmds({ id = ... })
Array autocmd_list = ARRAY_DICT_INIT;
- char_u *pattern_filters[AUCMD_MAX_PATTERNS];
- char_u pattern_buflocal[BUFLOCAL_PAT_LEN];
+ char *pattern_filters[AUCMD_MAX_PATTERNS];
+ char pattern_buflocal[BUFLOCAL_PAT_LEN];
Array buffers = ARRAY_DICT_INIT;
@@ -148,7 +148,7 @@ Array nvim_get_autocmds(Dict(get_autocmds) *opts, Error *err)
if (opts->pattern.type != kObjectTypeNil) {
Object v = opts->pattern;
if (v.type == kObjectTypeString) {
- pattern_filters[pattern_filter_count] = (char_u *)v.data.string.data;
+ pattern_filters[pattern_filter_count] = v.data.string.data;
pattern_filter_count += 1;
} else if (v.type == kObjectTypeArray) {
if (v.data.array.size > AUCMD_MAX_PATTERNS) {
@@ -164,7 +164,7 @@ Array nvim_get_autocmds(Dict(get_autocmds) *opts, Error *err)
goto cleanup;
}
- pattern_filters[pattern_filter_count] = (char_u *)item.data.string.data;
+ pattern_filters[pattern_filter_count] = item.data.string.data;
pattern_filter_count += 1;
});
} else {
@@ -211,7 +211,7 @@ Array nvim_get_autocmds(Dict(get_autocmds) *opts, Error *err)
}
FOREACH_ITEM(buffers, bufnr, {
- pattern_filters[pattern_filter_count] = (char_u *)bufnr.data.string.data;
+ pattern_filters[pattern_filter_count] = bufnr.data.string.data;
pattern_filter_count += 1;
});
@@ -237,7 +237,7 @@ Array nvim_get_autocmds(Dict(get_autocmds) *opts, Error *err)
assert(i < AUCMD_MAX_PATTERNS);
assert(pattern_filters[i]);
- char_u *pat = pattern_filters[i];
+ char *pat = pattern_filters[i];
int patlen = (int)STRLEN(pat);
if (aupat_is_buflocal(pat, patlen)) {
@@ -249,7 +249,7 @@ Array nvim_get_autocmds(Dict(get_autocmds) *opts, Error *err)
pat = pattern_buflocal;
}
- if (strequal((char *)ap->pat, (char *)pat)) {
+ if (strequal(ap->pat, pat)) {
passed = true;
break;
}
@@ -474,7 +474,7 @@ Integer nvim_create_autocmd(uint64_t channel_id, Object event, Dict(create_autoc
Object *command = &opts->command;
if (command->type == kObjectTypeString) {
aucmd.type = CALLABLE_EX;
- aucmd.callable.cmd = (char_u *)string_to_cstr(command->data.string);
+ aucmd.callable.cmd = string_to_cstr(command->data.string);
} else {
api_set_error(err,
kErrorTypeValidation,
@@ -531,7 +531,7 @@ Integer nvim_create_autocmd(uint64_t channel_id, Object event, Dict(create_autoc
WITH_SCRIPT_CONTEXT(channel_id, {
retval = autocmd_register(autocmd_id,
event_nr,
- (char_u *)pat.data.string.data,
+ pat.data.string.data,
(int)pat.data.string.size,
au_group,
is_once,
@@ -635,8 +635,8 @@ void nvim_clear_autocmds(Dict(clear_autocmds) *opts, Error *err)
if (event_array.size == 0) {
FOR_ALL_AUEVENTS(event) {
FOREACH_ITEM(patterns, pat_object, {
- char_u *pat = (char_u *)pat_object.data.string.data;
- if (!clear_autocmd(event, pat, au_group, err)) {
+ char *pat = pat_object.data.string.data;
+ if (!clear_autocmd(event, (char *)pat, au_group, err)) {
goto cleanup;
}
});
@@ -646,8 +646,8 @@ void nvim_clear_autocmds(Dict(clear_autocmds) *opts, Error *err)
GET_ONE_EVENT(event_nr, event_str, cleanup);
FOREACH_ITEM(patterns, pat_object, {
- char_u *pat = (char_u *)pat_object.data.string.data;
- if (!clear_autocmd(event_nr, pat, au_group, err)) {
+ char *pat = pat_object.data.string.data;
+ if (!clear_autocmd(event_nr, (char *)pat, au_group, err)) {
goto cleanup;
}
});
@@ -657,8 +657,6 @@ void nvim_clear_autocmds(Dict(clear_autocmds) *opts, Error *err)
cleanup:
api_free_array(event_array);
api_free_array(patterns);
-
- return;
}
/// Create or get an autocommand group |autocmd-groups|.
@@ -759,7 +757,7 @@ void nvim_exec_autocmds(Object event, Dict(exec_autocmds) *opts, Error *err)
buf_T *buf = curbuf;
bool set_buf = false;
- char_u *pattern = NULL;
+ char *pattern = NULL;
bool set_pattern = false;
Array event_array = ARRAY_DICT_INIT;
@@ -814,7 +812,7 @@ void nvim_exec_autocmds(Object event, Dict(exec_autocmds) *opts, Error *err)
goto cleanup;
}
- pattern = (char_u *)string_to_cstr(opts->pattern.data.string);
+ pattern = string_to_cstr(opts->pattern.data.string);
set_pattern = true;
}
@@ -922,7 +920,7 @@ static int get_augroup_from_object(Object group, Error *err)
static bool get_patterns_from_pattern_or_buf(Array *patterns, Object pattern, Object buffer,
Error *err)
{
- const char_u pattern_buflocal[BUFLOCAL_PAT_LEN];
+ const char pattern_buflocal[BUFLOCAL_PAT_LEN];
if (pattern.type != kObjectTypeNil && buffer.type != kObjectTypeNil) {
api_set_error(err, kErrorTypeValidation,
@@ -932,7 +930,7 @@ static bool get_patterns_from_pattern_or_buf(Array *patterns, Object pattern, Ob
Object *v = &pattern;
if (v->type == kObjectTypeString) {
- char_u *pat = (char_u *)v->data.string.data;
+ char *pat = v->data.string.data;
size_t patlen = aucmd_pattern_length(pat);
while (patlen) {
ADD(*patterns, STRING_OBJ(cbuf_to_string((char *)pat, patlen)));
@@ -947,7 +945,7 @@ static bool get_patterns_from_pattern_or_buf(Array *patterns, Object pattern, Ob
Array array = v->data.array;
for (size_t i = 0; i < array.size; i++) {
- char_u *pat = (char_u *)array.items[i].data.string.data;
+ char *pat = array.items[i].data.string.data;
size_t patlen = aucmd_pattern_length(pat);
while (patlen) {
ADD(*patterns, STRING_OBJ(cbuf_to_string((char *)pat, patlen)));
@@ -982,9 +980,9 @@ static bool get_patterns_from_pattern_or_buf(Array *patterns, Object pattern, Ob
return true;
}
-static bool clear_autocmd(event_T event, char_u *pat, int au_group, Error *err)
+static bool clear_autocmd(event_T event, char *pat, int au_group, Error *err)
{
- if (do_autocmd_event(event, pat, false, false, (char_u *)"", true, au_group) == FAIL) {
+ if (do_autocmd_event(event, pat, false, false, "", true, au_group) == FAIL) {
api_set_error(err, kErrorTypeException, "Failed to clear autocmd");
return false;
}
diff --git a/src/nvim/api/extmark.c b/src/nvim/api/extmark.c
index e408d88854..fa6923e6d5 100644
--- a/src/nvim/api/extmark.c
+++ b/src/nvim/api/extmark.c
@@ -146,6 +146,10 @@ static Array extmark_to_array(ExtmarkInfo extmark, bool id, bool add_dict)
STRING_OBJ(cstr_to_string(virt_text_pos_str[decor->virt_text_pos])));
}
+ if (decor->ui_watched) {
+ PUT(dict, "ui_watched", BOOLEAN_OBJ(true));
+ }
+
if (kv_size(decor->virt_lines)) {
Array all_chunks = ARRAY_DICT_INIT;
bool virt_lines_leftcol = false;
@@ -170,7 +174,7 @@ static Array extmark_to_array(ExtmarkInfo extmark, bool id, bool add_dict)
PUT(dict, "virt_lines_leftcol", BOOLEAN_OBJ(virt_lines_leftcol));
}
- if (decor->hl_id || kv_size(decor->virt_text)) {
+ if (decor->hl_id || kv_size(decor->virt_text) || decor->ui_watched) {
PUT(dict, "priority", INTEGER_OBJ(decor->priority));
}
@@ -472,6 +476,10 @@ Array nvim_buf_get_extmarks(Buffer buffer, Integer ns_id, Object start, Object e
/// When a character is supplied it is used as |:syn-cchar|.
/// "hl_group" is used as highlight for the cchar if provided,
/// otherwise it defaults to |hl-Conceal|.
+/// - ui_watched: boolean that indicates the mark should be drawn
+/// by a UI. When set, the UI will receive win_extmark events.
+/// Note: the mark is positioned by virt_text attributes. Can be
+/// used together with virt_text.
///
/// @param[out] err Error details, if any
/// @return Id of the created/updated extmark
@@ -709,6 +717,8 @@ Integer nvim_buf_set_extmark(Buffer buffer, Integer ns_id, Integer line, Integer
bool ephemeral = false;
OPTION_TO_BOOL(ephemeral, ephemeral, false);
+ OPTION_TO_BOOL(decor.ui_watched, ui_watched, false);
+
if (line < 0) {
api_set_error(err, kErrorTypeValidation, "line value outside range");
goto error;
@@ -762,7 +772,7 @@ Integer nvim_buf_set_extmark(Buffer buffer, Integer ns_id, Integer line, Integer
// TODO(bfredl): synergize these two branches even more
if (ephemeral && decor_state.buf == buf) {
- decor_add_ephemeral((int)line, (int)col, line2, col2, &decor);
+ decor_add_ephemeral((int)line, (int)col, line2, col2, &decor, (uint64_t)ns_id, id);
} else {
if (ephemeral) {
api_set_error(err, kErrorTypeException, "not yet implemented");
diff --git a/src/nvim/api/keysets.lua b/src/nvim/api/keysets.lua
index 8ad4dae928..5baffaf505 100644
--- a/src/nvim/api/keysets.lua
+++ b/src/nvim/api/keysets.lua
@@ -28,6 +28,7 @@ return {
"line_hl_group";
"cursorline_hl_group";
"conceal";
+ "ui_watched";
};
keymap = {
"noremap";
diff --git a/src/nvim/api/ui.h b/src/nvim/api/ui.h
index b3af14f8a8..bc70406acb 100644
--- a/src/nvim/api/ui.h
+++ b/src/nvim/api/ui.h
@@ -4,6 +4,7 @@
#include <stdint.h>
#include "nvim/api/private/defs.h"
+#include "nvim/map.h"
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "api/ui.h.generated.h"
diff --git a/src/nvim/api/ui_events.in.h b/src/nvim/api/ui_events.in.h
index db348359eb..63aaaae38a 100644
--- a/src/nvim/api/ui_events.in.h
+++ b/src/nvim/api/ui_events.in.h
@@ -123,6 +123,10 @@ void win_viewport(Integer grid, Window win, Integer topline,
Integer line_count)
FUNC_API_SINCE(7) FUNC_API_REMOTE_ONLY;
+void win_extmark(Integer grid, Window win, Integer ns_id, Integer mark_id,
+ Integer row, Integer col)
+ FUNC_API_SINCE(10) FUNC_API_REMOTE_ONLY;
+
void popupmenu_show(Array items, Integer selected,
Integer row, Integer col, Integer grid)
FUNC_API_SINCE(3) FUNC_API_REMOTE_ONLY;
diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c
index d9ab097316..2323b8db47 100644
--- a/src/nvim/api/vim.c
+++ b/src/nvim/api/vim.c
@@ -2210,7 +2210,7 @@ Array nvim_get_mark(String name, Dictionary opts, Error *err)
allocated = true;
// Marks comes from shada
} else {
- filename = (char *)mark.fname;
+ filename = mark.fname;
bufnr = 0;
}
@@ -2461,203 +2461,3 @@ void nvim_del_user_command(String name, Error *err)
{
nvim_buf_del_user_command(-1, name, err);
}
-
-/// Parse command line.
-///
-/// Doesn't check the validity of command arguments.
-///
-/// @param str Command line string to parse. Cannot contain "\n".
-/// @param opts Optional parameters. Reserved for future use.
-/// @param[out] err Error details, if any.
-/// @return Dictionary containing command information, with these keys:
-/// - cmd: (string) Command name.
-/// - line1: (number) Starting line of command range. Only applicable if command can take a
-/// range.
-/// - line2: (number) Final line of command range. Only applicable if command can take a
-/// range.
-/// - bang: (boolean) Whether command contains a bang (!) modifier.
-/// - args: (array) Command arguments.
-/// - addr: (string) Value of |:command-addr|. Uses short name.
-/// - nargs: (string) Value of |:command-nargs|.
-/// - nextcmd: (string) Next command if there are multiple commands separated by a |:bar|.
-/// Empty if there isn't a next command.
-/// - magic: (dictionary) Which characters have special meaning in the command arguments.
-/// - file: (boolean) The command expands filenames. Which means characters such as "%",
-/// "#" and wildcards are expanded.
-/// - bar: (boolean) The "|" character is treated as a command separator and the double
-/// quote character (\") is treated as the start of a comment.
-/// - mods: (dictionary) |:command-modifiers|.
-/// - silent: (boolean) |:silent|.
-/// - emsg_silent: (boolean) |:silent!|.
-/// - sandbox: (boolean) |:sandbox|.
-/// - noautocmd: (boolean) |:noautocmd|.
-/// - browse: (boolean) |:browse|.
-/// - confirm: (boolean) |:confirm|.
-/// - hide: (boolean) |:hide|.
-/// - keepalt: (boolean) |:keepalt|.
-/// - keepjumps: (boolean) |:keepjumps|.
-/// - keepmarks: (boolean) |:keepmarks|.
-/// - keeppatterns: (boolean) |:keeppatterns|.
-/// - lockmarks: (boolean) |:lockmarks|.
-/// - noswapfile: (boolean) |:noswapfile|.
-/// - tab: (integer) |:tab|.
-/// - verbose: (integer) |:verbose|.
-/// - vertical: (boolean) |:vertical|.
-/// - split: (string) Split modifier string, is an empty string when there's no split
-/// modifier. If there is a split modifier it can be one of:
-/// - "aboveleft": |:aboveleft|.
-/// - "belowright": |:belowright|.
-/// - "topleft": |:topleft|.
-/// - "botright": |:botright|.
-Dictionary nvim_parse_cmd(String str, Dictionary opts, Error *err)
- FUNC_API_SINCE(10) FUNC_API_FAST
-{
- Dictionary result = ARRAY_DICT_INIT;
-
- if (opts.size > 0) {
- api_set_error(err, kErrorTypeValidation, "opts dict isn't empty");
- return result;
- }
-
- // Parse command line
- exarg_T ea;
- CmdParseInfo cmdinfo;
- char_u *cmdline = (char_u *)string_to_cstr(str);
-
- if (!parse_cmdline(cmdline, &ea, &cmdinfo)) {
- api_set_error(err, kErrorTypeException, "Error while parsing command line");
- goto end;
- }
-
- // Parse arguments
- Array args = ARRAY_DICT_INIT;
- size_t length = STRLEN(ea.arg);
-
- // For nargs = 1 or '?', pass the entire argument list as a single argument,
- // otherwise split arguments by whitespace.
- if (ea.argt & EX_NOSPC) {
- if (*ea.arg != NUL) {
- ADD(args, STRING_OBJ(cstrn_to_string((char *)ea.arg, length)));
- }
- } else {
- size_t end = 0;
- size_t len = 0;
- char *buf = xcalloc(length, sizeof(char));
- bool done = false;
-
- while (!done) {
- done = uc_split_args_iter(ea.arg, length, &end, buf, &len);
- if (len > 0) {
- ADD(args, STRING_OBJ(cstrn_to_string(buf, len)));
- }
- }
-
- xfree(buf);
- }
-
- if (ea.cmdidx == CMD_USER) {
- PUT(result, "cmd", CSTR_TO_OBJ((char *)USER_CMD(ea.useridx)->uc_name));
- } else if (ea.cmdidx == CMD_USER_BUF) {
- PUT(result, "cmd", CSTR_TO_OBJ((char *)USER_CMD_GA(&curbuf->b_ucmds, ea.useridx)->uc_name));
- } else {
- PUT(result, "cmd", CSTR_TO_OBJ((char *)get_command_name(NULL, ea.cmdidx)));
- }
- PUT(result, "line1", INTEGER_OBJ(ea.line1));
- PUT(result, "line2", INTEGER_OBJ(ea.line2));
- PUT(result, "bang", BOOLEAN_OBJ(ea.forceit));
- PUT(result, "args", ARRAY_OBJ(args));
-
- char nargs[2];
- if (ea.argt & EX_EXTRA) {
- if (ea.argt & EX_NOSPC) {
- if (ea.argt & EX_NEEDARG) {
- nargs[0] = '1';
- } else {
- nargs[0] = '?';
- }
- } else if (ea.argt & EX_NEEDARG) {
- nargs[0] = '+';
- } else {
- nargs[0] = '*';
- }
- } else {
- nargs[0] = '0';
- }
- nargs[1] = '\0';
- PUT(result, "nargs", CSTR_TO_OBJ(nargs));
-
- const char *addr;
- switch (ea.addr_type) {
- case ADDR_LINES:
- addr = "line";
- break;
- case ADDR_ARGUMENTS:
- addr = "arg";
- break;
- case ADDR_BUFFERS:
- addr = "buf";
- break;
- case ADDR_LOADED_BUFFERS:
- addr = "load";
- break;
- case ADDR_WINDOWS:
- addr = "win";
- break;
- case ADDR_TABS:
- addr = "tab";
- break;
- case ADDR_QUICKFIX:
- addr = "qf";
- break;
- case ADDR_NONE:
- addr = "none";
- break;
- default:
- addr = "?";
- break;
- }
- PUT(result, "addr", CSTR_TO_OBJ(addr));
- PUT(result, "nextcmd", CSTR_TO_OBJ((char *)ea.nextcmd));
-
- Dictionary mods = ARRAY_DICT_INIT;
- PUT(mods, "silent", BOOLEAN_OBJ(cmdinfo.silent));
- PUT(mods, "emsg_silent", BOOLEAN_OBJ(cmdinfo.emsg_silent));
- PUT(mods, "sandbox", BOOLEAN_OBJ(cmdinfo.sandbox));
- PUT(mods, "noautocmd", BOOLEAN_OBJ(cmdinfo.noautocmd));
- PUT(mods, "tab", INTEGER_OBJ(cmdinfo.cmdmod.tab));
- PUT(mods, "verbose", INTEGER_OBJ(cmdinfo.verbose));
- PUT(mods, "browse", BOOLEAN_OBJ(cmdinfo.cmdmod.browse));
- PUT(mods, "confirm", BOOLEAN_OBJ(cmdinfo.cmdmod.confirm));
- PUT(mods, "hide", BOOLEAN_OBJ(cmdinfo.cmdmod.hide));
- PUT(mods, "keepalt", BOOLEAN_OBJ(cmdinfo.cmdmod.keepalt));
- PUT(mods, "keepjumps", BOOLEAN_OBJ(cmdinfo.cmdmod.keepjumps));
- PUT(mods, "keepmarks", BOOLEAN_OBJ(cmdinfo.cmdmod.keepmarks));
- PUT(mods, "keeppatterns", BOOLEAN_OBJ(cmdinfo.cmdmod.keeppatterns));
- PUT(mods, "lockmarks", BOOLEAN_OBJ(cmdinfo.cmdmod.lockmarks));
- PUT(mods, "noswapfile", BOOLEAN_OBJ(cmdinfo.cmdmod.noswapfile));
- PUT(mods, "vertical", BOOLEAN_OBJ(cmdinfo.cmdmod.split & WSP_VERT));
-
- const char *split;
- if (cmdinfo.cmdmod.split & WSP_BOT) {
- split = "botright";
- } else if (cmdinfo.cmdmod.split & WSP_TOP) {
- split = "topleft";
- } else if (cmdinfo.cmdmod.split & WSP_BELOW) {
- split = "belowright";
- } else if (cmdinfo.cmdmod.split & WSP_ABOVE) {
- split = "aboveleft";
- } else {
- split = "";
- }
- PUT(mods, "split", CSTR_TO_OBJ(split));
-
- PUT(result, "mods", DICTIONARY_OBJ(mods));
-
- Dictionary magic = ARRAY_DICT_INIT;
- PUT(magic, "file", BOOLEAN_OBJ(cmdinfo.magic.file));
- PUT(magic, "bar", BOOLEAN_OBJ(cmdinfo.magic.bar));
- PUT(result, "magic", DICTIONARY_OBJ(magic));
-end:
- xfree(cmdline);
- return result;
-}
diff --git a/src/nvim/api/vimscript.c b/src/nvim/api/vimscript.c
index 40ac0b8b64..acd89119f9 100644
--- a/src/nvim/api/vimscript.c
+++ b/src/nvim/api/vimscript.c
@@ -16,6 +16,7 @@
#include "nvim/ex_cmds2.h"
#include "nvim/viml/parser/expressions.h"
#include "nvim/viml/parser/parser.h"
+#include "nvim/window.h"
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "api/vimscript.c.generated.h"
@@ -736,3 +737,231 @@ Dictionary nvim_parse_expression(String expr, String flags, Boolean highlight, E
viml_parser_destroy(&pstate);
return ret;
}
+
+/// Parse command line.
+///
+/// Doesn't check the validity of command arguments.
+///
+/// @param str Command line string to parse. Cannot contain "\n".
+/// @param opts Optional parameters. Reserved for future use.
+/// @param[out] err Error details, if any.
+/// @return Dictionary containing command information, with these keys:
+/// - cmd: (string) Command name.
+/// - range: (number) Number of items in the command |<range>|. Can be 0, 1 or 2.
+/// - line1: (number) Starting line of command |<range>|. -1 if command cannot take a range.
+/// |<line1>|
+/// - line2: (number) Final line of command |<range>|. -1 if command cannot take a range.
+/// |<line2>|
+/// - count: (number) Any |<count>| that was supplied to the command. -1 if command cannot
+/// take a count.
+/// - reg: (number) The optional command |<register>|, if specified. Empty string if not
+/// specified or if command cannot take a register.
+/// - bang: (boolean) Whether command contains a |<bang>| (!) modifier.
+/// - args: (array) Command arguments.
+/// - addr: (string) Value of |:command-addr|. Uses short name.
+/// - nargs: (string) Value of |:command-nargs|.
+/// - nextcmd: (string) Next command if there are multiple commands separated by a |:bar|.
+/// Empty if there isn't a next command.
+/// - magic: (dictionary) Which characters have special meaning in the command arguments.
+/// - file: (boolean) The command expands filenames. Which means characters such as "%",
+/// "#" and wildcards are expanded.
+/// - bar: (boolean) The "|" character is treated as a command separator and the double
+/// quote character (\") is treated as the start of a comment.
+/// - mods: (dictionary) |:command-modifiers|.
+/// - silent: (boolean) |:silent|.
+/// - emsg_silent: (boolean) |:silent!|.
+/// - sandbox: (boolean) |:sandbox|.
+/// - noautocmd: (boolean) |:noautocmd|.
+/// - browse: (boolean) |:browse|.
+/// - confirm: (boolean) |:confirm|.
+/// - hide: (boolean) |:hide|.
+/// - keepalt: (boolean) |:keepalt|.
+/// - keepjumps: (boolean) |:keepjumps|.
+/// - keepmarks: (boolean) |:keepmarks|.
+/// - keeppatterns: (boolean) |:keeppatterns|.
+/// - lockmarks: (boolean) |:lockmarks|.
+/// - noswapfile: (boolean) |:noswapfile|.
+/// - tab: (integer) |:tab|.
+/// - verbose: (integer) |:verbose|. -1 when omitted.
+/// - vertical: (boolean) |:vertical|.
+/// - split: (string) Split modifier string, is an empty string when there's no split
+/// modifier. If there is a split modifier it can be one of:
+/// - "aboveleft": |:aboveleft|.
+/// - "belowright": |:belowright|.
+/// - "topleft": |:topleft|.
+/// - "botright": |:botright|.
+Dictionary nvim_parse_cmd(String str, Dictionary opts, Error *err)
+ FUNC_API_SINCE(10) FUNC_API_FAST
+{
+ Dictionary result = ARRAY_DICT_INIT;
+
+ if (opts.size > 0) {
+ api_set_error(err, kErrorTypeValidation, "opts dict isn't empty");
+ return result;
+ }
+
+ // Parse command line
+ exarg_T ea;
+ CmdParseInfo cmdinfo;
+ char_u *cmdline = (char_u *)string_to_cstr(str);
+
+ if (!parse_cmdline(cmdline, &ea, &cmdinfo)) {
+ api_set_error(err, kErrorTypeException, "Error while parsing command line");
+ goto end;
+ }
+
+ // Parse arguments
+ Array args = ARRAY_DICT_INIT;
+ size_t length = STRLEN(ea.arg);
+
+ // For nargs = 1 or '?', pass the entire argument list as a single argument,
+ // otherwise split arguments by whitespace.
+ if (ea.argt & EX_NOSPC) {
+ if (*ea.arg != NUL) {
+ ADD(args, STRING_OBJ(cstrn_to_string((char *)ea.arg, length)));
+ }
+ } else {
+ size_t end = 0;
+ size_t len = 0;
+ char *buf = xcalloc(length, sizeof(char));
+ bool done = false;
+
+ while (!done) {
+ done = uc_split_args_iter((char_u *)ea.arg, length, &end, buf, &len);
+ if (len > 0) {
+ ADD(args, STRING_OBJ(cstrn_to_string(buf, len)));
+ }
+ }
+
+ xfree(buf);
+ }
+
+ ucmd_T *cmd = NULL;
+ if (ea.cmdidx == CMD_USER) {
+ cmd = USER_CMD(ea.useridx);
+ } else if (ea.cmdidx == CMD_USER_BUF) {
+ cmd = USER_CMD_GA(&curbuf->b_ucmds, ea.useridx);
+ }
+
+ if (cmd != NULL) {
+ PUT(result, "cmd", CSTR_TO_OBJ((char *)cmd->uc_name));
+ } else {
+ PUT(result, "cmd", CSTR_TO_OBJ((char *)get_command_name(NULL, ea.cmdidx)));
+ }
+
+ PUT(result, "range", INTEGER_OBJ(ea.addr_count));
+ PUT(result, "line1", INTEGER_OBJ((ea.argt & EX_RANGE) ? ea.line1 : -1));
+ PUT(result, "line2", INTEGER_OBJ((ea.argt & EX_RANGE) ? ea.line2 : -1));
+
+ if (ea.argt & EX_COUNT) {
+ if (ea.addr_count > 0 || cmd == NULL) {
+ PUT(result, "count", INTEGER_OBJ(ea.line2));
+ } else {
+ PUT(result, "count", INTEGER_OBJ(cmd->uc_def));
+ }
+ } else {
+ PUT(result, "count", INTEGER_OBJ(-1));
+ }
+
+ char reg[2];
+ reg[0] = (char)ea.regname;
+ reg[1] = '\0';
+ PUT(result, "reg", CSTR_TO_OBJ(reg));
+
+ PUT(result, "bang", BOOLEAN_OBJ(ea.forceit));
+ PUT(result, "args", ARRAY_OBJ(args));
+
+ char nargs[2];
+ if (ea.argt & EX_EXTRA) {
+ if (ea.argt & EX_NOSPC) {
+ if (ea.argt & EX_NEEDARG) {
+ nargs[0] = '1';
+ } else {
+ nargs[0] = '?';
+ }
+ } else if (ea.argt & EX_NEEDARG) {
+ nargs[0] = '+';
+ } else {
+ nargs[0] = '*';
+ }
+ } else {
+ nargs[0] = '0';
+ }
+ nargs[1] = '\0';
+ PUT(result, "nargs", CSTR_TO_OBJ(nargs));
+
+ const char *addr;
+ switch (ea.addr_type) {
+ case ADDR_LINES:
+ addr = "line";
+ break;
+ case ADDR_ARGUMENTS:
+ addr = "arg";
+ break;
+ case ADDR_BUFFERS:
+ addr = "buf";
+ break;
+ case ADDR_LOADED_BUFFERS:
+ addr = "load";
+ break;
+ case ADDR_WINDOWS:
+ addr = "win";
+ break;
+ case ADDR_TABS:
+ addr = "tab";
+ break;
+ case ADDR_QUICKFIX:
+ addr = "qf";
+ break;
+ case ADDR_NONE:
+ addr = "none";
+ break;
+ default:
+ addr = "?";
+ break;
+ }
+ PUT(result, "addr", CSTR_TO_OBJ(addr));
+ PUT(result, "nextcmd", CSTR_TO_OBJ((char *)ea.nextcmd));
+
+ Dictionary mods = ARRAY_DICT_INIT;
+ PUT(mods, "silent", BOOLEAN_OBJ(cmdinfo.silent));
+ PUT(mods, "emsg_silent", BOOLEAN_OBJ(cmdinfo.emsg_silent));
+ PUT(mods, "sandbox", BOOLEAN_OBJ(cmdinfo.sandbox));
+ PUT(mods, "noautocmd", BOOLEAN_OBJ(cmdinfo.noautocmd));
+ PUT(mods, "tab", INTEGER_OBJ(cmdinfo.cmdmod.tab));
+ PUT(mods, "verbose", INTEGER_OBJ(cmdinfo.verbose));
+ PUT(mods, "browse", BOOLEAN_OBJ(cmdinfo.cmdmod.browse));
+ PUT(mods, "confirm", BOOLEAN_OBJ(cmdinfo.cmdmod.confirm));
+ PUT(mods, "hide", BOOLEAN_OBJ(cmdinfo.cmdmod.hide));
+ PUT(mods, "keepalt", BOOLEAN_OBJ(cmdinfo.cmdmod.keepalt));
+ PUT(mods, "keepjumps", BOOLEAN_OBJ(cmdinfo.cmdmod.keepjumps));
+ PUT(mods, "keepmarks", BOOLEAN_OBJ(cmdinfo.cmdmod.keepmarks));
+ PUT(mods, "keeppatterns", BOOLEAN_OBJ(cmdinfo.cmdmod.keeppatterns));
+ PUT(mods, "lockmarks", BOOLEAN_OBJ(cmdinfo.cmdmod.lockmarks));
+ PUT(mods, "noswapfile", BOOLEAN_OBJ(cmdinfo.cmdmod.noswapfile));
+ PUT(mods, "vertical", BOOLEAN_OBJ(cmdinfo.cmdmod.split & WSP_VERT));
+
+ const char *split;
+ if (cmdinfo.cmdmod.split & WSP_BOT) {
+ split = "botright";
+ } else if (cmdinfo.cmdmod.split & WSP_TOP) {
+ split = "topleft";
+ } else if (cmdinfo.cmdmod.split & WSP_BELOW) {
+ split = "belowright";
+ } else if (cmdinfo.cmdmod.split & WSP_ABOVE) {
+ split = "aboveleft";
+ } else {
+ split = "";
+ }
+ PUT(mods, "split", CSTR_TO_OBJ(split));
+
+ PUT(result, "mods", DICTIONARY_OBJ(mods));
+
+ Dictionary magic = ARRAY_DICT_INIT;
+ PUT(magic, "file", BOOLEAN_OBJ(cmdinfo.magic.file));
+ PUT(magic, "bar", BOOLEAN_OBJ(cmdinfo.magic.bar));
+ PUT(result, "magic", DICTIONARY_OBJ(magic));
+end:
+ xfree(cmdline);
+ return result;
+}
diff --git a/src/nvim/autocmd.c b/src/nvim/autocmd.c
index cd726b70b6..b015a3fce0 100644
--- a/src/nvim/autocmd.c
+++ b/src/nvim/autocmd.c
@@ -100,7 +100,7 @@ static int autocmd_blocked = 0; // block all autocmds
static bool autocmd_nested = false;
static bool autocmd_include_groups = false;
-static char_u *old_termresponse = NULL;
+static char *old_termresponse = NULL;
/// Iterates over all the AutoPats for a particular event
#define FOR_ALL_AUPATS_IN_EVENT(event, ap) \
@@ -175,7 +175,7 @@ static void aupat_show(AutoPat *ap, event_T event, int previous_group)
}
msg_col = 4;
- msg_outtrans(ap->pat);
+ msg_outtrans((char_u *)ap->pat);
for (AutoCmd *ac = ap->cmds; ac != NULL; ac = ac->next) {
// skip removed commands
@@ -206,14 +206,14 @@ static void aupat_show(AutoPat *ap, event_T event, int previous_group)
}
}
-static void au_show_for_all_events(int group, char_u *pat)
+static void au_show_for_all_events(int group, char *pat)
{
FOR_ALL_AUEVENTS(event) {
au_show_for_event(group, event, pat);
}
}
-static void au_show_for_event(int group, event_T event, char_u *pat)
+static void au_show_for_event(int group, event_T event, char *pat)
{
// Return early if there are no autocmds for this event
if (au_event_is_empty(event)) {
@@ -233,7 +233,7 @@ static void au_show_for_event(int group, event_T event, char_u *pat)
return;
}
- char_u buflocal_pat[BUFLOCAL_PAT_LEN]; // for "<buffer=X>"
+ char buflocal_pat[BUFLOCAL_PAT_LEN]; // for "<buffer=X>"
// Loop through all the specified patterns.
int patlen = (int)aucmd_pattern_length(pat);
while (patlen) {
@@ -241,7 +241,7 @@ static void au_show_for_event(int group, event_T event, char_u *pat)
if (aupat_is_buflocal(pat, patlen)) {
// normalize pat into standard "<buffer>#N" form
aupat_normalize_buflocal_pat(buflocal_pat, pat, patlen, aupat_get_buflocal_nr(pat, patlen));
- pat = buflocal_pat;
+ pat = (char *)buflocal_pat;
patlen = (int)STRLEN(buflocal_pat);
}
@@ -554,18 +554,18 @@ bool augroup_exists(const char *name)
}
/// ":augroup {name}".
-void do_augroup(char_u *arg, int del_group)
+void do_augroup(char *arg, int del_group)
{
if (del_group) {
if (*arg == NUL) {
emsg(_(e_argreq));
} else {
- augroup_del((char *)arg, true);
+ augroup_del(arg, true);
}
} else if (STRICMP(arg, "end") == 0) { // ":aug end": back to group 0
current_augroup = AUGROUP_DEFAULT;
} else if (*arg) { // ":aug xxx": switch to group xxx
- current_augroup = augroup_add((char *)arg);
+ current_augroup = augroup_add(arg);
} else { // ":aug": list the group names
msg_start();
@@ -618,9 +618,9 @@ void free_all_autocmds(void)
// Return the event number for event name "start".
// Return NUM_EVENTS if the event name was not found.
// Return a pointer to the next event name in "end".
-event_T event_name2nr(const char_u *start, char_u **end)
+event_T event_name2nr(const char *start, char **end)
{
- const char_u *p;
+ const char *p;
int i;
// the event name ends with end of line, '|', a blank or a comma
@@ -634,7 +634,7 @@ event_T event_name2nr(const char_u *start, char_u **end)
if (*p == ',') {
p++;
}
- *end = (char_u *)p;
+ *end = (char *)p;
if (event_names[i].name == NULL) {
return NUM_EVENTS;
}
@@ -664,7 +664,7 @@ const char *event_nr2name(event_T event)
static bool event_ignored(event_T event)
FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT
{
- char_u *p = p_ei;
+ char *p = (char *)p_ei;
while (*p != NUL) {
if (STRNICMP(p, "all", 3) == 0 && (p[3] == NUL || p[3] == ',')) {
@@ -681,7 +681,7 @@ static bool event_ignored(event_T event)
// Return OK when the contents of p_ei is valid, FAIL otherwise.
int check_ei(void)
{
- char_u *p = p_ei;
+ char *p = (char *)p_ei;
while (*p) {
if (STRNICMP(p, "all", 3) == 0 && (p[3] == NUL || p[3] == ',')) {
@@ -700,25 +700,25 @@ int check_ei(void)
// Add "what" to 'eventignore' to skip loading syntax highlighting for every
// buffer loaded into the window. "what" must start with a comma.
// Returns the old value of 'eventignore' in allocated memory.
-char_u *au_event_disable(char *what)
+char *au_event_disable(char *what)
{
- char_u *save_ei = vim_strsave(p_ei);
- char_u *new_ei = vim_strnsave(p_ei, STRLEN(p_ei) + STRLEN(what));
+ char *save_ei = (char *)vim_strsave(p_ei);
+ char *new_ei = (char *)vim_strnsave(p_ei, STRLEN(p_ei) + STRLEN(what));
if (*what == ',' && *p_ei == NUL) {
STRCPY(new_ei, what + 1);
} else {
STRCAT(new_ei, what);
}
- set_string_option_direct("ei", -1, new_ei, OPT_FREE, SID_NONE);
+ set_string_option_direct("ei", -1, (char_u *)new_ei, OPT_FREE, SID_NONE);
xfree(new_ei);
return save_ei;
}
-void au_event_restore(char_u *old_ei)
+void au_event_restore(char *old_ei)
{
if (old_ei != NULL) {
- set_string_option_direct("ei", -1, old_ei, OPT_FREE, SID_NONE);
+ set_string_option_direct("ei", -1, (char_u *)old_ei, OPT_FREE, SID_NONE);
xfree(old_ei);
}
}
@@ -755,18 +755,18 @@ void au_event_restore(char_u *old_ei)
// :autocmd * *.c show all autocommands for *.c files.
//
// Mostly a {group} argument can optionally appear before <event>.
-void do_autocmd(char_u *arg_in, int forceit)
+void do_autocmd(char *arg_in, int forceit)
{
- char_u *arg = arg_in;
- char_u *envpat = NULL;
- char_u *cmd;
+ char *arg = arg_in;
+ char *envpat = NULL;
+ char *cmd;
int need_free = false;
bool nested = false;
bool once = false;
int group;
if (*arg == '|') {
- arg = (char_u *)"";
+ arg = "";
group = AUGROUP_ALL; // no argument, use all groups
} else {
// Check for a legal group name. If not, use AUGROUP_ALL.
@@ -775,15 +775,15 @@ void do_autocmd(char_u *arg_in, int forceit)
// Scan over the events.
// If we find an illegal name, return here, don't do anything.
- char_u *pat = arg_event_skip(arg, group != AUGROUP_ALL);
+ char *pat = arg_event_skip(arg, group != AUGROUP_ALL);
if (pat == NULL) {
return;
}
- pat = skipwhite(pat);
+ pat = (char *)skipwhite((char_u *)pat);
if (*pat == '|') {
- pat = (char_u *)"";
- cmd = (char_u *)"";
+ pat = "";
+ cmd = "";
} else {
// Scan over the pattern. Put a NUL at the end.
cmd = pat;
@@ -796,13 +796,13 @@ void do_autocmd(char_u *arg_in, int forceit)
// Expand environment variables in the pattern. Set 'shellslash', we want
// forward slashes here.
- if (vim_strchr(pat, '$') != NULL || vim_strchr(pat, '~') != NULL) {
+ if (vim_strchr((char_u *)pat, '$') != NULL || vim_strchr((char_u *)pat, '~') != NULL) {
#ifdef BACKSLASH_IN_FILENAME
int p_ssl_save = p_ssl;
p_ssl = true;
#endif
- envpat = expand_env_save(pat);
+ envpat = (char *)expand_env_save((char_u *)pat);
#ifdef BACKSLASH_IN_FILENAME
p_ssl = p_ssl_save;
#endif
@@ -811,7 +811,7 @@ void do_autocmd(char_u *arg_in, int forceit)
}
}
- cmd = skipwhite(cmd);
+ cmd = (char *)skipwhite((char_u *)cmd);
bool invalid_flags = false;
for (size_t i = 0; i < 2; i++) {
@@ -831,7 +831,7 @@ void do_autocmd(char_u *arg_in, int forceit)
// Find the start of the commands.
// Expand <sfile> in it.
if (*cmd != NUL) {
- cmd = (char_u *)expand_sfile((char *)cmd);
+ cmd = expand_sfile(cmd);
if (cmd == NULL) { // some error
return;
}
@@ -878,7 +878,7 @@ void do_autocmd(char_u *arg_in, int forceit)
xfree(envpat);
}
-void do_all_autocmd_events(char_u *pat, bool once, int nested, char_u *cmd, bool delete, int group)
+void do_all_autocmd_events(char *pat, bool once, int nested, char *cmd, bool delete, int group)
{
FOR_ALL_AUEVENTS(event) {
if (do_autocmd_event(event, pat, once, nested, cmd, delete, group)
@@ -895,7 +895,7 @@ void do_all_autocmd_events(char_u *pat, bool once, int nested, char_u *cmd, bool
// If *cmd == NUL: show entries.
// If forceit == true: delete entries.
// If group is not AUGROUP_ALL: only use this group.
-int do_autocmd_event(event_T event, char_u *pat, bool once, int nested, char_u *cmd, bool delete,
+int do_autocmd_event(event_T event, char *pat, bool once, int nested, char *cmd, bool delete,
int group)
FUNC_ATTR_NONNULL_ALL
{
@@ -906,7 +906,7 @@ int do_autocmd_event(event_T event, char_u *pat, bool once, int nested, char_u *
AutoPat **prev_ap;
int findgroup;
int buflocal_nr;
- char_u buflocal_pat[BUFLOCAL_PAT_LEN]; // for "<buffer=X>"
+ char buflocal_pat[BUFLOCAL_PAT_LEN]; // for "<buffer=X>"
bool is_adding_cmd = *cmd != NUL;
@@ -984,7 +984,7 @@ int do_autocmd_event(event_T event, char_u *pat, bool once, int nested, char_u *
return OK;
}
-int autocmd_register(int64_t id, event_T event, char_u *pat, int patlen, int group, bool once,
+int autocmd_register(int64_t id, event_T event, char *pat, int patlen, int group, bool once,
bool nested, char *desc, AucmdExecutable aucmd)
{
// 0 is not a valid group.
@@ -994,7 +994,7 @@ int autocmd_register(int64_t id, event_T event, char_u *pat, int patlen, int gro
AutoPat **prev_ap;
AutoCmd *ac;
int findgroup;
- char_u buflocal_pat[BUFLOCAL_PAT_LEN]; // for "<buffer=X>"
+ char buflocal_pat[BUFLOCAL_PAT_LEN]; // for "<buffer=X>"
if (patlen > (int)STRLEN(pat)) {
return FAIL;
@@ -1060,19 +1060,20 @@ int autocmd_register(int64_t id, event_T event, char_u *pat, int patlen, int gro
}
ap = xmalloc(sizeof(AutoPat));
- ap->pat = vim_strnsave(pat, (size_t)patlen);
+ ap->pat = xstrnsave(pat, (size_t)patlen);
ap->patlen = patlen;
if (is_buflocal) {
ap->buflocal_nr = buflocal_nr;
ap->reg_prog = NULL;
} else {
- char_u *reg_pat;
+ char *reg_pat;
ap->buflocal_nr = 0;
- reg_pat = file_pat_to_reg_pat(pat, pat + patlen, &ap->allow_dirs, true);
+ reg_pat = (char *)file_pat_to_reg_pat((char_u *)pat, (char_u *)pat + patlen, &ap->allow_dirs,
+ true);
if (reg_pat != NULL) {
- ap->reg_prog = vim_regcomp(reg_pat, RE_MAGIC);
+ ap->reg_prog = vim_regcomp((char_u *)reg_pat, RE_MAGIC);
}
xfree(reg_pat);
if (reg_pat == NULL || ap->reg_prog == NULL) {
@@ -1143,14 +1144,14 @@ int autocmd_register(int64_t id, event_T event, char_u *pat, int patlen, int gro
return OK;
}
-size_t aucmd_pattern_length(char_u *pat)
+size_t aucmd_pattern_length(char *pat)
FUNC_ATTR_PURE
{
if (*pat == NUL) {
return 0;
}
- char_u *endpat;
+ char *endpat;
for (; *pat; pat = (*endpat == ',' ? endpat + 1 : endpat)) {
// Find end of the pattern.
@@ -1176,7 +1177,7 @@ size_t aucmd_pattern_length(char_u *pat)
return STRLEN(pat);
}
-char_u *aucmd_next_pattern(char_u *pat, size_t patlen)
+char *aucmd_next_pattern(char *pat, size_t patlen)
FUNC_ATTR_PURE
{
pat = pat + patlen;
@@ -1191,9 +1192,9 @@ char_u *aucmd_next_pattern(char_u *pat, size_t patlen)
/// Return OK for success, FAIL for failure;
///
/// @param do_msg give message for no matching autocmds?
-int do_doautocmd(char_u *arg_start, bool do_msg, bool *did_something)
+int do_doautocmd(char *arg_start, bool do_msg, bool *did_something)
{
- char_u *arg = arg_start;
+ char *arg = arg_start;
int nothing_done = true;
if (did_something != NULL) {
@@ -1210,12 +1211,12 @@ int do_doautocmd(char_u *arg_start, bool do_msg, bool *did_something)
// Scan over the events.
// If we find an illegal name, return here, don't do anything.
- char_u *fname = arg_event_skip(arg, group != AUGROUP_ALL);
+ char *fname = arg_event_skip(arg, group != AUGROUP_ALL);
if (fname == NULL) {
return FAIL;
}
- fname = skipwhite(fname);
+ fname = (char *)skipwhite((char_u *)fname);
// Loop over the events.
while (*arg && !ends_excmd(*arg) && !ascii_iswhite(*arg)) {
@@ -1240,8 +1241,8 @@ void ex_doautoall(exarg_T *eap)
{
int retval = OK;
aco_save_T aco;
- char_u *arg = eap->arg;
- int call_do_modelines = check_nomodeline(&arg);
+ char_u *arg = (char_u *)eap->arg;
+ int call_do_modelines = check_nomodeline((char **)&arg);
bufref_T bufref;
bool did_aucmd;
@@ -1260,7 +1261,7 @@ void ex_doautoall(exarg_T *eap)
set_bufref(&bufref, buf);
// execute the autocommands for this buffer
- retval = do_doautocmd(arg, false, &did_aucmd);
+ retval = do_doautocmd((char *)arg, false, &did_aucmd);
if (call_do_modelines && did_aucmd) {
// Execute the modeline settings, but don't set window-local
@@ -1281,7 +1282,7 @@ void ex_doautoall(exarg_T *eap)
// Execute autocommands for the current buffer last.
if (retval == OK) {
- (void)do_doautocmd(arg, false, &did_aucmd);
+ (void)do_doautocmd((char *)arg, false, &did_aucmd);
if (call_do_modelines && did_aucmd) {
do_modelines(0);
}
@@ -1293,11 +1294,11 @@ void ex_doautoall(exarg_T *eap)
/// called when true is returned.
///
/// @param[in,out] argp argument string
-bool check_nomodeline(char_u **argp)
+bool check_nomodeline(char **argp)
FUNC_ATTR_NONNULL_ALL FUNC_ATTR_WARN_UNUSED_RESULT
{
if (STRNCMP(*argp, "<nomodeline>", 12) == 0) {
- *argp = skipwhite(*argp + 12);
+ *argp = (char *)skipwhite((char_u *)(*argp) + 12);
return false;
}
return true;
@@ -1363,7 +1364,7 @@ void aucmd_prepbuf(aco_save_T *aco, buf_T *buf)
// Make sure w_localdir and globaldir are NULL to avoid a chdir() in
// win_enter_ext().
XFREE_CLEAR(aucmd_win->w_localdir);
- aco->globaldir = globaldir;
+ aco->globaldir = (char *)globaldir;
globaldir = NULL;
block_autocmds(); // We don't want BufEnter/WinEnter autocommands.
@@ -1450,7 +1451,7 @@ win_found:
hash_init(&aucmd_win->w_vars->dv_hashtab); // re-use the hashtab
xfree(globaldir);
- globaldir = aco->globaldir;
+ globaldir = (char_u *)aco->globaldir;
// the buffer contents may have changed
check_cursor();
@@ -1505,7 +1506,7 @@ win_found:
/// @return true if some commands were executed.
bool apply_autocmds(event_T event, char_u *fname, char_u *fname_io, bool force, buf_T *buf)
{
- return apply_autocmds_group(event, fname, fname_io, force, AUGROUP_ALL, buf,
+ return apply_autocmds_group(event, (char *)fname, (char *)fname_io, force, AUGROUP_ALL, buf,
NULL);
}
@@ -1523,7 +1524,7 @@ bool apply_autocmds(event_T event, char_u *fname, char_u *fname_io, bool force,
bool apply_autocmds_exarg(event_T event, char_u *fname, char_u *fname_io, bool force, buf_T *buf,
exarg_T *eap)
{
- return apply_autocmds_group(event, fname, fname_io, force, AUGROUP_ALL, buf,
+ return apply_autocmds_group(event, (char *)fname, (char *)fname_io, force, AUGROUP_ALL, buf,
eap);
}
@@ -1547,7 +1548,7 @@ bool apply_autocmds_retval(event_T event, char_u *fname, char_u *fname_io, bool
return false;
}
- bool did_cmd = apply_autocmds_group(event, fname, fname_io, force,
+ bool did_cmd = apply_autocmds_group(event, (char *)fname, (char *)fname_io, force,
AUGROUP_ALL, buf, NULL);
if (did_cmd && aborting()) {
*retval = FAIL;
@@ -1596,14 +1597,14 @@ bool trigger_cursorhold(void) FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT
/// @param eap Ex command arguments
///
/// @return true if some commands were executed.
-bool apply_autocmds_group(event_T event, char_u *fname, char_u *fname_io, bool force, int group,
+bool apply_autocmds_group(event_T event, char *fname, char *fname_io, bool force, int group,
buf_T *buf, exarg_T *eap)
{
- char_u *sfname = NULL; // short file name
+ char *sfname = NULL; // short file name
bool retval = false;
static int nesting = 0;
AutoPat *ap;
- char_u *save_cmdarg;
+ char *save_cmdarg;
long save_cmdbang;
static int filechangeshell_busy = false;
proftime_T wait_time;
@@ -1658,9 +1659,9 @@ bool apply_autocmds_group(event_T event, char_u *fname, char_u *fname_io, bool f
}
// Save the autocmd_* variables and info about the current buffer.
- char_u *save_autocmd_fname = autocmd_fname;
+ char *save_autocmd_fname = (char *)autocmd_fname;
int save_autocmd_bufnr = autocmd_bufnr;
- char_u *save_autocmd_match = autocmd_match;
+ char *save_autocmd_match = (char *)autocmd_match;
int save_autocmd_busy = autocmd_busy;
int save_autocmd_nested = autocmd_nested;
bool save_changed = curbuf->b_changed;
@@ -1674,14 +1675,14 @@ bool apply_autocmds_group(event_T event, char_u *fname, char_u *fname_io, bool f
|| event == EVENT_OPTIONSET || event == EVENT_MODECHANGED) {
autocmd_fname = NULL;
} else if (fname != NULL && !ends_excmd(*fname)) {
- autocmd_fname = fname;
+ autocmd_fname = (char_u *)fname;
} else if (buf != NULL) {
autocmd_fname = buf->b_ffname;
} else {
autocmd_fname = NULL;
}
} else {
- autocmd_fname = fname_io;
+ autocmd_fname = (char_u *)fname_io;
}
if (autocmd_fname != NULL) {
// Allocate MAXPATHL for when eval_vars() resolves the fullpath.
@@ -1703,22 +1704,22 @@ bool apply_autocmds_group(event_T event, char_u *fname, char_u *fname_io, bool f
fname = NULL;
} else {
if (event == EVENT_SYNTAX) {
- fname = buf->b_p_syn;
+ fname = (char *)buf->b_p_syn;
} else if (event == EVENT_FILETYPE) {
- fname = buf->b_p_ft;
+ fname = (char *)buf->b_p_ft;
} else {
if (buf->b_sfname != NULL) {
- sfname = vim_strsave(buf->b_sfname);
+ sfname = (char *)vim_strsave(buf->b_sfname);
}
- fname = buf->b_ffname;
+ fname = (char *)buf->b_ffname;
}
}
if (fname == NULL) {
- fname = (char_u *)"";
+ fname = "";
}
- fname = vim_strsave(fname); // make a copy, so we can change it
+ fname = xstrdup(fname); // make a copy, so we can change it
} else {
- sfname = vim_strsave(fname);
+ sfname = xstrdup(fname);
// Don't try expanding the following events.
if (event == EVENT_CMDLINECHANGED || event == EVENT_CMDLINEENTER
|| event == EVENT_CMDLINELEAVE || event == EVENT_CMDWINENTER
@@ -1732,9 +1733,9 @@ bool apply_autocmds_group(event_T event, char_u *fname, char_u *fname_io, bool f
|| event == EVENT_SYNTAX || event == EVENT_SIGNAL
|| event == EVENT_TABCLOSED || event == EVENT_USER
|| event == EVENT_WINCLOSED || event == EVENT_WINSCROLLED) {
- fname = vim_strsave(fname);
+ fname = xstrdup(fname);
} else {
- fname = (char_u *)FullName_save((char *)fname, false);
+ fname = FullName_save(fname, false);
}
}
if (fname == NULL) { // out of memory
@@ -1753,11 +1754,11 @@ bool apply_autocmds_group(event_T event, char_u *fname, char_u *fname_io, bool f
#endif
// Set the name to be used for <amatch>.
- autocmd_match = fname;
+ autocmd_match = (char_u *)fname;
// Don't redraw while doing autocommands.
RedrawingDisabled++;
- char_u *save_sourcing_name = sourcing_name;
+ char *save_sourcing_name = (char *)sourcing_name;
sourcing_name = NULL; // don't free this one
linenr_T save_sourcing_lnum = sourcing_lnum;
sourcing_lnum = 0; // no line number here
@@ -1792,7 +1793,7 @@ bool apply_autocmds_group(event_T event, char_u *fname, char_u *fname_io, bool f
did_filetype = true;
}
- char_u *tail = path_tail(fname);
+ char *tail = (char *)path_tail((char_u *)fname);
// Find first autocommand that matches
AutoPatCmd patcmd;
@@ -1816,7 +1817,7 @@ bool apply_autocmds_group(event_T event, char_u *fname, char_u *fname_io, bool f
// set v:cmdarg (only when there is a matching pattern)
save_cmdbang = (long)get_vim_var_nr(VV_CMDBANG);
if (eap != NULL) {
- save_cmdarg = (char_u *)set_cmdarg(eap, NULL);
+ save_cmdarg = set_cmdarg(eap, NULL);
set_vim_var_nr(VV_CMDBANG, (long)eap->forceit);
} else {
save_cmdarg = NULL; // avoid gcc warning
@@ -1845,7 +1846,7 @@ bool apply_autocmds_group(event_T event, char_u *fname, char_u *fname_io, bool f
if (eap != NULL) {
- (void)set_cmdarg(NULL, (char *)save_cmdarg);
+ (void)set_cmdarg(NULL, save_cmdarg);
set_vim_var_nr(VV_CMDBANG, save_cmdbang);
}
// delete from active_apc_list
@@ -1859,12 +1860,12 @@ bool apply_autocmds_group(event_T event, char_u *fname, char_u *fname_io, bool f
filechangeshell_busy = false;
autocmd_nested = save_autocmd_nested;
xfree(sourcing_name);
- sourcing_name = save_sourcing_name;
+ sourcing_name = (char_u *)save_sourcing_name;
sourcing_lnum = save_sourcing_lnum;
xfree(autocmd_fname);
- autocmd_fname = save_autocmd_fname;
+ autocmd_fname = (char_u *)save_autocmd_fname;
autocmd_bufnr = save_autocmd_bufnr;
- autocmd_match = save_autocmd_match;
+ autocmd_match = (char_u *)save_autocmd_match;
current_sctx = save_current_sctx;
restore_funccal();
if (do_profiling == PROF_YES) {
@@ -1932,7 +1933,7 @@ void block_autocmds(void)
{
// Remember the value of v:termresponse.
if (!is_autocmd_blocked()) {
- old_termresponse = get_vim_var_str(VV_TERMRESPONSE);
+ old_termresponse = (char *)get_vim_var_str(VV_TERMRESPONSE);
}
autocmd_blocked++;
}
@@ -1945,7 +1946,7 @@ void unblock_autocmds(void)
// the autocommands now. Esp. useful when executing a shell command
// during startup (nvim -d).
if (!is_autocmd_blocked()
- && get_vim_var_str(VV_TERMRESPONSE) != old_termresponse) {
+ && get_vim_var_str(VV_TERMRESPONSE) != (char_u *)old_termresponse) {
apply_autocmds(EVENT_TERMRESPONSE, NULL, NULL, false, curbuf);
}
}
@@ -1978,9 +1979,9 @@ void auto_next_pat(AutoPatCmd *apc, int stop_at_last)
if (ap->buflocal_nr == 0
? match_file_pat(NULL,
&ap->reg_prog,
- apc->fname,
- apc->sfname,
- apc->tail,
+ (char_u *)apc->fname,
+ (char_u *)apc->sfname,
+ (char_u *)apc->tail,
ap->allow_dirs)
: ap->buflocal_nr == apc->arg_bufnr) {
const char *const name = event_nr2name(apc->event);
@@ -1990,8 +1991,7 @@ void auto_next_pat(AutoPatCmd *apc, int stop_at_last)
= (STRLEN(s) + strlen(name) + (size_t)ap->patlen + 1);
sourcing_name = xmalloc(sourcing_name_len);
- snprintf((char *)sourcing_name, sourcing_name_len, s, name,
- (char *)ap->pat);
+ snprintf((char *)sourcing_name, sourcing_name_len, s, name, ap->pat);
if (p_verbose >= 8) {
verbose_enter();
smsg(_("Executing %s"), sourcing_name);
@@ -2072,7 +2072,7 @@ char_u *getnextac(int c, void *cookie, int indent, bool do_concat)
(void)do_concat;
AutoPatCmd *acp = (AutoPatCmd *)cookie;
- char_u *retval;
+ char *retval;
// Can be called again after returning the last line.
if (acp->curpat == NULL) {
@@ -2140,9 +2140,9 @@ char_u *getnextac(int c, void *cookie, int indent, bool do_concat)
// 2. make where we call do_cmdline for autocmds not have to return anything,
// and instead we loop over all the matches and just execute one-by-one.
// However, my expectation would be that could be expensive.
- retval = vim_strsave((char_u *)"");
+ retval = xstrdup("");
} else {
- retval = vim_strsave(ac->exec.callable.cmd);
+ retval = xstrdup(ac->exec.callable.cmd);
}
// Remove one-shot ("once") autocmd in anticipation of its execution.
@@ -2155,7 +2155,7 @@ char_u *getnextac(int c, void *cookie, int indent, bool do_concat)
acp->nextcmd = ac->next;
}
- return retval;
+ return (char_u *)retval;
}
/// Return true if there is a matching autocommand for "fname".
@@ -2167,10 +2167,10 @@ char_u *getnextac(int c, void *cookie, int indent, bool do_concat)
/// @param buf buffer the file is open in
bool has_autocmd(event_T event, char_u *sfname, buf_T *buf) FUNC_ATTR_WARN_UNUSED_RESULT
{
- char_u *tail = path_tail(sfname);
+ char *tail = (char *)path_tail(sfname);
bool retval = false;
- char_u *fname = (char_u *)FullName_save((char *)sfname, false);
+ char *fname = FullName_save((char *)sfname, false);
if (fname == NULL) {
return false;
}
@@ -2188,9 +2188,9 @@ bool has_autocmd(event_T event, char_u *sfname, buf_T *buf) FUNC_ATTR_WARN_UNUSE
&& (ap->buflocal_nr == 0
? match_file_pat(NULL,
&ap->reg_prog,
- fname,
+ (char_u *)fname,
sfname,
- tail,
+ (char_u *)tail,
ap->allow_dirs)
: buf != NULL && ap->buflocal_nr == buf->b_fnum)) {
retval = true;
@@ -2217,11 +2217,11 @@ char_u *expand_get_augroup_name(expand_T *xp, int idx)
}
/// @param doautocmd true for :doauto*, false for :autocmd
-char_u *set_context_in_autocmd(expand_T *xp, char_u *arg, int doautocmd)
+char *set_context_in_autocmd(expand_T *xp, char *arg, int doautocmd)
{
// check for a group name, skip it if present
autocmd_include_groups = false;
- char_u *p = arg;
+ char *p = arg;
int group = arg_augroup_get(&arg);
// If there only is a group name that's what we expand.
@@ -2246,7 +2246,7 @@ char_u *set_context_in_autocmd(expand_T *xp, char_u *arg, int doautocmd)
}
// skip over pattern
- arg = skipwhite(p);
+ arg = (char *)skipwhite((char_u *)p);
while (*arg && (!ascii_iswhite(*arg) || arg[-1] == '\\')) {
arg++;
}
@@ -2291,8 +2291,8 @@ char_u *expand_get_event_name(expand_T *xp, int idx)
bool autocmd_supported(const char *const event)
FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT
{
- char_u *p;
- return event_name2nr((const char_u *)event, &p) != NUM_EVENTS;
+ char *p;
+ return event_name2nr(event, &p) != NUM_EVENTS;
}
/// Return true if an autocommand is defined for a group, event and
@@ -2344,7 +2344,7 @@ bool au_exists(const char *const arg) FUNC_ATTR_WARN_UNUSED_RESULT
char *pattern = p; // "pattern" is NULL when there is no pattern.
// Find the index (enum) for the event name.
- event_T event = event_name2nr((char_u *)event_name, (char_u **)&p);
+ event_T event = event_name2nr(event_name, &p);
// return false if the event name is not recognized
if (event == NUM_EVENTS) {
@@ -2386,7 +2386,7 @@ theend:
}
// Checks if a pattern is buflocal
-bool aupat_is_buflocal(char_u *pat, int patlen)
+bool aupat_is_buflocal(char *pat, int patlen)
FUNC_ATTR_PURE
{
return patlen >= 8
@@ -2394,9 +2394,9 @@ bool aupat_is_buflocal(char_u *pat, int patlen)
&& (pat)[patlen - 1] == '>';
}
-int aupat_get_buflocal_nr(char_u *pat, int patlen)
+int aupat_get_buflocal_nr(char *pat, int patlen)
{
- assert(aupat_is_buflocal(pat, patlen));
+ assert(aupat_is_buflocal((char *)pat, patlen));
// "<buffer>"
if (patlen == 8) {
@@ -2410,8 +2410,8 @@ int aupat_get_buflocal_nr(char_u *pat, int patlen)
}
// "<buffer=123>"
- if (skipdigits(pat + 8) == pat + patlen - 1) {
- return atoi((char *)pat + 8);
+ if (skipdigits((char_u *)pat + 8) == (char_u *)pat + patlen - 1) {
+ return atoi(pat + 8);
}
}
@@ -2419,7 +2419,7 @@ int aupat_get_buflocal_nr(char_u *pat, int patlen)
}
// normalize buffer pattern
-void aupat_normalize_buflocal_pat(char_u *dest, char_u *pat, int patlen, int buflocal_nr)
+void aupat_normalize_buflocal_pat(char *dest, char *pat, int patlen, int buflocal_nr)
{
assert(aupat_is_buflocal(pat, patlen));
@@ -2428,7 +2428,7 @@ void aupat_normalize_buflocal_pat(char_u *dest, char_u *pat, int patlen, int buf
}
// normalize pat into standard "<buffer>#N" form
- snprintf((char *)dest,
+ snprintf(dest,
BUFLOCAL_PAT_LEN,
"<buffer=%d>",
buflocal_nr);
@@ -2437,7 +2437,7 @@ void aupat_normalize_buflocal_pat(char_u *dest, char_u *pat, int patlen, int buf
int autocmd_delete_event(int group, event_T event, char_u *pat)
FUNC_ATTR_NONNULL_ALL
{
- return do_autocmd_event(event, pat, false, false, (char_u *)"", true, group);
+ return do_autocmd_event(event, (char *)pat, false, false, "", true, group);
}
/// Deletes an autocmd by ID.
@@ -2501,7 +2501,7 @@ char *aucmd_exec_to_string(AutoCmd *ac, AucmdExecutable acc)
{
switch (acc.type) {
case CALLABLE_EX:
- return (char *)acc.callable.cmd;
+ return acc.callable.cmd;
case CALLABLE_CB:
return ac->desc;
case CALLABLE_NONE:
@@ -2534,7 +2534,7 @@ AucmdExecutable aucmd_exec_copy(AucmdExecutable src)
switch (src.type) {
case CALLABLE_EX:
dest.type = CALLABLE_EX;
- dest.callable.cmd = vim_strsave(src.callable.cmd);
+ dest.callable.cmd = xstrdup(src.callable.cmd);
return dest;
case CALLABLE_CB:
dest.type = CALLABLE_CB;
@@ -2572,10 +2572,10 @@ bool au_event_is_empty(event_T event)
/// Scan over the events. "*" stands for all events.
/// true when group name was found
-static char_u *arg_event_skip(char_u *arg, int have_group)
+static char *arg_event_skip(char *arg, int have_group)
{
- char_u *pat;
- char_u *p;
+ char *pat;
+ char *p;
if (*arg == '*') {
if (arg[1] && !ascii_iswhite(arg[1])) {
@@ -2602,20 +2602,20 @@ static char_u *arg_event_skip(char_u *arg, int have_group)
// The "argp" argument is advanced to the following argument.
//
// Returns the group ID or AUGROUP_ALL.
-static int arg_augroup_get(char_u **argp)
+static int arg_augroup_get(char **argp)
{
- char_u *p;
- char_u *arg = *argp;
+ char *p;
+ char *arg = *argp;
int group = AUGROUP_ALL;
for (p = arg; *p && !ascii_iswhite(*p) && *p != '|'; p++) {}
if (p > arg) {
- char_u *group_name = vim_strnsave(arg, (size_t)(p - arg));
- group = augroup_find((char *)group_name);
+ char *group_name = xstrnsave(arg, (size_t)(p - arg));
+ group = augroup_find(group_name);
if (group == AUGROUP_ERROR) {
group = AUGROUP_ALL; // no match, use all groups
} else {
- *argp = skipwhite(p); // match, skip over group name
+ *argp = (char *)skipwhite((char_u *)p); // match, skip over group name
}
xfree(group_name);
}
@@ -2623,7 +2623,7 @@ static int arg_augroup_get(char_u **argp)
}
/// Handles grabbing arguments from `:autocmd` such as ++once and ++nested
-static bool arg_autocmd_flag_get(bool *flag, char_u **cmd_ptr, char *pattern, int len)
+static bool arg_autocmd_flag_get(bool *flag, char **cmd_ptr, char *pattern, int len)
{
if (STRNCMP(*cmd_ptr, pattern, len) == 0 && ascii_iswhite((*cmd_ptr)[len])) {
if (*flag) {
@@ -2632,7 +2632,7 @@ static bool arg_autocmd_flag_get(bool *flag, char_u **cmd_ptr, char *pattern, in
}
*flag = true;
- *cmd_ptr = skipwhite((*cmd_ptr) + len);
+ *cmd_ptr = (char *)skipwhite((char_u *)(*cmd_ptr) + len);
}
return false;
diff --git a/src/nvim/autocmd.h b/src/nvim/autocmd.h
index 53ec7f2bb7..d3503672fd 100644
--- a/src/nvim/autocmd.h
+++ b/src/nvim/autocmd.h
@@ -18,7 +18,7 @@ typedef struct {
handle_T new_curwin_handle; ///< ID of new curwin
handle_T save_prevwin_handle; ///< ID of saved prevwin
bufref_T new_curbuf; ///< new curbuf
- char_u *globaldir; ///< saved value of globaldir
+ char *globaldir; ///< saved value of globaldir
bool save_VIsual_active; ///< saved VIsual_active
} aco_save_T;
@@ -36,7 +36,7 @@ typedef struct AutoCmd {
typedef struct AutoPat {
struct AutoPat *next; // next AutoPat in AutoPat list; MUST
// be the first entry
- char_u *pat; // pattern as typed (NULL when pattern
+ char *pat; // pattern as typed (NULL when pattern
// has been removed)
regprog_T *reg_prog; // compiled regprog for pattern
AutoCmd *cmds; // list of commands to do
@@ -51,14 +51,13 @@ typedef struct AutoPat {
typedef struct AutoPatCmd {
AutoPat *curpat; // next AutoPat to examine
AutoCmd *nextcmd; // next AutoCmd to execute
- int group; // group being used
- char_u *fname; // fname to match with
- char_u *sfname; // sfname to match with
- char_u *tail; // tail of fname
- event_T event; // current event
- int arg_bufnr; // initially equal to <abuf>, set to zero when
- // buf is deleted
- struct AutoPatCmd *next; // chain of active apc-s for auto-invalidation
+ int group; // group being used
+ char *fname; // fname to match with
+ char *sfname; // sfname to match with
+ char *tail; // tail of fname
+ event_T event; // current event
+ int arg_bufnr; // initially equal to <abuf>, set to zero when buf is deleted
+ struct AutoPatCmd *next; // chain of active apc-s for auto-invalidation
} AutoPatCmd;
diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c
index 14ed9921a0..1ae1811772 100644
--- a/src/nvim/buffer.c
+++ b/src/nvim/buffer.c
@@ -2622,7 +2622,7 @@ void buflist_list(exarg_T *eap)
garray_T buflist;
buf_T **buflist_data = NULL;
- if (vim_strchr(eap->arg, 't')) {
+ if (vim_strchr((char_u *)eap->arg, 't')) {
ga_init(&buflist, sizeof(buf_T *), 50);
for (buf = firstbuf; buf != NULL; buf = buf->b_next) {
ga_grow(&buflist, 1);
@@ -2645,21 +2645,21 @@ void buflist_list(exarg_T *eap)
const bool job_running = buf->terminal && terminal_running(buf->terminal);
// skip unspecified buffers
- if ((!buf->b_p_bl && !eap->forceit && !vim_strchr(eap->arg, 'u'))
- || (vim_strchr(eap->arg, 'u') && buf->b_p_bl)
- || (vim_strchr(eap->arg, '+')
+ if ((!buf->b_p_bl && !eap->forceit && !vim_strchr((char_u *)eap->arg, 'u'))
+ || (vim_strchr((char_u *)eap->arg, 'u') && buf->b_p_bl)
+ || (vim_strchr((char_u *)eap->arg, '+')
&& ((buf->b_flags & BF_READERR) || !bufIsChanged(buf)))
- || (vim_strchr(eap->arg, 'a')
+ || (vim_strchr((char_u *)eap->arg, 'a')
&& (buf->b_ml.ml_mfp == NULL || buf->b_nwindows == 0))
- || (vim_strchr(eap->arg, 'h')
+ || (vim_strchr((char_u *)eap->arg, 'h')
&& (buf->b_ml.ml_mfp == NULL || buf->b_nwindows != 0))
- || (vim_strchr(eap->arg, 'R') && (!is_terminal || !job_running))
- || (vim_strchr(eap->arg, 'F') && (!is_terminal || job_running))
- || (vim_strchr(eap->arg, '-') && buf->b_p_ma)
- || (vim_strchr(eap->arg, '=') && !buf->b_p_ro)
- || (vim_strchr(eap->arg, 'x') && !(buf->b_flags & BF_READERR))
- || (vim_strchr(eap->arg, '%') && buf != curbuf)
- || (vim_strchr(eap->arg, '#')
+ || (vim_strchr((char_u *)eap->arg, 'R') && (!is_terminal || !job_running))
+ || (vim_strchr((char_u *)eap->arg, 'F') && (!is_terminal || job_running))
+ || (vim_strchr((char_u *)eap->arg, '-') && buf->b_p_ma)
+ || (vim_strchr((char_u *)eap->arg, '=') && !buf->b_p_ro)
+ || (vim_strchr((char_u *)eap->arg, 'x') && !(buf->b_flags & BF_READERR))
+ || (vim_strchr((char_u *)eap->arg, '%') && buf != curbuf)
+ || (vim_strchr((char_u *)eap->arg, '#')
&& (buf == curbuf || curwin->w_alt_fnum != buf->b_fnum))) {
continue;
}
@@ -2700,7 +2700,7 @@ void buflist_list(exarg_T *eap)
do {
IObuff[len++] = ' ';
} while (--i > 0 && len < IOSIZE - 18);
- if (vim_strchr(eap->arg, 't') && buf->b_last_used) {
+ if (vim_strchr((char_u *)eap->arg, 't') && buf->b_last_used) {
undo_fmt_time(IObuff + len, (size_t)(IOSIZE - len), buf->b_last_used);
} else {
vim_snprintf((char *)IObuff + len, (size_t)(IOSIZE - len), _("line %" PRId64),
diff --git a/src/nvim/cursor_shape.c b/src/nvim/cursor_shape.c
index 82c3a714b1..b092873a35 100644
--- a/src/nvim/cursor_shape.c
+++ b/src/nvim/cursor_shape.c
@@ -94,11 +94,11 @@ Array mode_style_array(void)
/// @returns error message for an illegal option, NULL otherwise.
char *parse_shape_opt(int what)
{
- char_u *colonp;
- char_u *commap;
- char_u *slashp;
- char_u *p = NULL;
- char_u *endp;
+ char *colonp;
+ char *commap;
+ char *slashp;
+ char *p = NULL;
+ char *endp;
int idx = 0; // init for GCC
int all_idx;
int len;
@@ -118,10 +118,10 @@ char *parse_shape_opt(int what)
}
}
// Repeat for all comma separated parts.
- char_u *modep = p_guicursor;
+ char *modep = (char *)p_guicursor;
while (modep != NULL && *modep != NUL) {
- colonp = vim_strchr(modep, ':');
- commap = vim_strchr(modep, ',');
+ colonp = (char *)vim_strchr((char_u *)modep, ':');
+ commap = (char *)vim_strchr((char_u *)modep, ',');
if (colonp == NULL || (commap != NULL && commap < colonp)) {
return N_("E545: Missing colon");
@@ -169,7 +169,7 @@ char *parse_shape_opt(int what)
for (p = colonp + 1; *p && *p != ',';) {
{
// First handle the ones with a number argument.
- i = *p;
+ i = (uint8_t)(*p);
len = 0;
if (STRNICMP(p, "ver", 3) == 0) {
len = 3;
@@ -187,7 +187,7 @@ char *parse_shape_opt(int what)
if (!ascii_isdigit(*p)) {
return N_("E548: digit expected");
}
- int n = getdigits_int(&p, false, 0);
+ int n = getdigits_int((char_u **)&p, false, 0);
if (len == 3) { // "ver" or "hor"
if (n == 0) {
return N_("E549: Illegal percentage");
@@ -215,7 +215,7 @@ char *parse_shape_opt(int what)
}
p += 5;
} else { // must be a highlight group name then
- endp = vim_strchr(p, '-');
+ endp = (char *)vim_strchr((char_u *)p, '-');
if (commap == NULL) { // last part
if (endp == NULL) {
endp = p + STRLEN(p); // find end of part
@@ -223,14 +223,14 @@ char *parse_shape_opt(int what)
} else if (endp > commap || endp == NULL) {
endp = commap;
}
- slashp = vim_strchr(p, '/');
+ slashp = (char *)vim_strchr((char_u *)p, '/');
if (slashp != NULL && slashp < endp) {
// "group/langmap_group"
- i = syn_check_group((char *)p, (size_t)(slashp - p));
+ i = syn_check_group(p, (size_t)(slashp - p));
p = slashp + 1;
}
if (round == 2) {
- shape_table[idx].id = syn_check_group((char *)p, (size_t)(endp - p));
+ shape_table[idx].id = syn_check_group(p, (size_t)(endp - p));
shape_table[idx].id_lm = shape_table[idx].id;
if (slashp != NULL && slashp < endp) {
shape_table[idx].id = i;
diff --git a/src/nvim/debugger.c b/src/nvim/debugger.c
index cf062cfbe8..96bc4db71e 100644
--- a/src/nvim/debugger.c
+++ b/src/nvim/debugger.c
@@ -366,7 +366,7 @@ void ex_debug(exarg_T *eap)
int debug_break_level_save = debug_break_level;
debug_break_level = 9999;
- do_cmdline_cmd((char *)eap->arg);
+ do_cmdline_cmd(eap->arg);
debug_break_level = debug_break_level_save;
}
@@ -563,7 +563,7 @@ void ex_breakadd(exarg_T *eap)
gap = &prof_ga;
}
- if (dbg_parsearg(eap->arg, gap) == OK) {
+ if (dbg_parsearg((char_u *)eap->arg, gap) == OK) {
struct debuggy *bp = &DEBUGGY(gap, gap->ga_len);
bp->dbg_forceit = eap->forceit;
@@ -618,7 +618,7 @@ void ex_breakdel(exarg_T *eap)
if (ascii_isdigit(*eap->arg)) {
// ":breakdel {nr}"
- int nr = atoi((char *)eap->arg);
+ int nr = atoi(eap->arg);
for (int i = 0; i < gap->ga_len; i++) {
if (DEBUGGY(gap, i).dbg_nr == nr) {
todel = i;
@@ -630,7 +630,7 @@ void ex_breakdel(exarg_T *eap)
del_all = true;
} else {
// ":breakdel {func|file|expr} [lnum] {name}"
- if (dbg_parsearg(eap->arg, gap) == FAIL) {
+ if (dbg_parsearg((char_u *)eap->arg, gap) == FAIL) {
return;
}
bp = &DEBUGGY(gap, gap->ga_len);
diff --git a/src/nvim/decoration.c b/src/nvim/decoration.c
index c8f4b3e875..c48cf6e832 100644
--- a/src/nvim/decoration.c
+++ b/src/nvim/decoration.c
@@ -1,6 +1,7 @@
// This is an open source non-commercial project. Dear PVS-Studio, please check
// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com
+#include "nvim/api/ui.h"
#include "nvim/buffer.h"
#include "nvim/decoration.h"
#include "nvim/extmark.h"
@@ -73,7 +74,8 @@ void decor_redraw(buf_T *buf, int row1, int row2, Decoration *decor)
}
}
- if (decor && kv_size(decor->virt_text)) {
+ if (decor && (kv_size(decor->virt_text)
+ || decor->ui_watched)) {
redraw_buf_line_later(buf, row1 + 1);
}
@@ -195,9 +197,11 @@ bool decor_redraw_start(buf_T *buf, int top_row, DecorState *state)
Decoration decor = get_decor(mark);
// Exclude non-paired marks unless they contain virt_text or a sign
+ // or they are ui-watched
if (!mt_paired(mark)
&& !kv_size(decor.virt_text)
- && !decor_has_sign(&decor)) {
+ && !decor_has_sign(&decor)
+ && !decor.ui_watched) {
goto next_mark;
}
@@ -206,21 +210,22 @@ bool decor_redraw_start(buf_T *buf, int top_row, DecorState *state)
// Exclude start marks if the end mark position is above the top row
// Exclude end marks if we have already added the start mark
if ((mt_start(mark) && altpos.row < top_row
- && !kv_size(decor.virt_text))
+ && !kv_size(decor.virt_text)
+ && !decor.ui_watched)
|| (mt_end(mark) && altpos.row >= top_row)) {
goto next_mark;
}
if (mt_end(mark)) {
decor_add(state, altpos.row, altpos.col, mark.pos.row, mark.pos.col,
- &decor, false);
+ &decor, false, mark.ns, mark.id);
} else {
if (altpos.row == -1) {
altpos.row = mark.pos.row;
altpos.col = mark.pos.col;
}
decor_add(state, mark.pos.row, mark.pos.col, altpos.row, altpos.col,
- &decor, false);
+ &decor, false, mark.ns, mark.id);
}
next_mark:
@@ -246,13 +251,13 @@ bool decor_redraw_line(buf_T *buf, int row, DecorState *state)
}
static void decor_add(DecorState *state, int start_row, int start_col, int end_row, int end_col,
- Decoration *decor, bool owned)
+ Decoration *decor, bool owned, uint64_t ns_id, uint64_t mark_id)
{
int attr_id = decor->hl_id > 0 ? syn_id2attr(decor->hl_id) : 0;
DecorRange range = { start_row, start_col, end_row, end_col,
*decor, attr_id,
- kv_size(decor->virt_text) && owned, -1 };
+ kv_size(decor->virt_text) && owned, -1, ns_id, mark_id };
kv_pushp(state->active);
size_t index;
@@ -298,13 +303,13 @@ int decor_redraw_col(buf_T *buf, int col, int win_col, bool hidden, DecorState *
if (endpos.row < mark.pos.row
|| (endpos.row == mark.pos.row && endpos.col <= mark.pos.col)) {
- if (!kv_size(decor.virt_text)) {
+ if (!kv_size(decor.virt_text) && !decor.ui_watched) {
goto next_mark;
}
}
decor_add(state, mark.pos.row, mark.pos.col, endpos.row, endpos.col,
- &decor, false);
+ &decor, false, mark.ns, mark.id);
next_mark:
marktree_itr_next(buf->b_marktree, state->itr);
@@ -321,7 +326,8 @@ next_mark:
bool active = false, keep = true;
if (item.end_row < state->row
|| (item.end_row == state->row && item.end_col <= col)) {
- if (!(item.start_row >= state->row && kv_size(item.decor.virt_text))) {
+ if (!(item.start_row >= state->row
+ && (kv_size(item.decor.virt_text) || item.decor.ui_watched))) {
keep = false;
}
} else {
@@ -349,7 +355,7 @@ next_mark:
}
}
if ((item.start_row == state->row && item.start_col <= col)
- && kv_size(item.decor.virt_text)
+ && (kv_size(item.decor.virt_text) || item.decor.ui_watched)
&& item.decor.virt_text_pos == kVTOverlay && item.win_col == -1) {
item.win_col = (item.decor.virt_text_hide && hidden) ? -2 : win_col;
}
@@ -517,7 +523,8 @@ bool decor_redraw_eol(buf_T *buf, DecorState *state, int *eol_attr, int eol_col)
bool has_virttext = false;
for (size_t i = 0; i < kv_size(state->active); i++) {
DecorRange item = kv_A(state->active, i);
- if (item.start_row == state->row && kv_size(item.decor.virt_text)) {
+ if (item.start_row == state->row
+ && (kv_size(item.decor.virt_text) || item.decor.ui_watched)) {
has_virttext = true;
}
@@ -528,13 +535,14 @@ bool decor_redraw_eol(buf_T *buf, DecorState *state, int *eol_attr, int eol_col)
return has_virttext;
}
-void decor_add_ephemeral(int start_row, int start_col, int end_row, int end_col, Decoration *decor)
+void decor_add_ephemeral(int start_row, int start_col, int end_row, int end_col, Decoration *decor,
+ uint64_t ns_id, uint64_t mark_id)
{
if (end_row == -1) {
end_row = start_row;
end_col = start_col;
}
- decor_add(&decor_state, start_row, start_col, end_row, end_col, decor, true);
+ decor_add(&decor_state, start_row, start_col, end_row, end_col, decor, true, ns_id, mark_id);
}
diff --git a/src/nvim/decoration.h b/src/nvim/decoration.h
index 97ab218f86..9a82af8661 100644
--- a/src/nvim/decoration.h
+++ b/src/nvim/decoration.h
@@ -60,10 +60,11 @@ struct Decoration {
// TODO(bfredl): in principle this should be a schar_T, but we
// probably want some kind of glyph cache for that..
int conceal_char;
+ bool ui_watched; // watched for win_extmark
};
#define DECORATION_INIT { KV_INITIAL_VALUE, KV_INITIAL_VALUE, 0, kVTEndOfLine, \
kHlModeUnknown, false, false, false, false, DECOR_PRIORITY_BASE, \
- 0, 0, NULL, 0, 0, 0, 0, 0 }
+ 0, 0, NULL, 0, 0, 0, 0, 0, false }
typedef struct {
int start_row;
@@ -74,6 +75,8 @@ typedef struct {
int attr_id; // cached lookup of decor.hl_id
bool virt_text_owned;
int win_col;
+ uint64_t ns_id;
+ uint64_t mark_id;
} DecorRange;
typedef struct {
diff --git a/src/nvim/diff.c b/src/nvim/diff.c
index cfb1c35817..52ae1bc819 100644
--- a/src/nvim/diff.c
+++ b/src/nvim/diff.c
@@ -1186,9 +1186,9 @@ void ex_diffpatch(exarg_T *eap)
#ifdef UNIX
// Get the absolute path of the patchfile, changing directory below.
- fullname = FullName_save((char *)eap->arg, false);
+ fullname = FullName_save(eap->arg, false);
esc_name =
- vim_strsave_shellescape((fullname != NULL ? (char_u *)fullname : eap->arg), true, true);
+ vim_strsave_shellescape((char_u *)(fullname != NULL ? fullname : eap->arg), true, true);
#else
esc_name = vim_strsave_shellescape(eap->arg, true, true);
#endif
@@ -1219,7 +1219,7 @@ void ex_diffpatch(exarg_T *eap)
// Use 'patchexpr' to generate the new file.
#ifdef UNIX
eval_patch((char *)tmp_orig,
- (fullname != NULL ? fullname : (char *)eap->arg),
+ (fullname != NULL ? fullname : eap->arg),
(char *)tmp_new);
#else
eval_patch((char *)tmp_orig, (char *)eap->arg, (char *)tmp_new);
@@ -1268,7 +1268,7 @@ void ex_diffpatch(exarg_T *eap)
if (win_split(0, (diff_flags & DIFF_VERTICAL) ? WSP_VERT : 0) != FAIL) {
// Pretend it was a ":split fname" command
eap->cmdidx = CMD_split;
- eap->arg = tmp_new;
+ eap->arg = (char *)tmp_new;
do_exedit(eap, old_curwin);
// check that split worked and editing tmp_new
@@ -1279,7 +1279,7 @@ void ex_diffpatch(exarg_T *eap)
if (newname != NULL) {
// do a ":file filename.new" on the patched buffer
- eap->arg = newname;
+ eap->arg = (char *)newname;
ex_file(eap);
// Do filetype detection with the new name.
@@ -2469,10 +2469,10 @@ void nv_diffgetput(bool put, size_t count)
return;
}
if (count == 0) {
- ea.arg = (char_u *)"";
+ ea.arg = "";
} else {
vim_snprintf(buf, sizeof(buf), "%zu", count);
- ea.arg = (char_u *)buf;
+ ea.arg = buf;
}
if (put) {
@@ -2553,18 +2553,18 @@ void ex_diffgetput(exarg_T *eap)
}
} else {
// Buffer number or pattern given. Ignore trailing white space.
- p = eap->arg + STRLEN(eap->arg);
- while (p > eap->arg && ascii_iswhite(p[-1])) {
+ p = (char_u *)eap->arg + STRLEN(eap->arg);
+ while (p > (char_u *)eap->arg && ascii_iswhite(p[-1])) {
p--;
}
- for (i = 0; ascii_isdigit(eap->arg[i]) && eap->arg + i < p; i++) {}
+ for (i = 0; ascii_isdigit(eap->arg[i]) && (char_u *)eap->arg + i < p; i++) {}
- if (eap->arg + i == p) {
+ if ((char_u *)eap->arg + i == p) {
// digits only
- i = (int)atol((char *)eap->arg);
+ i = (int)atol(eap->arg);
} else {
- i = buflist_findpat(eap->arg, p, false, true, false);
+ i = buflist_findpat((char_u *)eap->arg, p, false, true, false);
if (i < 0) {
// error message already given
diff --git a/src/nvim/edit.c b/src/nvim/edit.c
index 6a6d433228..f17ac52f15 100644
--- a/src/nvim/edit.c
+++ b/src/nvim/edit.c
@@ -5278,7 +5278,7 @@ static int ins_complete(int c, bool enable_pum)
// "pattern not found" message.
compl_col = curs_col;
} else {
- compl_col = (int)(compl_xp.xp_pattern - compl_pattern);
+ compl_col = (int)((char_u *)compl_xp.xp_pattern - compl_pattern);
}
compl_length = curs_col - compl_col;
} else if (ctrl_x_mode == CTRL_X_FUNCTION || ctrl_x_mode == CTRL_X_OMNI
diff --git a/src/nvim/eval.c b/src/nvim/eval.c
index b4c3e62ddf..7f99d81bb4 100644
--- a/src/nvim/eval.c
+++ b/src/nvim/eval.c
@@ -1296,7 +1296,7 @@ static list_T *heredoc_get(exarg_T *eap, char *cmd)
// The amount of indentation trimmed is the same as the indentation of
// the first line after the :let command line. To find the end marker
// the indent of the :let command line is trimmed.
- p = (char *)(*eap->cmdlinep);
+ p = *eap->cmdlinep;
while (ascii_iswhite(*p)) {
p++;
marker_indent_len++;
@@ -1389,7 +1389,7 @@ void ex_let(exarg_T *eap)
static void ex_let_const(exarg_T *eap, const bool is_const)
{
- char *arg = (char *)eap->arg;
+ char *arg = eap->arg;
char *expr = NULL;
typval_T rettv;
int i;
@@ -1425,7 +1425,7 @@ static void ex_let_const(exarg_T *eap, const bool is_const)
list_func_vars(&first);
list_vim_vars(&first);
}
- eap->nextcmd = check_nextcmd((char_u *)arg);
+ eap->nextcmd = (char *)check_nextcmd((char_u *)arg);
} else if (expr[0] == '=' && expr[1] == '<' && expr[2] == '<') {
// HERE document
list_T *l = heredoc_get(eap, expr + 3);
@@ -1434,7 +1434,7 @@ static void ex_let_const(exarg_T *eap, const bool is_const)
if (!eap->skip) {
op[0] = '=';
op[1] = NUL;
- (void)ex_let_vars((char *)eap->arg, &rettv, false, semicolon, var_count,
+ (void)ex_let_vars(eap->arg, &rettv, false, semicolon, var_count,
is_const, (char *)op);
}
tv_clear(&rettv);
@@ -1457,14 +1457,14 @@ static void ex_let_const(exarg_T *eap, const bool is_const)
if (eap->skip) {
++emsg_skip;
}
- i = eval0(expr, &rettv, (char **)&eap->nextcmd, !eap->skip);
+ i = eval0(expr, &rettv, &eap->nextcmd, !eap->skip);
if (eap->skip) {
if (i != FAIL) {
tv_clear(&rettv);
}
emsg_skip--;
} else if (i != FAIL) {
- (void)ex_let_vars((char *)eap->arg, &rettv, false, semicolon, var_count,
+ (void)ex_let_vars(eap->arg, &rettv, false, semicolon, var_count,
is_const, (char *)op);
tv_clear(&rettv);
}
@@ -2715,7 +2715,7 @@ void set_context_for_expression(expand_T *xp, char *arg, cmdidx_T cmdidx)
if (strpbrk(arg, "\"'+-*/%.=!?~|&$([<>,#") == NULL) {
// ":let var1 var2 ...": find last space.
for (p = arg + STRLEN(arg); p >= arg;) {
- xp->xp_pattern = (char_u *)p;
+ xp->xp_pattern = p;
MB_PTR_BACK(arg, p);
if (ascii_iswhite(*p)) {
break;
@@ -2727,10 +2727,10 @@ void set_context_for_expression(expand_T *xp, char *arg, cmdidx_T cmdidx)
xp->xp_context = cmdidx == CMD_call ? EXPAND_FUNCTIONS
: EXPAND_EXPRESSION;
}
- while ((xp->xp_pattern = (char_u *)strpbrk(arg, "\"'+-*/%.=!?~|&$([<>,#")) != NULL) {
- c = *xp->xp_pattern;
+ while ((xp->xp_pattern = strpbrk(arg, "\"'+-*/%.=!?~|&$([<>,#")) != NULL) {
+ c = (uint8_t)(*xp->xp_pattern);
if (c == '&') {
- c = xp->xp_pattern[1];
+ c = (uint8_t)xp->xp_pattern[1];
if (c == '&') {
++xp->xp_pattern;
xp->xp_context = cmdidx != CMD_let || got_eq
@@ -2753,12 +2753,12 @@ void set_context_for_expression(expand_T *xp, char *arg, cmdidx_T cmdidx)
break;
} else if ((c == '<' || c == '#')
&& xp->xp_context == EXPAND_FUNCTIONS
- && vim_strchr(xp->xp_pattern, '(') == NULL) {
+ && vim_strchr((char_u *)xp->xp_pattern, '(') == NULL) {
// Function name can start with "<SNR>" and contain '#'.
break;
} else if (cmdidx != CMD_let || got_eq) {
if (c == '"') { // string
- while ((c = *++xp->xp_pattern) != NUL && c != '"') {
+ while ((c = (uint8_t)(*++xp->xp_pattern)) != NUL && c != '"') {
if (c == '\\' && xp->xp_pattern[1] != NUL) {
xp->xp_pattern++;
}
@@ -2766,7 +2766,7 @@ void set_context_for_expression(expand_T *xp, char *arg, cmdidx_T cmdidx)
xp->xp_context = EXPAND_NOTHING;
} else if (c == '\'') { // literal string
// Trick: '' is like stopping and starting a literal string.
- while ((c = *++xp->xp_pattern) != NUL && c != '\'') {}
+ while ((c = (uint8_t)(*++xp->xp_pattern)) != NUL && c != '\'') {}
xp->xp_context = EXPAND_NOTHING;
} else if (c == '|') {
if (xp->xp_pattern[1] == '|') {
@@ -2783,7 +2783,7 @@ void set_context_for_expression(expand_T *xp, char *arg, cmdidx_T cmdidx)
// anyway.
xp->xp_context = EXPAND_EXPRESSION;
}
- arg = (char *)xp->xp_pattern;
+ arg = xp->xp_pattern;
if (*arg != NUL) {
while ((c = (char_u)(*++arg)) != NUL && (c == ' ' || c == '\t')) {}
}
@@ -2805,13 +2805,13 @@ void set_context_for_expression(expand_T *xp, char *arg, cmdidx_T cmdidx)
}
}
- xp->xp_pattern = (char_u *)arg;
+ xp->xp_pattern = arg;
}
/// ":unlet[!] var1 ... " command.
void ex_unlet(exarg_T *eap)
{
- ex_unletlock(eap, (char *)eap->arg, 0, do_unlet_var);
+ ex_unletlock(eap, eap->arg, 0, do_unlet_var);
}
// TODO(ZyX-I): move to eval/ex_cmds
@@ -2819,7 +2819,7 @@ void ex_unlet(exarg_T *eap)
/// ":lockvar" and ":unlockvar" commands
void ex_lockvar(exarg_T *eap)
{
- char *arg = (char *)eap->arg;
+ char *arg = eap->arg;
int deep = 2;
if (eap->forceit) {
@@ -2894,7 +2894,7 @@ static void ex_unletlock(exarg_T *eap, char *argstart, int deep, ex_unletlock_ca
arg = (char *)skipwhite((char_u *)name_end);
} while (!ends_excmd(*arg));
- eap->nextcmd = check_nextcmd((char_u *)arg);
+ eap->nextcmd = (char *)check_nextcmd((char_u *)arg);
}
// TODO(ZyX-I): move to eval/ex_cmds
@@ -9422,7 +9422,7 @@ int var_item_copy(const vimconv_T *const conv, typval_T *const from, typval_T *c
/// ":echon expr1 ..." print each argument plain.
void ex_echo(exarg_T *eap)
{
- char *arg = (char *)eap->arg;
+ char *arg = eap->arg;
typval_T rettv;
bool atstart = true;
bool need_clear = true;
@@ -9478,7 +9478,7 @@ void ex_echo(exarg_T *eap)
tv_clear(&rettv);
arg = (char *)skipwhite((char_u *)arg);
}
- eap->nextcmd = check_nextcmd((char_u *)arg);
+ eap->nextcmd = (char *)check_nextcmd((char_u *)arg);
if (eap->skip) {
emsg_skip--;
@@ -9496,7 +9496,7 @@ void ex_echo(exarg_T *eap)
/// ":echohl {name}".
void ex_echohl(exarg_T *eap)
{
- echo_attr = syn_name2attr(eap->arg);
+ echo_attr = syn_name2attr((char_u *)eap->arg);
}
/// ":execute expr1 ..." execute the result of an expression.
@@ -9506,7 +9506,7 @@ void ex_echohl(exarg_T *eap)
/// echo commands
void ex_execute(exarg_T *eap)
{
- char *arg = (char *)eap->arg;
+ char *arg = eap->arg;
typval_T rettv;
int ret = OK;
garray_T ga;
@@ -9576,7 +9576,7 @@ void ex_execute(exarg_T *eap)
--emsg_skip;
}
- eap->nextcmd = check_nextcmd((char_u *)arg);
+ eap->nextcmd = (char *)check_nextcmd((char_u *)arg);
}
/// Skip over the name of an option: "&option", "&g:option" or "&l:option".
diff --git a/src/nvim/eval.h b/src/nvim/eval.h
index 53f19b8736..c81b31aba9 100644
--- a/src/nvim/eval.h
+++ b/src/nvim/eval.h
@@ -164,7 +164,7 @@ typedef enum {
VV_ARGV,
VV_COLLATE,
VV_EXITING,
- // Neovim
+ // Nvim
VV_STDERR,
VV_MSGPACK_TYPES,
VV__NULL_STRING, // String with NULL value. For test purposes only.
diff --git a/src/nvim/eval/funcs.c b/src/nvim/eval/funcs.c
index 88059ff21e..4aae070530 100644
--- a/src/nvim/eval/funcs.c
+++ b/src/nvim/eval/funcs.c
@@ -2194,7 +2194,7 @@ static void f_expandcmd(typval_T *argvars, typval_T *rettv, FunPtr fptr)
exarg_T eap = {
.cmd = (char *)cmdstr,
- .arg = cmdstr,
+ .arg = (char *)cmdstr,
.usefilter = false,
.nextcmd = NULL,
.cmdidx = CMD_USER,
@@ -3246,7 +3246,7 @@ static void f_getcompletion(typval_T *argvars, typval_T *rettv, FunPtr fptr)
}
ExpandInit(&xpc);
- xpc.xp_pattern = (char_u *)pattern;
+ xpc.xp_pattern = (char *)pattern;
xpc.xp_pattern_len = STRLEN(xpc.xp_pattern);
xpc.xp_context = cmdcomplete_str_to_type(type);
if (xpc.xp_context == EXPAND_NOTHING) {
@@ -3255,7 +3255,7 @@ static void f_getcompletion(typval_T *argvars, typval_T *rettv, FunPtr fptr)
}
if (xpc.xp_context == EXPAND_MENUS) {
- set_context_in_menu_cmd(&xpc, "menu", (char *)xpc.xp_pattern, false);
+ set_context_in_menu_cmd(&xpc, "menu", xpc.xp_pattern, false);
xpc.xp_pattern_len = STRLEN(xpc.xp_pattern);
}
@@ -3265,12 +3265,12 @@ static void f_getcompletion(typval_T *argvars, typval_T *rettv, FunPtr fptr)
}
if (xpc.xp_context == EXPAND_SIGN) {
- set_context_in_sign_cmd(&xpc, xpc.xp_pattern);
+ set_context_in_sign_cmd(&xpc, (char_u *)xpc.xp_pattern);
xpc.xp_pattern_len = STRLEN(xpc.xp_pattern);
}
theend:
- pat = addstar(xpc.xp_pattern, xpc.xp_pattern_len, xpc.xp_context);
+ pat = addstar((char_u *)xpc.xp_pattern, xpc.xp_pattern_len, xpc.xp_context);
ExpandOne(&xpc, pat, NULL, options, WILD_ALL_KEEP);
tv_list_alloc_ret(rettv, xpc.xp_numfiles);
@@ -3528,7 +3528,7 @@ static void f_getjumplist(typval_T *argvars, typval_T *rettv, FunPtr fptr)
tv_dict_add_nr(d, S_LEN("coladd"), wp->w_jumplist[i].fmark.mark.coladd);
tv_dict_add_nr(d, S_LEN("bufnr"), wp->w_jumplist[i].fmark.fnum);
if (wp->w_jumplist[i].fname != NULL) {
- tv_dict_add_str(d, S_LEN("filename"), (char *)wp->w_jumplist[i].fname);
+ tv_dict_add_str(d, S_LEN("filename"), wp->w_jumplist[i].fname);
}
}
}
@@ -5088,6 +5088,16 @@ static dict_T *create_environment(const dictitem_T *job_env, const bool clear_en
tv_dict_add_str(env, S_LEN("TERM"), pty_term_name);
}
+ // Set $NVIM (in the child process) to v:servername. #3118
+ char *nvim_addr = (char *)get_vim_var_str(VV_SEND_SERVER);
+ if (nvim_addr[0] != '\0') {
+ dictitem_T *dv = tv_dict_find(env, S_LEN("NVIM"));
+ if (dv) {
+ tv_dict_item_remove(env, dv);
+ }
+ tv_dict_add_str(env, S_LEN("NVIM"), nvim_addr);
+ }
+
if (job_env) {
#ifdef WIN32
TV_DICT_ITER(job_env->di_tv.vval.v_dict, var, {
@@ -10984,7 +10994,6 @@ static void f_tr(typval_T *argvars, typval_T *rettv, FunPtr fptr)
error:
semsg(_(e_invarg2), fromstr);
ga_clear(&ga);
- return;
}
/// "trim({expr})" function
diff --git a/src/nvim/eval/typval.c b/src/nvim/eval/typval.c
index 2a432ecb47..ff52962913 100644
--- a/src/nvim/eval/typval.c
+++ b/src/nvim/eval/typval.c
@@ -1588,8 +1588,6 @@ varnumber_T tv_dict_get_number(const dict_T *const d, const char *const key)
}
/// Converts a dict to an environment
-///
-///
char **tv_dict_to_env(dict_T *denv)
{
size_t env_size = (size_t)tv_dict_len(denv);
diff --git a/src/nvim/eval/userfunc.c b/src/nvim/eval/userfunc.c
index 0a35e6655f..fe8325760c 100644
--- a/src/nvim/eval/userfunc.c
+++ b/src/nvim/eval/userfunc.c
@@ -1953,7 +1953,7 @@ void ex_function(exarg_T *eap)
}
}
}
- eap->nextcmd = check_nextcmd(eap->arg);
+ eap->nextcmd = (char *)check_nextcmd((char_u *)eap->arg);
return;
}
@@ -1961,13 +1961,13 @@ void ex_function(exarg_T *eap)
* ":function /pat": list functions matching pattern.
*/
if (*eap->arg == '/') {
- p = skip_regexp(eap->arg + 1, '/', TRUE, NULL);
+ p = skip_regexp((char_u *)eap->arg + 1, '/', true, NULL);
if (!eap->skip) {
regmatch_T regmatch;
c = *p;
*p = NUL;
- regmatch.regprog = vim_regcomp(eap->arg + 1, RE_MAGIC);
+ regmatch.regprog = vim_regcomp((char_u *)eap->arg + 1, RE_MAGIC);
*p = c;
if (regmatch.regprog != NULL) {
regmatch.rm_ic = p_ic;
@@ -1989,7 +1989,7 @@ void ex_function(exarg_T *eap)
if (*p == '/') {
++p;
}
- eap->nextcmd = check_nextcmd(p);
+ eap->nextcmd = (char *)check_nextcmd(p);
return;
}
@@ -2007,7 +2007,7 @@ void ex_function(exarg_T *eap)
// "fudi.fd_di" set, "fudi.fd_newkey" == NULL
// s:func script-local function name
// g:func global function name, same as "func"
- p = eap->arg;
+ p = (char_u *)eap->arg;
name = trans_function_name(&p, eap->skip, TFN_NO_AUTOLOAD, &fudi, NULL);
paren = (vim_strchr(p, '(') != NULL);
if (name == NULL && (fudi.fd_dict == NULL || !paren) && !eap->skip) {
@@ -2043,7 +2043,7 @@ void ex_function(exarg_T *eap)
emsg(_(e_trailing));
goto ret_free;
}
- eap->nextcmd = check_nextcmd(p);
+ eap->nextcmd = (char *)check_nextcmd(p);
if (eap->nextcmd != NULL) {
*p = NUL;
}
@@ -2289,10 +2289,10 @@ void ex_function(exarg_T *eap)
// Another command follows. If the line came from "eap" we
// can simply point into it, otherwise we need to change
// "eap->cmdlinep".
- eap->nextcmd = nextcmd;
+ eap->nextcmd = (char *)nextcmd;
if (line_to_free != NULL) {
xfree(*eap->cmdlinep);
- *eap->cmdlinep = line_to_free;
+ *eap->cmdlinep = (char *)line_to_free;
line_to_free = NULL;
}
}
@@ -2693,7 +2693,7 @@ void ex_delfunction(exarg_T *eap)
char_u *name;
funcdict_T fudi;
- p = eap->arg;
+ p = (char_u *)eap->arg;
name = trans_function_name(&p, eap->skip, 0, &fudi, NULL);
xfree(fudi.fd_newkey);
if (name == NULL) {
@@ -2707,7 +2707,7 @@ void ex_delfunction(exarg_T *eap)
emsg(_(e_trailing));
return;
}
- eap->nextcmd = check_nextcmd(p);
+ eap->nextcmd = (char *)check_nextcmd(p);
if (eap->nextcmd != NULL) {
*p = NUL;
}
@@ -2858,7 +2858,7 @@ static int can_free_funccal(funccall_T *fc, int copyID)
/// ":return [expr]"
void ex_return(exarg_T *eap)
{
- char_u *arg = eap->arg;
+ char_u *arg = (char_u *)eap->arg;
typval_T rettv;
int returning = FALSE;
@@ -2873,7 +2873,7 @@ void ex_return(exarg_T *eap)
eap->nextcmd = NULL;
if ((*arg != NUL && *arg != '|' && *arg != '\n')
- && eval0((char *)arg, &rettv, (char **)&eap->nextcmd, !eap->skip) != FAIL) {
+ && eval0((char *)arg, &rettv, &eap->nextcmd, !eap->skip) != FAIL) {
if (!eap->skip) {
returning = do_return(eap, false, true, &rettv);
} else {
@@ -2896,7 +2896,7 @@ void ex_return(exarg_T *eap)
if (returning) {
eap->nextcmd = NULL;
} else if (eap->nextcmd == NULL) { // no argument
- eap->nextcmd = check_nextcmd(arg);
+ eap->nextcmd = (char *)check_nextcmd(arg);
}
if (eap->skip) {
@@ -2909,7 +2909,7 @@ void ex_return(exarg_T *eap)
/// ":1,25call func(arg1, arg2)" function call.
void ex_call(exarg_T *eap)
{
- char_u *arg = eap->arg;
+ char_u *arg = (char_u *)eap->arg;
char_u *startarg;
char_u *name;
char_u *tofree;
@@ -2926,7 +2926,7 @@ void ex_call(exarg_T *eap)
// instead to skip to any following command, e.g. for:
// :if 0 | call dict.foo().bar() | endif.
emsg_skip++;
- if (eval0((char *)eap->arg, &rettv, (char **)&eap->nextcmd, false) != FAIL) {
+ if (eval0(eap->arg, &rettv, &eap->nextcmd, false) != FAIL) {
tv_clear(&rettv);
}
emsg_skip--;
@@ -3025,7 +3025,7 @@ void ex_call(exarg_T *eap)
emsg(_(e_trailing));
}
} else {
- eap->nextcmd = check_nextcmd(arg);
+ eap->nextcmd = (char *)check_nextcmd(arg);
}
}
diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c
index 06fa981ba7..3953f2f67d 100644
--- a/src/nvim/ex_cmds.c
+++ b/src/nvim/ex_cmds.c
@@ -245,7 +245,7 @@ void ex_align(exarg_T *eap)
}
}
- width = atoi((char *)eap->arg);
+ width = atoi(eap->arg);
save_curpos = curwin->w_cursor;
if (eap->cmdidx == CMD_left) { // width is used for new indent
if (width >= 0) {
@@ -484,7 +484,7 @@ void ex_sort(exarg_T *eap)
size_t format_found = 0;
bool change_occurred = false; // Buffer contents changed.
- for (p = (char *)eap->arg; *p != NUL; p++) {
+ for (p = eap->arg; *p != NUL; p++) {
if (ascii_iswhite(*p)) {
// Skip
} else if (*p == 'i') {
@@ -514,7 +514,7 @@ void ex_sort(exarg_T *eap)
// comment start
break;
} else if (check_nextcmd((char_u *)p) != NULL) {
- eap->nextcmd = check_nextcmd((char_u *)p);
+ eap->nextcmd = (char *)check_nextcmd((char_u *)p);
break;
} else if (!ASCII_ISALPHA(*p) && regmatch.regprog == NULL) {
s = (char *)skip_regexp((char_u *)p + 1, *p, true, NULL);
@@ -746,8 +746,8 @@ void ex_retab(exarg_T *eap)
save_list = curwin->w_p_list;
curwin->w_p_list = 0; // don't want list mode here
- new_ts_str = (char *)eap->arg;
- if (!tabstop_set(eap->arg, &new_vts_array)) {
+ new_ts_str = eap->arg;
+ if (!tabstop_set((char_u *)eap->arg, &new_vts_array)) {
return;
}
while (ascii_isdigit(*(eap->arg)) || *(eap->arg) == ',') {
@@ -761,7 +761,7 @@ void ex_retab(exarg_T *eap)
new_vts_array = curbuf->b_p_vts_array;
new_ts_str = NULL;
} else {
- new_ts_str = xstrnsave(new_ts_str, eap->arg - (char_u *)new_ts_str);
+ new_ts_str = xstrnsave(new_ts_str, eap->arg - new_ts_str);
}
for (lnum = eap->line1; !got_int && lnum <= eap->line2; lnum++) {
ptr = (char *)ml_get(lnum);
@@ -1129,7 +1129,7 @@ void free_prev_shellcmd(void)
void do_bang(int addr_count, exarg_T *eap, bool forceit, bool do_in, bool do_out)
FUNC_ATTR_NONNULL_ALL
{
- char *arg = (char *)eap->arg; // command
+ char *arg = eap->arg; // command
linenr_T line1 = eap->line1; // start of range
linenr_T line2 = eap->line2; // end of range
char *newcmd = NULL; // the new command
@@ -1755,7 +1755,7 @@ void ex_file(exarg_T *eap)
}
if (*eap->arg != NUL || eap->addr_count == 1) {
- if (rename_buffer((char *)eap->arg) == FAIL) {
+ if (rename_buffer(eap->arg) == FAIL) {
return;
}
redraw_tabline = true;
@@ -1811,7 +1811,7 @@ int do_write(exarg_T *eap)
return FAIL;
}
- ffname = (char *)eap->arg;
+ ffname = eap->arg;
if (*ffname == NUL) {
if (eap->cmdidx == CMD_saveas) {
emsg(_(e_argreq));
@@ -1919,7 +1919,7 @@ int do_write(exarg_T *eap)
// If 'filetype' was empty try detecting it now.
if (*curbuf->b_p_ft == NUL) {
if (augroup_exists("filetypedetect")) {
- (void)do_doautocmd((char_u *)"filetypedetect BufRead", true, NULL);
+ (void)do_doautocmd("filetypedetect BufRead", true, NULL);
}
do_modelines(0);
}
@@ -2307,7 +2307,7 @@ int do_ecmd(int fnum, char *ffname, char *sfname, exarg_T *eap, linenr_T newlnum
long *so_ptr = curwin->w_p_so >= 0 ? &curwin->w_p_so : &p_so;
if (eap != NULL) {
- command = (char *)eap->do_ecmd_cmd;
+ command = eap->do_ecmd_cmd;
}
set_bufref(&old_curbuf, curbuf);
@@ -2961,15 +2961,15 @@ void ex_append(exarg_T *eap)
if (eap->nextcmd == NULL || *eap->nextcmd == NUL) {
break;
}
- p = (char *)vim_strchr(eap->nextcmd, NL);
+ p = (char *)vim_strchr((char_u *)eap->nextcmd, NL);
if (p == NULL) {
- p = (char *)eap->nextcmd + STRLEN(eap->nextcmd);
+ p = eap->nextcmd + STRLEN(eap->nextcmd);
}
- theline = (char *)vim_strnsave(eap->nextcmd, (char_u *)p - eap->nextcmd);
+ theline = xstrnsave(eap->nextcmd, p - eap->nextcmd);
if (*p != NUL) {
p++;
}
- eap->nextcmd = (char_u *)p;
+ eap->nextcmd = p;
} else {
// Set State to avoid the cursor shape to be set to INSERT mode
// when getline() returns.
@@ -3105,7 +3105,7 @@ void ex_z(exarg_T *eap)
bigness = 1;
}
- x = (char *)eap->arg;
+ x = eap->arg;
kind = x;
if (*kind == '-' || *kind == '+' || *kind == '='
|| *kind == '^' || *kind == '.') {
@@ -3463,7 +3463,7 @@ static buf_T *do_sub(exarg_T *eap, proftime_T timeout, bool do_buf_event, handle
bool got_quit = false;
bool got_match = false;
int which_pat;
- char *cmd = (char *)eap->arg;
+ char *cmd = eap->arg;
linenr_T first_line = 0; // first changed line
linenr_T last_line= 0; // below last changed line AFTER the change
linenr_T old_line_count = curbuf->b_ml.ml_line_count;
@@ -3519,7 +3519,7 @@ static buf_T *do_sub(exarg_T *eap, proftime_T timeout, bool do_buf_event, handle
which_pat = RE_LAST; // use last used regexp
delimiter = (char_u)(*cmd++); // remember delimiter character
pat = cmd; // remember start of search pat
- cmd = (char *)skip_regexp((char_u *)cmd, delimiter, p_magic, &eap->arg);
+ cmd = (char *)skip_regexp((char_u *)cmd, delimiter, p_magic, (char_u **)&eap->arg);
if (cmd[0] == delimiter) { // end delimiter found
*cmd++ = NUL; // replace it with a NUL
has_second_delim = true;
@@ -3592,7 +3592,7 @@ static buf_T *do_sub(exarg_T *eap, proftime_T timeout, bool do_buf_event, handle
*/
cmd = (char *)skipwhite((char_u *)cmd);
if (*cmd && *cmd != '"') { // if not end-of-line or comment
- eap->nextcmd = check_nextcmd((char_u *)cmd);
+ eap->nextcmd = (char *)check_nextcmd((char_u *)cmd);
if (eap->nextcmd == NULL) {
emsg(_(e_trailing));
return NULL;
@@ -4570,7 +4570,7 @@ void ex_global(exarg_T *eap)
} else {
type = (uint8_t)(*eap->cmd);
}
- cmd = (char *)eap->arg;
+ cmd = eap->arg;
which_pat = RE_LAST; // default: use last used regexp
/*
@@ -4600,7 +4600,7 @@ void ex_global(exarg_T *eap)
delim = *cmd; // get the delimiter
cmd++; // skip delimiter if there is one
pat = cmd; // remember start of pattern
- cmd = (char *)skip_regexp((char_u *)cmd, delim, p_magic, &eap->arg);
+ cmd = (char *)skip_regexp((char_u *)cmd, delim, p_magic, (char_u **)&eap->arg);
if (cmd[0] == delim) { // end delimiter found
*cmd++ = NUL; // replace it with a NUL
}
@@ -4776,15 +4776,15 @@ void ex_help(exarg_T *eap)
* A ":help" command ends at the first LF, or at a '|' that is
* followed by some text. Set nextcmd to the following command.
*/
- for (arg = (char *)eap->arg; *arg; arg++) {
+ for (arg = eap->arg; *arg; arg++) {
if (*arg == '\n' || *arg == '\r'
|| (*arg == '|' && arg[1] != NUL && arg[1] != '|')) {
*arg++ = NUL;
- eap->nextcmd = (char_u *)arg;
+ eap->nextcmd = arg;
break;
}
}
- arg = (char *)eap->arg;
+ arg = eap->arg;
if (eap->forceit && *arg == NUL && !curbuf->b_help) {
emsg(_("E478: Don't panic!"));
@@ -5835,7 +5835,7 @@ void ex_helptags(exarg_T *eap)
// Check for ":helptags ++t {dir}".
if (STRNCMP(eap->arg, "++t", 3) == 0 && ascii_iswhite(eap->arg[3])) {
add_help_tags = true;
- eap->arg = skipwhite(eap->arg + 3);
+ eap->arg = (char *)skipwhite((char_u *)eap->arg + 3);
}
if (STRCMP(eap->arg, "ALL") == 0) {
@@ -5843,7 +5843,7 @@ void ex_helptags(exarg_T *eap)
} else {
ExpandInit(&xpc);
xpc.xp_context = EXPAND_DIRECTORIES;
- dirname = (char *)ExpandOne(&xpc, eap->arg, NULL,
+ dirname = (char *)ExpandOne(&xpc, (char_u *)eap->arg, NULL,
WILD_LIST_NOTFOUND|WILD_SILENT, WILD_EXPAND_FREE);
if (dirname == NULL || !os_isdir((char_u *)dirname)) {
semsg(_("E150: Not a directory: %s"), eap->arg);
@@ -6060,7 +6060,7 @@ void ex_substitute(exarg_T *eap)
block_autocmds(); // Disable events during command preview.
- char *save_eap = (char *)eap->arg;
+ char *save_eap = eap->arg;
garray_T save_view;
win_size_save(&save_view); // Save current window sizes.
save_search_patterns();
@@ -6101,7 +6101,7 @@ void ex_substitute(exarg_T *eap)
curbuf->b_p_ul = save_b_p_ul;
curwin->w_p_cul = save_w_p_cul; // Restore 'cursorline'
curwin->w_p_cuc = save_w_p_cuc; // Restore 'cursorcolumn'
- eap->arg = (char_u *)save_eap;
+ eap->arg = save_eap;
restore_search_patterns();
win_size_restore(&save_view);
ga_clear(&save_view);
@@ -6204,7 +6204,7 @@ void ex_oldfiles(exarg_T *eap)
return;
}
char *const s = (char *)expand_env_save((char_u *)p);
- eap->arg = (char_u *)s;
+ eap->arg = s;
eap->cmdidx = CMD_edit;
cmdmod.browse = false;
do_exedit(eap, NULL);
diff --git a/src/nvim/ex_cmds2.c b/src/nvim/ex_cmds2.c
index edbd850cd0..39c5670e93 100644
--- a/src/nvim/ex_cmds2.c
+++ b/src/nvim/ex_cmds2.c
@@ -100,8 +100,8 @@ void ex_profile(exarg_T *eap)
char_u *e;
int len;
- e = skiptowhite(eap->arg);
- len = (int)(e - eap->arg);
+ e = skiptowhite((char_u *)eap->arg);
+ len = (int)(e - (char_u *)eap->arg);
e = skipwhite(e);
if (len == 5 && STRNCMP(eap->arg, "start", 5) == 0 && *e != NUL) {
@@ -218,7 +218,7 @@ void set_context_in_profile_cmd(expand_T *xp, const char *arg)
// Default: expand subcommands.
xp->xp_context = EXPAND_PROFILE;
pexpand_what = PEXP_SUBCMD;
- xp->xp_pattern = (char_u *)arg;
+ xp->xp_pattern = (char *)arg;
char_u *const end_subcmd = skiptowhite((const char_u *)arg);
if (*end_subcmd == NUL) {
@@ -227,7 +227,7 @@ void set_context_in_profile_cmd(expand_T *xp, const char *arg)
if ((const char *)end_subcmd - arg == 5 && strncmp(arg, "start", 5) == 0) {
xp->xp_context = EXPAND_FILES;
- xp->xp_pattern = skipwhite((const char_u *)end_subcmd);
+ xp->xp_pattern = (char *)skipwhite((const char_u *)end_subcmd);
return;
}
@@ -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(eap->arg, AL_SET, 0, true) == FAIL) {
+ if (do_arglist((char_u *)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(eap->arg, AL_ADD, i, true) == FAIL) {
+ if (do_arglist((char_u *)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(eap->arg, AL_ADD,
+ do_arglist((char_u *)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(eap->arg, AL_DEL, 0, false);
+ do_arglist((char_u *)eap->arg, AL_DEL, 0, false);
}
maketitle();
}
@@ -1295,7 +1295,7 @@ void ex_listdo(exarg_T *eap)
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 = au_event_disable(",Syntax");
+ save_ei = (char_u *)au_event_disable(",Syntax");
FOR_ALL_BUFFERS(buf) {
buf->b_flags &= ~BF_SYN_SET;
@@ -1427,7 +1427,7 @@ void ex_listdo(exarg_T *eap)
i++;
// execute the command
if (execute) {
- do_cmdline((char *)eap->arg, eap->getline, eap->cookie, DOCMD_VERBOSE + DOCMD_NOWAIT);
+ do_cmdline(eap->arg, eap->getline, eap->cookie, DOCMD_VERBOSE + DOCMD_NOWAIT);
}
if (eap->cmdidx == CMD_bufdo) {
@@ -1508,7 +1508,7 @@ void ex_listdo(exarg_T *eap)
buf_T *bnext;
aco_save_T aco;
- au_event_restore(save_ei);
+ au_event_restore((char *)save_ei);
for (buf_T *buf = firstbuf; buf != NULL; buf = bnext) {
bnext = buf->b_next;
@@ -1657,7 +1657,7 @@ void ex_options(exarg_T *eap)
/// ":source [{fname}]"
void ex_source(exarg_T *eap)
{
- cmd_source(eap->arg, eap);
+ cmd_source((char_u *)eap->arg, eap);
}
static void cmd_source(char_u *fname, exarg_T *eap)
@@ -2207,7 +2207,7 @@ void ex_scriptnames(exarg_T *eap)
if (eap->line2 < 1 || eap->line2 > script_items.ga_len) {
emsg(_(e_invarg));
} else {
- eap->arg = SCRIPT_ITEM(eap->line2).sn_name;
+ eap->arg = (char *)SCRIPT_ITEM(eap->line2).sn_name;
do_exedit(eap, NULL);
}
return;
@@ -2575,16 +2575,16 @@ void ex_scriptencoding(exarg_T *eap)
}
if (*eap->arg != NUL) {
- name = enc_canonize(eap->arg);
+ name = enc_canonize((char_u *)eap->arg);
} else {
- name = eap->arg;
+ name = (char_u *)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);
- if (name != eap->arg) {
+ if (name != (char_u *)eap->arg) {
xfree(name);
}
}
@@ -2786,26 +2786,26 @@ void ex_language(exarg_T *eap)
# define VIM_LC_MESSAGES 6789
# endif
- name = eap->arg;
+ name = (char_u *)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(eap->arg);
- if ((*p == NUL || ascii_iswhite(*p)) && p - eap->arg >= 3) {
- if (STRNICMP(eap->arg, "messages", p - eap->arg) == 0) {
+ 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) {
what = VIM_LC_MESSAGES;
name = skipwhite(p);
whatstr = "messages ";
- } else if (STRNICMP(eap->arg, "ctype", p - eap->arg) == 0) {
+ } else if (STRNICMP(eap->arg, "ctype", p - (char_u *)eap->arg) == 0) {
what = LC_CTYPE;
name = skipwhite(p);
whatstr = "ctype ";
- } else if (STRNICMP(eap->arg, "time", p - eap->arg) == 0) {
+ } else if (STRNICMP(eap->arg, "time", p - (char_u *)eap->arg) == 0) {
what = LC_TIME;
name = skipwhite(p);
whatstr = "time ";
- } else if (STRNICMP(eap->arg, "collate", p - eap->arg) == 0) {
+ } else if (STRNICMP(eap->arg, "collate", p - (char_u *)eap->arg) == 0) {
what = LC_COLLATE;
name = skipwhite(p);
whatstr = "collate ";
@@ -2999,7 +2999,7 @@ static void script_host_execute_file(char *name, exarg_T *eap)
{
if (!eap->skip) {
uint8_t buffer[MAXPATHL];
- vim_FullName((char *)eap->arg, (char *)buffer, sizeof(buffer), false);
+ vim_FullName(eap->arg, (char *)buffer, sizeof(buffer), false);
list_T *args = tv_list_alloc(3);
// filename
@@ -3036,7 +3036,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(eap->arg, AL_SET, 0, false);
+ do_arglist((char_u *)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
diff --git a/src/nvim/ex_cmds_defs.h b/src/nvim/ex_cmds_defs.h
index f3b3e094f5..7d1ca316a1 100644
--- a/src/nvim/ex_cmds_defs.h
+++ b/src/nvim/ex_cmds_defs.h
@@ -114,7 +114,7 @@ typedef struct aucmd_executable_t AucmdExecutable;
struct aucmd_executable_t {
AucmdExecutableType type;
union {
- char_u *cmd;
+ char *cmd;
Callback cb;
} callable;
};
@@ -174,10 +174,10 @@ enum {
/// Arguments used for Ex commands.
struct exarg {
- char_u *arg; ///< argument of the command
- char_u *nextcmd; ///< next command (NULL if none)
- char *cmd; ///< the name of the command (except for :make)
- char_u **cmdlinep; ///< pointer to pointer of allocated cmdline
+ char *arg; ///< argument of the command
+ char *nextcmd; ///< next command (NULL if none)
+ char *cmd; ///< the name of the command (except for :make)
+ char **cmdlinep; ///< pointer to pointer of allocated cmdline
cmdidx_T cmdidx; ///< the index for the command
uint32_t argt; ///< flags for the command
int skip; ///< don't execute the command, only parse it
@@ -187,7 +187,7 @@ struct exarg {
linenr_T line2; ///< the second line number or count
cmd_addr_T addr_type; ///< type of the count/range
int flags; ///< extra flags after count: EXFLAG_
- char_u *do_ecmd_cmd; ///< +command arg to be used in edited file
+ char *do_ecmd_cmd; ///< +command arg to be used in edited file
linenr_T do_ecmd_lnum; ///< the line number in an edited file
int append; ///< TRUE with ":w >>file" command
int usefilter; ///< TRUE with ":w !command" and ":r!command"
@@ -201,7 +201,7 @@ struct exarg {
int useridx; ///< user command index
char *errmsg; ///< returned error message
LineGetter getline; ///< Function used to get the next line
- void *cookie; ///< argument for getline()
+ void *cookie; ///< argument for getline()
cstack_T *cstack; ///< condition stack for ":if" etc.
long verbose_save; ///< saved value of p_verbose
int save_msg_silent; ///< saved value of msg_silent
@@ -219,10 +219,10 @@ struct exarg {
// used for completion on the command line
struct expand {
- char_u *xp_pattern; // start of item to expand
+ char *xp_pattern; // start of item to expand
int xp_context; // type of expansion
size_t xp_pattern_len; // bytes in xp_pattern before cursor
- char_u *xp_arg; // completion function
+ char *xp_arg; // completion function
LuaRef xp_luaref; // Ref to Lua completion function
sctx_T xp_script_ctx; // SCTX for completion function
int xp_backslash; // one of the XP_BS_ values
@@ -232,8 +232,8 @@ struct expand {
#endif
int xp_numfiles; // number of files found by file name completion
int xp_col; // cursor position in line
- char_u **xp_files; // list of files
- char_u *xp_line; // text being completed
+ char **xp_files; // list of files
+ char *xp_line; // text being completed
};
// values for xp_backslash
@@ -256,7 +256,7 @@ typedef struct {
bool keeppatterns; ///< true when ":keeppatterns" was used
bool lockmarks; ///< true when ":lockmarks" was used
bool noswapfile; ///< true when ":noswapfile" was used
- char_u *save_ei; ///< saved value of 'eventignore'
+ char *save_ei; ///< saved value of 'eventignore'
regmatch_T filter_regmatch; ///< set by :filter /pat/
bool filter_force; ///< set for :filter!
} cmdmod_T;
diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c
index 4aa2ef6ae0..5ed058cd89 100644
--- a/src/nvim/ex_docmd.c
+++ b/src/nvim/ex_docmd.c
@@ -348,7 +348,7 @@ int do_cmdline(char *cmdline, LineGetter fgetline, void *cookie, int flags)
emsg(_("E169: Command too recursive"));
// When converting to an exception, we do not include the command name
// since this is not an error of the specific command.
- do_errthrow((cstack_T *)NULL, (char_u *)NULL);
+ do_errthrow((cstack_T *)NULL, NULL);
msg_list = saved_msg_list;
return FAIL;
}
@@ -558,7 +558,7 @@ int do_cmdline(char *cmdline, LineGetter fgetline, void *cookie, int flags)
* :endwhile/:endfor.
*/
if (current_line == lines_ga.ga_len
- && (cstack.cs_looplevel || has_loop_cmd((char_u *)next_cmdline))) {
+ && (cstack.cs_looplevel || has_loop_cmd(next_cmdline))) {
store_loop_line(&lines_ga, next_cmdline);
}
did_endif = false;
@@ -797,8 +797,7 @@ int do_cmdline(char *cmdline, LineGetter fgetline, void *cookie, int flags)
// If a missing ":endtry", ":endwhile", ":endfor", or ":endif" or a memory
// lack was reported above and the error message is to be converted to an
// exception, do this now after rewinding the cstack.
- do_errthrow(&cstack, getline_equal(fgetline, cookie, get_func_line)
- ? (char_u *)"endfunction" : (char_u *)NULL);
+ do_errthrow(&cstack, getline_equal(fgetline, cookie, get_func_line) ? "endfunction" : NULL);
if (trylevel == 0) {
// When an exception is being thrown out of the outermost try
@@ -835,7 +834,7 @@ int do_cmdline(char *cmdline, LineGetter fgetline, void *cookie, int flags)
saved_sourcing_name = (char *)sourcing_name;
saved_sourcing_lnum = sourcing_lnum;
- sourcing_name = current_exception->throw_name;
+ sourcing_name = (char_u *)current_exception->throw_name;
sourcing_lnum = current_exception->throw_lnum;
current_exception->throw_name = NULL;
@@ -1240,7 +1239,7 @@ static void set_cmd_addr_type(exarg_T *eap, char_u *p)
}
}
-/// Set default command range based on the addr type of the command
+/// Set default command range for -range=% based on the addr type of the command
static void set_cmd_default_range(exarg_T *eap)
{
buf_T *buf;
@@ -1298,6 +1297,66 @@ static void set_cmd_default_range(exarg_T *eap)
}
}
+static void parse_register(exarg_T *eap)
+{
+ // Accept numbered register only when no count allowed (:put)
+ if ((eap->argt & EX_REGSTR)
+ && *eap->arg != NUL
+ // Do not allow register = for user commands
+ && (!IS_USER_CMDIDX(eap->cmdidx) || *eap->arg != '=')
+ && !((eap->argt & EX_COUNT) && ascii_isdigit(*eap->arg))) {
+ if (valid_yank_reg(*eap->arg, (eap->cmdidx != CMD_put
+ && !IS_USER_CMDIDX(eap->cmdidx)))) {
+ eap->regname = (uint8_t)(*eap->arg++);
+ // for '=' register: accept the rest of the line as an expression
+ if (eap->arg[-1] == '=' && eap->arg[0] != NUL) {
+ if (!eap->skip) {
+ set_expr_line(vim_strsave((char_u *)eap->arg));
+ }
+ eap->arg += STRLEN(eap->arg);
+ }
+ eap->arg = (char *)skipwhite((char_u *)eap->arg);
+ }
+ }
+}
+
+static int parse_count(exarg_T *eap, char **errormsg)
+{
+ // Check for a count. When accepting a EX_BUFNAME, don't use "123foo" as a
+ // count, it's a buffer name.
+ char *p;
+ long n;
+
+ if ((eap->argt & EX_COUNT) && ascii_isdigit(*eap->arg)
+ && (!(eap->argt & EX_BUFNAME) || *(p = (char *)skipdigits((char_u *)eap->arg + 1)) == NUL
+ || ascii_iswhite(*p))) {
+ n = getdigits_long((char_u **)&eap->arg, false, -1);
+ eap->arg = (char *)skipwhite((char_u *)eap->arg);
+ if (n <= 0 && (eap->argt & EX_ZEROR) == 0) {
+ if (errormsg != NULL) {
+ *errormsg = _(e_zerocount);
+ }
+ return FAIL;
+ }
+ if (eap->addr_type != ADDR_LINES) { // e.g. :buffer 2, :sleep 3
+ eap->line2 = n;
+ if (eap->addr_count == 0) {
+ eap->addr_count = 1;
+ }
+ } else {
+ eap->line1 = eap->line2;
+ eap->line2 += n - 1;
+ eap->addr_count++;
+ // Be vi compatible: no error message for out of range.
+ if (eap->line2 > curbuf->b_ml.ml_line_count) {
+ eap->line2 = curbuf->b_ml.ml_line_count;
+ }
+ }
+ }
+
+ return OK;
+}
+
/// Parse command line and return information about the first command.
///
/// @return Success or failure
@@ -1316,7 +1375,7 @@ bool parse_cmdline(char_u *cmdline, exarg_T *eap, CmdParseInfo *cmdinfo)
eap->line1 = 1;
eap->line2 = 1;
eap->cmd = (char *)cmdline;
- eap->cmdlinep = &cmdline;
+ eap->cmdlinep = (char **)&cmdline;
eap->getline = NULL;
eap->cookie = NULL;
@@ -1339,12 +1398,14 @@ bool parse_cmdline(char_u *cmdline, exarg_T *eap, CmdParseInfo *cmdinfo)
}
if (cmdmod.save_ei != NULL) {
cmdinfo->noautocmd = true;
- set_string_option_direct("ei", -1, cmdmod.save_ei, OPT_FREE, SID_NONE);
- free_string_option(cmdmod.save_ei);
+ set_string_option_direct("ei", -1, (char_u *)cmdmod.save_ei, OPT_FREE, SID_NONE);
+ free_string_option((char_u *)cmdmod.save_ei);
}
if (eap->verbose_save != -1) {
cmdinfo->verbose = p_verbose;
p_verbose = eap->verbose_save;
+ } else {
+ cmdinfo->verbose = -1;
}
cmdinfo->cmdmod = cmdmod;
cmdmod = save_cmdmod;
@@ -1392,9 +1453,9 @@ bool parse_cmdline(char_u *cmdline, exarg_T *eap, CmdParseInfo *cmdinfo)
// Skip to start of argument.
// Don't do this for the ":!" command, because ":!! -l" needs the space.
if (eap->cmdidx == CMD_bang) {
- eap->arg = (char_u *)p;
+ eap->arg = p;
} else {
- eap->arg = skipwhite((char_u *)p);
+ eap->arg = (char *)skipwhite((char_u *)p);
}
// Don't treat ":r! filter" like a bang
@@ -1422,9 +1483,15 @@ bool parse_cmdline(char_u *cmdline, exarg_T *eap, CmdParseInfo *cmdinfo)
set_cmd_default_range(eap);
}
+ // Parse register and count
+ parse_register(eap);
+ if (parse_count(eap, NULL) == FAIL) {
+ return false;
+ }
+
// Remove leading whitespace and colon from next command
if (eap->nextcmd) {
- eap->nextcmd = (char_u *)skip_colon_white((char *)eap->nextcmd, true);
+ eap->nextcmd = skip_colon_white(eap->nextcmd, true);
}
// Set the "magic" values (characters that get treated specially)
@@ -1460,7 +1527,6 @@ static char *do_one_cmd(char **cmdlinep, int flags, cstack_T *cstack, LineGetter
{
char *p;
linenr_T lnum;
- long n;
char *errormsg = NULL; // error message
char *after_modifier = NULL;
exarg_T ea;
@@ -1501,7 +1567,7 @@ static char *do_one_cmd(char **cmdlinep, int flags, cstack_T *cstack, LineGetter
// The "ea" structure holds the arguments that can be used.
ea.cmd = *cmdlinep;
- ea.cmdlinep = (char_u **)cmdlinep;
+ ea.cmdlinep = cmdlinep;
ea.getline = fgetline;
ea.cookie = cookie;
ea.cstack = cstack;
@@ -1604,7 +1670,7 @@ static char *do_one_cmd(char **cmdlinep, int flags, cstack_T *cstack, LineGetter
* If we find a '|' or '\n' we set ea.nextcmd.
*/
if (*ea.cmd == NUL || *ea.cmd == '"'
- || (ea.nextcmd = check_nextcmd((char_u *)ea.cmd)) != NULL) {
+ || (ea.nextcmd = (char *)check_nextcmd((char_u *)ea.cmd)) != NULL) {
// strange vi behaviour:
// ":3" jumps to line 3
// ":3|..." prints line 3
@@ -1800,9 +1866,9 @@ static char *do_one_cmd(char **cmdlinep, int flags, cstack_T *cstack, LineGetter
* Don't do this for the ":!" command, because ":!! -l" needs the space.
*/
if (ea.cmdidx == CMD_bang) {
- ea.arg = (char_u *)p;
+ ea.arg = p;
} else {
- ea.arg = skipwhite((char_u *)p);
+ ea.arg = (char *)skipwhite((char_u *)p);
}
// ":file" cannot be run with an argument when "curbuf->b_ro_locked" is set
@@ -1829,8 +1895,8 @@ static char *do_one_cmd(char **cmdlinep, int flags, cstack_T *cstack, LineGetter
errormsg = _("E494: Use w or w>>");
goto doend;
}
- ea.arg = skipwhite(ea.arg + 1);
- ea.append = TRUE;
+ ea.arg = (char *)skipwhite((char_u *)ea.arg + 1);
+ ea.append = true;
} else if (*ea.arg == '!' && ea.cmdidx == CMD_write) { // :w !filter
++ea.arg;
ea.usefilter = TRUE;
@@ -1849,11 +1915,11 @@ static char *do_one_cmd(char **cmdlinep, int flags, cstack_T *cstack, LineGetter
if (ea.cmdidx == CMD_lshift || ea.cmdidx == CMD_rshift) {
ea.amount = 1;
- while (*ea.arg == (char_u)(*ea.cmd)) { // count number of '>' or '<'
+ while (*ea.arg == *ea.cmd) { // count number of '>' or '<'
ea.arg++;
ea.amount++;
}
- ea.arg = skipwhite(ea.arg);
+ ea.arg = (char *)skipwhite((char_u *)ea.arg);
}
/*
@@ -1861,7 +1927,7 @@ static char *do_one_cmd(char **cmdlinep, int flags, cstack_T *cstack, LineGetter
* Don't do this for ":read !cmd" and ":write !cmd".
*/
if ((ea.argt & EX_CMDARG) && !ea.usefilter) {
- ea.do_ecmd_cmd = (char_u *)getargcmd((char **)&ea.arg);
+ ea.do_ecmd_cmd = getargcmd(&ea.arg);
}
/*
@@ -1878,7 +1944,7 @@ static char *do_one_cmd(char **cmdlinep, int flags, cstack_T *cstack, LineGetter
// Check for <newline> to end a shell command.
// Also do this for ":read !cmd", ":write !cmd" and ":global".
// Any others?
- for (p = (char *)ea.arg; *p; p++) {
+ for (p = ea.arg; *p; p++) {
// Remove one backslash before a newline, so that it's possible to
// pass a newline to the shell and also a newline that is preceded
// with a backslash. This makes it impossible to end a shell
@@ -1888,7 +1954,7 @@ static char *do_one_cmd(char **cmdlinep, int flags, cstack_T *cstack, LineGetter
if (*p == '\\' && p[1] == '\n') {
STRMOVE(p, p + 1);
} else if (*p == '\n') {
- ea.nextcmd = (char_u *)p + 1;
+ ea.nextcmd = p + 1;
*p = NUL;
break;
}
@@ -1899,53 +1965,10 @@ static char *do_one_cmd(char **cmdlinep, int flags, cstack_T *cstack, LineGetter
set_cmd_default_range(&ea);
}
- // accept numbered register only when no count allowed (:put)
- if ((ea.argt & EX_REGSTR)
- && *ea.arg != NUL
- // Do not allow register = for user commands
- && (!IS_USER_CMDIDX(ea.cmdidx) || *ea.arg != '=')
- && !((ea.argt & EX_COUNT) && ascii_isdigit(*ea.arg))) {
- if (valid_yank_reg(*ea.arg, (ea.cmdidx != CMD_put
- && !IS_USER_CMDIDX(ea.cmdidx)))) {
- ea.regname = *ea.arg++;
- // for '=' register: accept the rest of the line as an expression
- if (ea.arg[-1] == '=' && ea.arg[0] != NUL) {
- if (!ea.skip) {
- set_expr_line(vim_strsave(ea.arg));
- }
- ea.arg += STRLEN(ea.arg);
- }
- ea.arg = skipwhite(ea.arg);
- }
- }
-
- //
- // Check for a count. When accepting a EX_BUFNAME, don't use "123foo" as a
- // count, it's a buffer name.
- ///
- if ((ea.argt & EX_COUNT) && ascii_isdigit(*ea.arg)
- && (!(ea.argt & EX_BUFNAME) || *(p = (char *)skipdigits(ea.arg + 1)) == NUL
- || ascii_iswhite(*p))) {
- n = getdigits_long(&ea.arg, false, -1);
- ea.arg = skipwhite(ea.arg);
- if (n <= 0 && !ni && (ea.argt & EX_ZEROR) == 0) {
- errormsg = _(e_zerocount);
- goto doend;
- }
- if (ea.addr_type != ADDR_LINES) { // e.g. :buffer 2, :sleep 3
- ea.line2 = n;
- if (ea.addr_count == 0) {
- ea.addr_count = 1;
- }
- } else {
- ea.line1 = ea.line2;
- ea.line2 += n - 1;
- ++ea.addr_count;
- // Be vi compatible: no error message for out of range.
- if (ea.line2 > curbuf->b_ml.ml_line_count) {
- ea.line2 = curbuf->b_ml.ml_line_count;
- }
- }
+ // Parse register and count
+ parse_register(&ea);
+ if (parse_count(&ea, &errormsg) == FAIL) {
+ goto doend;
}
/*
@@ -2083,20 +2106,20 @@ static char *do_one_cmd(char **cmdlinep, int flags, cstack_T *cstack, LineGetter
*/
if (ea.cmdidx == CMD_bdelete || ea.cmdidx == CMD_bwipeout
|| ea.cmdidx == CMD_bunload) {
- p = (char *)skiptowhite_esc(ea.arg);
+ p = (char *)skiptowhite_esc((char_u *)ea.arg);
} else {
- p = (char *)ea.arg + STRLEN(ea.arg);
- while ((char_u *)p > ea.arg && ascii_iswhite(p[-1])) {
+ p = ea.arg + STRLEN(ea.arg);
+ while (p > ea.arg && ascii_iswhite(p[-1])) {
p--;
}
}
- ea.line2 = buflist_findpat(ea.arg, (char_u *)p, (ea.argt & EX_BUFUNL) != 0,
+ ea.line2 = buflist_findpat((char_u *)ea.arg, (char_u *)p, (ea.argt & EX_BUFUNL) != 0,
false, false);
if (ea.line2 < 0) { // failed
goto doend;
}
ea.addr_count = 1;
- ea.arg = skipwhite((char_u *)p);
+ ea.arg = (char *)skipwhite((char_u *)p);
}
// The :try command saves the emsg_silent flag, reset it here when
@@ -2163,9 +2186,8 @@ doend:
emsg(errormsg);
}
do_errthrow(cstack,
- (ea.cmdidx != CMD_SIZE && !IS_USER_CMDIDX(ea.cmdidx))
- ? cmdnames[(int)ea.cmdidx].cmd_name
- : (char_u *)NULL);
+ (ea.cmdidx != CMD_SIZE
+ && !IS_USER_CMDIDX(ea.cmdidx)) ? (char *)cmdnames[(int)ea.cmdidx].cmd_name : NULL);
undo_cmdmod(&ea, save_msg_scroll);
cmdmod = save_cmdmod;
@@ -2182,7 +2204,7 @@ doend:
--ex_nesting_level;
- return (char *)ea.nextcmd;
+ return ea.nextcmd;
} // NOLINT(readability/fn_size)
static char ex_error_buf[MSG_BUF_LEN];
@@ -2358,9 +2380,8 @@ int parse_command_modifiers(exarg_T *eap, char **errormsg, bool skip_only)
if (cmdmod.save_ei == NULL && !skip_only) {
// Set 'eventignore' to "all". Restore the
// existing option value later.
- cmdmod.save_ei = vim_strsave(p_ei);
- set_string_option_direct("ei", -1,
- (char_u *)"all", OPT_FREE, SID_NONE);
+ cmdmod.save_ei = (char *)vim_strsave(p_ei);
+ set_string_option_direct("ei", -1, (char_u *)"all", OPT_FREE, SID_NONE);
}
continue;
}
@@ -2480,8 +2501,8 @@ static void undo_cmdmod(const exarg_T *eap, int save_msg_scroll)
if (cmdmod.save_ei != NULL) {
// Restore 'eventignore' to the value before ":noautocmd".
- set_string_option_direct("ei", -1, cmdmod.save_ei, OPT_FREE, SID_NONE);
- free_string_option(cmdmod.save_ei);
+ set_string_option_direct("ei", -1, (char_u *)cmdmod.save_ei, OPT_FREE, SID_NONE);
+ free_string_option((char_u *)cmdmod.save_ei);
}
vim_regfree(cmdmod.filter_regmatch.regprog);
@@ -2919,7 +2940,7 @@ static char *find_ucmd(exarg_T *eap, char *p, int *full, expand_T *xp, int *comp
}
if (xp != NULL) {
xp->xp_luaref = uc->uc_compl_luaref;
- xp->xp_arg = uc->uc_compl_arg;
+ xp->xp_arg = (char *)uc->uc_compl_arg;
xp->xp_script_ctx = uc->uc_script_ctx;
xp->xp_script_ctx.sc_lnum += sourcing_lnum;
}
@@ -3099,15 +3120,15 @@ const char *set_one_cmd_context(expand_T *xp, const char *buff)
bool usefilter = false; // Filter instead of file name.
ExpandInit(xp);
- xp->xp_pattern = (char_u *)buff;
- xp->xp_line = (char_u *)buff;
+ xp->xp_pattern = (char *)buff;
+ xp->xp_line = (char *)buff;
xp->xp_context = EXPAND_COMMANDS; // Default until we get past command
ea.argt = 0;
// 2. skip comment lines and leading space, colons or bars
const char *cmd;
for (cmd = buff; vim_strchr((const char_u *)" \t:|", *cmd) != NULL; cmd++) {}
- xp->xp_pattern = (char_u *)cmd;
+ xp->xp_pattern = (char *)cmd;
if (*cmd == NUL) {
return NULL;
@@ -3125,7 +3146,7 @@ const char *set_one_cmd_context(expand_T *xp, const char *buff)
/*
* 4. parse command
*/
- xp->xp_pattern = (char_u *)cmd;
+ xp->xp_pattern = (char *)cmd;
if (*cmd == NUL) {
return NULL;
}
@@ -3319,12 +3340,12 @@ const char *set_one_cmd_context(expand_T *xp, const char *buff)
// Find start of last argument (argument just before cursor):
p = buff;
- xp->xp_pattern = (char_u *)p;
+ xp->xp_pattern = (char *)p;
len = strlen(buff);
while (*p && p < buff + len) {
if (*p == ' ' || *p == TAB) {
// Argument starts after a space.
- xp->xp_pattern = (char_u *)++p;
+ xp->xp_pattern = (char *)++p;
} else {
if (*p == '\\' && *(p + 1) != NUL) {
p++; // skip over escaped character
@@ -3342,7 +3363,7 @@ const char *set_one_cmd_context(expand_T *xp, const char *buff)
* Allow spaces within back-quotes to count as part of the argument
* being expanded.
*/
- xp->xp_pattern = skipwhite((const char_u *)arg);
+ xp->xp_pattern = (char *)skipwhite((const char_u *)arg);
p = (const char *)xp->xp_pattern;
while (*p != NUL) {
c = utf_ptr2char((const char_u *)p);
@@ -3350,7 +3371,7 @@ const char *set_one_cmd_context(expand_T *xp, const char *buff)
p++;
} else if (c == '`') {
if (!in_quote) {
- xp->xp_pattern = (char_u *)p;
+ xp->xp_pattern = (char *)p;
bow = p + 1;
}
in_quote = !in_quote;
@@ -3373,7 +3394,7 @@ const char *set_one_cmd_context(expand_T *xp, const char *buff)
if (in_quote) {
bow = p;
} else {
- xp->xp_pattern = (char_u *)p;
+ xp->xp_pattern = (char *)p;
}
p -= len;
}
@@ -3385,7 +3406,7 @@ const char *set_one_cmd_context(expand_T *xp, const char *buff)
* expand from there.
*/
if (bow != NULL && in_quote) {
- xp->xp_pattern = (char_u *)bow;
+ xp->xp_pattern = (char *)bow;
}
xp->xp_context = EXPAND_FILES;
@@ -3395,7 +3416,7 @@ const char *set_one_cmd_context(expand_T *xp, const char *buff)
xp->xp_shell = TRUE;
#endif
// When still after the command name expand executables.
- if (xp->xp_pattern == skipwhite((const char_u *)arg)) {
+ if ((char_u *)xp->xp_pattern == skipwhite((const char_u *)arg)) {
xp->xp_context = EXPAND_SHELLCMD;
}
}
@@ -3423,7 +3444,7 @@ const char *set_one_cmd_context(expand_T *xp, const char *buff)
// A full match ~user<Tab> will be replaced by user's home
// directory i.e. something like ~user<Tab> -> /home/user/
if (*p == NUL && p > (const char *)xp->xp_pattern + 1
- && match_user(xp->xp_pattern + 1) >= 1) {
+ && match_user((char_u *)xp->xp_pattern + 1) >= 1) {
xp->xp_context = EXPAND_USER;
++xp->xp_pattern;
}
@@ -3453,7 +3474,7 @@ const char *set_one_cmd_context(expand_T *xp, const char *buff)
break;
case CMD_help:
xp->xp_context = EXPAND_HELP;
- xp->xp_pattern = (char_u *)arg;
+ xp->xp_pattern = (char *)arg;
break;
/* Command modifiers: return the argument.
@@ -3530,7 +3551,7 @@ const char *set_one_cmd_context(expand_T *xp, const char *buff)
if (p == NULL) {
// No "=", so complete attribute names.
xp->xp_context = EXPAND_USER_CMD_FLAGS;
- xp->xp_pattern = (char_u *)arg;
+ xp->xp_pattern = (char *)arg;
return NULL;
}
@@ -3538,15 +3559,15 @@ const char *set_one_cmd_context(expand_T *xp, const char *buff)
// their arguments as well.
if (STRNICMP(arg, "complete", p - arg) == 0) {
xp->xp_context = EXPAND_USER_COMPLETE;
- xp->xp_pattern = (char_u *)p + 1;
+ xp->xp_pattern = (char *)p + 1;
return NULL;
} else if (STRNICMP(arg, "nargs", p - arg) == 0) {
xp->xp_context = EXPAND_USER_NARGS;
- xp->xp_pattern = (char_u *)p + 1;
+ xp->xp_pattern = (char *)p + 1;
return NULL;
} else if (STRNICMP(arg, "addr", p - arg) == 0) {
xp->xp_context = EXPAND_USER_ADDR_TYPE;
- xp->xp_pattern = (char_u *)p + 1;
+ xp->xp_pattern = (char *)p + 1;
return NULL;
}
return NULL;
@@ -3558,7 +3579,7 @@ const char *set_one_cmd_context(expand_T *xp, const char *buff)
p = (const char *)skiptowhite((const char_u *)arg);
if (*p == NUL) {
xp->xp_context = EXPAND_USER_COMMANDS;
- xp->xp_pattern = (char_u *)arg;
+ xp->xp_pattern = (char *)arg;
break;
}
@@ -3567,7 +3588,7 @@ const char *set_one_cmd_context(expand_T *xp, const char *buff)
case CMD_delcommand:
xp->xp_context = EXPAND_USER_COMMANDS;
- xp->xp_pattern = (char_u *)arg;
+ xp->xp_pattern = (char *)arg;
break;
case CMD_global:
@@ -3644,11 +3665,11 @@ const char *set_one_cmd_context(expand_T *xp, const char *buff)
}
break;
case CMD_autocmd:
- return (const char *)set_context_in_autocmd(xp, (char_u *)arg, false);
+ return (const char *)set_context_in_autocmd(xp, (char *)arg, false);
case CMD_doautocmd:
case CMD_doautoall:
- return (const char *)set_context_in_autocmd(xp, (char_u *)arg, true);
+ return (const char *)set_context_in_autocmd(xp, (char *)arg, true);
case CMD_set:
set_context_in_set_cmd(xp, (char_u *)arg, 0);
break;
@@ -3673,11 +3694,11 @@ const char *set_one_cmd_context(expand_T *xp, const char *buff)
} else {
xp->xp_context = EXPAND_TAGS;
}
- xp->xp_pattern = (char_u *)arg;
+ xp->xp_pattern = (char *)arg;
break;
case CMD_augroup:
xp->xp_context = EXPAND_AUGROUP;
- xp->xp_pattern = (char_u *)arg;
+ xp->xp_pattern = (char *)arg;
break;
case CMD_syntax:
set_context_in_syntax_cmd(xp, arg);
@@ -3705,12 +3726,12 @@ const char *set_one_cmd_context(expand_T *xp, const char *buff)
break;
case CMD_unlet:
- while ((xp->xp_pattern = (char_u *)strchr(arg, ' ')) != NULL) {
+ while ((xp->xp_pattern = strchr(arg, ' ')) != NULL) {
arg = (const char *)xp->xp_pattern + 1;
}
xp->xp_context = EXPAND_USER_VARS;
- xp->xp_pattern = (char_u *)arg;
+ xp->xp_pattern = (char *)arg;
if (*xp->xp_pattern == '$') {
xp->xp_context = EXPAND_ENV_VARS;
@@ -3722,7 +3743,7 @@ const char *set_one_cmd_context(expand_T *xp, const char *buff)
case CMD_function:
case CMD_delfunction:
xp->xp_context = EXPAND_USER_FUNC;
- xp->xp_pattern = (char_u *)arg;
+ xp->xp_pattern = (char *)arg;
break;
case CMD_echohl:
@@ -3742,7 +3763,7 @@ const char *set_one_cmd_context(expand_T *xp, const char *buff)
case CMD_bdelete:
case CMD_bwipeout:
case CMD_bunload:
- while ((xp->xp_pattern = (char_u *)strchr(arg, ' ')) != NULL) {
+ while ((xp->xp_pattern = strchr(arg, ' ')) != NULL) {
arg = (const char *)xp->xp_pattern + 1;
}
FALLTHROUGH;
@@ -3750,14 +3771,14 @@ const char *set_one_cmd_context(expand_T *xp, const char *buff)
case CMD_sbuffer:
case CMD_checktime:
xp->xp_context = EXPAND_BUFFERS;
- xp->xp_pattern = (char_u *)arg;
+ xp->xp_pattern = (char *)arg;
break;
case CMD_diffget:
case CMD_diffput:
// If current buffer is in diff mode, complete buffer names
// which are in diff mode, and different than current buffer.
xp->xp_context = EXPAND_DIFF_BUFFERS;
- xp->xp_pattern = (char_u *)arg;
+ xp->xp_pattern = (char *)arg;
break;
case CMD_USER:
case CMD_USER_BUF:
@@ -3784,7 +3805,7 @@ const char *set_one_cmd_context(expand_T *xp, const char *buff)
}
MB_PTR_ADV(p);
}
- xp->xp_pattern = (char_u *)arg;
+ xp->xp_pattern = (char *)arg;
}
xp->xp_context = context;
}
@@ -3830,7 +3851,7 @@ const char *set_one_cmd_context(expand_T *xp, const char *buff)
case CMD_smapclear:
case CMD_xmapclear:
xp->xp_context = EXPAND_MAPCLEAR;
- xp->xp_pattern = (char_u *)arg;
+ xp->xp_pattern = (char *)arg;
break;
case CMD_abbreviate:
@@ -3875,27 +3896,27 @@ const char *set_one_cmd_context(expand_T *xp, const char *buff)
case CMD_colorscheme:
xp->xp_context = EXPAND_COLORS;
- xp->xp_pattern = (char_u *)arg;
+ xp->xp_pattern = (char *)arg;
break;
case CMD_compiler:
xp->xp_context = EXPAND_COMPILER;
- xp->xp_pattern = (char_u *)arg;
+ xp->xp_pattern = (char *)arg;
break;
case CMD_ownsyntax:
xp->xp_context = EXPAND_OWNSYNTAX;
- xp->xp_pattern = (char_u *)arg;
+ xp->xp_pattern = (char *)arg;
break;
case CMD_setfiletype:
xp->xp_context = EXPAND_FILETYPE;
- xp->xp_pattern = (char_u *)arg;
+ xp->xp_pattern = (char *)arg;
break;
case CMD_packadd:
xp->xp_context = EXPAND_PACKADD;
- xp->xp_pattern = (char_u *)arg;
+ xp->xp_pattern = (char *)arg;
break;
#ifdef HAVE_WORKING_LIBINTL
@@ -3903,14 +3924,14 @@ const char *set_one_cmd_context(expand_T *xp, const char *buff)
p = (const char *)skiptowhite((const char_u *)arg);
if (*p == NUL) {
xp->xp_context = EXPAND_LANGUAGE;
- xp->xp_pattern = (char_u *)arg;
+ xp->xp_pattern = (char *)arg;
} else {
if (strncmp(arg, "messages", (size_t)(p - arg)) == 0
|| strncmp(arg, "ctype", (size_t)(p - arg)) == 0
|| strncmp(arg, "time", (size_t)(p - arg)) == 0
|| strncmp(arg, "collate", (size_t)(p - arg)) == 0) {
xp->xp_context = EXPAND_LOCALES;
- xp->xp_pattern = skipwhite((const char_u *)p);
+ xp->xp_pattern = (char *)skipwhite((const char_u *)p);
} else {
xp->xp_context = EXPAND_NOTHING;
}
@@ -3922,33 +3943,33 @@ const char *set_one_cmd_context(expand_T *xp, const char *buff)
break;
case CMD_checkhealth:
xp->xp_context = EXPAND_CHECKHEALTH;
- xp->xp_pattern = (char_u *)arg;
+ xp->xp_pattern = (char *)arg;
break;
case CMD_behave:
xp->xp_context = EXPAND_BEHAVE;
- xp->xp_pattern = (char_u *)arg;
+ xp->xp_pattern = (char *)arg;
break;
case CMD_messages:
xp->xp_context = EXPAND_MESSAGES;
- xp->xp_pattern = (char_u *)arg;
+ xp->xp_pattern = (char *)arg;
break;
case CMD_history:
xp->xp_context = EXPAND_HISTORY;
- xp->xp_pattern = (char_u *)arg;
+ xp->xp_pattern = (char *)arg;
break;
case CMD_syntime:
xp->xp_context = EXPAND_SYNTIME;
- xp->xp_pattern = (char_u *)arg;
+ xp->xp_pattern = (char *)arg;
break;
case CMD_argdelete:
- while ((xp->xp_pattern = vim_strchr((const char_u *)arg, ' ')) != NULL) {
+ while ((xp->xp_pattern = (char *)vim_strchr((const char_u *)arg, ' ')) != NULL) {
arg = (const char *)(xp->xp_pattern + 1);
}
xp->xp_context = EXPAND_ARGLIST;
- xp->xp_pattern = (char_u *)arg;
+ xp->xp_pattern = (char *)arg;
break;
case CMD_lua:
@@ -4353,7 +4374,7 @@ static void get_flags(exarg_T *eap)
} else {
eap->flags |= EXFLAG_NR;
}
- eap->arg = skipwhite(eap->arg + 1);
+ eap->arg = (char *)skipwhite((char_u *)eap->arg + 1);
}
}
@@ -4483,7 +4504,7 @@ static void correct_range(exarg_T *eap)
/// pattern. Otherwise return eap->arg.
static char *skip_grep_pat(exarg_T *eap)
{
- char *p = (char *)eap->arg;
+ char *p = eap->arg;
if (*p != NUL && (eap->cmdidx == CMD_vimgrep || eap->cmdidx == CMD_lvimgrep
|| eap->cmdidx == CMD_vimgrepadd
@@ -4491,7 +4512,7 @@ static char *skip_grep_pat(exarg_T *eap)
|| grep_internal(eap->cmdidx))) {
p = skip_vimgrep_pat(p, NULL, NULL);
if (p == NULL) {
- p = (char *)eap->arg;
+ p = eap->arg;
}
}
return p;
@@ -4609,7 +4630,7 @@ int expand_filename(exarg_T *eap, char_u **cmdlinep, char **errormsgp)
/*
* Try to find a match at this position.
*/
- repl = (char *)eval_vars((char_u *)p, eap->arg, &srclen, &(eap->do_ecmd_lnum),
+ repl = (char *)eval_vars((char_u *)p, (char_u *)eap->arg, &srclen, &(eap->do_ecmd_lnum),
errormsgp, &escaped);
if (*errormsgp != NULL) { // error detected
return FAIL;
@@ -4694,16 +4715,16 @@ int expand_filename(exarg_T *eap, char_u **cmdlinep, char **errormsgp)
* After expanding environment variables, check again
* if there are still wildcards present.
*/
- if (vim_strchr(eap->arg, '$') != NULL
- || vim_strchr(eap->arg, '~') != NULL) {
- expand_env_esc(eap->arg, NameBuff, MAXPATHL, true, true, NULL);
+ if (vim_strchr((char_u *)eap->arg, '$') != NULL
+ || vim_strchr((char_u *)eap->arg, '~') != NULL) {
+ expand_env_esc((char_u *)eap->arg, NameBuff, MAXPATHL, true, true, NULL);
has_wildcards = path_has_wildcard(NameBuff);
p = (char *)NameBuff;
} else {
p = NULL;
}
if (p != NULL) {
- (void)repl_cmdline(eap, (char *)eap->arg, STRLEN(eap->arg), p, (char **)cmdlinep);
+ (void)repl_cmdline(eap, eap->arg, STRLEN(eap->arg), p, (char **)cmdlinep);
}
}
@@ -4715,7 +4736,7 @@ int expand_filename(exarg_T *eap, char_u **cmdlinep, char **errormsgp)
#ifdef UNIX
if (!has_wildcards)
#endif
- backslash_halve(eap->arg);
+ backslash_halve((char_u *)eap->arg);
if (has_wildcards) {
expand_T xpc;
@@ -4726,11 +4747,11 @@ int expand_filename(exarg_T *eap, char_u **cmdlinep, char **errormsgp)
if (p_wic) {
options += WILD_ICASE;
}
- p = (char *)ExpandOne(&xpc, eap->arg, NULL, options, WILD_EXPAND_FREE);
+ p = (char *)ExpandOne(&xpc, (char_u *)eap->arg, NULL, options, WILD_EXPAND_FREE);
if (p == NULL) {
return FAIL;
}
- (void)repl_cmdline(eap, (char *)eap->arg, STRLEN(eap->arg), p, (char **)cmdlinep);
+ (void)repl_cmdline(eap, eap->arg, STRLEN(eap->arg), p, (char **)cmdlinep);
xfree(p);
}
}
@@ -4774,12 +4795,12 @@ static char *repl_cmdline(exarg_T *eap, char *src, size_t srclen, char *repl, ch
if (eap->nextcmd != NULL) { // append next command
i = STRLEN(new_cmdline) + 1;
STRCPY(new_cmdline + i, eap->nextcmd);
- eap->nextcmd = (char_u *)new_cmdline + i;
+ eap->nextcmd = new_cmdline + i;
}
eap->cmd = new_cmdline + (eap->cmd - *cmdlinep);
- eap->arg = (char_u *)new_cmdline + ((char *)eap->arg - *cmdlinep);
- if (eap->do_ecmd_cmd != NULL && eap->do_ecmd_cmd != (char_u *)dollar_command) {
- eap->do_ecmd_cmd = (char_u *)new_cmdline + ((char *)eap->do_ecmd_cmd - *cmdlinep);
+ eap->arg = new_cmdline + (eap->arg - *cmdlinep);
+ if (eap->do_ecmd_cmd != NULL && eap->do_ecmd_cmd != dollar_command) {
+ eap->do_ecmd_cmd = new_cmdline + (eap->do_ecmd_cmd - *cmdlinep);
}
xfree(*cmdlinep);
*cmdlinep = new_cmdline;
@@ -4816,9 +4837,9 @@ void separate_nextcmd(exarg_T *eap)
// :redir @" doesn't either.
(*p == '"'
&& !(eap->argt & EX_NOTRLCOM)
- && (eap->cmdidx != CMD_at || (char_u *)p != eap->arg)
+ && (eap->cmdidx != CMD_at || p != eap->arg)
&& (eap->cmdidx != CMD_redir
- || (char_u *)p != eap->arg + 1 || p[-1] != '@')) || *p == '|' || *p == '\n') {
+ || p != eap->arg + 1 || p[-1] != '@')) || *p == '|' || *p == '\n') {
// We remove the '\' before the '|', unless EX_CTRLV is used
// AND 'b' is present in 'cpoptions'.
if ((vim_strchr(p_cpo, CPO_BAR) == NULL
@@ -4826,7 +4847,7 @@ void separate_nextcmd(exarg_T *eap)
STRMOVE(p - 1, p); // remove the '\'
p--;
} else {
- eap->nextcmd = check_nextcmd((char_u *)p);
+ eap->nextcmd = (char *)check_nextcmd((char_u *)p);
*p = NUL;
break;
}
@@ -4834,7 +4855,7 @@ void separate_nextcmd(exarg_T *eap)
}
if (!(eap->argt & EX_NOTRLCOM)) { // remove trailing spaces
- del_trailing_spaces(eap->arg);
+ del_trailing_spaces((char_u *)eap->arg);
}
}
@@ -4900,7 +4921,7 @@ int get_bad_opt(const char_u *p, exarg_T *eap)
/// @return FAIL or OK.
static int getargopt(exarg_T *eap)
{
- char *arg = (char *)eap->arg + 2;
+ char *arg = eap->arg + 2;
int *pp = NULL;
int bad_char_idx;
char *p;
@@ -4916,14 +4937,14 @@ static int getargopt(exarg_T *eap)
if (!checkforcmd(&arg, "binary", 3)) {
return FAIL;
}
- eap->arg = skipwhite((char_u *)arg);
+ eap->arg = (char *)skipwhite((char_u *)arg);
return OK;
}
// ":read ++edit file"
if (STRNCMP(arg, "edit", 4) == 0) {
eap->read_edit = true;
- eap->arg = skipwhite((char_u *)arg + 4);
+ eap->arg = (char *)skipwhite((char_u *)arg + 4);
return OK;
}
@@ -4952,7 +4973,7 @@ static int getargopt(exarg_T *eap)
arg++;
*pp = (int)(arg - eap->cmd);
arg = skip_cmd_arg(arg, false);
- eap->arg = skipwhite((char_u *)arg);
+ eap->arg = (char *)skipwhite((char_u *)arg);
*arg = NUL;
if (pp == &eap->force_ff) {
@@ -4986,7 +5007,7 @@ static int get_tabpage_arg(exarg_T *eap)
int unaccept_arg0 = (eap->cmdidx == CMD_tabmove) ? 0 : 1;
if (eap->arg && *eap->arg != NUL) {
- char *p = (char *)eap->arg;
+ char *p = eap->arg;
char *p_save;
int relative = 0; // argument +N/-N means: go to N places to the
// right/left relative to the current position.
@@ -5009,7 +5030,7 @@ static int get_tabpage_arg(exarg_T *eap)
if (valid_tabpage(lastused_tabpage)) {
tab_number = tabpage_index(lastused_tabpage);
} else {
- eap->errmsg = ex_errmsg(e_invargval, (char *)eap->arg);
+ eap->errmsg = ex_errmsg(e_invargval, eap->arg);
tab_number = 0;
goto theend;
}
@@ -5041,7 +5062,7 @@ static int get_tabpage_arg(exarg_T *eap)
tab_number = 0;
} else {
tab_number = (int)eap->line2;
- if (!unaccept_arg0 && *skipwhite(*eap->cmdlinep) == '-') {
+ if (!unaccept_arg0 && *skipwhite((char_u *)(*eap->cmdlinep)) == '-') {
tab_number--;
if (tab_number < unaccept_arg0) {
eap->errmsg = e_invarg;
@@ -5098,13 +5119,13 @@ static void ex_unmap(exarg_T *eap)
/// ":mapclear" and friends.
static void ex_mapclear(exarg_T *eap)
{
- map_clear_mode((char_u *)eap->cmd, eap->arg, eap->forceit, false);
+ map_clear_mode((char_u *)eap->cmd, (char_u *)eap->arg, eap->forceit, false);
}
/// ":abclear" and friends.
static void ex_abclear(exarg_T *eap)
{
- map_clear_mode((char_u *)eap->cmd, eap->arg, true, true);
+ map_clear_mode((char_u *)eap->cmd, (char_u *)eap->arg, true, true);
}
static void ex_autocmd(exarg_T *eap)
@@ -5124,11 +5145,11 @@ static void ex_autocmd(exarg_T *eap)
/// ":doautocmd": Apply the automatic commands to the current buffer.
static void ex_doautocmd(exarg_T *eap)
{
- char *arg = (char *)eap->arg;
- int call_do_modelines = check_nomodeline((char_u **)&arg);
+ char *arg = eap->arg;
+ int call_do_modelines = check_nomodeline(&arg);
bool did_aucmd;
- (void)do_doautocmd((char_u *)arg, false, &did_aucmd);
+ (void)do_doautocmd(arg, false, &did_aucmd);
// Only when there is no <nomodeline>.
if (call_do_modelines && did_aucmd) {
do_modelines(0);
@@ -5140,11 +5161,13 @@ static void ex_doautocmd(exarg_T *eap)
/// :[N]bwipeout[!] [N] [bufname] delete buffer really
static void ex_bunload(exarg_T *eap)
{
- eap->errmsg = do_bufdel(eap->cmdidx == CMD_bdelete ? DOBUF_DEL
- : eap->cmdidx == CMD_bwipeout ? DOBUF_WIPE
- : DOBUF_UNLOAD,
- eap->arg,
- eap->addr_count, (int)eap->line1, (int)eap->line2, eap->forceit);
+ eap->errmsg = do_bufdel(eap->cmdidx == CMD_bdelete
+ ? DOBUF_DEL
+ : eap->cmdidx == CMD_bwipeout
+ ? DOBUF_WIPE
+ : DOBUF_UNLOAD,
+ (char_u *)eap->arg, eap->addr_count, (int)eap->line1, (int)eap->line2,
+ eap->forceit);
}
/// :[N]buffer [N] to buffer N
@@ -5160,7 +5183,7 @@ static void ex_buffer(exarg_T *eap)
goto_buffer(eap, DOBUF_FIRST, FORWARD, (int)eap->line2);
}
if (eap->do_ecmd_cmd != NULL) {
- do_cmdline_cmd((char *)eap->do_ecmd_cmd);
+ do_cmdline_cmd(eap->do_ecmd_cmd);
}
}
}
@@ -5171,7 +5194,7 @@ static void ex_bmodified(exarg_T *eap)
{
goto_buffer(eap, DOBUF_MOD, FORWARD, (int)eap->line2);
if (eap->do_ecmd_cmd != NULL) {
- do_cmdline_cmd((char *)eap->do_ecmd_cmd);
+ do_cmdline_cmd(eap->do_ecmd_cmd);
}
}
@@ -5181,7 +5204,7 @@ static void ex_bnext(exarg_T *eap)
{
goto_buffer(eap, DOBUF_CURRENT, FORWARD, (int)eap->line2);
if (eap->do_ecmd_cmd != NULL) {
- do_cmdline_cmd((char *)eap->do_ecmd_cmd);
+ do_cmdline_cmd(eap->do_ecmd_cmd);
}
}
@@ -5193,7 +5216,7 @@ static void ex_bprevious(exarg_T *eap)
{
goto_buffer(eap, DOBUF_CURRENT, BACKWARD, (int)eap->line2);
if (eap->do_ecmd_cmd != NULL) {
- do_cmdline_cmd((char *)eap->do_ecmd_cmd);
+ do_cmdline_cmd(eap->do_ecmd_cmd);
}
}
@@ -5205,7 +5228,7 @@ static void ex_brewind(exarg_T *eap)
{
goto_buffer(eap, DOBUF_FIRST, FORWARD, 0);
if (eap->do_ecmd_cmd != NULL) {
- do_cmdline_cmd((char *)eap->do_ecmd_cmd);
+ do_cmdline_cmd(eap->do_ecmd_cmd);
}
}
@@ -5215,7 +5238,7 @@ static void ex_blast(exarg_T *eap)
{
goto_buffer(eap, DOBUF_LAST, BACKWARD, 0);
if (eap->do_ecmd_cmd != NULL) {
- do_cmdline_cmd((char *)eap->do_ecmd_cmd);
+ do_cmdline_cmd(eap->do_ecmd_cmd);
}
}
@@ -5811,7 +5834,7 @@ static void ex_command(exarg_T *eap)
int has_attr = (eap->arg[0] == '-');
size_t name_len;
- p = (char *)eap->arg;
+ p = eap->arg;
// Check for attributes
while (*p == '-') {
@@ -5880,7 +5903,7 @@ static void ex_delcommand(exarg_T *eap)
ucmd_T *cmd = NULL;
int res = -1;
garray_T *gap;
- const char *arg = (char *)eap->arg;
+ const char *arg = eap->arg;
bool buffer_only = false;
if (STRNCMP(arg, "-buffer", 7) == 0 && ascii_iswhite(arg[7])) {
@@ -6142,7 +6165,7 @@ static size_t uc_check_code(char *code, size_t len, char *buf, ucmd_T *cmd, exar
break;
case 1: // Quote, but don't split
result = STRLEN(eap->arg) + 2;
- for (p = (char *)eap->arg; *p; p++) {
+ for (p = eap->arg; *p; p++) {
if (*p == '\\' || *p == '"') {
result++;
}
@@ -6150,7 +6173,7 @@ static size_t uc_check_code(char *code, size_t len, char *buf, ucmd_T *cmd, exar
if (buf != NULL) {
*buf++ = '"';
- for (p = (char *)eap->arg; *p; p++) {
+ for (p = eap->arg; *p; p++) {
if (*p == '\\' || *p == '"') {
*buf++ = '\\';
}
@@ -6163,7 +6186,7 @@ static size_t uc_check_code(char *code, size_t len, char *buf, ucmd_T *cmd, exar
case 2: // Quote and split (<f-args>)
// This is hard, so only do it once, and cache the result
if (*split_buf == NULL) {
- *split_buf = uc_split_args((char *)eap->arg, split_len);
+ *split_buf = uc_split_args(eap->arg, split_len);
}
result = *split_len;
@@ -6679,7 +6702,7 @@ static void ex_colorscheme(exarg_T *eap)
} else {
msg("default");
}
- } else if (load_colors(eap->arg) == FAIL) {
+ } else if (load_colors((char_u *)eap->arg) == FAIL) {
semsg(_("E185: Cannot find color scheme '%s'"), eap->arg);
}
}
@@ -7337,7 +7360,7 @@ static void ex_recover(exarg_T *eap)
| CCGD_EXCMD)
&& (*eap->arg == NUL
- || setfname(curbuf, eap->arg, NULL, true) == OK)) {
+ || setfname(curbuf, (char_u *)eap->arg, NULL, true) == OK)) {
ml_recover(true);
}
recoverymode = false;
@@ -7380,12 +7403,12 @@ void ex_splitview(exarg_T *eap)
}
if (eap->cmdidx == CMD_sfind || eap->cmdidx == CMD_tabfind) {
- fname = (char *)find_file_in_path(eap->arg, STRLEN(eap->arg),
+ fname = (char *)find_file_in_path((char_u *)eap->arg, STRLEN(eap->arg),
FNAME_MESS, true, curbuf->b_ffname);
if (fname == NULL) {
goto theend;
}
- eap->arg = (char_u *)fname;
+ eap->arg = fname;
}
/*
@@ -7393,7 +7416,7 @@ void ex_splitview(exarg_T *eap)
*/
if (use_tab) {
if (win_new_tabpage(cmdmod.tab != 0 ? cmdmod.tab : eap->addr_count == 0
- ? 0 : (int)eap->line2 + 1, eap->arg) != FAIL) {
+ ? 0 : (int)eap->line2 + 1, (char_u *)eap->arg) != FAIL) {
do_exedit(eap, old_curwin);
apply_autocmds(EVENT_TABNEWENTERED, NULL, NULL, false, curbuf);
@@ -7430,7 +7453,7 @@ void tabpage_new(void)
memset(&ea, 0, sizeof(ea));
ea.cmdidx = CMD_tabnew;
ea.cmd = "tabn";
- ea.arg = (char_u *)"";
+ ea.arg = "";
ex_splitview(&ea);
}
@@ -7450,7 +7473,7 @@ static void ex_tabnext(exarg_T *eap)
case CMD_tabprevious:
case CMD_tabNext:
if (eap->arg && *eap->arg != NUL) {
- char *p = (char *)eap->arg;
+ char *p = eap->arg;
char *p_save = p;
tab_number = (int)getdigits((char_u **)&p, false, 0);
if (p == p_save || *p_save == '-' || *p_save == '+' || *p != NUL
@@ -7560,7 +7583,7 @@ static void ex_resize(exarg_T *eap)
for (wp = firstwin; wp->w_next != NULL && --n > 0; wp = wp->w_next) {}
}
- n = (int)atol((char *)eap->arg);
+ n = (int)atol(eap->arg);
if (cmdmod.split & WSP_VERT) {
if (*eap->arg == '-' || *eap->arg == '+') {
n += wp->w_width;
@@ -7584,7 +7607,7 @@ static void ex_find(exarg_T *eap)
char *fname;
linenr_T count;
- fname = (char *)find_file_in_path(eap->arg, STRLEN(eap->arg),
+ fname = (char *)find_file_in_path((char_u *)eap->arg, STRLEN(eap->arg),
FNAME_MESS, true, curbuf->b_ffname);
if (eap->addr_count > 0) {
// Repeat finding the file "count" times. This matters when it
@@ -7597,7 +7620,7 @@ static void ex_find(exarg_T *eap)
}
if (fname != NULL) {
- eap->arg = (char_u *)fname;
+ eap->arg = fname;
do_exedit(eap, NULL);
xfree(fname);
}
@@ -7678,7 +7701,7 @@ void do_exedit(exarg_T *eap, win_T *old_curwin)
if (eap->cmdidx != CMD_balt && eap->cmdidx != CMD_badd) {
setpcmark();
}
- if (do_ecmd(0, eap->cmdidx == CMD_enew ? NULL : (char *)eap->arg,
+ if (do_ecmd(0, eap->cmdidx == CMD_enew ? NULL : eap->arg,
NULL, eap, eap->do_ecmd_lnum,
(buf_hide(curbuf) ? ECMD_HIDE : 0)
+ (eap->forceit ? ECMD_FORCEIT : 0)
@@ -7714,7 +7737,7 @@ void do_exedit(exarg_T *eap, win_T *old_curwin)
readonlymode = n;
} else {
if (eap->do_ecmd_cmd != NULL) {
- do_cmdline_cmd((char *)eap->do_ecmd_cmd);
+ do_cmdline_cmd(eap->do_ecmd_cmd);
}
n = curwin->w_arg_idx_invalid;
check_arg_idx(curwin);
@@ -7845,9 +7868,9 @@ static void ex_read(exarg_T *eap)
eap->line2, (linenr_T)0, (linenr_T)MAXLNUM, eap, 0, false);
} else {
if (vim_strchr(p_cpo, CPO_ALTREAD) != NULL) {
- (void)setaltfname(eap->arg, eap->arg, (linenr_T)1);
+ (void)setaltfname((char_u *)eap->arg, (char_u *)eap->arg, (linenr_T)1);
}
- i = readfile(eap->arg, NULL,
+ i = readfile((char_u *)eap->arg, NULL,
eap->line2, (linenr_T)0, (linenr_T)MAXLNUM, eap, 0, false);
}
if (i != OK) {
@@ -8022,7 +8045,7 @@ bool changedir_func(char *new_dir, CdScope scope)
/// ":cd", ":tcd", ":lcd", ":chdir", "tchdir" and ":lchdir".
void ex_cd(exarg_T *eap)
{
- char *new_dir = (char *)eap->arg;
+ char *new_dir = eap->arg;
#if !defined(UNIX)
// for non-UNIX ":cd" means: print current directory unless 'cdhome' is set
if (*new_dir == NUL && !p_cdh) {
@@ -8132,7 +8155,7 @@ static void do_exmap(exarg_T *eap, int isabbrev)
mode = get_map_mode((char_u **)&cmdp, eap->forceit || isabbrev);
switch (do_map((*cmdp == 'n') ? 2 : (*cmdp == 'u'),
- eap->arg, mode, isabbrev)) {
+ (char_u *)eap->arg, mode, isabbrev)) {
case 1:
emsg(_(e_invarg));
break;
@@ -8145,7 +8168,7 @@ static void do_exmap(exarg_T *eap, int isabbrev)
/// ":winsize" command (obsolete).
static void ex_winsize(exarg_T *eap)
{
- char *arg = (char *)eap->arg;
+ char *arg = eap->arg;
if (!ascii_isdigit(*arg)) {
semsg(_(e_invarg2), arg);
@@ -8173,13 +8196,13 @@ static void ex_wincmd(exarg_T *eap)
emsg(_(e_invarg));
return;
}
- xchar = eap->arg[1];
- p = (char *)eap->arg + 2;
+ xchar = (uint8_t)eap->arg[1];
+ p = eap->arg + 2;
} else {
- p = (char *)eap->arg + 1;
+ p = eap->arg + 1;
}
- eap->nextcmd = check_nextcmd((char_u *)p);
+ eap->nextcmd = (char *)check_nextcmd((char_u *)p);
p = (char *)skipwhite((char_u *)p);
if (*p != NUL && *p != '"' && eap->nextcmd == NULL) {
emsg(_(e_invarg));
@@ -8257,7 +8280,7 @@ static void ex_put(exarg_T *eap)
/// Handle ":copy" and ":move".
static void ex_copymove(exarg_T *eap)
{
- long n = get_address(eap, (char **)&eap->arg, eap->addr_type, false, false, false, 1);
+ long n = get_address(eap, &eap->arg, eap->addr_type, false, false, false, 1);
if (eap->arg == NULL) { // error detected
eap->nextcmd = NULL;
return;
@@ -8332,7 +8355,7 @@ static void ex_at(exarg_T *eap)
check_cursor_col();
// Get the register name. No name means use the previous one.
- int c = *eap->arg;
+ int c = (uint8_t)(*eap->arg);
if (c == NUL) {
c = '@';
}
@@ -8408,7 +8431,7 @@ static void ex_wundo(exarg_T *eap)
char hash[UNDO_HASH_SIZE];
u_compute_hash(curbuf, (char_u *)hash);
- u_write_undo((char *)eap->arg, eap->forceit, curbuf, (char_u *)hash);
+ u_write_undo(eap->arg, eap->forceit, curbuf, (char_u *)hash);
}
static void ex_rundo(exarg_T *eap)
@@ -8416,7 +8439,7 @@ static void ex_rundo(exarg_T *eap)
char hash[UNDO_HASH_SIZE];
u_compute_hash(curbuf, (char_u *)hash);
- u_read_undo((char *)eap->arg, (char_u *)hash, NULL);
+ u_read_undo(eap->arg, (char_u *)hash, NULL);
}
/// ":redo".
@@ -8431,7 +8454,7 @@ static void ex_later(exarg_T *eap)
long count = 0;
bool sec = false;
bool file = false;
- char *p = (char *)eap->arg;
+ char *p = eap->arg;
if (*p == NUL) {
count = 1;
@@ -8464,7 +8487,7 @@ static void ex_redir(exarg_T *eap)
{
char *mode;
char *fname;
- char *arg = (char *)eap->arg;
+ char *arg = eap->arg;
if (STRICMP(eap->arg, "END") == 0) {
close_redir();
@@ -8789,7 +8812,7 @@ static void ex_normal(exarg_T *eap)
int len = 0;
// Count the number of characters to be escaped.
- for (p = (char *)eap->arg; *p != NUL; p++) {
+ for (p = eap->arg; *p != NUL; p++) {
for (l = utfc_ptr2len((char_u *)p) - 1; l > 0; l--) {
if (*++p == (char)K_SPECIAL) { // trailbyte K_SPECIAL
len += 2;
@@ -8799,7 +8822,7 @@ static void ex_normal(exarg_T *eap)
if (len > 0) {
arg = xmalloc(STRLEN(eap->arg) + (size_t)len + 1);
len = 0;
- for (p = (char *)eap->arg; *p != NUL; p++) {
+ for (p = eap->arg; *p != NUL; p++) {
arg[len++] = *p;
for (l = utfc_ptr2len((char_u *)p) - 1; l > 0; l--) {
arg[len++] = *++p;
@@ -8825,7 +8848,7 @@ static void ex_normal(exarg_T *eap)
check_cursor_moved(curwin);
}
- exec_normal_cmd(arg != NULL ? (char_u *)arg : eap->arg,
+ exec_normal_cmd((char_u *)(arg != NULL ? arg : eap->arg),
eap->forceit ? REMAP_NONE : REMAP_YES, false);
} while (eap->addr_count > 0 && eap->line1 <= eap->line2 && !got_int);
}
@@ -8957,13 +8980,13 @@ static void ex_findpat(exarg_T *eap)
n = 1;
if (ascii_isdigit(*eap->arg)) { // get count
- n = getdigits_long(&eap->arg, false, 0);
- eap->arg = skipwhite(eap->arg);
+ n = getdigits_long((char_u **)&eap->arg, false, 0);
+ eap->arg = (char *)skipwhite((char_u *)eap->arg);
}
if (*eap->arg == '/') { // Match regexp, not just whole words
whole = false;
eap->arg++;
- p = (char *)skip_regexp(eap->arg, '/', p_magic, NULL);
+ p = (char *)skip_regexp((char_u *)eap->arg, '/', p_magic, NULL);
if (*p) {
*p++ = NUL;
p = (char *)skipwhite((char_u *)p);
@@ -8972,12 +8995,12 @@ static void ex_findpat(exarg_T *eap)
if (!ends_excmd(*p)) {
eap->errmsg = e_trailing;
} else {
- eap->nextcmd = check_nextcmd((char_u *)p);
+ eap->nextcmd = (char *)check_nextcmd((char_u *)p);
}
}
}
if (!eap->skip) {
- find_pattern_in_path(eap->arg, 0, STRLEN(eap->arg), whole, !eap->forceit,
+ find_pattern_in_path((char_u *)eap->arg, 0, STRLEN(eap->arg), whole, !eap->forceit,
*eap->cmd == 'd' ? FIND_DEFINE : FIND_ANY,
n, action, eap->line1, eap->line2);
}
@@ -9070,8 +9093,8 @@ static void ex_tag_cmd(exarg_T *eap, char *name)
cmd = DT_LTAG;
}
- do_tag(eap->arg, cmd, eap->addr_count > 0 ? (int)eap->line2 : 1,
- eap->forceit, TRUE);
+ do_tag((char_u *)eap->arg, cmd, eap->addr_count > 0 ? (int)eap->line2 : 1,
+ eap->forceit, true);
}
enum {
@@ -9526,9 +9549,9 @@ static void ex_shada(exarg_T *eap)
p_shada = (char_u *)"'100";
}
if (eap->cmdidx == CMD_rviminfo || eap->cmdidx == CMD_rshada) {
- (void)shada_read_everything((char *)eap->arg, eap->forceit, false);
+ (void)shada_read_everything(eap->arg, eap->forceit, false);
} else {
- shada_write_file((char *)eap->arg, eap->forceit);
+ shada_write_file(eap->arg, eap->forceit);
}
p_shada = (char_u *)save_shada;
}
@@ -9605,7 +9628,7 @@ static TriState filetype_indent = kNone;
/// indent off: load indoff.vim
static void ex_filetype(exarg_T *eap)
{
- char *arg = (char *)eap->arg;
+ char *arg = eap->arg;
bool plugin = false;
bool indent = false;
@@ -9646,7 +9669,7 @@ static void ex_filetype(exarg_T *eap)
}
}
if (*arg == 'd') {
- (void)do_doautocmd((char_u *)"filetypedetect BufRead", true, NULL);
+ (void)do_doautocmd("filetypedetect BufRead", true, NULL);
do_modelines(0);
}
} else if (STRCMP(arg, "off") == 0) {
@@ -9700,14 +9723,14 @@ void filetype_maybe_enable(void)
static void ex_setfiletype(exarg_T *eap)
{
if (!did_filetype) {
- char *arg = (char *)eap->arg;
+ char *arg = eap->arg;
if (STRNCMP(arg, "FALLBACK ", 9) == 0) {
arg += 9;
}
set_option_value("filetype", 0L, arg, OPT_LOCAL);
- if ((char_u *)arg != eap->arg) {
+ if (arg != eap->arg) {
did_filetype = false;
}
}
@@ -9716,7 +9739,7 @@ static void ex_setfiletype(exarg_T *eap)
static void ex_digraphs(exarg_T *eap)
{
if (*eap->arg != NUL) {
- putdigraph(eap->arg);
+ putdigraph((char_u *)eap->arg);
} else {
listdigraphs(eap->forceit);
}
@@ -9760,7 +9783,7 @@ static void ex_folddo(exarg_T *eap)
}
}
- global_exe((char *)eap->arg); // Execute the command on the marked lines.
+ global_exe(eap->arg); // Execute the command on the marked lines.
ml_clearmarked(); // clear rest of the marks
}
@@ -9791,7 +9814,7 @@ static void ex_terminal(exarg_T *eap)
char ex_cmd[1024];
if (*eap->arg != NUL) { // Run {cmd} in 'shell'.
- char *name = (char *)vim_strsave_escaped(eap->arg, (char_u *)"\"\\");
+ char *name = (char *)vim_strsave_escaped((char_u *)eap->arg, (char_u *)"\"\\");
snprintf(ex_cmd, sizeof(ex_cmd),
":enew%s | call termopen(\"%s\")",
eap->forceit ? "!" : "", name);
diff --git a/src/nvim/ex_eval.c b/src/nvim/ex_eval.c
index 570ae0d85e..c00f27a3c1 100644
--- a/src/nvim/ex_eval.c
+++ b/src/nvim/ex_eval.c
@@ -148,7 +148,7 @@ int aborted_in_try(void)
/// When several messages appear in the same command, the first is usually the
/// most specific one and used as the exception value. The "severe" flag can be
/// set to true, if a later but severer message should be used instead.
-bool cause_errthrow(const char_u *mesg, bool severe, bool *ignore)
+bool cause_errthrow(const char *mesg, bool severe, bool *ignore)
FUNC_ATTR_NONNULL_ALL
{
struct msglist *elem;
@@ -197,7 +197,7 @@ bool cause_errthrow(const char_u *mesg, bool severe, bool *ignore)
* interrupt exception is catchable by the innermost try conditional and
* not replaced by an interrupt message error exception.
*/
- if (mesg == (char_u *)_(e_interr)) {
+ if (mesg == _(e_interr)) {
*ignore = true;
return true;
}
@@ -255,7 +255,7 @@ bool cause_errthrow(const char_u *mesg, bool severe, bool *ignore)
}
elem = xmalloc(sizeof(struct msglist));
- elem->msg = (char *)vim_strsave(mesg);
+ elem->msg = xstrdup(mesg);
elem->next = NULL;
elem->throw_msg = NULL;
*plist = elem;
@@ -305,7 +305,7 @@ void free_global_msglist(void)
/// Throw the message specified in the call to cause_errthrow() above as an
/// error exception. If cstack is NULL, postpone the throw until do_cmdline()
/// has returned (see do_one_cmd()).
-void do_errthrow(cstack_T *cstack, char_u *cmdname)
+void do_errthrow(cstack_T *cstack, char *cmdname)
{
/*
* Ensure that all commands in nested function calls and sourced files
@@ -382,7 +382,7 @@ int do_intthrow(cstack_T *cstack)
}
/// Get an exception message that is to be stored in current_exception->value.
-char *get_exception_string(void *value, except_type_T type, char_u *cmdname, int *should_free)
+char *get_exception_string(void *value, except_type_T type, char *cmdname, int *should_free)
{
char *ret, *mesg;
char *p, *val;
@@ -446,7 +446,7 @@ char *get_exception_string(void *value, except_type_T type, char_u *cmdname, int
///
/// @return FAIL when out of memory or it was tried to throw an illegal user
/// exception.
-static int throw_exception(void *value, except_type_T type, char_u *cmdname)
+static int throw_exception(void *value, except_type_T type, char *cmdname)
{
except_T *excp;
int should_free;
@@ -479,8 +479,7 @@ static int throw_exception(void *value, except_type_T type, char_u *cmdname)
}
excp->type = type;
- excp->throw_name = vim_strsave(sourcing_name == NULL
- ? (char_u *)"" : sourcing_name);
+ excp->throw_name = (char *)vim_strsave(sourcing_name == NULL ? (char_u *)"" : sourcing_name);
excp->throw_lnum = sourcing_lnum;
if (p_verbose >= 13 || debug_break_level > 0) {
@@ -525,7 +524,7 @@ fail:
/// caught and the catch clause has been ended normally.
static void discard_exception(except_T *excp, bool was_finished)
{
- char_u *saved_IObuff;
+ char *saved_IObuff;
if (current_exception == excp) {
current_exception = NULL;
@@ -538,7 +537,7 @@ static void discard_exception(except_T *excp, bool was_finished)
if (p_verbose >= 13 || debug_break_level > 0) {
int save_msg_silent = msg_silent;
- saved_IObuff = vim_strsave(IObuff);
+ saved_IObuff = (char *)vim_strsave(IObuff);
if (debug_break_level > 0) {
msg_silent = FALSE; // display messages
} else {
@@ -801,7 +800,7 @@ void ex_eval(exarg_T *eap)
{
typval_T tv;
- if (eval0((char *)eap->arg, &tv, (char **)&eap->nextcmd, !eap->skip) == OK) {
+ if (eval0(eap->arg, &tv, &eap->nextcmd, !eap->skip) == OK) {
tv_clear(&tv);
}
}
@@ -822,7 +821,7 @@ void ex_if(exarg_T *eap)
skip = CHECK_SKIP;
bool error;
- result = eval_to_bool((char *)eap->arg, &error, (char **)&eap->nextcmd, skip);
+ result = eval_to_bool(eap->arg, &error, &eap->nextcmd, skip);
if (!skip && !error) {
if (result) {
@@ -911,7 +910,7 @@ void ex_else(exarg_T *eap)
if (eap->cmdidx == CMD_elseif) {
bool error;
- result = eval_to_bool((char *)eap->arg, &error, (char **)&eap->nextcmd, skip);
+ result = eval_to_bool(eap->arg, &error, &eap->nextcmd, skip);
// When throwing error exceptions, we want to throw always the first
// of several errors in a row. This is what actually happens when
// a conditional error was detected above and there is another failure
@@ -962,7 +961,7 @@ void ex_while(exarg_T *eap)
/*
* ":while bool-expr"
*/
- result = eval_to_bool((char *)eap->arg, &error, (char **)&eap->nextcmd, skip);
+ result = eval_to_bool(eap->arg, &error, &eap->nextcmd, skip);
} else {
void *fi;
@@ -976,13 +975,13 @@ void ex_while(exarg_T *eap)
error = FALSE;
} else {
// Evaluate the argument and get the info in a structure.
- fi = eval_for_line((char *)eap->arg, &error, (char **)&eap->nextcmd, skip);
+ fi = eval_for_line(eap->arg, &error, &eap->nextcmd, skip);
cstack->cs_forinfo[cstack->cs_idx] = fi;
}
// use the element at the start of the list and advance
if (!error && fi != NULL && !skip) {
- result = next_for_item(fi, (char *)eap->arg);
+ result = next_for_item(fi, eap->arg);
} else {
result = FALSE;
}
@@ -1283,13 +1282,13 @@ void ex_catch(exarg_T *eap)
bool give_up = false;
bool skip = false;
bool caught = false;
- char_u *end;
- char_u save_char = 0;
- char_u *save_cpo;
+ char *end;
+ char save_char = 0;
+ char *save_cpo;
regmatch_T regmatch;
int prev_got_int;
cstack_T *const cstack = eap->cstack;
- char_u *pat;
+ char *pat;
if (cstack->cs_trylevel <= 0 || cstack->cs_idx < 0) {
eap->errmsg = N_("E603: :catch without :try");
@@ -1318,12 +1317,12 @@ void ex_catch(exarg_T *eap)
}
if (ends_excmd(*eap->arg)) { // no argument, catch all errors
- pat = (char_u *)".*";
+ pat = ".*";
end = NULL;
- eap->nextcmd = find_nextcmd(eap->arg);
+ eap->nextcmd = (char *)find_nextcmd((char_u *)eap->arg);
} else {
pat = eap->arg + 1;
- end = skip_regexp(pat, *eap->arg, TRUE, NULL);
+ end = (char *)skip_regexp((char_u *)pat, *eap->arg, true, NULL);
}
if (!give_up) {
@@ -1343,7 +1342,7 @@ void ex_catch(exarg_T *eap)
*/
if (!skip && (cstack->cs_flags[idx] & CSF_THROWN)
&& !(cstack->cs_flags[idx] & CSF_CAUGHT)) {
- if (end != NULL && *end != NUL && !ends_excmd(*skipwhite(end + 1))) {
+ if (end != NULL && *end != NUL && !ends_excmd(*skipwhite((char_u *)end + 1))) {
emsg(_(e_trailing));
return;
}
@@ -1362,18 +1361,18 @@ void ex_catch(exarg_T *eap)
save_char = *end;
*end = NUL;
}
- save_cpo = p_cpo;
+ save_cpo = (char *)p_cpo;
p_cpo = (char_u *)"";
// Disable error messages, it will make current exception
// invalid
emsg_off++;
- regmatch.regprog = vim_regcomp(pat, RE_MAGIC + RE_STRING);
+ regmatch.regprog = vim_regcomp((char_u *)pat, RE_MAGIC + RE_STRING);
emsg_off--;
regmatch.rm_ic = false;
if (end != NULL) {
*end = save_char;
}
- p_cpo = save_cpo;
+ p_cpo = (char_u *)save_cpo;
if (regmatch.regprog == NULL) {
semsg(_(e_invarg2), pat);
} else {
@@ -1426,7 +1425,7 @@ void ex_catch(exarg_T *eap)
}
if (end != NULL) {
- eap->nextcmd = find_nextcmd(end);
+ eap->nextcmd = (char *)find_nextcmd((char_u *)end);
}
}
@@ -2036,7 +2035,7 @@ void ex_endfunction(exarg_T *eap)
}
/// @return TRUE if the string "p" looks like a ":while" or ":for" command.
-int has_loop_cmd(char_u *p)
+int has_loop_cmd(char *p)
{
int len;
@@ -2045,7 +2044,7 @@ int has_loop_cmd(char_u *p)
while (*p == ' ' || *p == '\t' || *p == ':') {
++p;
}
- len = modifier_len((char *)p);
+ len = modifier_len(p);
if (len == 0) {
break;
}
diff --git a/src/nvim/ex_eval.h b/src/nvim/ex_eval.h
index 98573c7182..235875fb91 100644
--- a/src/nvim/ex_eval.h
+++ b/src/nvim/ex_eval.h
@@ -62,7 +62,7 @@ struct vim_exception {
except_type_T type; // exception type
char *value; // exception value
struct msglist *messages; // message(s) causing error exception
- char_u *throw_name; // name of the throw point
+ char *throw_name; // name of the throw point
linenr_T throw_lnum; // line number of the throw point
except_T *caught; // next exception on the caught stack
};
diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c
index 8a37c5bc93..25cbb33e55 100644
--- a/src/nvim/ex_getln.c
+++ b/src/nvim/ex_getln.c
@@ -833,8 +833,8 @@ static uint8_t *command_line_enter(int firstc, long count, int indent, bool init
if (ccline.input_fn) {
s->xpc.xp_context = ccline.xp_context;
- s->xpc.xp_pattern = ccline.cmdbuff;
- s->xpc.xp_arg = ccline.xp_arg;
+ s->xpc.xp_pattern = (char *)ccline.cmdbuff;
+ s->xpc.xp_arg = (char *)ccline.xp_arg;
}
// Avoid scrolling when called by a recursive do_cmdline(), e.g. when
@@ -1210,7 +1210,7 @@ static int command_line_execute(VimState *state, int key)
// cursor
int found = false;
- int j = (int)(s->xpc.xp_pattern - ccline.cmdbuff);
+ int j = (int)((char_u *)s->xpc.xp_pattern - ccline.cmdbuff);
int i = 0;
while (--j > 0) {
// check for start of menu name
@@ -1265,7 +1265,7 @@ static int command_line_execute(VimState *state, int key)
int found = false;
int j = ccline.cmdpos;
- int i = (int)(s->xpc.xp_pattern - ccline.cmdbuff);
+ int i = (int)((char_u *)s->xpc.xp_pattern - ccline.cmdbuff);
while (--j > i) {
j -= utf_head_off(ccline.cmdbuff, ccline.cmdbuff + j);
if (vim_ispathsep(ccline.cmdbuff[j])) {
@@ -1286,7 +1286,7 @@ static int command_line_execute(VimState *state, int key)
int found = false;
int j = ccline.cmdpos - 1;
- int i = (int)(s->xpc.xp_pattern - ccline.cmdbuff);
+ int i = (int)((char_u *)s->xpc.xp_pattern - ccline.cmdbuff);
while (--j > i) {
j -= utf_head_off(ccline.cmdbuff, ccline.cmdbuff + j);
if (vim_ispathsep(ccline.cmdbuff[j])
@@ -2665,12 +2665,12 @@ static void realloc_cmdbuff(int len)
&& ccline.xpc->xp_pattern != NULL
&& ccline.xpc->xp_context != EXPAND_NOTHING
&& ccline.xpc->xp_context != EXPAND_UNSUCCESSFUL) {
- int i = (int)(ccline.xpc->xp_pattern - p);
+ int i = (int)((char_u *)ccline.xpc->xp_pattern - p);
// If xp_pattern points inside the old cmdbuff it needs to be adjusted
// to point into the newly allocated memory.
if (i >= 0 && i <= ccline.cmdlen) {
- ccline.xpc->xp_pattern = ccline.cmdbuff + i;
+ ccline.xpc->xp_pattern = (char *)ccline.cmdbuff + i;
}
}
}
@@ -3764,7 +3764,7 @@ static int nextwild(expand_T *xp, int type, int options, int escape)
ui_flush();
}
- i = (int)(xp->xp_pattern - ccline.cmdbuff);
+ i = (int)((char_u *)xp->xp_pattern - ccline.cmdbuff);
assert(ccline.cmdpos >= i);
xp->xp_pattern_len = (size_t)ccline.cmdpos - (size_t)i;
@@ -3773,7 +3773,7 @@ static int nextwild(expand_T *xp, int type, int options, int escape)
p2 = ExpandOne(xp, NULL, NULL, 0, type);
} else {
// Translate string into pattern and expand it.
- p1 = addstar(xp->xp_pattern, xp->xp_pattern_len, xp->xp_context);
+ p1 = addstar((char_u *)xp->xp_pattern, xp->xp_pattern_len, xp->xp_context);
const int use_options = (
options
| WILD_HOME_REPLACE
@@ -3787,7 +3787,7 @@ static int nextwild(expand_T *xp, int type, int options, int escape)
// xp->xp_pattern might have been modified by ExpandOne (for example,
// in lua completion), so recompute the pattern index and length
- i = (int)(xp->xp_pattern - ccline.cmdbuff);
+ i = (int)((char_u *)xp->xp_pattern - ccline.cmdbuff);
xp->xp_pattern_len = (size_t)ccline.cmdpos - (size_t)i;
// Longest match: make sure it is not shorter, happens with :help.
@@ -3808,7 +3808,7 @@ static int nextwild(expand_T *xp, int type, int options, int escape)
difflen = (int)STRLEN(p2) - (int)(xp->xp_pattern_len);
if (ccline.cmdlen + difflen + 4 > ccline.cmdbufflen) {
realloc_cmdbuff(ccline.cmdlen + difflen + 4);
- xp->xp_pattern = ccline.cmdbuff + i;
+ xp->xp_pattern = (char *)ccline.cmdbuff + i;
}
assert(ccline.cmdpos <= ccline.cmdlen);
memmove(&ccline.cmdbuff[ccline.cmdpos + difflen],
@@ -3918,13 +3918,13 @@ char_u *ExpandOne(expand_T *xp, char_u *str, char_u *orig, int options, int mode
compl_selected = findex;
cmdline_pum_display(false);
} else if (p_wmnu) {
- win_redr_status_matches(xp, xp->xp_numfiles, xp->xp_files,
+ win_redr_status_matches(xp, xp->xp_numfiles, (char_u **)xp->xp_files,
findex, cmd_showtail);
}
if (findex == -1) {
return vim_strsave(orig_save);
}
- return vim_strsave(xp->xp_files[findex]);
+ return vim_strsave((char_u *)xp->xp_files[findex]);
} else {
return NULL;
}
@@ -3934,12 +3934,12 @@ char_u *ExpandOne(expand_T *xp, char_u *str, char_u *orig, int options, int mode
ss = vim_strsave(orig_save ? orig_save : (char_u *)"");
} else if (mode == WILD_APPLY) {
ss = vim_strsave(findex == -1 ? (orig_save ? orig_save : (char_u *)"") :
- xp->xp_files[findex]);
+ (char_u *)xp->xp_files[findex]);
}
// free old names
if (xp->xp_numfiles != -1 && mode != WILD_ALL && mode != WILD_LONGEST) {
- FreeWild(xp->xp_numfiles, xp->xp_files);
+ FreeWild(xp->xp_numfiles, (char_u **)xp->xp_files);
xp->xp_numfiles = -1;
XFREE_CLEAR(orig_save);
}
@@ -3957,7 +3957,7 @@ char_u *ExpandOne(expand_T *xp, char_u *str, char_u *orig, int options, int mode
/*
* Do the expansion.
*/
- if (ExpandFromContext(xp, str, &xp->xp_numfiles, &xp->xp_files,
+ if (ExpandFromContext(xp, str, &xp->xp_numfiles, (char_u ***)&xp->xp_files,
options) == FAIL) {
#ifdef FNAME_ILLEGAL
/* Illegal file name has been silently skipped. But when there
@@ -3974,7 +3974,7 @@ char_u *ExpandOne(expand_T *xp, char_u *str, char_u *orig, int options, int mode
}
} else {
// Escape the matches for use on the command line.
- ExpandEscape(xp, str, xp->xp_numfiles, xp->xp_files, options);
+ ExpandEscape(xp, str, xp->xp_numfiles, (char_u **)xp->xp_files, options);
/*
* Check for matching suffixes in file names.
@@ -3995,9 +3995,9 @@ char_u *ExpandOne(expand_T *xp, char_u *str, char_u *orig, int options, int mode
* expand_wildcards, only need to check the first two.
*/
non_suf_match = 0;
- for (i = 0; i < 2; ++i) {
- if (match_suffix(xp->xp_files[i])) {
- ++non_suf_match;
+ for (i = 0; i < 2; i++) {
+ if (match_suffix((char_u *)xp->xp_files[i])) {
+ non_suf_match++;
}
}
}
@@ -4014,7 +4014,7 @@ char_u *ExpandOne(expand_T *xp, char_u *str, char_u *orig, int options, int mode
}
}
if (!(non_suf_match != 1 && mode == WILD_EXPAND_FREE)) {
- ss = vim_strsave(xp->xp_files[0]);
+ ss = vim_strsave((char_u *)xp->xp_files[0]);
}
}
}
@@ -4025,10 +4025,10 @@ char_u *ExpandOne(expand_T *xp, char_u *str, char_u *orig, int options, int mode
size_t len = 0;
for (size_t mb_len; xp->xp_files[0][len]; len += mb_len) {
- mb_len = (size_t)utfc_ptr2len(&xp->xp_files[0][len]);
- int c0 = utf_ptr2char(&xp->xp_files[0][len]);
+ mb_len = (size_t)utfc_ptr2len((char_u *)&xp->xp_files[0][len]);
+ int c0 = utf_ptr2char((char_u *)&xp->xp_files[0][len]);
for (i = 1; i < xp->xp_numfiles; i++) {
- int ci = utf_ptr2char(&xp->xp_files[i][len]);
+ int ci = utf_ptr2char((char_u *)&xp->xp_files[i][len]);
if (p_fic && (xp->xp_context == EXPAND_DIRECTORIES
|| xp->xp_context == EXPAND_FILES
@@ -4049,7 +4049,7 @@ char_u *ExpandOne(expand_T *xp, char_u *str, char_u *orig, int options, int mode
}
}
- ss = (char_u *)xstrndup((char *)xp->xp_files[0], len);
+ ss = (char_u *)xstrndup(xp->xp_files[0], len);
findex = -1; // next p_wc gets first one
}
@@ -4099,7 +4099,7 @@ void ExpandInit(expand_T *xp)
void ExpandCleanup(expand_T *xp)
{
if (xp->xp_numfiles >= 0) {
- FreeWild(xp->xp_numfiles, xp->xp_files);
+ FreeWild(xp->xp_numfiles, (char_u **)xp->xp_files);
xp->xp_numfiles = -1;
}
}
@@ -4288,7 +4288,7 @@ static int showmatches(expand_T *xp, int wildmenu)
}
} else {
num_files = xp->xp_numfiles;
- files_found = xp->xp_files;
+ files_found = (char_u **)xp->xp_files;
showtail = cmd_showtail;
}
@@ -4306,7 +4306,7 @@ static int showmatches(expand_T *xp, int wildmenu)
compl_match_array[i].pum_text = L_SHOWFILE(i);
}
char_u *endpos = (showtail
- ? sm_gettail(xp->xp_pattern, true) : xp->xp_pattern);
+ ? sm_gettail((char_u *)xp->xp_pattern, true) : (char_u *)xp->xp_pattern);
if (ui_has(kUICmdline)) {
compl_startcol = (int)(endpos - ccline.cmdbuff);
} else {
@@ -4490,14 +4490,14 @@ static int expand_showtail(expand_T *xp)
return FALSE;
}
- end = path_tail(xp->xp_pattern);
- if (end == xp->xp_pattern) { // there is no path separator
- return FALSE;
+ end = path_tail((char_u *)xp->xp_pattern);
+ if (end == (char_u *)xp->xp_pattern) { // there is no path separator
+ return false;
}
- for (s = xp->xp_pattern; s < end; s++) {
- /* Skip escaped wildcards. Only when the backslash is not a path
- * separator, on DOS the '*' "path\*\file" must not be skipped. */
+ for (s = (char_u *)xp->xp_pattern; s < end; s++) {
+ // Skip escaped wildcards. Only when the backslash is not a path
+ // separator, on DOS the '*' "path\*\file" must not be skipped.
if (rem_backslash(s)) {
++s;
} else if (vim_strchr((char_u *)"*?[", *s) != NULL) {
@@ -4718,8 +4718,8 @@ void set_cmd_context(expand_T *xp, char_u *str, int len, int col, int use_ccline
set_context_for_expression(xp, (char *)str, CMD_SIZE);
} else if (use_ccline && ccline.input_fn) {
xp->xp_context = ccline.xp_context;
- xp->xp_pattern = ccline.cmdbuff;
- xp->xp_arg = ccline.xp_arg;
+ xp->xp_pattern = (char *)ccline.cmdbuff;
+ xp->xp_arg = (char *)ccline.xp_arg;
} else {
while (nextcomm != NULL) {
nextcomm = set_one_cmd_context(xp, nextcomm);
@@ -4728,7 +4728,7 @@ void set_cmd_context(expand_T *xp, char_u *str, int len, int col, int use_ccline
/* Store the string here so that call_user_expand_func() can get to them
* easily. */
- xp->xp_line = str;
+ xp->xp_line = (char *)str;
xp->xp_col = col;
str[col] = old_char;
@@ -4763,9 +4763,9 @@ int expand_cmdline(expand_T *xp, char_u *str, int col, int *matchcount, char_u *
}
// add star to file name, or convert to regexp if not exp. files.
- assert((str + col) - xp->xp_pattern >= 0);
- xp->xp_pattern_len = (size_t)((str + col) - xp->xp_pattern);
- file_str = addstar(xp->xp_pattern, xp->xp_pattern_len, xp->xp_context);
+ assert((str + col) - (char_u *)xp->xp_pattern >= 0);
+ xp->xp_pattern_len = (size_t)((str + col) - (char_u *)xp->xp_pattern);
+ file_str = addstar((char_u *)xp->xp_pattern, xp->xp_pattern_len, xp->xp_context);
if (p_wic) {
options += WILD_ICASE;
@@ -5312,18 +5312,18 @@ static void *call_user_expand_func(user_expand_func_T user_expand_func, expand_T
ccline.cmdbuff[ccline.cmdlen] = 0;
}
- pat = vim_strnsave(xp->xp_pattern, xp->xp_pattern_len);
+ pat = vim_strnsave((char_u *)xp->xp_pattern, xp->xp_pattern_len);
args[0].v_type = VAR_STRING;
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 = xp->xp_line;
+ args[1].vval.v_string = (char_u *)xp->xp_line;
args[2].vval.v_number = xp->xp_col;
current_sctx = xp->xp_script_ctx;
- void *const ret = user_expand_func(xp->xp_arg, 3, args);
+ void *const ret = user_expand_func((char_u *)xp->xp_arg, 3, args);
current_sctx = save_current_sctx;
if (ccline.cmdbuff != NULL) {
@@ -6239,7 +6239,7 @@ void ex_history(exarg_T *eap)
int idx;
int i, j, k;
char_u *end;
- char_u *arg = eap->arg;
+ char_u *arg = (char_u *)eap->arg;
if (hislen == 0) {
msg(_("'history' option is zero"));
diff --git a/src/nvim/extmark.c b/src/nvim/extmark.c
index ffd68926f1..1b0e2c8590 100644
--- a/src/nvim/extmark.c
+++ b/src/nvim/extmark.c
@@ -69,7 +69,8 @@ void extmark_set(buf_T *buf, uint32_t ns_id, uint32_t *idp, int row, colnr_T col
if (decor) {
if (kv_size(decor->virt_text)
|| kv_size(decor->virt_lines)
- || decor_has_sign(decor)) {
+ || decor_has_sign(decor)
+ || decor->ui_watched) {
decor_full = true;
decor = xmemdup(decor, sizeof *decor);
}
diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c
index 95c373ec5c..1c91df6387 100644
--- a/src/nvim/fileio.c
+++ b/src/nvim/fileio.c
@@ -3797,7 +3797,7 @@ static int set_rw_fname(char_u *fname, char_u *sfname)
// Do filetype detection now if 'filetype' is empty.
if (*curbuf->b_p_ft == NUL) {
if (augroup_exists("filetypedetect")) {
- (void)do_doautocmd((char_u *)"filetypedetect BufRead", false, NULL);
+ (void)do_doautocmd("filetypedetect BufRead", false, NULL);
}
do_modelines(0);
}
diff --git a/src/nvim/getchar.c b/src/nvim/getchar.c
index 539f6e3a1f..df9297dc0b 100644
--- a/src/nvim/getchar.c
+++ b/src/nvim/getchar.c
@@ -3938,7 +3938,7 @@ char_u *set_context_in_map_cmd(expand_T *xp, char_u *cmd, char_u *arg, bool forc
}
break;
}
- xp->xp_pattern = arg;
+ xp->xp_pattern = (char *)arg;
}
return NULL;
diff --git a/src/nvim/hardcopy.c b/src/nvim/hardcopy.c
index a6e7ba9fc1..b2974854c1 100644
--- a/src/nvim/hardcopy.c
+++ b/src/nvim/hardcopy.c
@@ -641,15 +641,15 @@ void ex_hardcopy(exarg_T *eap)
char *errormsg = NULL;
// Expand things like "%.ps".
- if (expand_filename(eap, eap->cmdlinep, &errormsg) == FAIL) {
+ if (expand_filename(eap, (char_u **)eap->cmdlinep, &errormsg) == FAIL) {
if (errormsg != NULL) {
emsg(errormsg);
}
return;
}
- settings.outfile = skipwhite(eap->arg + 1);
+ settings.outfile = skipwhite((char_u *)eap->arg + 1);
} else if (*eap->arg != NUL) {
- settings.arguments = eap->arg;
+ settings.arguments = (char_u *)eap->arg;
}
/*
diff --git a/src/nvim/highlight_group.c b/src/nvim/highlight_group.c
index 45c7863d00..9a0173f1d2 100644
--- a/src/nvim/highlight_group.c
+++ b/src/nvim/highlight_group.c
@@ -1453,8 +1453,7 @@ static bool highlight_list_arg(const int id, bool didh, const int type, int iarg
}
}
- (void)syn_list_header(didh, (int)(vim_strsize((char_u *)ts) + (int)STRLEN(name)
- + 1), id, false);
+ (void)syn_list_header(didh, vim_strsize((char_u *)ts) + (int)STRLEN(name) + 1, id, false);
didh = true;
if (!got_int) {
if (*name != NUL) {
@@ -1973,7 +1972,7 @@ void set_context_in_highlight_cmd(expand_T *xp, const char *arg)
{
// Default: expand group names.
xp->xp_context = EXPAND_HIGHLIGHT;
- xp->xp_pattern = (char_u *)arg;
+ xp->xp_pattern = (char *)arg;
include_link = 2;
include_default = 1;
@@ -1984,7 +1983,7 @@ void set_context_in_highlight_cmd(expand_T *xp, const char *arg)
include_default = 0;
if (strncmp("default", arg, (unsigned)(p - arg)) == 0) {
arg = (const char *)skipwhite((const char_u *)p);
- xp->xp_pattern = (char_u *)arg;
+ xp->xp_pattern = (char *)arg;
p = (const char *)skiptowhite((const char_u *)arg);
}
if (*p != NUL) { // past group name
@@ -1994,11 +1993,11 @@ void set_context_in_highlight_cmd(expand_T *xp, const char *arg)
}
if (strncmp("link", arg, (unsigned)(p - arg)) == 0
|| strncmp("clear", arg, (unsigned)(p - arg)) == 0) {
- xp->xp_pattern = skipwhite((const char_u *)p);
- p = (const char *)skiptowhite(xp->xp_pattern);
+ xp->xp_pattern = (char *)skipwhite((const char_u *)p);
+ p = (const char *)skiptowhite((char_u *)xp->xp_pattern);
if (*p != NUL) { // Past first group name.
- xp->xp_pattern = skipwhite((const char_u *)p);
- p = (const char *)skiptowhite(xp->xp_pattern);
+ xp->xp_pattern = (char *)skipwhite((const char_u *)p);
+ p = (const char *)skiptowhite((char_u *)xp->xp_pattern);
}
}
if (*p != NUL) { // Past group name(s).
diff --git a/src/nvim/if_cscope.c b/src/nvim/if_cscope.c
index 55af044658..ea1a0efec1 100644
--- a/src/nvim/if_cscope.c
+++ b/src/nvim/if_cscope.c
@@ -145,7 +145,7 @@ void set_context_in_cscope_cmd(expand_T *xp, const char *arg, cmdidx_T cmdidx)
{
// Default: expand subcommands.
xp->xp_context = EXPAND_CSCOPE;
- xp->xp_pattern = (char_u *)arg;
+ xp->xp_pattern = (char *)arg;
expand_what = ((cmdidx == CMD_scscope)
? EXP_SCSCOPE_SUBCMD : EXP_CSCOPE_SUBCMD);
@@ -153,8 +153,8 @@ void set_context_in_cscope_cmd(expand_T *xp, const char *arg, cmdidx_T cmdidx)
if (*arg != NUL) {
const char *p = (const char *)skiptowhite((const char_u *)arg);
if (*p != NUL) { // Past first word.
- xp->xp_pattern = skipwhite((const char_u *)p);
- if (*skiptowhite(xp->xp_pattern) != NUL) {
+ xp->xp_pattern = (char *)skipwhite((const char_u *)p);
+ if (*skiptowhite((char_u *)xp->xp_pattern) != NUL) {
xp->xp_context = EXPAND_NOTHING;
} else if (STRNICMP(arg, "add", p - arg) == 0) {
xp->xp_context = EXPAND_FILES;
@@ -224,8 +224,8 @@ void ex_cstag(exarg_T *eap)
switch (p_csto) {
case 0:
if (cs_check_for_connections()) {
- ret = cs_find_common("g", (char *)(eap->arg), eap->forceit, false,
- false, *eap->cmdlinep);
+ ret = cs_find_common("g", eap->arg, eap->forceit, false,
+ false, (char_u *)(*eap->cmdlinep));
if (ret == false) {
cs_free_tags();
if (msg_col) {
@@ -233,32 +233,32 @@ void ex_cstag(exarg_T *eap)
}
if (cs_check_for_tags()) {
- ret = do_tag(eap->arg, DT_JUMP, 0, eap->forceit, FALSE);
+ ret = do_tag((char_u *)eap->arg, DT_JUMP, 0, eap->forceit, false);
}
}
} else if (cs_check_for_tags()) {
- ret = do_tag(eap->arg, DT_JUMP, 0, eap->forceit, FALSE);
+ ret = do_tag((char_u *)eap->arg, DT_JUMP, 0, eap->forceit, false);
}
break;
case 1:
if (cs_check_for_tags()) {
- ret = do_tag(eap->arg, DT_JUMP, 0, eap->forceit, FALSE);
- if (ret == FALSE) {
+ ret = do_tag((char_u *)eap->arg, DT_JUMP, 0, eap->forceit, false);
+ if (ret == false) {
if (msg_col) {
msg_putchar('\n');
}
if (cs_check_for_connections()) {
- ret = cs_find_common("g", (char *)(eap->arg), eap->forceit,
- false, false, *eap->cmdlinep);
+ ret = cs_find_common("g", eap->arg, eap->forceit,
+ false, false, (char_u *)(*eap->cmdlinep));
if (ret == false) {
cs_free_tags();
}
}
}
} else if (cs_check_for_connections()) {
- ret = cs_find_common("g", (char *)(eap->arg), eap->forceit, false,
- false, *eap->cmdlinep);
+ ret = cs_find_common("g", eap->arg, eap->forceit, false,
+ false, (char_u *)(*eap->cmdlinep));
if (ret == false) {
cs_free_tags();
}
@@ -899,7 +899,7 @@ static int cs_find(exarg_T *eap)
}
pat = opt + strlen(opt) + 1;
- if (pat >= (char *)eap->arg + eap_arg_len) {
+ if (pat >= eap->arg + eap_arg_len) {
cs_usage_msg(Find);
return false;
}
@@ -915,7 +915,7 @@ static int cs_find(exarg_T *eap)
}
return cs_find_common(opt, pat, eap->forceit, true,
- eap->cmdidx == CMD_lcscope, *eap->cmdlinep);
+ eap->cmdidx == CMD_lcscope, (char_u *)(*eap->cmdlinep));
}
@@ -1210,7 +1210,7 @@ static cscmd_T *cs_lookup_cmd(exarg_T *eap)
// Store length of eap->arg before it gets modified by strtok().
eap_arg_len = (int)STRLEN(eap->arg);
- if ((stok = strtok((char *)(eap->arg), (const char *)" ")) == NULL) {
+ if ((stok = strtok(eap->arg, (const char *)" ")) == NULL) { // NOLINT(runtime/threadsafe_fn)
return NULL;
}
diff --git a/src/nvim/lua/executor.c b/src/nvim/lua/executor.c
index 9cdc299ea7..1777ba0a76 100644
--- a/src/nvim/lua/executor.c
+++ b/src/nvim/lua/executor.c
@@ -1873,7 +1873,7 @@ void nlua_do_ucmd(ucmd_T *cmd, exarg_T *eap)
char *buf = xcalloc(length, sizeof(char));
bool done = false;
while (!done) {
- done = uc_split_args_iter(eap->arg, length, &end, buf, &len);
+ done = uc_split_args_iter((char_u *)eap->arg, length, &end, buf, &len);
if (len > 0) {
lua_pushlstring(lstate, buf, len);
lua_rawseti(lstate, -2, i);
diff --git a/src/nvim/lua/treesitter.c b/src/nvim/lua/treesitter.c
index a871cd29ce..d3693207ec 100644
--- a/src/nvim/lua/treesitter.c
+++ b/src/nvim/lua/treesitter.c
@@ -16,6 +16,7 @@
#include "nvim/api/private/helpers.h"
#include "nvim/buffer.h"
+#include "nvim/lib/kvec.h"
#include "nvim/lua/treesitter.h"
#include "nvim/memline.h"
#include "tree_sitter/api.h"
@@ -104,6 +105,7 @@ static struct luaL_Reg treecursor_meta[] = {
{ NULL, NULL }
};
+static kvec_t(TSQueryCursor *) cursors = KV_INITIAL_VALUE;
static PMap(cstr_t) langs = MAP_INIT;
static void build_meta(lua_State *L, const char *tname, const luaL_Reg *meta)
@@ -1116,13 +1118,17 @@ static int node_rawquery(lua_State *L)
return 0;
}
TSQuery *query = query_check(L, 2);
- // TODO(bfredl): these are expensive allegedly,
- // use a reuse list later on?
- TSQueryCursor *cursor = ts_query_cursor_new();
+
+ TSQueryCursor *cursor;
+ if (kv_size(cursors) > 0) {
+ cursor = kv_pop(cursors);
+ } else {
+ cursor = ts_query_cursor_new();
+ }
// TODO(clason): API introduced after tree-sitter release 0.19.5
// remove guard when minimum ts version is bumped to 0.19.6+
#ifdef NVIM_TS_HAS_SET_MATCH_LIMIT
- ts_query_cursor_set_match_limit(cursor, 32);
+ ts_query_cursor_set_match_limit(cursor, 64);
#endif
ts_query_cursor_exec(cursor, query, node);
@@ -1161,7 +1167,8 @@ static int node_rawquery(lua_State *L)
static int querycursor_gc(lua_State *L)
{
TSLua_cursor *ud = luaL_checkudata(L, 1, TS_META_QUERYCURSOR);
- ts_query_cursor_delete(ud->cursor);
+ kv_push(cursors, ud->cursor);
+ ud->cursor = NULL;
return 0;
}
diff --git a/src/nvim/main.c b/src/nvim/main.c
index 5a496a10b4..3f9e875d74 100644
--- a/src/nvim/main.c
+++ b/src/nvim/main.c
@@ -513,7 +513,7 @@ int main(int argc, char **argv)
// Need to jump to the tag before executing the '-c command'.
// Makes "vim -c '/return' -t main" work.
- handle_tag(params.tagname);
+ handle_tag((char_u *)params.tagname);
// Execute any "+", "-c" and "-S" arguments.
if (params.n_commands > 0) {
@@ -1131,7 +1131,7 @@ static void command_line_scan(mparm_T *parmp)
}
parmp->edit_type = EDIT_QF;
if (argv[0][argv_idx]) { // "-q{errorfile}"
- parmp->use_ef = (char_u *)argv[0] + argv_idx;
+ parmp->use_ef = argv[0] + argv_idx;
argv_idx = -1;
} else if (argc > 1) { // "-q {errorfile}"
want_argument = true;
@@ -1160,7 +1160,7 @@ static void command_line_scan(mparm_T *parmp)
}
parmp->edit_type = EDIT_TAG;
if (argv[0][argv_idx]) { // "-t{tag}"
- parmp->tagname = (char_u *)argv[0] + argv_idx;
+ parmp->tagname = argv[0] + argv_idx;
argv_idx = -1;
} else { // "-t {tag}"
want_argument = true;
@@ -1272,7 +1272,7 @@ static void command_line_scan(mparm_T *parmp)
break;
case 'q': // "-q {errorfile}" QuickFix mode
- parmp->use_ef = (char_u *)argv[0];
+ parmp->use_ef = argv[0];
break;
case 'i': // "-i {shada}" use for shada
@@ -1313,7 +1313,7 @@ scripterror:
}
case 't': // "-t {tag}"
- parmp->tagname = (char_u *)argv[0];
+ parmp->tagname = argv[0];
break;
case 'u': // "-u {vimrc}" vim inits file
parmp->use_vimrc = argv[0];
@@ -1507,7 +1507,7 @@ static void handle_quickfix(mparm_T *paramp)
{
if (paramp->edit_type == EDIT_QF) {
if (paramp->use_ef != NULL) {
- set_string_option_direct("ef", -1, paramp->use_ef, OPT_FREE, SID_CARG);
+ set_string_option_direct("ef", -1, (char_u *)paramp->use_ef, OPT_FREE, SID_CARG);
}
vim_snprintf((char *)IObuff, IOSIZE, "cfile %s", p_ef);
if (qf_init(NULL, (char *)p_ef, p_efm, true, (char *)IObuff, (char *)p_menc) < 0) {
diff --git a/src/nvim/main.h b/src/nvim/main.h
index e55bef6e33..d5384ecc95 100644
--- a/src/nvim/main.h
+++ b/src/nvim/main.h
@@ -19,13 +19,13 @@ typedef struct {
int n_commands; // no. of commands from + or -c
char *commands[MAX_ARG_CMDS]; // commands from + or -c arg
- char_u cmds_tofree[MAX_ARG_CMDS]; // commands that need free()
+ char cmds_tofree[MAX_ARG_CMDS]; // commands that need free()
int n_pre_commands; // no. of commands from --cmd
char *pre_commands[MAX_ARG_CMDS]; // commands from --cmd argument
int edit_type; // type of editing to do
- char_u *tagname; // tag from -t argument
- char_u *use_ef; // 'errorfile' from -q argument
+ char *tagname; // tag from -t argument
+ char *use_ef; // 'errorfile' from -q argument
bool input_isatty; // stdin is a terminal
bool output_isatty; // stdout is a terminal
diff --git a/src/nvim/mark.c b/src/nvim/mark.c
index 4f4eea554a..0a9b1b26ef 100644
--- a/src/nvim/mark.c
+++ b/src/nvim/mark.c
@@ -651,7 +651,7 @@ static char_u *mark_line(pos_T *mp, int lead_len)
*/
void ex_marks(exarg_T *eap)
{
- char_u *arg = eap->arg;
+ char_u *arg = (char_u *)eap->arg;
int i;
char_u *name;
pos_T *posp, *startp, *endp;
@@ -668,7 +668,7 @@ void ex_marks(exarg_T *eap)
if (namedfm[i].fmark.fnum != 0) {
name = fm_getname(&namedfm[i].fmark, 15);
} else {
- name = namedfm[i].fname;
+ name = (char_u *)namedfm[i].fname;
}
if (name != NULL) {
show_one_mark(i >= NMARKS ? i - NMARKS + '0' : i + 'A',
@@ -767,7 +767,7 @@ void ex_delmarks(exarg_T *eap)
emsg(_(e_argreq));
} else {
// clear specified marks only
- for (p = eap->arg; *p != NUL; ++p) {
+ for (p = (char_u *)eap->arg; *p != NUL; p++) {
lower = ASCII_ISLOWER(*p);
digit = ascii_isdigit(*p);
if (lower || digit || ASCII_ISUPPER(*p)) {
@@ -1311,7 +1311,7 @@ void copy_jumplist(win_T *from, win_T *to)
for (i = 0; i < from->w_jumplistlen; ++i) {
to->w_jumplist[i] = from->w_jumplist[i];
if (from->w_jumplist[i].fname != NULL) {
- to->w_jumplist[i].fname = vim_strsave(from->w_jumplist[i].fname);
+ to->w_jumplist[i].fname = xstrdup(from->w_jumplist[i].fname);
}
}
to->w_jumplistlen = from->w_jumplistlen;
@@ -1665,7 +1665,7 @@ void get_global_marks(list_T *l)
if (namedfm[i].fmark.fnum != 0) {
name = (char *)buflist_nr2name(namedfm[i].fmark.fnum, true, true);
} else {
- name = (char *)namedfm[i].fname;
+ name = namedfm[i].fname;
}
if (name != NULL) {
mname[1] = i >= NMARKS ? (char)(i - NMARKS + '0') : (char)(i + 'A');
diff --git a/src/nvim/mark_defs.h b/src/nvim/mark_defs.h
index 51199a09e0..994ad30633 100644
--- a/src/nvim/mark_defs.h
+++ b/src/nvim/mark_defs.h
@@ -42,7 +42,7 @@ typedef struct filemark {
/// Structure defining extended mark (mark with file name attached)
typedef struct xfilemark {
fmark_T fmark; ///< Actual mark.
- char_u *fname; ///< File name, used when fnum == 0.
+ char *fname; ///< File name, used when fnum == 0.
} xfmark_T;
#endif // NVIM_MARK_DEFS_H
diff --git a/src/nvim/match.c b/src/nvim/match.c
index 86ddad0d47..e6f34c5876 100644
--- a/src/nvim/match.c
+++ b/src/nvim/match.c
@@ -1176,14 +1176,14 @@ void ex_match(exarg_T *eap)
}
if (ends_excmd(*eap->arg)) {
- end = eap->arg;
+ end = (char_u *)eap->arg;
} else if ((STRNICMP(eap->arg, "none", 4) == 0
&& (ascii_iswhite(eap->arg[4]) || ends_excmd(eap->arg[4])))) {
- end = eap->arg + 4;
+ end = (char_u *)eap->arg + 4;
} else {
- p = skiptowhite(eap->arg);
+ p = skiptowhite((char_u *)eap->arg);
if (!eap->skip) {
- g = vim_strnsave(eap->arg, (size_t)(p - eap->arg));
+ g = vim_strnsave((char_u *)eap->arg, (size_t)(p - (char_u *)eap->arg));
}
p = skipwhite(p);
if (*p == NUL) {
@@ -1213,5 +1213,5 @@ void ex_match(exarg_T *eap)
*end = (char_u)c;
}
}
- eap->nextcmd = find_nextcmd(end);
+ eap->nextcmd = (char *)find_nextcmd(end);
}
diff --git a/src/nvim/menu.c b/src/nvim/menu.c
index 54d3f4c55d..1bde0d1be9 100644
--- a/src/nvim/menu.c
+++ b/src/nvim/menu.c
@@ -76,8 +76,8 @@ void ex_menu(exarg_T *eap)
// kFalse for "menu disable
vimmenu_T menuarg;
- modes = get_menu_cmd_modes((char *)eap->cmd, eap->forceit, &noremap, &unmenu);
- arg = (char *)eap->arg;
+ modes = get_menu_cmd_modes(eap->cmd, eap->forceit, &noremap, &unmenu);
+ arg = eap->arg;
for (;;) {
if (STRNCMP(arg, "<script>", 8) == 0) {
@@ -1022,7 +1022,7 @@ char *set_context_in_menu_cmd(expand_T *xp, const char *cmd, char *arg, bool for
xfree(path_name);
xp->xp_context = expand_menus ? EXPAND_MENUNAMES : EXPAND_MENUS;
- xp->xp_pattern = (char_u *)after_dot;
+ xp->xp_pattern = after_dot;
expand_menu = menu;
} else { // We're in the mapping part
xp->xp_context = EXPAND_NOTHING;
@@ -1470,7 +1470,7 @@ static void execute_menu(const exarg_T *eap, vimmenu_T *menu)
// execute it.
void ex_emenu(exarg_T *eap)
{
- char *saved_name = xstrdup((char *)eap->arg);
+ char *saved_name = xstrdup(eap->arg);
vimmenu_T *menu = *get_root_menu(saved_name);
char *name = saved_name;
while (*name) {
@@ -1531,7 +1531,7 @@ static garray_T menutrans_ga = GA_EMPTY_INIT_VALUE;
*/
void ex_menutranslate(exarg_T *eap)
{
- char *arg = (char *)eap->arg;
+ char *arg = eap->arg;
char *from, *from_noamp, *to;
if (menutrans_ga.ga_itemsize == 0) {
diff --git a/src/nvim/message.c b/src/nvim/message.c
index e5e661c708..f0ef4e1d4f 100644
--- a/src/nvim/message.c
+++ b/src/nvim/message.c
@@ -631,7 +631,7 @@ static bool emsg_multiline(const char *s, bool multiline)
* when the message should be ignored completely (used for the
* interrupt message).
*/
- if (cause_errthrow((char_u *)s, severe, &ignore)) {
+ if (cause_errthrow(s, severe, &ignore)) {
if (!ignore) {
did_emsg++;
}
diff --git a/src/nvim/move.c b/src/nvim/move.c
index 49fa7bbf7f..11feb497ea 100644
--- a/src/nvim/move.c
+++ b/src/nvim/move.c
@@ -801,9 +801,9 @@ void curs_columns(win_T *wp, int may_scroll)
// When cursor wraps to first char of next line in Insert
// mode, the 'showbreak' string isn't shown, backup to first
// column
- char_u *const sbr = get_showbreak_value(wp);
+ char *const sbr = (char *)get_showbreak_value(wp);
if (*sbr && *get_cursor_pos_ptr() == NUL
- && wp->w_wcol == vim_strsize(sbr)) {
+ && wp->w_wcol == vim_strsize((char_u *)sbr)) {
wp->w_wcol = 0;
}
}
diff --git a/src/nvim/msgpack_rpc/server.c b/src/nvim/msgpack_rpc/server.c
index e954e4b3a3..f15ce82917 100644
--- a/src/nvim/msgpack_rpc/server.c
+++ b/src/nvim/msgpack_rpc/server.c
@@ -22,7 +22,8 @@
#include "nvim/vim.h"
#define MAX_CONNECTIONS 32
-#define LISTEN_ADDRESS_ENV_VAR "NVIM_LISTEN_ADDRESS"
+#define ENV_LISTEN "NVIM_LISTEN_ADDRESS" // deprecated
+#define ENV_NVIM "NVIM"
static garray_T watchers = GA_EMPTY_INIT_VALUE;
@@ -35,20 +36,24 @@ bool server_init(const char *listen_addr)
{
ga_init(&watchers, sizeof(SocketWatcher *), 1);
- // $NVIM_LISTEN_ADDRESS
- const char *env_addr = os_getenv(LISTEN_ADDRESS_ENV_VAR);
- int rv = listen_addr == NULL ? 1 : server_start(listen_addr);
+ // $NVIM_LISTEN_ADDRESS (deprecated)
+ if (!listen_addr && os_env_exists(ENV_LISTEN)) {
+ listen_addr = os_getenv(ENV_LISTEN);
+ }
+ int rv = listen_addr ? server_start(listen_addr) : 1;
if (0 != rv) {
- rv = env_addr == NULL ? 1 : server_start(env_addr);
- if (0 != rv) {
- listen_addr = server_address_new();
- if (listen_addr == NULL) {
- return false;
- }
- rv = server_start(listen_addr);
- xfree((char *)listen_addr);
+ listen_addr = server_address_new();
+ if (!listen_addr) {
+ return false;
}
+ rv = server_start(listen_addr);
+ xfree((char *)listen_addr);
+ }
+
+ if (os_env_exists(ENV_LISTEN)) {
+ // Unset $NVIM_LISTEN_ADDRESS, it's a liability hereafter.
+ os_unsetenv(ENV_LISTEN);
}
return rv == 0;
@@ -60,8 +65,8 @@ static void close_socket_watcher(SocketWatcher **watcher)
socket_watcher_close(*watcher, free_server);
}
-/// Set v:servername to the first server in the server list, or unset it if no
-/// servers are known.
+/// Sets the "primary address" (v:servername and $NVIM) to the first server in
+/// the server list, or unsets if no servers are known.
static void set_vservername(garray_T *srvs)
{
char *default_server = (srvs->ga_len > 0)
@@ -156,12 +161,6 @@ int server_start(const char *endpoint)
return result;
}
- // Update $NVIM_LISTEN_ADDRESS, if not set.
- const char *listen_address = os_getenv(LISTEN_ADDRESS_ENV_VAR);
- if (listen_address == NULL) {
- os_setenv(LISTEN_ADDRESS_ENV_VAR, watcher->addr, 1);
- }
-
// Add the watcher to the list.
ga_grow(&watchers, 1);
((SocketWatcher **)watchers.ga_data)[watchers.ga_len++] = watcher;
@@ -200,12 +199,6 @@ bool server_stop(char *endpoint)
return false;
}
- // Unset $NVIM_LISTEN_ADDRESS if it is the stopped address.
- const char *listen_address = os_getenv(LISTEN_ADDRESS_ENV_VAR);
- if (listen_address && STRCMP(addr, listen_address) == 0) {
- os_unsetenv(LISTEN_ADDRESS_ENV_VAR);
- }
-
socket_watcher_close(watcher, free_server);
// Remove this server from the list by swapping it with the last item.
@@ -215,8 +208,8 @@ bool server_stop(char *endpoint)
}
watchers.ga_len--;
- // If v:servername is the stopped address, re-initialize it.
- if (STRCMP(addr, get_vim_var_str(VV_SEND_SERVER)) == 0) {
+ // Bump v:servername to the next available server, if any.
+ if (strequal(addr, (char *)get_vim_var_str(VV_SEND_SERVER))) {
set_vservername(&watchers);
}
diff --git a/src/nvim/ops.c b/src/nvim/ops.c
index f0b328dd5f..611242dd0d 100644
--- a/src/nvim/ops.c
+++ b/src/nvim/ops.c
@@ -3830,7 +3830,7 @@ void ex_display(exarg_T *eap)
char_u *p;
yankreg_T *yb;
int name;
- char_u *arg = eap->arg;
+ char_u *arg = (char_u *)eap->arg;
int clen;
int type;
diff --git a/src/nvim/option.c b/src/nvim/option.c
index 1a40bac91a..16c4abfa2a 100644
--- a/src/nvim/option.c
+++ b/src/nvim/option.c
@@ -948,7 +948,7 @@ void ex_set(exarg_T *eap)
if (eap->forceit) {
flags |= OPT_ONECOLUMN;
}
- (void)do_set(eap->arg, flags);
+ (void)do_set((char_u *)eap->arg, flags);
}
/// Parse 'arg' for option settings.
@@ -6698,12 +6698,12 @@ void set_context_in_set_cmd(expand_T *xp, char_u *arg, int opt_flags)
xp->xp_context = EXPAND_SETTINGS;
if (*arg == NUL) {
- xp->xp_pattern = arg;
+ xp->xp_pattern = (char *)arg;
return;
}
p = arg + STRLEN(arg) - 1;
if (*p == ' ' && *(p - 1) != '\\') {
- xp->xp_pattern = p + 1;
+ xp->xp_pattern = (char *)p + 1;
return;
}
while (p > arg) {
@@ -6729,7 +6729,8 @@ void set_context_in_set_cmd(expand_T *xp, char_u *arg, int opt_flags)
xp->xp_context = EXPAND_BOOL_SETTINGS;
p += 3;
}
- xp->xp_pattern = arg = p;
+ xp->xp_pattern = (char *)p;
+ arg = p;
if (*arg == '<') {
while (*p != '>') {
if (*p++ == NUL) { // expand terminal option name
@@ -6796,7 +6797,7 @@ void set_context_in_set_cmd(expand_T *xp, char_u *arg, int opt_flags)
} else {
expand_option_idx = opt_idx;
}
- xp->xp_pattern = p + 1;
+ xp->xp_pattern = (char *)p + 1;
return;
}
xp->xp_context = EXPAND_NOTHING;
@@ -6804,7 +6805,7 @@ void set_context_in_set_cmd(expand_T *xp, char_u *arg, int opt_flags)
return;
}
- xp->xp_pattern = p + 1;
+ xp->xp_pattern = (char *)p + 1;
if (flags & P_EXPAND) {
p = options[opt_idx].var;
@@ -6837,16 +6838,16 @@ void set_context_in_set_cmd(expand_T *xp, char_u *arg, int opt_flags)
// For an option that is a list of file names, find the start of the
// last file name.
- for (p = arg + STRLEN(arg) - 1; p > xp->xp_pattern; p--) {
+ for (p = arg + STRLEN(arg) - 1; p > (char_u *)xp->xp_pattern; p--) {
// count number of backslashes before ' ' or ','
if (*p == ' ' || *p == ',') {
s = p;
- while (s > xp->xp_pattern && *(s - 1) == '\\') {
+ while (s > (char_u *)xp->xp_pattern && *(s - 1) == '\\') {
s--;
}
if ((*p == ' ' && (xp->xp_backslash == XP_BS_THREE && (p - s) < 3))
|| (*p == ',' && (flags & P_COMMA) && ((p - s) & 1) == 0)) {
- xp->xp_pattern = p + 1;
+ xp->xp_pattern = (char *)p + 1;
break;
}
}
@@ -6854,7 +6855,7 @@ void set_context_in_set_cmd(expand_T *xp, char_u *arg, int opt_flags)
// for 'spellsuggest' start at "file:"
if (options[opt_idx].var == (char_u *)&p_sps
&& STRNCMP(p, "file:", 5) == 0) {
- xp->xp_pattern = p + 5;
+ xp->xp_pattern = (char *)p + 5;
break;
}
}
diff --git a/src/nvim/path.c b/src/nvim/path.c
index bf394ec9ab..4cbe6ebcf5 100644
--- a/src/nvim/path.c
+++ b/src/nvim/path.c
@@ -503,7 +503,7 @@ char *save_abs_path(const char *name)
if (!path_is_absolute((char_u *)name)) {
return FullName_save(name, true);
}
- return (char *)vim_strsave((char_u *)name);
+ return xstrdup(name);
}
/// Checks if a path has a wildcard character including '~', unless at the end.
diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c
index f13fd11fd3..667c0cd7b6 100644
--- a/src/nvim/quickfix.c
+++ b/src/nvim/quickfix.c
@@ -3174,7 +3174,7 @@ void qf_list(exarg_T *eap)
int i;
int idx1 = 1;
int idx2 = -1;
- char *arg = (char *)eap->arg;
+ char *arg = eap->arg;
int all = eap->forceit; // if not :cl!, only show
// recognised errors
qf_info_T *qi;
@@ -4392,7 +4392,7 @@ void ex_make(exarg_T *eap)
}
os_remove(fname); // in case it's not unique
- char *const cmd = make_get_fullcmd((char *)eap->arg, fname);
+ char *const cmd = make_get_fullcmd(eap->arg, fname);
do_shell(cmd, 0);
@@ -4401,7 +4401,7 @@ void ex_make(exarg_T *eap)
res = qf_init(wp, fname, (eap->cmdidx != CMD_make
&& eap->cmdidx != CMD_lmake) ? p_gefm : p_efm,
(eap->cmdidx != CMD_grepadd && eap->cmdidx != CMD_lgrepadd),
- qf_cmdtitle((char *)(*eap->cmdlinep)), enc);
+ qf_cmdtitle(*eap->cmdlinep), enc);
if (wp != NULL) {
qi = GET_LOC_LIST(wp);
if (qi == NULL) {
@@ -5112,7 +5112,7 @@ void ex_cfile(exarg_T *eap)
}
}
if (*eap->arg != NUL) {
- set_string_option_direct("ef", -1, eap->arg, OPT_FREE, 0);
+ set_string_option_direct("ef", -1, (char_u *)eap->arg, OPT_FREE, 0);
}
char *enc = (*curbuf->b_p_menc != NUL) ? (char *)curbuf->b_p_menc : (char *)p_menc;
@@ -5133,7 +5133,7 @@ void ex_cfile(exarg_T *eap)
// quickfix list then a new list is created.
int res = qf_init(wp, (char *)p_ef, p_efm, (eap->cmdidx != CMD_caddfile
&& eap->cmdidx != CMD_laddfile),
- qf_cmdtitle((char *)(*eap->cmdlinep)), enc);
+ qf_cmdtitle(*eap->cmdlinep), enc);
if (wp != NULL) {
qi = GET_LOC_LIST(wp);
if (qi == NULL) {
@@ -5229,7 +5229,7 @@ static buf_T *vgr_load_dummy_buf(char *fname, char *dirname_start, char *dirname
{
// Don't do Filetype autocommands to avoid loading syntax and
// indent scripts, a great speed improvement.
- char *save_ei = (char *)au_event_disable(",Filetype");
+ char *save_ei = au_event_disable(",Filetype");
long save_mls = p_mls;
p_mls = 0;
@@ -5239,7 +5239,7 @@ static buf_T *vgr_load_dummy_buf(char *fname, char *dirname_start, char *dirname
buf_T *buf = load_dummy_buffer(fname, dirname_start, dirname_now);
p_mls = save_mls;
- au_event_restore((char_u *)save_ei);
+ au_event_restore(save_ei);
return buf;
}
@@ -5385,7 +5385,7 @@ static void vgr_jump_to_match(qf_info_T *qi, int forceit, bool *redraw_for_dummy
// Jump to the directory used after loading the buffer.
if (curbuf == first_match_buf && target_dir != NULL) {
exarg_T ea = {
- .arg = (char_u *)target_dir,
+ .arg = target_dir,
.cmdidx = CMD_lcd,
};
ex_cd(&ea);
@@ -5414,7 +5414,7 @@ static int vgr_process_args(exarg_T *eap, vgr_args_T *args)
memset(args, 0, sizeof(*args));
args->regmatch.regprog = NULL;
- args->qf_title = xstrdup(qf_cmdtitle((char *)(*eap->cmdlinep)));
+ args->qf_title = xstrdup(qf_cmdtitle(*eap->cmdlinep));
if (eap->addr_count > 0) {
args->tomatch = eap->line2;
@@ -5423,7 +5423,7 @@ static int vgr_process_args(exarg_T *eap, vgr_args_T *args)
}
// Get the search pattern: either white-separated or enclosed in //
- char *p = skip_vimgrep_pat((char *)eap->arg, &args->spat, &args->flags);
+ char *p = skip_vimgrep_pat(eap->arg, &args->spat, &args->flags);
if (p == NULL) {
emsg(_(e_invalpat));
return FAIL;
@@ -5682,7 +5682,7 @@ static void restore_start_dir(char *dirname_start)
// If the directory has changed, change it back by building up an
// appropriate ex command and executing it.
exarg_T ea = {
- .arg = (char_u *)dirname_start,
+ .arg = dirname_start,
.cmdidx = (curwin->w_localdir == NULL) ? CMD_cd : CMD_lcd,
};
ex_cd(&ea);
@@ -6887,8 +6887,8 @@ static int cbuffer_process_args(exarg_T *eap, buf_T **bufp, linenr_T *line1, lin
if (*eap->arg == NUL) {
buf = curbuf;
- } else if (*skipwhite(skipdigits(eap->arg)) == NUL) {
- buf = buflist_findnr(atoi((char *)eap->arg));
+ } else if (*skipwhite(skipdigits((char_u *)eap->arg)) == NUL) {
+ buf = buflist_findnr(atoi(eap->arg));
}
if (buf == NULL) {
@@ -6949,7 +6949,7 @@ void ex_cbuffer(exarg_T *eap)
return;
}
- qf_title = qf_cmdtitle((char *)(*eap->cmdlinep));
+ qf_title = qf_cmdtitle(*eap->cmdlinep);
if (buf->b_sfname) {
vim_snprintf((char *)IObuff, IOSIZE, "%s (%s)",
@@ -7035,7 +7035,7 @@ void ex_cexpr(exarg_T *eap)
// Evaluate the expression. When the result is a string or a list we can
// use it to fill the errorlist.
typval_T tv;
- if (eval0((char *)eap->arg, &tv, (char **)&eap->nextcmd, true) != FAIL) {
+ if (eval0(eap->arg, &tv, &eap->nextcmd, true) != FAIL) {
if ((tv.v_type == VAR_STRING && tv.vval.v_string != NULL)
|| tv.v_type == VAR_LIST) {
incr_quickfix_busy();
@@ -7043,7 +7043,7 @@ void ex_cexpr(exarg_T *eap)
(eap->cmdidx != CMD_caddexpr
&& eap->cmdidx != CMD_laddexpr),
(linenr_T)0, (linenr_T)0,
- qf_cmdtitle((char *)(*eap->cmdlinep)), NULL);
+ qf_cmdtitle(*eap->cmdlinep), NULL);
if (qf_stack_empty(qi)) {
decr_quickfix_busy();
goto cleanup;
@@ -7238,14 +7238,14 @@ void ex_helpgrep(exarg_T *eap)
incr_quickfix_busy();
// Check for a specified language
- char *const lang = check_help_lang((char *)eap->arg);
+ char *const lang = check_help_lang(eap->arg);
regmatch_T regmatch = {
- .regprog = vim_regcomp(eap->arg, RE_MAGIC + RE_STRING),
+ .regprog = vim_regcomp((char_u *)eap->arg, RE_MAGIC + RE_STRING),
.rm_ic = false,
};
if (regmatch.regprog != NULL) {
// Create a new quickfix list.
- qf_new_list(qi, qf_cmdtitle((char *)(*eap->cmdlinep)));
+ qf_new_list(qi, qf_cmdtitle(*eap->cmdlinep));
qf_list_T *const qfl = qf_get_curlist(qi);
hgr_search_in_rtp(qfl, &regmatch, lang);
diff --git a/src/nvim/runtime.c b/src/nvim/runtime.c
index 3f21fae995..43de92f497 100644
--- a/src/nvim/runtime.c
+++ b/src/nvim/runtime.c
@@ -35,7 +35,7 @@ void runtime_init(void)
/// ":runtime [what] {name}"
void ex_runtime(exarg_T *eap)
{
- char_u *arg = eap->arg;
+ char_u *arg = (char_u *)eap->arg;
char_u *p = skiptowhite(arg);
ptrdiff_t len = p - arg;
int flags = eap->forceit ? DIP_ALL : 0;
diff --git a/src/nvim/screen.c b/src/nvim/screen.c
index 58abc1599a..746b3ac4d8 100644
--- a/src/nvim/screen.c
+++ b/src/nvim/screen.c
@@ -67,6 +67,7 @@
#include "nvim/api/extmark.h"
#include "nvim/api/private/helpers.h"
+#include "nvim/api/ui.h"
#include "nvim/api/vim.h"
#include "nvim/arabic.h"
#include "nvim/ascii.h"
@@ -161,6 +162,14 @@ static bool msg_grid_invalid = false;
static bool resizing = false;
+typedef struct {
+ NS ns_id;
+ uint64_t mark_id;
+ int win_row;
+ int win_col;
+} WinExtmark;
+static kvec_t(WinExtmark) win_extmark_arr INIT(= KV_INITIAL_VALUE);
+
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "screen.c.generated.h"
@@ -1314,6 +1323,8 @@ static void win_update(win_T *wp, DecorProviders *providers)
srow = 0;
lnum = wp->w_topline; // first line shown in window
+ win_extmark_arr.size = 0;
+
decor_redraw_reset(buf, &decor_state);
DecorProviders line_providers;
@@ -1692,6 +1703,15 @@ static void win_update(win_T *wp, DecorProviders *providers)
wp->w_old_topfill = wp->w_topfill;
wp->w_old_botfill = wp->w_botfill;
+ // Send win_extmarks if needed
+ if (kv_size(win_extmark_arr) > 0) {
+ for (size_t n = 0; n < kv_size(win_extmark_arr); n++) {
+ ui_call_win_extmark(wp->w_grid_alloc.handle, wp->handle,
+ kv_A(win_extmark_arr, n).ns_id, kv_A(win_extmark_arr, n).mark_id,
+ kv_A(win_extmark_arr, n).win_row, kv_A(win_extmark_arr, n).win_col);
+ }
+ }
+
if (dollar_vcol == -1) {
/*
* There is a trick with w_botline. If we invalidate it on each
@@ -1964,7 +1984,7 @@ static inline void provider_err_virt_text(linenr_T lnum, char *err)
((VirtTextChunk){ .text = provider_err,
.hl_id = hl_err }));
err_decor.virt_text_width = mb_string2cells((char_u *)err);
- decor_add_ephemeral(lnum - 1, 0, lnum - 1, 0, &err_decor);
+ decor_add_ephemeral(lnum - 1, 0, lnum - 1, 0, &err_decor, 0, 0);
}
static inline void get_line_number_str(win_T *wp, linenr_T lnum, char_u *buf, size_t buf_len)
@@ -2881,7 +2901,7 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool noc
&& vcol >= (long)wp->w_virtcol)
|| (number_only && draw_state > WL_NR))
&& filler_todo <= 0) {
- draw_virt_text(buf, win_col_offset, &col, grid->Columns);
+ draw_virt_text(wp, buf, win_col_offset, &col, grid->Columns, row);
grid_put_linebuf(grid, row, 0, col, -grid->Columns, wp->w_p_rl, wp,
wp->w_hl_attr_normal, false);
// Pretend we have finished updating the window. Except when
@@ -3951,7 +3971,7 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool noc
}
}
- draw_virt_text(buf, win_col_offset, &col, grid->Columns);
+ draw_virt_text(wp, buf, win_col_offset, &col, grid->Columns, row);
grid_put_linebuf(grid, row, 0, col, grid->Columns, wp->w_p_rl, wp,
wp->w_hl_attr_normal, false);
row++;
@@ -4195,7 +4215,7 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool noc
kHlModeReplace, grid->Columns, offset);
}
} else {
- draw_virt_text(buf, win_col_offset, &draw_col, grid->Columns);
+ draw_virt_text(wp, buf, win_col_offset, &draw_col, grid->Columns, row);
}
grid_put_linebuf(grid, row, 0, draw_col, grid->Columns, wp->w_p_rl,
@@ -4274,14 +4294,15 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool noc
return row;
}
-void draw_virt_text(buf_T *buf, int col_off, int *end_col, int max_col)
+void draw_virt_text(win_T *wp, buf_T *buf, int col_off, int *end_col, int max_col, int win_row)
{
DecorState *state = &decor_state;
int right_pos = max_col;
bool do_eol = state->eol_col > -1;
for (size_t i = 0; i < kv_size(state->active); i++) {
DecorRange *item = &kv_A(state->active, i);
- if (!(item->start_row == state->row && kv_size(item->decor.virt_text))) {
+ if (!(item->start_row == state->row
+ && (kv_size(item->decor.virt_text) || item->decor.ui_watched))) {
continue;
}
if (item->win_col == -1) {
@@ -4297,9 +4318,17 @@ void draw_virt_text(buf_T *buf, int col_off, int *end_col, int max_col)
if (item->win_col < 0) {
continue;
}
-
- int col = draw_virt_text_item(buf, item->win_col, item->decor.virt_text,
- item->decor.hl_mode, max_col, item->win_col - col_off);
+ int col;
+ if (item->decor.ui_watched) {
+ // send mark position to UI
+ col = item->win_col;
+ WinExtmark m = { item->ns_id, item->mark_id, win_row, col };
+ kv_push(win_extmark_arr, m);
+ }
+ if (kv_size(item->decor.virt_text)) {
+ col = draw_virt_text_item(buf, item->win_col, item->decor.virt_text,
+ item->decor.hl_mode, max_col, item->win_col - col_off);
+ }
item->win_col = -2; // deactivate
if (item->decor.virt_text_pos == kVTEndOfLine && do_eol) {
state->eol_col = col + 1;
diff --git a/src/nvim/shada.c b/src/nvim/shada.c
index a19dbac6f3..e89efe1cbc 100644
--- a/src/nvim/shada.c
+++ b/src/nvim/shada.c
@@ -1289,9 +1289,7 @@ static void shada_read(ShaDaReadDef *const sd_reader, const int flags)
XFREE_CLEAR(cur_entry.data.filemark.fname);
}
xfmark_T fm = (xfmark_T) {
- .fname = (char_u *)(buf == NULL
- ? cur_entry.data.filemark.fname
- : NULL),
+ .fname = buf == NULL ? cur_entry.data.filemark.fname : NULL,
.fmark = {
.mark = cur_entry.data.filemark.mark,
.fnum = (buf == NULL ? 0 : buf->b_fnum),
@@ -4027,9 +4025,9 @@ static inline size_t shada_init_jumps(PossiblyFreedShadaEntry *jumps,
: fm.fmark.fnum != 0) {
continue;
}
- const char *const fname = (char *)(fm.fmark.fnum == 0
- ? (fm.fname == NULL ? NULL : fm.fname)
- : buf ? buf->b_ffname : NULL);
+ const char *const fname =
+ (char *)(fm.fmark.fnum ==
+ 0 ? (fm.fname == NULL ? NULL : (char_u *)fm.fname) : buf ? buf->b_ffname : NULL);
if (fname == NULL) {
continue;
}
diff --git a/src/nvim/sign.c b/src/nvim/sign.c
index db3ce45b51..e2d40b4a21 100644
--- a/src/nvim/sign.c
+++ b/src/nvim/sign.c
@@ -1419,7 +1419,7 @@ static int parse_sign_cmd_args(int cmd, char_u *arg, char_u **sign_name, int *si
/// ":sign" command
void ex_sign(exarg_T *eap)
{
- char_u *arg = eap->arg;
+ char_u *arg = (char_u *)eap->arg;
char_u *p;
int idx;
sign_T *sp;
@@ -1785,7 +1785,7 @@ void set_context_in_sign_cmd(expand_T *xp, char_u *arg)
// Default: expand subcommands.
xp->xp_context = EXPAND_SIGN;
expand_what = EXP_SUBCMD;
- xp->xp_pattern = arg;
+ xp->xp_pattern = (char *)arg;
end_subcmd = skiptowhite(arg);
if (*end_subcmd == NUL) {
@@ -1822,7 +1822,7 @@ void set_context_in_sign_cmd(expand_T *xp, char_u *arg)
// last p
if (p == NULL) {
// Expand last argument name (before equal sign).
- xp->xp_pattern = last;
+ xp->xp_pattern = (char *)last;
switch (cmd_idx) {
case SIGNCMD_DEFINE:
expand_what = EXP_DEFINE;
@@ -1852,7 +1852,7 @@ void set_context_in_sign_cmd(expand_T *xp, char_u *arg)
}
} else {
// Expand last argument value (after equal sign).
- xp->xp_pattern = p + 1;
+ xp->xp_pattern = (char *)p + 1;
switch (cmd_idx) {
case SIGNCMD_DEFINE:
if (STRNCMP(last, "texthl", 6) == 0
diff --git a/src/nvim/spellfile.c b/src/nvim/spellfile.c
index f4e50778cf..c1b116e498 100644
--- a/src/nvim/spellfile.c
+++ b/src/nvim/spellfile.c
@@ -4874,7 +4874,7 @@ void ex_mkspell(exarg_T *eap)
{
int fcount;
char_u **fnames;
- char_u *arg = eap->arg;
+ char_u *arg = (char_u *)eap->arg;
bool ascii = false;
if (STRNCMP(arg, "-ascii", 6) == 0) {
@@ -5501,7 +5501,7 @@ static void spell_message(const spellinfo_T *spin, char_u *str)
// ":[count]spellrare {word}"
void ex_spell(exarg_T *eap)
{
- spell_add_word(eap->arg, (int)STRLEN(eap->arg),
+ spell_add_word((char_u *)eap->arg, (int)STRLEN(eap->arg),
eap->cmdidx == CMD_spellwrong ? SPELL_ADD_BAD :
eap->cmdidx == CMD_spellrare ? SPELL_ADD_RARE : SPELL_ADD_GOOD,
eap->forceit ? 0 : (int)eap->line2,
diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c
index 4ba89319e7..7afabdeb96 100644
--- a/src/nvim/syntax.c
+++ b/src/nvim/syntax.c
@@ -3032,10 +3032,10 @@ static keyentry_T *match_keyword(char_u *keyword, hashtab_T *ht, stateitem_T *cu
*/
static void syn_cmd_conceal(exarg_T *eap, int syncing)
{
- char_u *arg = eap->arg;
+ char_u *arg = (char_u *)eap->arg;
char_u *next;
- eap->nextcmd = find_nextcmd(arg);
+ eap->nextcmd = (char *)find_nextcmd(arg);
if (eap->skip) {
return;
}
@@ -3061,10 +3061,10 @@ static void syn_cmd_conceal(exarg_T *eap, int syncing)
*/
static void syn_cmd_case(exarg_T *eap, int syncing)
{
- char_u *arg = eap->arg;
+ char_u *arg = (char_u *)eap->arg;
char_u *next;
- eap->nextcmd = find_nextcmd(arg);
+ eap->nextcmd = (char *)find_nextcmd(arg);
if (eap->skip) {
return;
}
@@ -3088,10 +3088,10 @@ static void syn_cmd_case(exarg_T *eap, int syncing)
/// Handle ":syntax foldlevel" command.
static void syn_cmd_foldlevel(exarg_T *eap, int syncing)
{
- char_u *arg = eap->arg;
+ char_u *arg = (char_u *)eap->arg;
char_u *arg_end;
- eap->nextcmd = find_nextcmd(arg);
+ eap->nextcmd = (char *)find_nextcmd(arg);
if (eap->skip) {
return;
}
@@ -3129,10 +3129,10 @@ static void syn_cmd_foldlevel(exarg_T *eap, int syncing)
*/
static void syn_cmd_spell(exarg_T *eap, int syncing)
{
- char_u *arg = eap->arg;
+ char_u *arg = (char_u *)eap->arg;
char_u *next;
- eap->nextcmd = find_nextcmd(arg);
+ eap->nextcmd = (char *)find_nextcmd(arg);
if (eap->skip) {
return;
}
@@ -3164,7 +3164,7 @@ static void syn_cmd_spell(exarg_T *eap, int syncing)
/// Handle ":syntax iskeyword" command.
static void syn_cmd_iskeyword(exarg_T *eap, int syncing)
{
- char_u *arg = eap->arg;
+ char_u *arg = (char_u *)eap->arg;
char_u save_chartab[32];
char_u *save_isk;
@@ -3336,11 +3336,11 @@ static void syn_clear_cluster(synblock_T *block, int i)
*/
static void syn_cmd_clear(exarg_T *eap, int syncing)
{
- char_u *arg = eap->arg;
+ char_u *arg = (char_u *)eap->arg;
char_u *arg_end;
int id;
- eap->nextcmd = find_nextcmd(arg);
+ eap->nextcmd = (char *)find_nextcmd(arg);
if (eap->skip) {
return;
}
@@ -3440,7 +3440,7 @@ static void syn_cmd_on(exarg_T *eap, int syncing)
*/
static void syn_cmd_reset(exarg_T *eap, int syncing)
{
- eap->nextcmd = check_nextcmd(eap->arg);
+ eap->nextcmd = (char *)check_nextcmd((char_u *)eap->arg);
if (!eap->skip) {
init_highlight(true, true);
}
@@ -3465,7 +3465,7 @@ static void syn_cmd_off(exarg_T *eap, int syncing)
static void syn_cmd_onoff(exarg_T *eap, char *name)
FUNC_ATTR_NONNULL_ALL
{
- eap->nextcmd = check_nextcmd(eap->arg);
+ eap->nextcmd = (char *)check_nextcmd((char_u *)eap->arg);
if (!eap->skip) {
did_syntax_onoff = true;
char buf[100];
@@ -3479,7 +3479,7 @@ void syn_maybe_enable(void)
{
if (!did_syntax_onoff) {
exarg_T ea;
- ea.arg = (char_u *)"";
+ ea.arg = "";
ea.skip = false;
syn_cmd_on(&ea, false);
}
@@ -3490,10 +3490,10 @@ void syn_maybe_enable(void)
/// @param syncing when TRUE: list syncing items
static void syn_cmd_list(exarg_T *eap, int syncing)
{
- char_u *arg = eap->arg;
+ char_u *arg = (char_u *)eap->arg;
char_u *arg_end;
- eap->nextcmd = find_nextcmd(arg);
+ eap->nextcmd = (char *)find_nextcmd(arg);
if (eap->skip) {
return;
}
@@ -3569,7 +3569,7 @@ static void syn_cmd_list(exarg_T *eap, int syncing)
arg = skipwhite(arg_end);
}
}
- eap->nextcmd = check_nextcmd(arg);
+ eap->nextcmd = (char *)check_nextcmd(arg);
}
static void syn_lines_msg(void)
@@ -4261,7 +4261,7 @@ static void syn_incl_toplevel(int id, int *flagsp)
*/
static void syn_cmd_include(exarg_T *eap, int syncing)
{
- char_u *arg = eap->arg;
+ char_u *arg = (char_u *)eap->arg;
int sgl_id = 1;
char_u *group_name_end;
char_u *rest;
@@ -4270,7 +4270,7 @@ static void syn_cmd_include(exarg_T *eap, int syncing)
int prev_syn_inc_tag;
bool source = false;
- eap->nextcmd = find_nextcmd(arg);
+ eap->nextcmd = (char *)find_nextcmd(arg);
if (eap->skip) {
return;
}
@@ -4287,7 +4287,7 @@ static void syn_cmd_include(exarg_T *eap, int syncing)
return;
}
// separate_nextcmd() and expand_filename() depend on this
- eap->arg = rest;
+ eap->arg = (char *)rest;
}
/*
@@ -4296,7 +4296,7 @@ static void syn_cmd_include(exarg_T *eap, int syncing)
*/
eap->argt |= (EX_XFILE | EX_NOSPC);
separate_nextcmd(eap);
- if (*eap->arg == '<' || *eap->arg == '$' || path_is_absolute(eap->arg)) {
+ if (*eap->arg == '<' || *eap->arg == '$' || path_is_absolute((char_u *)eap->arg)) {
// For an absolute path, "$VIM/..." or "<sfile>.." we ":source" the
// file. Need to expand the file name first. In other cases
// ":runtime!" is used.
@@ -4322,8 +4322,8 @@ static void syn_cmd_include(exarg_T *eap, int syncing)
prev_toplvl_grp = curwin->w_s->b_syn_topgrp;
curwin->w_s->b_syn_topgrp = sgl_id;
if (source
- ? do_source((char *)eap->arg, false, DOSO_NONE) == FAIL
- : source_runtime((char *)eap->arg, DIP_ALL) == FAIL) {
+ ? do_source(eap->arg, false, DOSO_NONE) == FAIL
+ : source_runtime(eap->arg, DIP_ALL) == FAIL) {
semsg(_(e_notopen), eap->arg);
}
curwin->w_s->b_syn_topgrp = prev_toplvl_grp;
@@ -4335,7 +4335,7 @@ static void syn_cmd_include(exarg_T *eap, int syncing)
*/
static void syn_cmd_keyword(exarg_T *eap, int syncing)
{
- char_u *arg = eap->arg;
+ char_u *arg = (char_u *)eap->arg;
char_u *group_name_end;
int syn_id;
char_u *rest;
@@ -4432,7 +4432,7 @@ error:
}
if (rest != NULL) {
- eap->nextcmd = check_nextcmd(rest);
+ eap->nextcmd = (char *)check_nextcmd(rest);
} else {
semsg(_(e_invarg2), arg);
}
@@ -4448,7 +4448,7 @@ error:
/// @param syncing TRUE for ":syntax sync match .. "
static void syn_cmd_match(exarg_T *eap, int syncing)
{
- char_u *arg = eap->arg;
+ char_u *arg = (char_u *)eap->arg;
char_u *group_name_end;
char_u *rest;
synpat_T item; // the item found in the line
@@ -4485,7 +4485,7 @@ static void syn_cmd_match(exarg_T *eap, int syncing)
/*
* Check for trailing command and illegal trailing arguments.
*/
- eap->nextcmd = check_nextcmd(rest);
+ eap->nextcmd = (char *)check_nextcmd(rest);
if (!ends_excmd(*rest) || eap->skip) {
rest = NULL;
} else {
@@ -4546,7 +4546,7 @@ static void syn_cmd_match(exarg_T *eap, int syncing)
/// @param syncing TRUE for ":syntax sync region .."
static void syn_cmd_region(exarg_T *eap, int syncing)
{
- char_u *arg = eap->arg;
+ char_u *arg = (char_u *)eap->arg;
char_u *group_name_end;
char_u *rest; // next arg, NULL on error
char_u *key_end;
@@ -4692,7 +4692,7 @@ static void syn_cmd_region(exarg_T *eap, int syncing)
* Check for trailing garbage or command.
* If OK, add the item.
*/
- eap->nextcmd = check_nextcmd(rest);
+ eap->nextcmd = (char *)check_nextcmd(rest);
if (!ends_excmd(*rest) || eap->skip) {
rest = NULL;
} else {
@@ -4990,14 +4990,14 @@ static int syn_add_cluster(char_u *name)
*/
static void syn_cmd_cluster(exarg_T *eap, int syncing)
{
- char_u *arg = eap->arg;
+ char_u *arg = (char_u *)eap->arg;
char_u *group_name_end;
char_u *rest;
bool got_clstr = false;
int opt_len;
int list_op;
- eap->nextcmd = find_nextcmd(arg);
+ eap->nextcmd = (char *)find_nextcmd(arg);
if (eap->skip) {
return;
}
@@ -5167,7 +5167,7 @@ static char_u *get_syn_pattern(char_u *arg, synpat_T *ci)
*/
static void syn_cmd_sync(exarg_T *eap, int syncing)
{
- char_u *arg_start = eap->arg;
+ char_u *arg_start = (char_u *)eap->arg;
char_u *arg_end;
char_u *key = NULL;
char_u *next_arg;
@@ -5267,7 +5267,7 @@ static void syn_cmd_sync(exarg_T *eap, int syncing)
}
next_arg = skipwhite(arg_end + 1);
} else {
- eap->arg = next_arg;
+ eap->arg = (char *)next_arg;
if (STRCMP(key, "MATCH") == 0) {
syn_cmd_match(eap, TRUE);
} else if (STRCMP(key, "REGION") == 0) {
@@ -5286,7 +5286,7 @@ static void syn_cmd_sync(exarg_T *eap, int syncing)
if (illegal) {
semsg(_("E404: Illegal arguments: %s"), arg_start);
} else if (!finished) {
- eap->nextcmd = check_nextcmd(arg_start);
+ eap->nextcmd = (char *)check_nextcmd(arg_start);
redraw_curbuf_later(SOME_VALID);
syn_stack_free_all(curwin->w_s); // Need to recompute all syntax.
}
@@ -5614,10 +5614,10 @@ static struct subcommand subcommands[] =
*/
void ex_syntax(exarg_T *eap)
{
- char_u *arg = eap->arg;
+ char_u *arg = (char_u *)eap->arg;
char_u *subcmd_end;
- syn_cmdlinep = eap->cmdlinep;
+ syn_cmdlinep = (char_u **)eap->cmdlinep;
// isolate subcommand name
for (subcmd_end = arg; ASCII_ISALPHA(*subcmd_end); subcmd_end++) {}
@@ -5631,8 +5631,8 @@ void ex_syntax(exarg_T *eap)
break;
}
if (STRCMP(subcmd_name, (char_u *)subcommands[i].name) == 0) {
- eap->arg = skipwhite(subcmd_end);
- (subcommands[i].func)(eap, FALSE);
+ eap->arg = (char *)skipwhite(subcmd_end);
+ (subcommands[i].func)(eap, false);
break;
}
}
@@ -5669,7 +5669,7 @@ void ex_ownsyntax(exarg_T *eap)
}
// Apply the "syntax" autocommand event, this finds and loads the syntax file.
- apply_autocmds(EVENT_SYNTAX, eap->arg, curbuf->b_fname, true, curbuf);
+ apply_autocmds(EVENT_SYNTAX, (char_u *)eap->arg, curbuf->b_fname, true, curbuf);
// Move value of b:current_syntax to w:current_syntax.
new_value = get_var_value("b:current_syntax");
@@ -5718,7 +5718,7 @@ void reset_expand_highlight(void)
void set_context_in_echohl_cmd(expand_T *xp, const char *arg)
{
xp->xp_context = EXPAND_HIGHLIGHT;
- xp->xp_pattern = (char_u *)arg;
+ xp->xp_pattern = (char *)arg;
include_none = 1;
}
@@ -5730,7 +5730,7 @@ void set_context_in_syntax_cmd(expand_T *xp, const char *arg)
// Default: expand subcommands.
xp->xp_context = EXPAND_SYNTAX;
expand_what = EXP_SUBCMD;
- xp->xp_pattern = (char_u *)arg;
+ xp->xp_pattern = (char *)arg;
include_link = 0;
include_default = 0;
@@ -5738,8 +5738,8 @@ void set_context_in_syntax_cmd(expand_T *xp, const char *arg)
if (*arg != NUL) {
const char *p = (const char *)skiptowhite((const char_u *)arg);
if (*p != NUL) { // Past first word.
- xp->xp_pattern = skipwhite((const char_u *)p);
- if (*skiptowhite(xp->xp_pattern) != NUL) {
+ xp->xp_pattern = (char *)skipwhite((const char_u *)p);
+ if (*skiptowhite((char_u *)xp->xp_pattern) != NUL) {
xp->xp_context = EXPAND_NOTHING;
} else if (STRNICMP(arg, "case", p - arg) == 0) {
expand_what = EXP_CASE;
diff --git a/src/nvim/terminal.c b/src/nvim/terminal.c
index b07c3786c3..225aa0100e 100644
--- a/src/nvim/terminal.c
+++ b/src/nvim/terminal.c
@@ -179,6 +179,13 @@ static void term_output_callback(const char *s, size_t len, void *user_data)
// public API {{{
+/// Initializes terminal properties, and triggers TermOpen.
+///
+/// The PTY process (TerminalOptions.data) was already started by termopen(),
+/// via ex_terminal() or the term:// BufReadCmd.
+///
+/// @param buf Buffer used for presentation of the terminal.
+/// @param opts PTY process channel, various terminal properties and callbacks.
Terminal *terminal_open(buf_T *buf, TerminalOptions opts)
{
// Create a new terminal instance and configure it
@@ -374,6 +381,7 @@ void terminal_check_size(Terminal *term)
invalidate_terminal(term, -1, -1);
}
+/// Implements TERM_FOCUS mode. :help Terminal-mode
void terminal_enter(void)
{
buf_T *buf = curbuf;
@@ -502,6 +510,7 @@ static int terminal_check(VimState *state)
return 1;
}
+/// Processes one char of terminal-mode input.
static int terminal_execute(VimState *state, int key)
{
TerminalState *s = (TerminalState *)state;
@@ -1448,7 +1457,8 @@ static void refresh_terminal(Terminal *term)
long ml_added = buf->b_ml.ml_line_count - ml_before;
adjust_topline(term, buf, ml_added);
}
-// Calls refresh_terminal() on all invalidated_terminals.
+
+/// Calls refresh_terminal() on all invalidated_terminals.
static void refresh_timer_cb(TimeWatcher *watcher, void *data)
{
refresh_pending = false;
diff --git a/src/nvim/terminal.h b/src/nvim/terminal.h
index 001adbadc3..a83929e224 100644
--- a/src/nvim/terminal.h
+++ b/src/nvim/terminal.h
@@ -13,7 +13,7 @@ typedef void (*terminal_close_cb)(void *data);
#include "nvim/buffer_defs.h"
typedef struct {
- void *data;
+ void *data; // PTY process channel
uint16_t width, height;
terminal_write_cb write_cb;
terminal_resize_cb resize_cb;