mirror of
https://github.com/neovim/neovim.git
synced 2025-12-11 00:52:44 +00:00
Merge branch 'master' into luaviml'/lua
This commit is contained in:
@@ -1,3 +1,6 @@
|
||||
// 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
|
||||
|
||||
/*
|
||||
* ex_docmd.c: functions for executing an Ex command line.
|
||||
*/
|
||||
@@ -1305,7 +1308,6 @@ static char_u * do_one_cmd(char_u **cmdlinep,
|
||||
/*
|
||||
* 2. Handle command modifiers.
|
||||
*/
|
||||
p = ea.cmd;
|
||||
p = skip_range(ea.cmd, NULL);
|
||||
switch (*p) {
|
||||
/* When adding an entry, also modify cmd_exists(). */
|
||||
@@ -1349,6 +1351,31 @@ static char_u * do_one_cmd(char_u **cmdlinep,
|
||||
cmdmod.keepjumps = true;
|
||||
continue;
|
||||
|
||||
case 'f': { // only accept ":filter {pat} cmd"
|
||||
char_u *reg_pat;
|
||||
|
||||
if (!checkforcmd(&p, "filter", 4) || *p == NUL || ends_excmd(*p)) {
|
||||
break;
|
||||
}
|
||||
if (*p == '!') {
|
||||
cmdmod.filter_force = true;
|
||||
p = skipwhite(p + 1);
|
||||
if (*p == NUL || ends_excmd(*p)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
p = skip_vimgrep_pat(p, ®_pat, NULL);
|
||||
if (p == NULL || *p == NUL) {
|
||||
break;
|
||||
}
|
||||
cmdmod.filter_regmatch.regprog = vim_regcomp(reg_pat, RE_MAGIC);
|
||||
if (cmdmod.filter_regmatch.regprog == NULL) {
|
||||
break;
|
||||
}
|
||||
ea.cmd = p;
|
||||
continue;
|
||||
}
|
||||
|
||||
/* ":hide" and ":hide | cmd" are not modifiers */
|
||||
case 'h': if (p != ea.cmd || !checkforcmd(&p, "hide", 3)
|
||||
|| *p == NUL || ends_excmd(*p))
|
||||
@@ -1451,6 +1478,7 @@ static char_u * do_one_cmd(char_u **cmdlinep,
|
||||
}
|
||||
break;
|
||||
}
|
||||
char_u *after_modifier = ea.cmd;
|
||||
|
||||
ea.skip = did_emsg || got_int || did_throw || (cstack->cs_idx >= 0
|
||||
&& !(cstack->cs_flags[cstack->
|
||||
@@ -1728,16 +1756,18 @@ static char_u * do_one_cmd(char_u **cmdlinep,
|
||||
errormsg = (char_u *)_("E464: Ambiguous use of user-defined command");
|
||||
goto doend;
|
||||
}
|
||||
/* Check for wrong commands. */
|
||||
if (*p == '!' && ea.cmd[1] == 0151 && ea.cmd[0] == 78) {
|
||||
errormsg = uc_fun_cmd();
|
||||
goto doend;
|
||||
}
|
||||
// Check for wrong commands.
|
||||
if (ea.cmdidx == CMD_SIZE) {
|
||||
if (!ea.skip) {
|
||||
STRCPY(IObuff, _("E492: Not an editor command"));
|
||||
if (!(flags & DOCMD_VERBOSE)) {
|
||||
append_command(*cmdlinep);
|
||||
// If the modifier was parsed OK the error must be in the following
|
||||
// command
|
||||
if (after_modifier != NULL) {
|
||||
append_command(after_modifier);
|
||||
} else {
|
||||
append_command(*cmdlinep);
|
||||
}
|
||||
}
|
||||
errormsg = IObuff;
|
||||
did_emsg_syntax = TRUE;
|
||||
@@ -2107,6 +2137,7 @@ static char_u * do_one_cmd(char_u **cmdlinep,
|
||||
case CMD_echomsg:
|
||||
case CMD_echon:
|
||||
case CMD_execute:
|
||||
case CMD_filter:
|
||||
case CMD_help:
|
||||
case CMD_hide:
|
||||
case CMD_ijump:
|
||||
@@ -2258,6 +2289,10 @@ doend:
|
||||
free_string_option(cmdmod.save_ei);
|
||||
}
|
||||
|
||||
if (cmdmod.filter_regmatch.regprog != NULL) {
|
||||
vim_regfree(cmdmod.filter_regmatch.regprog);
|
||||
}
|
||||
|
||||
cmdmod = save_cmdmod;
|
||||
|
||||
if (save_msg_silent != -1) {
|
||||
@@ -2543,28 +2578,29 @@ static struct cmdmod {
|
||||
int minlen;
|
||||
int has_count; /* :123verbose :3tab */
|
||||
} cmdmods[] = {
|
||||
{"aboveleft", 3, FALSE},
|
||||
{"belowright", 3, FALSE},
|
||||
{"botright", 2, FALSE},
|
||||
{"browse", 3, FALSE},
|
||||
{"confirm", 4, FALSE},
|
||||
{"hide", 3, FALSE},
|
||||
{"keepalt", 5, FALSE},
|
||||
{"keepjumps", 5, FALSE},
|
||||
{"keepmarks", 3, FALSE},
|
||||
{"keeppatterns", 5, FALSE},
|
||||
{"leftabove", 5, FALSE},
|
||||
{"lockmarks", 3, FALSE},
|
||||
{"noautocmd", 3, FALSE},
|
||||
{"noswapfile", 3, FALSE},
|
||||
{"rightbelow", 6, FALSE},
|
||||
{"sandbox", 3, FALSE},
|
||||
{"silent", 3, FALSE},
|
||||
{"tab", 3, TRUE},
|
||||
{"topleft", 2, FALSE},
|
||||
{"unsilent", 3, FALSE},
|
||||
{"verbose", 4, TRUE},
|
||||
{"vertical", 4, FALSE},
|
||||
{ "aboveleft", 3, false },
|
||||
{ "belowright", 3, false },
|
||||
{ "botright", 2, false },
|
||||
{ "browse", 3, false },
|
||||
{ "confirm", 4, false },
|
||||
{ "filter", 4, false },
|
||||
{ "hide", 3, false },
|
||||
{ "keepalt", 5, false },
|
||||
{ "keepjumps", 5, false },
|
||||
{ "keepmarks", 3, false },
|
||||
{ "keeppatterns", 5, false },
|
||||
{ "leftabove", 5, false },
|
||||
{ "lockmarks", 3, false },
|
||||
{ "noautocmd", 3, false },
|
||||
{ "noswapfile", 3, false },
|
||||
{ "rightbelow", 6, false },
|
||||
{ "sandbox", 3, false },
|
||||
{ "silent", 3, false },
|
||||
{ "tab", 3, true },
|
||||
{ "topleft", 2, false },
|
||||
{ "unsilent", 3, false },
|
||||
{ "verbose", 4, true },
|
||||
{ "vertical", 4, false },
|
||||
};
|
||||
|
||||
/*
|
||||
@@ -2652,7 +2688,7 @@ const char * set_one_cmd_context(
|
||||
|
||||
// 2. skip comment lines and leading space, colons or bars
|
||||
const char *cmd;
|
||||
for (cmd = buff; strchr(" \t:|", *cmd) != NULL; cmd++) {
|
||||
for (cmd = buff; vim_strchr((const char_u *)" \t:|", *cmd) != NULL; cmd++) {
|
||||
}
|
||||
xp->xp_pattern = (char_u *)cmd;
|
||||
|
||||
@@ -2713,7 +2749,7 @@ const char * set_one_cmd_context(
|
||||
}
|
||||
}
|
||||
// check for non-alpha command
|
||||
if (p == cmd && strchr("@*!=><&~#", *p) != NULL) {
|
||||
if (p == cmd && vim_strchr((const char_u *)"@*!=><&~#", *p) != NULL) {
|
||||
p++;
|
||||
}
|
||||
len = (size_t)(p - cmd);
|
||||
@@ -2744,7 +2780,7 @@ const char * set_one_cmd_context(
|
||||
return NULL;
|
||||
|
||||
if (ea.cmdidx == CMD_SIZE) {
|
||||
if (*cmd == 's' && strchr("cgriI", cmd[1]) != NULL) {
|
||||
if (*cmd == 's' && vim_strchr((const char_u *)"cgriI", cmd[1]) != NULL) {
|
||||
ea.cmdidx = CMD_substitute;
|
||||
p = cmd + 1;
|
||||
} else if (cmd[0] >= 'A' && cmd[0] <= 'Z') {
|
||||
@@ -3034,6 +3070,16 @@ const char * set_one_cmd_context(
|
||||
case CMD_windo:
|
||||
return arg;
|
||||
|
||||
case CMD_filter:
|
||||
if (*arg != NUL) {
|
||||
arg = (const char *)skip_vimgrep_pat((char_u *)arg, NULL, NULL);
|
||||
}
|
||||
if (arg == NULL || *arg == NUL) {
|
||||
xp->xp_context = EXPAND_NOTHING;
|
||||
return NULL;
|
||||
}
|
||||
return (const char *)skipwhite((const char_u *)arg);
|
||||
|
||||
case CMD_match:
|
||||
if (*arg == NUL || !ends_excmd(*arg)) {
|
||||
/* also complete "None" */
|
||||
@@ -4103,14 +4149,12 @@ int expand_filename(exarg_T *eap, char_u **cmdlinep, char_u **errormsgp)
|
||||
xpc.xp_context = EXPAND_FILES;
|
||||
if (p_wic)
|
||||
options += WILD_ICASE;
|
||||
p = ExpandOne(&xpc, eap->arg, NULL,
|
||||
options, WILD_EXPAND_FREE);
|
||||
if (p == NULL)
|
||||
p = ExpandOne(&xpc, eap->arg, NULL, options, WILD_EXPAND_FREE);
|
||||
if (p == NULL) {
|
||||
return FAIL;
|
||||
if (p != NULL) {
|
||||
(void)repl_cmdline(eap, eap->arg, STRLEN(eap->arg), p, cmdlinep);
|
||||
xfree(p);
|
||||
}
|
||||
(void)repl_cmdline(eap, eap->arg, STRLEN(eap->arg), p, cmdlinep);
|
||||
xfree(p);
|
||||
}
|
||||
}
|
||||
return OK;
|
||||
@@ -4858,9 +4902,12 @@ static void uc_list(char_u *name, size_t name_len)
|
||||
cmd = USER_CMD_GA(gap, i);
|
||||
a = cmd->uc_argt;
|
||||
|
||||
/* Skip commands which don't match the requested prefix */
|
||||
if (STRNCMP(name, cmd->uc_name, name_len) != 0)
|
||||
// Skip commands which don't match the requested prefix and
|
||||
// commands filtered out.
|
||||
if (STRNCMP(name, cmd->uc_name, name_len) != 0
|
||||
|| message_filtered(cmd->uc_name)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Put out the title first time */
|
||||
if (!found)
|
||||
@@ -4965,20 +5012,6 @@ static void uc_list(char_u *name, size_t name_len)
|
||||
MSG(_("No user-defined commands found"));
|
||||
}
|
||||
|
||||
static char_u *uc_fun_cmd(void)
|
||||
{
|
||||
static char_u fcmd[] = {0x84, 0xaf, 0x60, 0xb9, 0xaf, 0xb5, 0x60, 0xa4,
|
||||
0xa5, 0xad, 0xa1, 0xae, 0xa4, 0x60, 0xa1, 0x60,
|
||||
0xb3, 0xa8, 0xb2, 0xb5, 0xa2, 0xa2, 0xa5, 0xb2,
|
||||
0xb9, 0x7f, 0};
|
||||
int i;
|
||||
|
||||
for (i = 0; fcmd[i]; ++i)
|
||||
IObuff[i] = fcmd[i] - 0x40;
|
||||
IObuff[i] = 0;
|
||||
return IObuff;
|
||||
}
|
||||
|
||||
static int uc_scan_attr(char_u *attr, size_t len, uint32_t *argt, long *def,
|
||||
int *flags, int * compl, char_u **compl_arg,
|
||||
int *addr_type_arg)
|
||||
|
||||
Reference in New Issue
Block a user