mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
refactor: replace char_u variables and functions with char
Work on https://github.com/neovim/neovim/issues/459
This commit is contained in:
parent
4f17e7e1c3
commit
f08477789f
@ -23,9 +23,9 @@
|
|||||||
// Copy string or array of strings into an empty array.
|
// Copy string or array of strings into an empty array.
|
||||||
// Get the event number, unless it is an error. Then goto `goto_name`.
|
// Get the event number, unless it is an error. Then goto `goto_name`.
|
||||||
#define GET_ONE_EVENT(event_nr, event_str, goto_name) \
|
#define GET_ONE_EVENT(event_nr, event_str, goto_name) \
|
||||||
char_u *__next_ev; \
|
char *__next_ev; \
|
||||||
event_T event_nr = \
|
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) { \
|
if (event_nr >= NUM_EVENTS) { \
|
||||||
api_set_error(err, kErrorTypeValidation, "unexpected event"); \
|
api_set_error(err, kErrorTypeValidation, "unexpected event"); \
|
||||||
goto goto_name; \
|
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 = ... })
|
// TODO(tjdevries): Would be cool to add nvim_get_autocmds({ id = ... })
|
||||||
|
|
||||||
Array autocmd_list = ARRAY_DICT_INIT;
|
Array autocmd_list = ARRAY_DICT_INIT;
|
||||||
char_u *pattern_filters[AUCMD_MAX_PATTERNS];
|
char *pattern_filters[AUCMD_MAX_PATTERNS];
|
||||||
char_u pattern_buflocal[BUFLOCAL_PAT_LEN];
|
char pattern_buflocal[BUFLOCAL_PAT_LEN];
|
||||||
|
|
||||||
Array buffers = ARRAY_DICT_INIT;
|
Array buffers = ARRAY_DICT_INIT;
|
||||||
|
|
||||||
@ -148,7 +148,7 @@ Array nvim_get_autocmds(Dict(get_autocmds) *opts, Error *err)
|
|||||||
if (opts->pattern.type != kObjectTypeNil) {
|
if (opts->pattern.type != kObjectTypeNil) {
|
||||||
Object v = opts->pattern;
|
Object v = opts->pattern;
|
||||||
if (v.type == kObjectTypeString) {
|
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;
|
pattern_filter_count += 1;
|
||||||
} else if (v.type == kObjectTypeArray) {
|
} else if (v.type == kObjectTypeArray) {
|
||||||
if (v.data.array.size > AUCMD_MAX_PATTERNS) {
|
if (v.data.array.size > AUCMD_MAX_PATTERNS) {
|
||||||
@ -164,7 +164,7 @@ Array nvim_get_autocmds(Dict(get_autocmds) *opts, Error *err)
|
|||||||
goto cleanup;
|
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;
|
pattern_filter_count += 1;
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
@ -211,7 +211,7 @@ Array nvim_get_autocmds(Dict(get_autocmds) *opts, Error *err)
|
|||||||
}
|
}
|
||||||
|
|
||||||
FOREACH_ITEM(buffers, bufnr, {
|
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;
|
pattern_filter_count += 1;
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -237,7 +237,7 @@ Array nvim_get_autocmds(Dict(get_autocmds) *opts, Error *err)
|
|||||||
assert(i < AUCMD_MAX_PATTERNS);
|
assert(i < AUCMD_MAX_PATTERNS);
|
||||||
assert(pattern_filters[i]);
|
assert(pattern_filters[i]);
|
||||||
|
|
||||||
char_u *pat = pattern_filters[i];
|
char *pat = pattern_filters[i];
|
||||||
int patlen = (int)STRLEN(pat);
|
int patlen = (int)STRLEN(pat);
|
||||||
|
|
||||||
if (aupat_is_buflocal(pat, patlen)) {
|
if (aupat_is_buflocal(pat, patlen)) {
|
||||||
@ -249,7 +249,7 @@ Array nvim_get_autocmds(Dict(get_autocmds) *opts, Error *err)
|
|||||||
pat = pattern_buflocal;
|
pat = pattern_buflocal;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strequal((char *)ap->pat, (char *)pat)) {
|
if (strequal(ap->pat, pat)) {
|
||||||
passed = true;
|
passed = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -531,7 +531,7 @@ Integer nvim_create_autocmd(uint64_t channel_id, Object event, Dict(create_autoc
|
|||||||
WITH_SCRIPT_CONTEXT(channel_id, {
|
WITH_SCRIPT_CONTEXT(channel_id, {
|
||||||
retval = autocmd_register(autocmd_id,
|
retval = autocmd_register(autocmd_id,
|
||||||
event_nr,
|
event_nr,
|
||||||
(char_u *)pat.data.string.data,
|
pat.data.string.data,
|
||||||
(int)pat.data.string.size,
|
(int)pat.data.string.size,
|
||||||
au_group,
|
au_group,
|
||||||
is_once,
|
is_once,
|
||||||
@ -635,8 +635,8 @@ void nvim_clear_autocmds(Dict(clear_autocmds) *opts, Error *err)
|
|||||||
if (event_array.size == 0) {
|
if (event_array.size == 0) {
|
||||||
FOR_ALL_AUEVENTS(event) {
|
FOR_ALL_AUEVENTS(event) {
|
||||||
FOREACH_ITEM(patterns, pat_object, {
|
FOREACH_ITEM(patterns, pat_object, {
|
||||||
char_u *pat = (char_u *)pat_object.data.string.data;
|
char *pat = pat_object.data.string.data;
|
||||||
if (!clear_autocmd(event, pat, au_group, err)) {
|
if (!clear_autocmd(event, (char *)pat, au_group, err)) {
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -646,8 +646,8 @@ void nvim_clear_autocmds(Dict(clear_autocmds) *opts, Error *err)
|
|||||||
GET_ONE_EVENT(event_nr, event_str, cleanup);
|
GET_ONE_EVENT(event_nr, event_str, cleanup);
|
||||||
|
|
||||||
FOREACH_ITEM(patterns, pat_object, {
|
FOREACH_ITEM(patterns, pat_object, {
|
||||||
char_u *pat = (char_u *)pat_object.data.string.data;
|
char *pat = pat_object.data.string.data;
|
||||||
if (!clear_autocmd(event_nr, pat, au_group, err)) {
|
if (!clear_autocmd(event_nr, (char *)pat, au_group, err)) {
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -757,7 +757,7 @@ void nvim_exec_autocmds(Object event, Dict(exec_autocmds) *opts, Error *err)
|
|||||||
buf_T *buf = curbuf;
|
buf_T *buf = curbuf;
|
||||||
bool set_buf = false;
|
bool set_buf = false;
|
||||||
|
|
||||||
char_u *pattern = NULL;
|
char *pattern = NULL;
|
||||||
bool set_pattern = false;
|
bool set_pattern = false;
|
||||||
|
|
||||||
Array event_array = ARRAY_DICT_INIT;
|
Array event_array = ARRAY_DICT_INIT;
|
||||||
@ -812,7 +812,7 @@ void nvim_exec_autocmds(Object event, Dict(exec_autocmds) *opts, Error *err)
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
pattern = (char_u *)string_to_cstr(opts->pattern.data.string);
|
pattern = string_to_cstr(opts->pattern.data.string);
|
||||||
set_pattern = true;
|
set_pattern = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -920,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,
|
static bool get_patterns_from_pattern_or_buf(Array *patterns, Object pattern, Object buffer,
|
||||||
Error *err)
|
Error *err)
|
||||||
{
|
{
|
||||||
const char_u pattern_buflocal[BUFLOCAL_PAT_LEN];
|
const char pattern_buflocal[BUFLOCAL_PAT_LEN];
|
||||||
|
|
||||||
if (pattern.type != kObjectTypeNil && buffer.type != kObjectTypeNil) {
|
if (pattern.type != kObjectTypeNil && buffer.type != kObjectTypeNil) {
|
||||||
api_set_error(err, kErrorTypeValidation,
|
api_set_error(err, kErrorTypeValidation,
|
||||||
@ -930,7 +930,7 @@ static bool get_patterns_from_pattern_or_buf(Array *patterns, Object pattern, Ob
|
|||||||
Object *v = &pattern;
|
Object *v = &pattern;
|
||||||
|
|
||||||
if (v->type == kObjectTypeString) {
|
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);
|
size_t patlen = aucmd_pattern_length(pat);
|
||||||
while (patlen) {
|
while (patlen) {
|
||||||
ADD(*patterns, STRING_OBJ(cbuf_to_string((char *)pat, patlen)));
|
ADD(*patterns, STRING_OBJ(cbuf_to_string((char *)pat, patlen)));
|
||||||
@ -945,7 +945,7 @@ static bool get_patterns_from_pattern_or_buf(Array *patterns, Object pattern, Ob
|
|||||||
|
|
||||||
Array array = v->data.array;
|
Array array = v->data.array;
|
||||||
for (size_t i = 0; i < array.size; i++) {
|
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);
|
size_t patlen = aucmd_pattern_length(pat);
|
||||||
while (patlen) {
|
while (patlen) {
|
||||||
ADD(*patterns, STRING_OBJ(cbuf_to_string((char *)pat, patlen)));
|
ADD(*patterns, STRING_OBJ(cbuf_to_string((char *)pat, patlen)));
|
||||||
@ -980,9 +980,9 @@ static bool get_patterns_from_pattern_or_buf(Array *patterns, Object pattern, Ob
|
|||||||
return true;
|
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");
|
api_set_error(err, kErrorTypeException, "Failed to clear autocmd");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -810,4 +810,3 @@ static void remote_ui_inspect(UI *ui, Dictionary *info)
|
|||||||
UIData *data = ui->data;
|
UIData *data = ui->data;
|
||||||
PUT(*info, "chan", INTEGER_OBJ((Integer)data->channel_id));
|
PUT(*info, "chan", INTEGER_OBJ((Integer)data->channel_id));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,7 +100,7 @@ static int autocmd_blocked = 0; // block all autocmds
|
|||||||
static bool autocmd_nested = false;
|
static bool autocmd_nested = false;
|
||||||
static bool autocmd_include_groups = 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
|
/// Iterates over all the AutoPats for a particular event
|
||||||
#define FOR_ALL_AUPATS_IN_EVENT(event, ap) \
|
#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_col = 4;
|
||||||
msg_outtrans(ap->pat);
|
msg_outtrans((char_u *)ap->pat);
|
||||||
|
|
||||||
for (AutoCmd *ac = ap->cmds; ac != NULL; ac = ac->next) {
|
for (AutoCmd *ac = ap->cmds; ac != NULL; ac = ac->next) {
|
||||||
// skip removed commands
|
// 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) {
|
FOR_ALL_AUEVENTS(event) {
|
||||||
au_show_for_event(group, event, pat);
|
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
|
// Return early if there are no autocmds for this event
|
||||||
if (au_event_is_empty(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;
|
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.
|
// Loop through all the specified patterns.
|
||||||
int patlen = (int)aucmd_pattern_length(pat);
|
int patlen = (int)aucmd_pattern_length(pat);
|
||||||
while (patlen) {
|
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)) {
|
if (aupat_is_buflocal(pat, patlen)) {
|
||||||
// normalize pat into standard "<buffer>#N" form
|
// normalize pat into standard "<buffer>#N" form
|
||||||
aupat_normalize_buflocal_pat(buflocal_pat, pat, patlen, aupat_get_buflocal_nr(pat, patlen));
|
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);
|
patlen = (int)STRLEN(buflocal_pat);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -554,18 +554,18 @@ bool augroup_exists(const char *name)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// ":augroup {name}".
|
/// ":augroup {name}".
|
||||||
void do_augroup(char_u *arg, int del_group)
|
void do_augroup(char *arg, int del_group)
|
||||||
{
|
{
|
||||||
if (del_group) {
|
if (del_group) {
|
||||||
if (*arg == NUL) {
|
if (*arg == NUL) {
|
||||||
emsg(_(e_argreq));
|
emsg(_(e_argreq));
|
||||||
} else {
|
} else {
|
||||||
augroup_del((char *)arg, true);
|
augroup_del(arg, true);
|
||||||
}
|
}
|
||||||
} else if (STRICMP(arg, "end") == 0) { // ":aug end": back to group 0
|
} else if (STRICMP(arg, "end") == 0) { // ":aug end": back to group 0
|
||||||
current_augroup = AUGROUP_DEFAULT;
|
current_augroup = AUGROUP_DEFAULT;
|
||||||
} else if (*arg) { // ":aug xxx": switch to group xxx
|
} 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
|
} else { // ":aug": list the group names
|
||||||
msg_start();
|
msg_start();
|
||||||
|
|
||||||
@ -618,9 +618,9 @@ void free_all_autocmds(void)
|
|||||||
// Return the event number for event name "start".
|
// Return the event number for event name "start".
|
||||||
// Return NUM_EVENTS if the event name was not found.
|
// Return NUM_EVENTS if the event name was not found.
|
||||||
// Return a pointer to the next event name in "end".
|
// 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;
|
int i;
|
||||||
|
|
||||||
// the event name ends with end of line, '|', a blank or a comma
|
// 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 == ',') {
|
if (*p == ',') {
|
||||||
p++;
|
p++;
|
||||||
}
|
}
|
||||||
*end = (char_u *)p;
|
*end = (char *)p;
|
||||||
if (event_names[i].name == NULL) {
|
if (event_names[i].name == NULL) {
|
||||||
return NUM_EVENTS;
|
return NUM_EVENTS;
|
||||||
}
|
}
|
||||||
@ -664,7 +664,7 @@ const char *event_nr2name(event_T event)
|
|||||||
static bool event_ignored(event_T event)
|
static bool event_ignored(event_T event)
|
||||||
FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT
|
FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT
|
||||||
{
|
{
|
||||||
char_u *p = p_ei;
|
char *p = (char *)p_ei;
|
||||||
|
|
||||||
while (*p != NUL) {
|
while (*p != NUL) {
|
||||||
if (STRNICMP(p, "all", 3) == 0 && (p[3] == NUL || p[3] == ',')) {
|
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.
|
// Return OK when the contents of p_ei is valid, FAIL otherwise.
|
||||||
int check_ei(void)
|
int check_ei(void)
|
||||||
{
|
{
|
||||||
char_u *p = p_ei;
|
char *p = (char *)p_ei;
|
||||||
|
|
||||||
while (*p) {
|
while (*p) {
|
||||||
if (STRNICMP(p, "all", 3) == 0 && (p[3] == NUL || p[3] == ',')) {
|
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
|
// Add "what" to 'eventignore' to skip loading syntax highlighting for every
|
||||||
// buffer loaded into the window. "what" must start with a comma.
|
// buffer loaded into the window. "what" must start with a comma.
|
||||||
// Returns the old value of 'eventignore' in allocated memory.
|
// 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 *save_ei = (char *)vim_strsave(p_ei);
|
||||||
char_u *new_ei = vim_strnsave(p_ei, STRLEN(p_ei) + STRLEN(what));
|
char *new_ei = (char *)vim_strnsave(p_ei, STRLEN(p_ei) + STRLEN(what));
|
||||||
if (*what == ',' && *p_ei == NUL) {
|
if (*what == ',' && *p_ei == NUL) {
|
||||||
STRCPY(new_ei, what + 1);
|
STRCPY(new_ei, what + 1);
|
||||||
} else {
|
} else {
|
||||||
STRCAT(new_ei, what);
|
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);
|
xfree(new_ei);
|
||||||
|
|
||||||
return save_ei;
|
return save_ei;
|
||||||
}
|
}
|
||||||
|
|
||||||
void au_event_restore(char_u *old_ei)
|
void au_event_restore(char *old_ei)
|
||||||
{
|
{
|
||||||
if (old_ei != NULL) {
|
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);
|
xfree(old_ei);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -755,18 +755,18 @@ void au_event_restore(char_u *old_ei)
|
|||||||
// :autocmd * *.c show all autocommands for *.c files.
|
// :autocmd * *.c show all autocommands for *.c files.
|
||||||
//
|
//
|
||||||
// Mostly a {group} argument can optionally appear before <event>.
|
// 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 *arg = arg_in;
|
||||||
char_u *envpat = NULL;
|
char *envpat = NULL;
|
||||||
char_u *cmd;
|
char *cmd;
|
||||||
int need_free = false;
|
int need_free = false;
|
||||||
bool nested = false;
|
bool nested = false;
|
||||||
bool once = false;
|
bool once = false;
|
||||||
int group;
|
int group;
|
||||||
|
|
||||||
if (*arg == '|') {
|
if (*arg == '|') {
|
||||||
arg = (char_u *)"";
|
arg = "";
|
||||||
group = AUGROUP_ALL; // no argument, use all groups
|
group = AUGROUP_ALL; // no argument, use all groups
|
||||||
} else {
|
} else {
|
||||||
// Check for a legal group name. If not, use AUGROUP_ALL.
|
// 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.
|
// Scan over the events.
|
||||||
// If we find an illegal name, return here, don't do anything.
|
// 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) {
|
if (pat == NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
pat = skipwhite(pat);
|
pat = (char *)skipwhite((char_u *)pat);
|
||||||
if (*pat == '|') {
|
if (*pat == '|') {
|
||||||
pat = (char_u *)"";
|
pat = "";
|
||||||
cmd = (char_u *)"";
|
cmd = "";
|
||||||
} else {
|
} else {
|
||||||
// Scan over the pattern. Put a NUL at the end.
|
// Scan over the pattern. Put a NUL at the end.
|
||||||
cmd = pat;
|
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
|
// Expand environment variables in the pattern. Set 'shellslash', we want
|
||||||
// forward slashes here.
|
// 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
|
#ifdef BACKSLASH_IN_FILENAME
|
||||||
int p_ssl_save = p_ssl;
|
int p_ssl_save = p_ssl;
|
||||||
|
|
||||||
p_ssl = true;
|
p_ssl = true;
|
||||||
#endif
|
#endif
|
||||||
envpat = expand_env_save(pat);
|
envpat = (char *)expand_env_save((char_u *)pat);
|
||||||
#ifdef BACKSLASH_IN_FILENAME
|
#ifdef BACKSLASH_IN_FILENAME
|
||||||
p_ssl = p_ssl_save;
|
p_ssl = p_ssl_save;
|
||||||
#endif
|
#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;
|
bool invalid_flags = false;
|
||||||
for (size_t i = 0; i < 2; i++) {
|
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.
|
// Find the start of the commands.
|
||||||
// Expand <sfile> in it.
|
// Expand <sfile> in it.
|
||||||
if (*cmd != NUL) {
|
if (*cmd != NUL) {
|
||||||
cmd = (char_u *)expand_sfile((char *)cmd);
|
cmd = expand_sfile(cmd);
|
||||||
if (cmd == NULL) { // some error
|
if (cmd == NULL) { // some error
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -878,7 +878,7 @@ void do_autocmd(char_u *arg_in, int forceit)
|
|||||||
xfree(envpat);
|
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) {
|
FOR_ALL_AUEVENTS(event) {
|
||||||
if (do_autocmd_event(event, pat, once, nested, cmd, delete, group)
|
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 *cmd == NUL: show entries.
|
||||||
// If forceit == true: delete entries.
|
// If forceit == true: delete entries.
|
||||||
// If group is not AUGROUP_ALL: only use this group.
|
// 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)
|
int group)
|
||||||
FUNC_ATTR_NONNULL_ALL
|
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;
|
AutoPat **prev_ap;
|
||||||
int findgroup;
|
int findgroup;
|
||||||
int buflocal_nr;
|
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;
|
bool is_adding_cmd = *cmd != NUL;
|
||||||
|
|
||||||
@ -972,7 +972,7 @@ int do_autocmd_event(event_T event, char_u *pat, bool once, int nested, char_u *
|
|||||||
if (is_adding_cmd) {
|
if (is_adding_cmd) {
|
||||||
AucmdExecutable exec = AUCMD_EXECUTABLE_INIT;
|
AucmdExecutable exec = AUCMD_EXECUTABLE_INIT;
|
||||||
exec.type = CALLABLE_EX;
|
exec.type = CALLABLE_EX;
|
||||||
exec.callable.cmd = (char *)cmd;
|
exec.callable.cmd = cmd;
|
||||||
autocmd_register(0, event, pat, patlen, group, once, nested, NULL, exec);
|
autocmd_register(0, event, pat, patlen, group, once, nested, NULL, exec);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -984,7 +984,7 @@ int do_autocmd_event(event_T event, char_u *pat, bool once, int nested, char_u *
|
|||||||
return OK;
|
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)
|
bool nested, char *desc, AucmdExecutable aucmd)
|
||||||
{
|
{
|
||||||
// 0 is not a valid group.
|
// 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;
|
AutoPat **prev_ap;
|
||||||
AutoCmd *ac;
|
AutoCmd *ac;
|
||||||
int findgroup;
|
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)) {
|
if (patlen > (int)STRLEN(pat)) {
|
||||||
return FAIL;
|
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 = xmalloc(sizeof(AutoPat));
|
||||||
ap->pat = vim_strnsave(pat, (size_t)patlen);
|
ap->pat = xstrnsave(pat, (size_t)patlen);
|
||||||
ap->patlen = patlen;
|
ap->patlen = patlen;
|
||||||
|
|
||||||
if (is_buflocal) {
|
if (is_buflocal) {
|
||||||
ap->buflocal_nr = buflocal_nr;
|
ap->buflocal_nr = buflocal_nr;
|
||||||
ap->reg_prog = NULL;
|
ap->reg_prog = NULL;
|
||||||
} else {
|
} else {
|
||||||
char_u *reg_pat;
|
char *reg_pat;
|
||||||
|
|
||||||
ap->buflocal_nr = 0;
|
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) {
|
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);
|
xfree(reg_pat);
|
||||||
if (reg_pat == NULL || ap->reg_prog == NULL) {
|
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;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t aucmd_pattern_length(char_u *pat)
|
size_t aucmd_pattern_length(char *pat)
|
||||||
FUNC_ATTR_PURE
|
FUNC_ATTR_PURE
|
||||||
{
|
{
|
||||||
if (*pat == NUL) {
|
if (*pat == NUL) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
char_u *endpat;
|
char *endpat;
|
||||||
|
|
||||||
for (; *pat; pat = (*endpat == ',' ? endpat + 1 : endpat)) {
|
for (; *pat; pat = (*endpat == ',' ? endpat + 1 : endpat)) {
|
||||||
// Find end of the pattern.
|
// Find end of the pattern.
|
||||||
@ -1176,7 +1177,7 @@ size_t aucmd_pattern_length(char_u *pat)
|
|||||||
return STRLEN(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
|
FUNC_ATTR_PURE
|
||||||
{
|
{
|
||||||
pat = pat + patlen;
|
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;
|
/// Return OK for success, FAIL for failure;
|
||||||
///
|
///
|
||||||
/// @param do_msg give message for no matching autocmds?
|
/// @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;
|
int nothing_done = true;
|
||||||
|
|
||||||
if (did_something != NULL) {
|
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.
|
// Scan over the events.
|
||||||
// If we find an illegal name, return here, don't do anything.
|
// 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) {
|
if (fname == NULL) {
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
fname = skipwhite(fname);
|
fname = (char *)skipwhite((char_u *)fname);
|
||||||
|
|
||||||
// Loop over the events.
|
// Loop over the events.
|
||||||
while (*arg && !ends_excmd(*arg) && !ascii_iswhite(*arg)) {
|
while (*arg && !ends_excmd(*arg) && !ascii_iswhite(*arg)) {
|
||||||
@ -1241,7 +1242,7 @@ void ex_doautoall(exarg_T *eap)
|
|||||||
int retval = OK;
|
int retval = OK;
|
||||||
aco_save_T aco;
|
aco_save_T aco;
|
||||||
char_u *arg = (char_u *)eap->arg;
|
char_u *arg = (char_u *)eap->arg;
|
||||||
int call_do_modelines = check_nomodeline(&arg);
|
int call_do_modelines = check_nomodeline((char **)&arg);
|
||||||
bufref_T bufref;
|
bufref_T bufref;
|
||||||
bool did_aucmd;
|
bool did_aucmd;
|
||||||
|
|
||||||
@ -1260,7 +1261,7 @@ void ex_doautoall(exarg_T *eap)
|
|||||||
set_bufref(&bufref, buf);
|
set_bufref(&bufref, buf);
|
||||||
|
|
||||||
// execute the autocommands for this buffer
|
// 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) {
|
if (call_do_modelines && did_aucmd) {
|
||||||
// Execute the modeline settings, but don't set window-local
|
// 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.
|
// Execute autocommands for the current buffer last.
|
||||||
if (retval == OK) {
|
if (retval == OK) {
|
||||||
(void)do_doautocmd(arg, false, &did_aucmd);
|
(void)do_doautocmd((char *)arg, false, &did_aucmd);
|
||||||
if (call_do_modelines && did_aucmd) {
|
if (call_do_modelines && did_aucmd) {
|
||||||
do_modelines(0);
|
do_modelines(0);
|
||||||
}
|
}
|
||||||
@ -1293,11 +1294,11 @@ void ex_doautoall(exarg_T *eap)
|
|||||||
/// called when true is returned.
|
/// called when true is returned.
|
||||||
///
|
///
|
||||||
/// @param[in,out] argp argument string
|
/// @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
|
FUNC_ATTR_NONNULL_ALL FUNC_ATTR_WARN_UNUSED_RESULT
|
||||||
{
|
{
|
||||||
if (STRNCMP(*argp, "<nomodeline>", 12) == 0) {
|
if (STRNCMP(*argp, "<nomodeline>", 12) == 0) {
|
||||||
*argp = skipwhite(*argp + 12);
|
*argp = (char *)skipwhite((char_u *)(*argp) + 12);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
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
|
// Make sure w_localdir and globaldir are NULL to avoid a chdir() in
|
||||||
// win_enter_ext().
|
// win_enter_ext().
|
||||||
XFREE_CLEAR(aucmd_win->w_localdir);
|
XFREE_CLEAR(aucmd_win->w_localdir);
|
||||||
aco->globaldir = globaldir;
|
aco->globaldir = (char *)globaldir;
|
||||||
globaldir = NULL;
|
globaldir = NULL;
|
||||||
|
|
||||||
block_autocmds(); // We don't want BufEnter/WinEnter autocommands.
|
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
|
hash_init(&aucmd_win->w_vars->dv_hashtab); // re-use the hashtab
|
||||||
|
|
||||||
xfree(globaldir);
|
xfree(globaldir);
|
||||||
globaldir = aco->globaldir;
|
globaldir = (char_u *)aco->globaldir;
|
||||||
|
|
||||||
// the buffer contents may have changed
|
// the buffer contents may have changed
|
||||||
check_cursor();
|
check_cursor();
|
||||||
@ -1505,7 +1506,7 @@ win_found:
|
|||||||
/// @return true if some commands were executed.
|
/// @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)
|
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);
|
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,
|
bool apply_autocmds_exarg(event_T event, char_u *fname, char_u *fname_io, bool force, buf_T *buf,
|
||||||
exarg_T *eap)
|
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);
|
eap);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1547,7 +1548,7 @@ bool apply_autocmds_retval(event_T event, char_u *fname, char_u *fname_io, bool
|
|||||||
return false;
|
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);
|
AUGROUP_ALL, buf, NULL);
|
||||||
if (did_cmd && aborting()) {
|
if (did_cmd && aborting()) {
|
||||||
*retval = FAIL;
|
*retval = FAIL;
|
||||||
@ -1596,14 +1597,14 @@ bool trigger_cursorhold(void) FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT
|
|||||||
/// @param eap Ex command arguments
|
/// @param eap Ex command arguments
|
||||||
///
|
///
|
||||||
/// @return true if some commands were executed.
|
/// @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)
|
buf_T *buf, exarg_T *eap)
|
||||||
{
|
{
|
||||||
char_u *sfname = NULL; // short file name
|
char *sfname = NULL; // short file name
|
||||||
bool retval = false;
|
bool retval = false;
|
||||||
static int nesting = 0;
|
static int nesting = 0;
|
||||||
AutoPat *ap;
|
AutoPat *ap;
|
||||||
char_u *save_cmdarg;
|
char *save_cmdarg;
|
||||||
long save_cmdbang;
|
long save_cmdbang;
|
||||||
static int filechangeshell_busy = false;
|
static int filechangeshell_busy = false;
|
||||||
proftime_T wait_time;
|
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.
|
// 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;
|
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_busy = autocmd_busy;
|
||||||
int save_autocmd_nested = autocmd_nested;
|
int save_autocmd_nested = autocmd_nested;
|
||||||
bool save_changed = curbuf->b_changed;
|
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) {
|
|| event == EVENT_OPTIONSET || event == EVENT_MODECHANGED) {
|
||||||
autocmd_fname = NULL;
|
autocmd_fname = NULL;
|
||||||
} else if (fname != NULL && !ends_excmd(*fname)) {
|
} else if (fname != NULL && !ends_excmd(*fname)) {
|
||||||
autocmd_fname = fname;
|
autocmd_fname = (char_u *)fname;
|
||||||
} else if (buf != NULL) {
|
} else if (buf != NULL) {
|
||||||
autocmd_fname = buf->b_ffname;
|
autocmd_fname = buf->b_ffname;
|
||||||
} else {
|
} else {
|
||||||
autocmd_fname = NULL;
|
autocmd_fname = NULL;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
autocmd_fname = fname_io;
|
autocmd_fname = (char_u *)fname_io;
|
||||||
}
|
}
|
||||||
if (autocmd_fname != NULL) {
|
if (autocmd_fname != NULL) {
|
||||||
// Allocate MAXPATHL for when eval_vars() resolves the fullpath.
|
// 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;
|
fname = NULL;
|
||||||
} else {
|
} else {
|
||||||
if (event == EVENT_SYNTAX) {
|
if (event == EVENT_SYNTAX) {
|
||||||
fname = buf->b_p_syn;
|
fname = (char *)buf->b_p_syn;
|
||||||
} else if (event == EVENT_FILETYPE) {
|
} else if (event == EVENT_FILETYPE) {
|
||||||
fname = buf->b_p_ft;
|
fname = (char *)buf->b_p_ft;
|
||||||
} else {
|
} else {
|
||||||
if (buf->b_sfname != NULL) {
|
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) {
|
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 {
|
} else {
|
||||||
sfname = vim_strsave(fname);
|
sfname = xstrdup(fname);
|
||||||
// Don't try expanding the following events.
|
// Don't try expanding the following events.
|
||||||
if (event == EVENT_CMDLINECHANGED || event == EVENT_CMDLINEENTER
|
if (event == EVENT_CMDLINECHANGED || event == EVENT_CMDLINEENTER
|
||||||
|| event == EVENT_CMDLINELEAVE || event == EVENT_CMDWINENTER
|
|| 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_SYNTAX || event == EVENT_SIGNAL
|
||||||
|| event == EVENT_TABCLOSED || event == EVENT_USER
|
|| event == EVENT_TABCLOSED || event == EVENT_USER
|
||||||
|| event == EVENT_WINCLOSED || event == EVENT_WINSCROLLED) {
|
|| event == EVENT_WINCLOSED || event == EVENT_WINSCROLLED) {
|
||||||
fname = vim_strsave(fname);
|
fname = xstrdup(fname);
|
||||||
} else {
|
} else {
|
||||||
fname = (char_u *)FullName_save((char *)fname, false);
|
fname = FullName_save(fname, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (fname == NULL) { // out of memory
|
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
|
#endif
|
||||||
|
|
||||||
// Set the name to be used for <amatch>.
|
// Set the name to be used for <amatch>.
|
||||||
autocmd_match = fname;
|
autocmd_match = (char_u *)fname;
|
||||||
|
|
||||||
// Don't redraw while doing autocommands.
|
// Don't redraw while doing autocommands.
|
||||||
RedrawingDisabled++;
|
RedrawingDisabled++;
|
||||||
char_u *save_sourcing_name = sourcing_name;
|
char *save_sourcing_name = (char *)sourcing_name;
|
||||||
sourcing_name = NULL; // don't free this one
|
sourcing_name = NULL; // don't free this one
|
||||||
linenr_T save_sourcing_lnum = sourcing_lnum;
|
linenr_T save_sourcing_lnum = sourcing_lnum;
|
||||||
sourcing_lnum = 0; // no line number here
|
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;
|
did_filetype = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
char_u *tail = path_tail(fname);
|
char *tail = (char *)path_tail((char_u *)fname);
|
||||||
|
|
||||||
// Find first autocommand that matches
|
// Find first autocommand that matches
|
||||||
AutoPatCmd patcmd;
|
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)
|
// set v:cmdarg (only when there is a matching pattern)
|
||||||
save_cmdbang = (long)get_vim_var_nr(VV_CMDBANG);
|
save_cmdbang = (long)get_vim_var_nr(VV_CMDBANG);
|
||||||
if (eap != NULL) {
|
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);
|
set_vim_var_nr(VV_CMDBANG, (long)eap->forceit);
|
||||||
} else {
|
} else {
|
||||||
save_cmdarg = NULL; // avoid gcc warning
|
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) {
|
if (eap != NULL) {
|
||||||
(void)set_cmdarg(NULL, (char *)save_cmdarg);
|
(void)set_cmdarg(NULL, save_cmdarg);
|
||||||
set_vim_var_nr(VV_CMDBANG, save_cmdbang);
|
set_vim_var_nr(VV_CMDBANG, save_cmdbang);
|
||||||
}
|
}
|
||||||
// delete from active_apc_list
|
// 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;
|
filechangeshell_busy = false;
|
||||||
autocmd_nested = save_autocmd_nested;
|
autocmd_nested = save_autocmd_nested;
|
||||||
xfree(sourcing_name);
|
xfree(sourcing_name);
|
||||||
sourcing_name = save_sourcing_name;
|
sourcing_name = (char_u *)save_sourcing_name;
|
||||||
sourcing_lnum = save_sourcing_lnum;
|
sourcing_lnum = save_sourcing_lnum;
|
||||||
xfree(autocmd_fname);
|
xfree(autocmd_fname);
|
||||||
autocmd_fname = save_autocmd_fname;
|
autocmd_fname = (char_u *)save_autocmd_fname;
|
||||||
autocmd_bufnr = save_autocmd_bufnr;
|
autocmd_bufnr = save_autocmd_bufnr;
|
||||||
autocmd_match = save_autocmd_match;
|
autocmd_match = (char_u *)save_autocmd_match;
|
||||||
current_sctx = save_current_sctx;
|
current_sctx = save_current_sctx;
|
||||||
restore_funccal();
|
restore_funccal();
|
||||||
if (do_profiling == PROF_YES) {
|
if (do_profiling == PROF_YES) {
|
||||||
@ -1932,7 +1933,7 @@ void block_autocmds(void)
|
|||||||
{
|
{
|
||||||
// Remember the value of v:termresponse.
|
// Remember the value of v:termresponse.
|
||||||
if (!is_autocmd_blocked()) {
|
if (!is_autocmd_blocked()) {
|
||||||
old_termresponse = get_vim_var_str(VV_TERMRESPONSE);
|
old_termresponse = (char *)get_vim_var_str(VV_TERMRESPONSE);
|
||||||
}
|
}
|
||||||
autocmd_blocked++;
|
autocmd_blocked++;
|
||||||
}
|
}
|
||||||
@ -1945,7 +1946,7 @@ void unblock_autocmds(void)
|
|||||||
// the autocommands now. Esp. useful when executing a shell command
|
// the autocommands now. Esp. useful when executing a shell command
|
||||||
// during startup (nvim -d).
|
// during startup (nvim -d).
|
||||||
if (!is_autocmd_blocked()
|
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);
|
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
|
if (ap->buflocal_nr == 0
|
||||||
? match_file_pat(NULL,
|
? match_file_pat(NULL,
|
||||||
&ap->reg_prog,
|
&ap->reg_prog,
|
||||||
apc->fname,
|
(char_u *)apc->fname,
|
||||||
apc->sfname,
|
(char_u *)apc->sfname,
|
||||||
apc->tail,
|
(char_u *)apc->tail,
|
||||||
ap->allow_dirs)
|
ap->allow_dirs)
|
||||||
: ap->buflocal_nr == apc->arg_bufnr) {
|
: ap->buflocal_nr == apc->arg_bufnr) {
|
||||||
const char *const name = event_nr2name(apc->event);
|
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);
|
= (STRLEN(s) + strlen(name) + (size_t)ap->patlen + 1);
|
||||||
|
|
||||||
sourcing_name = xmalloc(sourcing_name_len);
|
sourcing_name = xmalloc(sourcing_name_len);
|
||||||
snprintf((char *)sourcing_name, sourcing_name_len, s, name,
|
snprintf((char *)sourcing_name, sourcing_name_len, s, name, ap->pat);
|
||||||
(char *)ap->pat);
|
|
||||||
if (p_verbose >= 8) {
|
if (p_verbose >= 8) {
|
||||||
verbose_enter();
|
verbose_enter();
|
||||||
smsg(_("Executing %s"), sourcing_name);
|
smsg(_("Executing %s"), sourcing_name);
|
||||||
@ -2072,7 +2072,7 @@ char_u *getnextac(int c, void *cookie, int indent, bool do_concat)
|
|||||||
(void)do_concat;
|
(void)do_concat;
|
||||||
|
|
||||||
AutoPatCmd *acp = (AutoPatCmd *)cookie;
|
AutoPatCmd *acp = (AutoPatCmd *)cookie;
|
||||||
char_u *retval;
|
char *retval;
|
||||||
|
|
||||||
// Can be called again after returning the last line.
|
// Can be called again after returning the last line.
|
||||||
if (acp->curpat == NULL) {
|
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,
|
// 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.
|
// and instead we loop over all the matches and just execute one-by-one.
|
||||||
// However, my expectation would be that could be expensive.
|
// However, my expectation would be that could be expensive.
|
||||||
retval = vim_strsave((char_u *)"");
|
retval = xstrdup("");
|
||||||
} else {
|
} else {
|
||||||
retval = vim_strsave((char_u *)ac->exec.callable.cmd);
|
retval = xstrdup(ac->exec.callable.cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove one-shot ("once") autocmd in anticipation of its execution.
|
// 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;
|
acp->nextcmd = ac->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
return retval;
|
return (char_u *)retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return true if there is a matching autocommand for "fname".
|
/// 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
|
/// @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
|
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;
|
bool retval = false;
|
||||||
|
|
||||||
char_u *fname = (char_u *)FullName_save((char *)sfname, false);
|
char *fname = FullName_save((char *)sfname, false);
|
||||||
if (fname == NULL) {
|
if (fname == NULL) {
|
||||||
return false;
|
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
|
&& (ap->buflocal_nr == 0
|
||||||
? match_file_pat(NULL,
|
? match_file_pat(NULL,
|
||||||
&ap->reg_prog,
|
&ap->reg_prog,
|
||||||
fname,
|
(char_u *)fname,
|
||||||
sfname,
|
sfname,
|
||||||
tail,
|
(char_u *)tail,
|
||||||
ap->allow_dirs)
|
ap->allow_dirs)
|
||||||
: buf != NULL && ap->buflocal_nr == buf->b_fnum)) {
|
: buf != NULL && ap->buflocal_nr == buf->b_fnum)) {
|
||||||
retval = true;
|
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
|
/// @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
|
// check for a group name, skip it if present
|
||||||
autocmd_include_groups = false;
|
autocmd_include_groups = false;
|
||||||
char_u *p = arg;
|
char *p = arg;
|
||||||
int group = arg_augroup_get(&arg);
|
int group = arg_augroup_get(&arg);
|
||||||
|
|
||||||
// If there only is a group name that's what we expand.
|
// If there only is a group name that's what we expand.
|
||||||
@ -2241,12 +2241,12 @@ char_u *set_context_in_autocmd(expand_T *xp, char_u *arg, int doautocmd)
|
|||||||
autocmd_include_groups = true;
|
autocmd_include_groups = true;
|
||||||
}
|
}
|
||||||
xp->xp_context = EXPAND_EVENTS; // expand event name
|
xp->xp_context = EXPAND_EVENTS; // expand event name
|
||||||
xp->xp_pattern = (char *)arg;
|
xp->xp_pattern = arg;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// skip over pattern
|
// skip over pattern
|
||||||
arg = skipwhite(p);
|
arg = (char *)skipwhite((char_u *)p);
|
||||||
while (*arg && (!ascii_iswhite(*arg) || arg[-1] == '\\')) {
|
while (*arg && (!ascii_iswhite(*arg) || arg[-1] == '\\')) {
|
||||||
arg++;
|
arg++;
|
||||||
}
|
}
|
||||||
@ -2291,8 +2291,8 @@ char_u *expand_get_event_name(expand_T *xp, int idx)
|
|||||||
bool autocmd_supported(const char *const event)
|
bool autocmd_supported(const char *const event)
|
||||||
FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT
|
FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT
|
||||||
{
|
{
|
||||||
char_u *p;
|
char *p;
|
||||||
return event_name2nr((const char_u *)event, &p) != NUM_EVENTS;
|
return event_name2nr(event, &p) != NUM_EVENTS;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return true if an autocommand is defined for a group, event and
|
/// 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.
|
char *pattern = p; // "pattern" is NULL when there is no pattern.
|
||||||
|
|
||||||
// Find the index (enum) for the event name.
|
// 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
|
// return false if the event name is not recognized
|
||||||
if (event == NUM_EVENTS) {
|
if (event == NUM_EVENTS) {
|
||||||
@ -2386,7 +2386,7 @@ theend:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Checks if a pattern is buflocal
|
// 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
|
FUNC_ATTR_PURE
|
||||||
{
|
{
|
||||||
return patlen >= 8
|
return patlen >= 8
|
||||||
@ -2394,9 +2394,9 @@ bool aupat_is_buflocal(char_u *pat, int patlen)
|
|||||||
&& (pat)[patlen - 1] == '>';
|
&& (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>"
|
// "<buffer>"
|
||||||
if (patlen == 8) {
|
if (patlen == 8) {
|
||||||
@ -2410,8 +2410,8 @@ int aupat_get_buflocal_nr(char_u *pat, int patlen)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// "<buffer=123>"
|
// "<buffer=123>"
|
||||||
if (skipdigits(pat + 8) == pat + patlen - 1) {
|
if (skipdigits((char_u *)pat + 8) == (char_u *)pat + patlen - 1) {
|
||||||
return atoi((char *)pat + 8);
|
return atoi(pat + 8);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2419,7 +2419,7 @@ int aupat_get_buflocal_nr(char_u *pat, int patlen)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// normalize buffer pattern
|
// 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));
|
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
|
// normalize pat into standard "<buffer>#N" form
|
||||||
snprintf((char *)dest,
|
snprintf(dest,
|
||||||
BUFLOCAL_PAT_LEN,
|
BUFLOCAL_PAT_LEN,
|
||||||
"<buffer=%d>",
|
"<buffer=%d>",
|
||||||
buflocal_nr);
|
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)
|
int autocmd_delete_event(int group, event_T event, char_u *pat)
|
||||||
FUNC_ATTR_NONNULL_ALL
|
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.
|
/// Deletes an autocmd by ID.
|
||||||
@ -2572,10 +2572,10 @@ bool au_event_is_empty(event_T event)
|
|||||||
|
|
||||||
/// Scan over the events. "*" stands for all events.
|
/// Scan over the events. "*" stands for all events.
|
||||||
/// true when group name was found
|
/// 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 *pat;
|
||||||
char_u *p;
|
char *p;
|
||||||
|
|
||||||
if (*arg == '*') {
|
if (*arg == '*') {
|
||||||
if (arg[1] && !ascii_iswhite(arg[1])) {
|
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.
|
// The "argp" argument is advanced to the following argument.
|
||||||
//
|
//
|
||||||
// Returns the group ID or AUGROUP_ALL.
|
// 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 *p;
|
||||||
char_u *arg = *argp;
|
char *arg = *argp;
|
||||||
int group = AUGROUP_ALL;
|
int group = AUGROUP_ALL;
|
||||||
|
|
||||||
for (p = arg; *p && !ascii_iswhite(*p) && *p != '|'; p++) {}
|
for (p = arg; *p && !ascii_iswhite(*p) && *p != '|'; p++) {}
|
||||||
if (p > arg) {
|
if (p > arg) {
|
||||||
char_u *group_name = vim_strnsave(arg, (size_t)(p - arg));
|
char *group_name = xstrnsave(arg, (size_t)(p - arg));
|
||||||
group = augroup_find((char *)group_name);
|
group = augroup_find(group_name);
|
||||||
if (group == AUGROUP_ERROR) {
|
if (group == AUGROUP_ERROR) {
|
||||||
group = AUGROUP_ALL; // no match, use all groups
|
group = AUGROUP_ALL; // no match, use all groups
|
||||||
} else {
|
} else {
|
||||||
*argp = skipwhite(p); // match, skip over group name
|
*argp = (char *)skipwhite((char_u *)p); // match, skip over group name
|
||||||
}
|
}
|
||||||
xfree(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
|
/// 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 (STRNCMP(*cmd_ptr, pattern, len) == 0 && ascii_iswhite((*cmd_ptr)[len])) {
|
||||||
if (*flag) {
|
if (*flag) {
|
||||||
@ -2632,7 +2632,7 @@ static bool arg_autocmd_flag_get(bool *flag, char_u **cmd_ptr, char *pattern, in
|
|||||||
}
|
}
|
||||||
|
|
||||||
*flag = true;
|
*flag = true;
|
||||||
*cmd_ptr = skipwhite((*cmd_ptr) + len);
|
*cmd_ptr = (char *)skipwhite((char_u *)(*cmd_ptr) + len);
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -18,7 +18,7 @@ typedef struct {
|
|||||||
handle_T new_curwin_handle; ///< ID of new curwin
|
handle_T new_curwin_handle; ///< ID of new curwin
|
||||||
handle_T save_prevwin_handle; ///< ID of saved prevwin
|
handle_T save_prevwin_handle; ///< ID of saved prevwin
|
||||||
bufref_T new_curbuf; ///< new curbuf
|
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
|
bool save_VIsual_active; ///< saved VIsual_active
|
||||||
} aco_save_T;
|
} aco_save_T;
|
||||||
|
|
||||||
@ -36,7 +36,7 @@ typedef struct AutoCmd {
|
|||||||
typedef struct AutoPat {
|
typedef struct AutoPat {
|
||||||
struct AutoPat *next; // next AutoPat in AutoPat list; MUST
|
struct AutoPat *next; // next AutoPat in AutoPat list; MUST
|
||||||
// be the first entry
|
// be the first entry
|
||||||
char_u *pat; // pattern as typed (NULL when pattern
|
char *pat; // pattern as typed (NULL when pattern
|
||||||
// has been removed)
|
// has been removed)
|
||||||
regprog_T *reg_prog; // compiled regprog for pattern
|
regprog_T *reg_prog; // compiled regprog for pattern
|
||||||
AutoCmd *cmds; // list of commands to do
|
AutoCmd *cmds; // list of commands to do
|
||||||
@ -51,14 +51,13 @@ typedef struct AutoPat {
|
|||||||
typedef struct AutoPatCmd {
|
typedef struct AutoPatCmd {
|
||||||
AutoPat *curpat; // next AutoPat to examine
|
AutoPat *curpat; // next AutoPat to examine
|
||||||
AutoCmd *nextcmd; // next AutoCmd to execute
|
AutoCmd *nextcmd; // next AutoCmd to execute
|
||||||
int group; // group being used
|
int group; // group being used
|
||||||
char_u *fname; // fname to match with
|
char *fname; // fname to match with
|
||||||
char_u *sfname; // sfname to match with
|
char *sfname; // sfname to match with
|
||||||
char_u *tail; // tail of fname
|
char *tail; // tail of fname
|
||||||
event_T event; // current event
|
event_T event; // current event
|
||||||
int arg_bufnr; // initially equal to <abuf>, set to zero when
|
int arg_bufnr; // initially equal to <abuf>, set to zero when buf is deleted
|
||||||
// buf is deleted
|
struct AutoPatCmd *next; // chain of active apc-s for auto-invalidation
|
||||||
struct AutoPatCmd *next; // chain of active apc-s for auto-invalidation
|
|
||||||
} AutoPatCmd;
|
} AutoPatCmd;
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
// This is an open source non-commercial project. Dear PVS-Studio, please check
|
// 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
|
// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com
|
||||||
|
|
||||||
#include "nvim/buffer.h"
|
|
||||||
#include "nvim/api/ui.h"
|
#include "nvim/api/ui.h"
|
||||||
|
#include "nvim/buffer.h"
|
||||||
#include "nvim/decoration.h"
|
#include "nvim/decoration.h"
|
||||||
#include "nvim/extmark.h"
|
#include "nvim/extmark.h"
|
||||||
#include "nvim/highlight.h"
|
#include "nvim/highlight.h"
|
||||||
@ -535,8 +535,8 @@ bool decor_redraw_eol(buf_T *buf, DecorState *state, int *eol_attr, int eol_col)
|
|||||||
return has_virttext;
|
return has_virttext;
|
||||||
}
|
}
|
||||||
|
|
||||||
void decor_add_ephemeral(int start_row, int start_col, int end_row, int end_col,
|
void decor_add_ephemeral(int start_row, int start_col, int end_row, int end_col, Decoration *decor,
|
||||||
Decoration *decor, uint64_t ns_id, uint64_t mark_id)
|
uint64_t ns_id, uint64_t mark_id)
|
||||||
{
|
{
|
||||||
if (end_row == -1) {
|
if (end_row == -1) {
|
||||||
end_row = start_row;
|
end_row = start_row;
|
||||||
|
@ -1919,7 +1919,7 @@ int do_write(exarg_T *eap)
|
|||||||
// If 'filetype' was empty try detecting it now.
|
// If 'filetype' was empty try detecting it now.
|
||||||
if (*curbuf->b_p_ft == NUL) {
|
if (*curbuf->b_p_ft == NUL) {
|
||||||
if (augroup_exists("filetypedetect")) {
|
if (augroup_exists("filetypedetect")) {
|
||||||
(void)do_doautocmd((char_u *)"filetypedetect BufRead", true, NULL);
|
(void)do_doautocmd("filetypedetect BufRead", true, NULL);
|
||||||
}
|
}
|
||||||
do_modelines(0);
|
do_modelines(0);
|
||||||
}
|
}
|
||||||
|
@ -1295,7 +1295,7 @@ void ex_listdo(exarg_T *eap)
|
|||||||
if (eap->cmdidx != CMD_windo && eap->cmdidx != CMD_tabdo) {
|
if (eap->cmdidx != CMD_windo && eap->cmdidx != CMD_tabdo) {
|
||||||
// Don't do syntax HL autocommands. Skipping the syntax file is a
|
// Don't do syntax HL autocommands. Skipping the syntax file is a
|
||||||
// great speed improvement.
|
// great speed improvement.
|
||||||
save_ei = au_event_disable(",Syntax");
|
save_ei = (char_u *)au_event_disable(",Syntax");
|
||||||
|
|
||||||
FOR_ALL_BUFFERS(buf) {
|
FOR_ALL_BUFFERS(buf) {
|
||||||
buf->b_flags &= ~BF_SYN_SET;
|
buf->b_flags &= ~BF_SYN_SET;
|
||||||
@ -1508,7 +1508,7 @@ void ex_listdo(exarg_T *eap)
|
|||||||
buf_T *bnext;
|
buf_T *bnext;
|
||||||
aco_save_T aco;
|
aco_save_T aco;
|
||||||
|
|
||||||
au_event_restore(save_ei);
|
au_event_restore((char *)save_ei);
|
||||||
|
|
||||||
for (buf_T *buf = firstbuf; buf != NULL; buf = bnext) {
|
for (buf_T *buf = firstbuf; buf != NULL; buf = bnext) {
|
||||||
bnext = buf->b_next;
|
bnext = buf->b_next;
|
||||||
|
@ -3665,11 +3665,11 @@ const char *set_one_cmd_context(expand_T *xp, const char *buff)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case CMD_autocmd:
|
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_doautocmd:
|
||||||
case CMD_doautoall:
|
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:
|
case CMD_set:
|
||||||
set_context_in_set_cmd(xp, (char_u *)arg, 0);
|
set_context_in_set_cmd(xp, (char_u *)arg, 0);
|
||||||
break;
|
break;
|
||||||
@ -5136,9 +5136,9 @@ static void ex_autocmd(exarg_T *eap)
|
|||||||
secure = 2;
|
secure = 2;
|
||||||
eap->errmsg = e_curdir;
|
eap->errmsg = e_curdir;
|
||||||
} else if (eap->cmdidx == CMD_autocmd) {
|
} else if (eap->cmdidx == CMD_autocmd) {
|
||||||
do_autocmd((char_u *)eap->arg, eap->forceit);
|
do_autocmd(eap->arg, eap->forceit);
|
||||||
} else {
|
} else {
|
||||||
do_augroup((char_u *)eap->arg, eap->forceit);
|
do_augroup(eap->arg, eap->forceit);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5146,10 +5146,10 @@ static void ex_autocmd(exarg_T *eap)
|
|||||||
static void ex_doautocmd(exarg_T *eap)
|
static void ex_doautocmd(exarg_T *eap)
|
||||||
{
|
{
|
||||||
char *arg = eap->arg;
|
char *arg = eap->arg;
|
||||||
int call_do_modelines = check_nomodeline((char_u **)&arg);
|
int call_do_modelines = check_nomodeline(&arg);
|
||||||
bool did_aucmd;
|
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>.
|
// Only when there is no <nomodeline>.
|
||||||
if (call_do_modelines && did_aucmd) {
|
if (call_do_modelines && did_aucmd) {
|
||||||
do_modelines(0);
|
do_modelines(0);
|
||||||
@ -9669,7 +9669,7 @@ static void ex_filetype(exarg_T *eap)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (*arg == 'd') {
|
if (*arg == 'd') {
|
||||||
(void)do_doautocmd((char_u *)"filetypedetect BufRead", true, NULL);
|
(void)do_doautocmd("filetypedetect BufRead", true, NULL);
|
||||||
do_modelines(0);
|
do_modelines(0);
|
||||||
}
|
}
|
||||||
} else if (STRCMP(arg, "off") == 0) {
|
} else if (STRCMP(arg, "off") == 0) {
|
||||||
|
@ -3797,7 +3797,7 @@ static int set_rw_fname(char_u *fname, char_u *sfname)
|
|||||||
// Do filetype detection now if 'filetype' is empty.
|
// Do filetype detection now if 'filetype' is empty.
|
||||||
if (*curbuf->b_p_ft == NUL) {
|
if (*curbuf->b_p_ft == NUL) {
|
||||||
if (augroup_exists("filetypedetect")) {
|
if (augroup_exists("filetypedetect")) {
|
||||||
(void)do_doautocmd((char_u *)"filetypedetect BufRead", false, NULL);
|
(void)do_doautocmd("filetypedetect BufRead", false, NULL);
|
||||||
}
|
}
|
||||||
do_modelines(0);
|
do_modelines(0);
|
||||||
}
|
}
|
||||||
|
@ -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
|
// Don't do Filetype autocommands to avoid loading syntax and
|
||||||
// indent scripts, a great speed improvement.
|
// 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;
|
long save_mls = p_mls;
|
||||||
p_mls = 0;
|
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);
|
buf_T *buf = load_dummy_buffer(fname, dirname_start, dirname_now);
|
||||||
|
|
||||||
p_mls = save_mls;
|
p_mls = save_mls;
|
||||||
au_event_restore((char_u *)save_ei);
|
au_event_restore(save_ei);
|
||||||
|
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
@ -1706,10 +1706,9 @@ static void win_update(win_T *wp, DecorProviders *providers)
|
|||||||
// Send win_extmarks if needed
|
// Send win_extmarks if needed
|
||||||
if (kv_size(win_extmark_arr) > 0) {
|
if (kv_size(win_extmark_arr) > 0) {
|
||||||
for (size_t n = 0; n < kv_size(win_extmark_arr); n++) {
|
for (size_t n = 0; n < kv_size(win_extmark_arr); n++) {
|
||||||
ui_call_win_extmark(
|
ui_call_win_extmark(wp->w_grid_alloc.handle, wp->handle,
|
||||||
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).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);
|
||||||
kv_A(win_extmark_arr, n).win_row, kv_A(win_extmark_arr, n).win_col);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user