Merge pull request #13665 from janlazo/vim-8.2.0917

vim-patch:8.1.{1667,1672,1822},8.2.{407,917}
This commit is contained in:
Matthieu Coudron 2021-01-03 10:10:10 +01:00 committed by GitHub
commit 7a81a0c073
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 450 additions and 331 deletions

View File

@ -1330,7 +1330,11 @@ Basic items
%v virtual column number (finds a number representing
screen column of the error (1 <tab> == 8 screen
columns))
%t error type (finds a single character)
%t error type (finds a single character):
e - error message
w - warning message
i - info message
n - note message
%n error number (finds a number)
%m error message (finds a string)
%r matches the "rest" of a single-line file message %O/P/Q
@ -1401,6 +1405,7 @@ prefixes are:
%E start of a multi-line error message
%W start of a multi-line warning message
%I start of a multi-line informational message
%N start of a multi-line note message
%A start of a multi-line message (unspecified type)
%> for next line start with current pattern again |efm-%>|
%C continuation of a multi-line message

View File

@ -2159,10 +2159,11 @@ static buf_T *buflist_findname_file_id(char_u *ffname, FileID *file_id,
int buflist_findpat(
const char_u *pattern,
const char_u *pattern_end, // pointer to first char after pattern
int unlisted, // find unlisted buffers
int diffmode, // find diff-mode buffers only
int curtab_only // find buffers in current tab only
bool unlisted, // find unlisted buffers
bool diffmode, // find diff-mode buffers only
bool curtab_only // find buffers in current tab only
)
FUNC_ATTR_NONNULL_ARG(1)
{
int match = -1;
int find_listed;

View File

@ -726,7 +726,7 @@ buf_T *tv_get_buf(typval_T *tv, int curtab_only)
p_cpo = (char_u *)"";
buf = buflist_findnr(buflist_findpat(name, name + STRLEN(name),
TRUE, FALSE, curtab_only));
true, false, curtab_only));
p_magic = save_magic;
p_cpo = save_cpo;
@ -2165,7 +2165,7 @@ static void f_expandcmd(typval_T *argvars, typval_T *rettv, FunPtr fptr)
.nextcmd = NULL,
.cmdidx = CMD_USER,
};
eap.argt |= NOSPC;
eap.argt |= EX_NOSPC;
expand_filename(&eap, &cmdstr, &errormsg);
if (errormsg != NULL && *errormsg != NUL) {

File diff suppressed because it is too large Load Diff

View File

@ -36,34 +36,34 @@
// 4. Add documentation in ../doc/xxx.txt. Add a tag for both the short and
// long name of the command.
#define RANGE 0x001 // allow a linespecs
#define BANG 0x002 // allow a ! after the command name
#define EXTRA 0x004 // allow extra args after command name
#define XFILE 0x008 // expand wildcards in extra part
#define NOSPC 0x010 // no spaces allowed in the extra part
#define DFLALL 0x020 // default file range is 1,$
#define WHOLEFOLD 0x040 // extend range to include whole fold also
#define EX_RANGE 0x001 // allow a linespecs
#define EX_BANG 0x002 // allow a ! after the command name
#define EX_EXTRA 0x004 // allow extra args after command name
#define EX_XFILE 0x008 // expand wildcards in extra part
#define EX_NOSPC 0x010 // no spaces allowed in the extra part
#define EX_DFLALL 0x020 // default file range is 1,$
#define EX_WHOLEFOLD 0x040 // extend range to include whole fold also
// when less than two numbers given
#define NEEDARG 0x080 // argument required
#define TRLBAR 0x100 // check for trailing vertical bar
#define REGSTR 0x200 // allow "x for register designation
#define COUNT 0x400 // allow count in argument, after command
#define NOTRLCOM 0x800 // no trailing comment allowed
#define ZEROR 0x1000 // zero line number allowed
#define USECTRLV 0x2000 // do not remove CTRL-V from argument
#define EDITCMD 0x4000 // allow "+command" argument
#define BUFNAME 0x8000 // accepts buffer name
#define BUFUNL 0x10000L // accepts unlisted buffer too
#define ARGOPT 0x20000L // allow "++opt=val" argument
#define SBOXOK 0x40000L // allowed in the sandbox
#define CMDWIN 0x80000L // allowed in cmdline window; when missing
#define EX_NEEDARG 0x080 // argument required
#define EX_TRLBAR 0x100 // check for trailing vertical bar
#define EX_REGSTR 0x200 // allow "x for register designation
#define EX_COUNT 0x400 // allow count in argument, after command
#define EX_NOTRLCOM 0x800 // no trailing comment allowed
#define EX_ZEROR 0x1000 // zero line number allowed
#define EX_CTRLV 0x2000 // do not remove CTRL-V from argument
#define EX_CMDARG 0x4000 // allow "+command" argument
#define EX_BUFNAME 0x8000 // accepts buffer name
#define EX_BUFUNL 0x10000 // accepts unlisted buffer too
#define EX_ARGOPT 0x20000 // allow "++opt=val" argument
#define EX_SBOXOK 0x40000 // allowed in the sandbox
#define EX_CMDWIN 0x80000 // allowed in cmdline window; when missing
// disallows editing another buffer when
// curbuf_lock is set
#define MODIFY 0x100000L // forbidden in non-'modifiable' buffer
#define EXFLAGS 0x200000L // allow flags after count in argument
#define FILES (XFILE | EXTRA) // multiple extra files allowed
#define WORD1 (EXTRA | NOSPC) // one extra word allowed
#define FILE1 (FILES | NOSPC) // 1 file allowed, defaults to current file
#define EX_MODIFY 0x100000 // forbidden in non-'modifiable' buffer
#define EX_FLAGS 0x200000 // allow flags after count in argument
#define EX_FILES (EX_XFILE | EX_EXTRA) // multiple extra files allowed
#define EX_FILE1 (EX_FILES | EX_NOSPC) // 1 file, defaults to current file
#define EX_WORD1 (EX_EXTRA | EX_NOSPC) // one extra word allowed
// values for cmd_addr_type
typedef enum {

View File

@ -1418,7 +1418,7 @@ static char_u * do_one_cmd(char_u **cmdlinep,
}
if (*ea.cmd == '|' || (exmode_active && ea.line1 != ea.line2)) {
ea.cmdidx = CMD_print;
ea.argt = RANGE | COUNT | TRLBAR;
ea.argt = EX_RANGE | EX_COUNT | EX_TRLBAR;
if ((errormsg = invalid_range(&ea)) == NULL) {
correct_range(&ea);
ex_print(&ea);
@ -1503,12 +1503,12 @@ static char_u * do_one_cmd(char_u **cmdlinep,
}
if (!ea.skip) {
if (sandbox != 0 && !(ea.argt & SBOXOK)) {
if (sandbox != 0 && !(ea.argt & EX_SBOXOK)) {
// Command not allowed in sandbox.
errormsg = (char_u *)_(e_sandbox);
goto doend;
}
if (!MODIFIABLE(curbuf) && (ea.argt & MODIFY)
if (!MODIFIABLE(curbuf) && (ea.argt & EX_MODIFY)
// allow :put in terminals
&& (!curbuf->terminal || ea.cmdidx != CMD_put)) {
/* Command not allowed in non-'modifiable' buffer */
@ -1516,7 +1516,7 @@ static char_u * do_one_cmd(char_u **cmdlinep,
goto doend;
}
if (text_locked() && !(ea.argt & CMDWIN)
if (text_locked() && !(ea.argt & EX_CMDWIN)
&& !IS_USER_CMDIDX(ea.cmdidx)) {
// Command not allowed when editing the command line.
errormsg = (char_u *)_(get_text_locked_msg());
@ -1527,7 +1527,7 @@ static char_u * do_one_cmd(char_u **cmdlinep,
// Do allow ":checktime" (it is postponed).
// Do allow ":edit" (check for an argument later).
// Do allow ":file" with no arguments (check for an argument later).
if (!(ea.argt & CMDWIN)
if (!(ea.argt & EX_CMDWIN)
&& ea.cmdidx != CMD_checktime
&& ea.cmdidx != CMD_edit
&& ea.cmdidx != CMD_file
@ -1536,14 +1536,14 @@ static char_u * do_one_cmd(char_u **cmdlinep,
goto doend;
}
if (!ni && !(ea.argt & RANGE) && ea.addr_count > 0) {
/* no range allowed */
if (!ni && !(ea.argt & EX_RANGE) && ea.addr_count > 0) {
// no range allowed
errormsg = (char_u *)_(e_norange);
goto doend;
}
}
if (!ni && !(ea.argt & BANG) && ea.forceit) { /* no <!> allowed */
if (!ni && !(ea.argt & EX_BANG) && ea.forceit) { // no <!> allowed
errormsg = (char_u *)_(e_nobang);
goto doend;
}
@ -1552,7 +1552,7 @@ static char_u * do_one_cmd(char_u **cmdlinep,
* Don't complain about the range if it is not used
* (could happen if line_count is accidentally set to 0).
*/
if (!ea.skip && !ni && (ea.argt & RANGE)) {
if (!ea.skip && !ni && (ea.argt & EX_RANGE)) {
// If the range is backwards, ask for confirmation and, if given, swap
// ea.line1 & ea.line2 so it's forwards again.
// When global command is busy, don't ask, will fail below.
@ -1581,7 +1581,7 @@ static char_u * do_one_cmd(char_u **cmdlinep,
correct_range(&ea);
if (((ea.argt & WHOLEFOLD) || ea.addr_count >= 2) && !global_busy
if (((ea.argt & EX_WHOLEFOLD) || ea.addr_count >= 2) && !global_busy
&& ea.addr_type == ADDR_LINES) {
// Put the first line at the start of a closed fold, put the last line
// at the end of a closed fold.
@ -1615,12 +1615,14 @@ static char_u * do_one_cmd(char_u **cmdlinep,
* Check for "++opt=val" argument.
* Must be first, allow ":w ++enc=utf8 !cmd"
*/
if (ea.argt & ARGOPT)
while (ea.arg[0] == '+' && ea.arg[1] == '+')
if (ea.argt & EX_ARGOPT) {
while (ea.arg[0] == '+' && ea.arg[1] == '+') {
if (getargopt(&ea) == FAIL && !ni) {
errormsg = (char_u *)_(e_invarg);
goto doend;
}
}
}
if (ea.cmdidx == CMD_write || ea.cmdidx == CMD_update) {
if (*ea.arg == '>') { /* append */
@ -1659,14 +1661,15 @@ static char_u * do_one_cmd(char_u **cmdlinep,
* Check for "+command" argument, before checking for next command.
* Don't do this for ":read !cmd" and ":write !cmd".
*/
if ((ea.argt & EDITCMD) && !ea.usefilter)
if ((ea.argt & EX_CMDARG) && !ea.usefilter) {
ea.do_ecmd_cmd = getargcmd(&ea.arg);
}
/*
* Check for '|' to separate commands and '"' to start comments.
* Don't do this for ":read !cmd" and ":write !cmd".
*/
if ((ea.argt & TRLBAR) && !ea.usefilter) {
if ((ea.argt & EX_TRLBAR) && !ea.usefilter) {
separate_nextcmd(&ea);
} else if (ea.cmdidx == CMD_bang
|| ea.cmdidx == CMD_terminal
@ -1693,7 +1696,7 @@ static char_u * do_one_cmd(char_u **cmdlinep,
}
}
if ((ea.argt & DFLALL) && ea.addr_count == 0) {
if ((ea.argt & EX_DFLALL) && ea.addr_count == 0) {
buf_T *buf;
ea.line1 = 1;
@ -1743,18 +1746,18 @@ static char_u * do_one_cmd(char_u **cmdlinep,
case ADDR_NONE:
case ADDR_UNSIGNED:
case ADDR_QUICKFIX:
IEMSG(_("INTERNAL: Cannot use DFLALL "
IEMSG(_("INTERNAL: Cannot use EX_DFLALL "
"with ADDR_NONE, ADDR_UNSIGNED or ADDR_QUICKFIX"));
break;
}
}
/* accept numbered register only when no count allowed (:put) */
if ((ea.argt & REGSTR)
// 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 & COUNT) && ascii_isdigit(*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++;
@ -1768,15 +1771,15 @@ static char_u * do_one_cmd(char_u **cmdlinep,
}
//
// Check for a count. When accepting a BUFNAME, don't use "123foo" as a
// Check for a count. When accepting a EX_BUFNAME, don't use "123foo" as a
// count, it's a buffer name.
///
if ((ea.argt & COUNT) && ascii_isdigit(*ea.arg)
&& (!(ea.argt & BUFNAME) || *(p = skipdigits(ea.arg)) == NUL
if ((ea.argt & EX_COUNT) && ascii_isdigit(*ea.arg)
&& (!(ea.argt & EX_BUFNAME) || *(p = skipdigits(ea.arg)) == NUL
|| ascii_iswhite(*p))) {
n = getdigits_long(&ea.arg, false, -1);
ea.arg = skipwhite(ea.arg);
if (n <= 0 && !ni && (ea.argt & ZEROR) == 0) {
if (n <= 0 && !ni && (ea.argt & EX_ZEROR) == 0) {
errormsg = (char_u *)_(e_zerocount);
goto doend;
}
@ -1798,16 +1801,17 @@ static char_u * do_one_cmd(char_u **cmdlinep,
/*
* Check for flags: 'l', 'p' and '#'.
*/
if (ea.argt & EXFLAGS)
if (ea.argt & EX_FLAGS) {
get_flags(&ea);
/* no arguments allowed */
if (!ni && !(ea.argt & EXTRA) && *ea.arg != NUL
&& *ea.arg != '"' && (*ea.arg != '|' || (ea.argt & TRLBAR) == 0)) {
}
if (!ni && !(ea.argt & EX_EXTRA) && *ea.arg != NUL
&& *ea.arg != '"' && (*ea.arg != '|' || (ea.argt & EX_TRLBAR) == 0)) {
// no arguments allowed but there is something
errormsg = (char_u *)_(e_trailing);
goto doend;
}
if (!ni && (ea.argt & NEEDARG) && *ea.arg == NUL) {
if (!ni && (ea.argt & EX_NEEDARG) && *ea.arg == NUL) {
errormsg = (char_u *)_(e_argreq);
goto doend;
}
@ -1836,9 +1840,9 @@ static char_u * do_one_cmd(char_u **cmdlinep,
case CMD_function:
break;
/* Commands that handle '|' themselves. Check: A command should
* either have the TRLBAR flag, appear in this list or appear in
* the list at ":help :bar". */
// Commands that handle '|' themselves. Check: A command should
// either have the EX_TRLBAR flag, appear in this list or appear in
// the list at ":help :bar".
case CMD_aboveleft:
case CMD_and:
case CMD_belowright:
@ -1909,16 +1913,17 @@ static char_u * do_one_cmd(char_u **cmdlinep,
}
}
if (ea.argt & XFILE) {
if (expand_filename(&ea, cmdlinep, &errormsg) == FAIL)
if (ea.argt & EX_XFILE) {
if (expand_filename(&ea, cmdlinep, &errormsg) == FAIL) {
goto doend;
}
}
/*
* Accept buffer name. Cannot be used at the same time with a buffer
* number. Don't do this for a user command.
*/
if ((ea.argt & BUFNAME) && *ea.arg != NUL && ea.addr_count == 0
if ((ea.argt & EX_BUFNAME) && *ea.arg != NUL && ea.addr_count == 0
&& !IS_USER_CMDIDX(ea.cmdidx)
) {
/*
@ -1934,10 +1939,11 @@ static char_u * do_one_cmd(char_u **cmdlinep,
while (p > ea.arg && ascii_iswhite(p[-1]))
--p;
}
ea.line2 = buflist_findpat(ea.arg, p, (ea.argt & BUFUNL) != 0,
FALSE, FALSE);
if (ea.line2 < 0) /* failed */
ea.line2 = buflist_findpat(ea.arg, p, (ea.argt & EX_BUFUNL) != 0,
false, false);
if (ea.line2 < 0) { // failed
goto doend;
}
ea.addr_count = 1;
ea.arg = skipwhite(p);
}
@ -2994,7 +3000,7 @@ const char * set_one_cmd_context(
const char *arg = (const char *)skipwhite((const char_u *)p);
// Skip over ++argopt argument
if ((ea.argt & ARGOPT) && *arg != NUL && strncmp(arg, "++", 2) == 0) {
if ((ea.argt & EX_ARGOPT) && *arg != NUL && strncmp(arg, "++", 2) == 0) {
p = arg;
while (*p && !ascii_isspace(*p)) {
MB_PTR_ADV(p);
@ -3029,9 +3035,9 @@ const char * set_one_cmd_context(
arg = (const char *)skipwhite((const char_u *)arg);
}
/* Does command allow "+command"? */
if ((ea.argt & EDITCMD) && !usefilter && *arg == '+') {
/* Check if we're in the +command */
// Does command allow "+command"?
if ((ea.argt & EX_CMDARG) && !usefilter && *arg == '+') {
// Check if we're in the +command
p = arg + 1;
arg = (const char *)skip_cmd_arg((char_u *)arg, false);
@ -3047,17 +3053,19 @@ const char * set_one_cmd_context(
* Check for '|' to separate commands and '"' to start comments.
* Don't do this for ":read !cmd" and ":write !cmd".
*/
if ((ea.argt & TRLBAR) && !usefilter) {
if ((ea.argt & EX_TRLBAR) && !usefilter) {
p = arg;
/* ":redir @" is not the start of a comment */
if (ea.cmdidx == CMD_redir && p[0] == '@' && p[1] == '"')
p += 2;
while (*p) {
if (*p == Ctrl_V) {
if (p[1] != NUL)
++p;
} else if ( (*p == '"' && !(ea.argt & NOTRLCOM))
|| *p == '|' || *p == '\n') {
if (p[1] != NUL) {
p++;
}
} else if ((*p == '"' && !(ea.argt & EX_NOTRLCOM))
|| *p == '|'
|| *p == '\n') {
if (*(p - 1) != '\\') {
if (*p == '|' || *p == '\n')
return p + 1;
@ -3068,8 +3076,8 @@ const char * set_one_cmd_context(
}
}
// no arguments allowed
if (!(ea.argt & EXTRA) && *arg != NUL && strchr("|\"", *arg) == NULL) {
if (!(ea.argt & EX_EXTRA) && *arg != NUL && strchr("|\"", *arg) == NULL) {
// no arguments allowed but there is something
return NULL;
}
@ -3089,7 +3097,7 @@ const char * set_one_cmd_context(
}
}
if (ea.argt & XFILE) {
if (ea.argt & EX_XFILE) {
int c;
int in_quote = false;
const char *bow = NULL; // Beginning of word.
@ -3510,8 +3518,8 @@ const char * set_one_cmd_context(
case CMD_USER:
case CMD_USER_BUF:
if (context != EXPAND_NOTHING) {
// XFILE: file names are handled above.
if (!(ea.argt & XFILE)) {
// EX_XFILE: file names are handled above.
if (!(ea.argt & EX_XFILE)) {
if (context == EXPAND_MENUS) {
return (const char *)set_context_in_menu_cmd(xp, (char_u *)cmd,
(char_u *)arg, forceit);
@ -3721,6 +3729,15 @@ char_u *skip_range(
return (char_u *)cmd;
}
static void addr_error(cmd_addr_T addr_type)
{
if (addr_type == ADDR_NONE) {
EMSG(_(e_norange));
} else {
EMSG(_(e_invrange));
}
}
// Get a single EX address
//
// Set ptr to the next character after the part that was interpreted.
@ -3770,10 +3787,10 @@ static linenr_T get_address(exarg_T *eap,
case ADDR_TABS:
lnum = CURRENT_TAB_NR;
break;
case ADDR_TABS_RELATIVE:
case ADDR_NONE:
case ADDR_TABS_RELATIVE:
case ADDR_UNSIGNED:
EMSG(_(e_invrange));
addr_error(addr_type);
cmd = NULL;
goto error;
break;
@ -3815,10 +3832,10 @@ static linenr_T get_address(exarg_T *eap,
case ADDR_TABS:
lnum = LAST_TAB_NR;
break;
case ADDR_TABS_RELATIVE:
case ADDR_NONE:
case ADDR_TABS_RELATIVE:
case ADDR_UNSIGNED:
EMSG(_(e_invrange));
addr_error(addr_type);
cmd = NULL;
goto error;
break;
@ -3843,7 +3860,7 @@ static linenr_T get_address(exarg_T *eap,
goto error;
}
if (addr_type != ADDR_LINES) {
EMSG(_(e_invaddr));
addr_error(addr_type);
cmd = NULL;
goto error;
}
@ -3871,7 +3888,7 @@ static linenr_T get_address(exarg_T *eap,
case '?': /* '/' or '?' - search */
c = *cmd++;
if (addr_type != ADDR_LINES) {
EMSG(_(e_invaddr));
addr_error(addr_type);
cmd = NULL;
goto error;
}
@ -3918,7 +3935,7 @@ static linenr_T get_address(exarg_T *eap,
case '\\': /* "\?", "\/" or "\&", repeat search */
++cmd;
if (addr_type != ADDR_LINES) {
EMSG(_(e_invaddr));
addr_error(addr_type);
cmd = NULL;
goto error;
}
@ -4084,7 +4101,7 @@ static char_u *invalid_range(exarg_T *eap)
return (char_u *)_(e_invrange);
}
if (eap->argt & RANGE) {
if (eap->argt & EX_RANGE) {
switch (eap->addr_type) {
case ADDR_LINES:
if (eap->line2 > (curbuf->b_ml.ml_line_count
@ -4171,12 +4188,14 @@ static char_u *invalid_range(exarg_T *eap)
*/
static void correct_range(exarg_T *eap)
{
if (!(eap->argt & ZEROR)) { /* zero in range not allowed */
if (eap->line1 == 0)
if (!(eap->argt & EX_ZEROR)) { // zero in range not allowed
if (eap->line1 == 0) {
eap->line1 = 1;
if (eap->line2 == 0)
}
if (eap->line2 == 0) {
eap->line2 = 1;
}
}
}
@ -4342,7 +4361,7 @@ int expand_filename(exarg_T *eap, char_u **cmdlinep, char_u **errormsgp)
&& eap->cmdidx != CMD_lmake
&& eap->cmdidx != CMD_make
&& eap->cmdidx != CMD_terminal
&& !(eap->argt & NOSPC)
&& !(eap->argt & EX_NOSPC)
) {
char_u *l;
#ifdef BACKSLASH_IN_FILENAME
@ -4383,7 +4402,7 @@ int expand_filename(exarg_T *eap, char_u **cmdlinep, char_u **errormsgp)
* One file argument: Expand wildcards.
* Don't do this with ":r !command" or ":w !command".
*/
if ((eap->argt & NOSPC) && !eap->usefilter) {
if ((eap->argt & EX_NOSPC) && !eap->usefilter) {
// Replace environment variables.
if (has_wildcards) {
/*
@ -4496,38 +4515,39 @@ void separate_nextcmd(exarg_T *eap)
for (; *p; MB_PTR_ADV(p)) {
if (*p == Ctrl_V) {
if (eap->argt & (USECTRLV | XFILE))
++p; /* skip CTRL-V and next char */
else
/* remove CTRL-V and skip next char */
if (eap->argt & (EX_CTRLV | EX_XFILE)) {
p++; // skip CTRL-V and next char
} else {
// remove CTRL-V and skip next char
STRMOVE(p, p + 1);
if (*p == NUL) /* stop at NUL after CTRL-V */
}
if (*p == NUL) { // stop at NUL after CTRL-V
break;
}
/* Skip over `=expr` when wildcards are expanded. */
else if (p[0] == '`' && p[1] == '=' && (eap->argt & XFILE)) {
} else if (p[0] == '`' && p[1] == '=' && (eap->argt & EX_XFILE)) {
// Skip over `=expr` when wildcards are expanded.
p += 2;
(void)skip_expr(&p);
if (*p == NUL) { // stop at NUL after CTRL-V
break;
}
}
/* Check for '"': start of comment or '|': next command */
/* :@" does not start a comment!
* :redir @" doesn't either. */
else if ((*p == '"' && !(eap->argt & NOTRLCOM)
} else if (
// Check for '"': start of comment or '|': next command */
// :@" does not start a comment!
// :redir @" doesn't either.
(*p == '"'
&& !(eap->argt & EX_NOTRLCOM)
&& (eap->cmdidx != CMD_at || p != eap->arg)
&& (eap->cmdidx != CMD_redir
|| p != eap->arg + 1 || p[-1] != '@'))
|| *p == '|' || *p == '\n') {
/*
* We remove the '\' before the '|', unless USECTRLV is used
* AND 'b' is present in 'cpoptions'.
*/
|| *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
|| !(eap->argt & USECTRLV)) && *(p - 1) == '\\') {
STRMOVE(p - 1, p); /* remove the '\' */
--p;
|| !(eap->argt & EX_CTRLV)) && *(p - 1) == '\\') {
STRMOVE(p - 1, p); // remove the '\'
p--;
} else {
eap->nextcmd = check_nextcmd(p);
*p = NUL;
@ -4536,8 +4556,9 @@ void separate_nextcmd(exarg_T *eap)
}
}
if (!(eap->argt & NOTRLCOM)) /* remove trailing spaces */
if (!(eap->argt & EX_NOTRLCOM)) { // remove trailing spaces
del_trailing_spaces(eap->arg);
}
}
/*
@ -5226,11 +5247,11 @@ static void uc_list(char_u *name, size_t name_len)
// Special cases
int len = 4;
if (a & BANG) {
if (a & EX_BANG) {
msg_putchar('!');
len--;
}
if (a & REGSTR) {
if (a & EX_REGSTR) {
msg_putchar('"');
len--;
}
@ -5238,7 +5259,7 @@ static void uc_list(char_u *name, size_t name_len)
msg_putchar('b');
len--;
}
if (a & TRLBAR) {
if (a & EX_TRLBAR) {
msg_putchar('|');
len--;
}
@ -5260,20 +5281,20 @@ static void uc_list(char_u *name, size_t name_len)
len = 0;
// Arguments
switch (a & (EXTRA|NOSPC|NEEDARG)) {
switch (a & (EX_EXTRA | EX_NOSPC | EX_NEEDARG)) {
case 0:
IObuff[len++] = '0';
break;
case (EXTRA):
case (EX_EXTRA):
IObuff[len++] = '*';
break;
case (EXTRA|NOSPC):
case (EX_EXTRA | EX_NOSPC):
IObuff[len++] = '?';
break;
case (EXTRA|NEEDARG):
case (EX_EXTRA | EX_NEEDARG):
IObuff[len++] = '+';
break;
case (EXTRA|NOSPC|NEEDARG):
case (EX_EXTRA | EX_NOSPC | EX_NEEDARG):
IObuff[len++] = '1';
break;
}
@ -5283,13 +5304,13 @@ static void uc_list(char_u *name, size_t name_len)
} while (len < 5 - over);
// Address / Range
if (a & (RANGE|COUNT)) {
if (a & COUNT) {
if (a & (EX_RANGE | EX_COUNT)) {
if (a & EX_COUNT) {
// -count=N
snprintf((char *)IObuff + len, IOSIZE, "%" PRId64 "c",
(int64_t)cmd->uc_def);
len += (int)STRLEN(IObuff + len);
} else if (a & DFLALL) {
} else if (a & EX_DFLALL) {
IObuff[len++] = '%';
} else if (cmd->uc_def >= 0) {
// -range=N
@ -5364,16 +5385,16 @@ static int uc_scan_attr(char_u *attr, size_t len, uint32_t *argt, long *def,
return FAIL;
}
/* First, try the simple attributes (no arguments) */
if (STRNICMP(attr, "bang", len) == 0)
*argt |= BANG;
else if (STRNICMP(attr, "buffer", len) == 0)
// First, try the simple attributes (no arguments)
if (STRNICMP(attr, "bang", len) == 0) {
*argt |= EX_BANG;
} else if (STRNICMP(attr, "buffer", len) == 0) {
*flags |= UC_BUFFER;
else if (STRNICMP(attr, "register", len) == 0)
*argt |= REGSTR;
else if (STRNICMP(attr, "bar", len) == 0)
*argt |= TRLBAR;
else {
} else if (STRNICMP(attr, "register", len) == 0) {
*argt |= EX_REGSTR;
} else if (STRNICMP(attr, "bar", len) == 0) {
*argt |= EX_TRLBAR;
} else {
int i;
char_u *val = NULL;
size_t vallen = 0;
@ -5391,28 +5412,29 @@ static int uc_scan_attr(char_u *attr, size_t len, uint32_t *argt, long *def,
if (STRNICMP(attr, "nargs", attrlen) == 0) {
if (vallen == 1) {
if (*val == '0')
/* Do nothing - this is the default */;
else if (*val == '1')
*argt |= (EXTRA | NOSPC | NEEDARG);
else if (*val == '*')
*argt |= EXTRA;
else if (*val == '?')
*argt |= (EXTRA | NOSPC);
else if (*val == '+')
*argt |= (EXTRA | NEEDARG);
else
if (*val == '0') {
// Do nothing - this is the default;
} else if (*val == '1') {
*argt |= (EX_EXTRA | EX_NOSPC | EX_NEEDARG);
} else if (*val == '*') {
*argt |= EX_EXTRA;
} else if (*val == '?') {
*argt |= (EX_EXTRA | EX_NOSPC);
} else if (*val == '+') {
*argt |= (EX_EXTRA | EX_NEEDARG);
} else {
goto wrong_nargs;
}
} else {
wrong_nargs:
EMSG(_("E176: Invalid number of arguments"));
return FAIL;
}
} else if (STRNICMP(attr, "range", attrlen) == 0) {
*argt |= RANGE;
if (vallen == 1 && *val == '%')
*argt |= DFLALL;
else if (val != NULL) {
*argt |= EX_RANGE;
if (vallen == 1 && *val == '%') {
*argt |= EX_DFLALL;
} else if (val != NULL) {
p = val;
if (*def >= 0) {
two_count:
@ -5421,7 +5443,7 @@ two_count:
}
*def = getdigits_long(&p, true, 0);
*argt |= ZEROR;
*argt |= EX_ZEROR;
if (p != val + vallen || vallen == 0) {
invalid_count:
@ -5434,7 +5456,7 @@ invalid_count:
*addr_type_arg = ADDR_LINES;
}
} else if (STRNICMP(attr, "count", attrlen) == 0) {
*argt |= (COUNT | ZEROR | RANGE);
*argt |= (EX_COUNT | EX_ZEROR | EX_RANGE);
// default for -count is using any number
if (*addr_type_arg == ADDR_NONE) {
*addr_type_arg = ADDR_OTHER;
@ -5464,7 +5486,7 @@ invalid_count:
return FAIL;
}
} else if (STRNICMP(attr, "addr", attrlen) == 0) {
*argt |= RANGE;
*argt |= EX_RANGE;
if (val == NULL) {
EMSG(_("E179: argument required for -addr"));
return FAIL;
@ -5473,7 +5495,7 @@ invalid_count:
return FAIL;
}
if (*addr_type_arg != ADDR_LINES) {
*argt |= ZEROR;
*argt |= EX_ZEROR;
}
} else {
char_u ch = attr[len];
@ -5777,8 +5799,9 @@ uc_check_code(
/* When specified there is a single argument don't split it.
* Works for ":Cmd %" when % is "a b c". */
if ((eap->argt & NOSPC) && quote == 2)
if ((eap->argt & EX_NOSPC) && quote == 2) {
quote = 1;
}
switch (quote) {
case 0: /* No quoting, no splitting */
@ -6218,9 +6241,9 @@ int parse_compl_arg(const char_u *value, int vallen, int *complp,
&& STRNCMP(value, command_complete[i], valend) == 0) {
*complp = i;
if (i == EXPAND_BUFFERS) {
*argt |= BUFNAME;
*argt |= EX_BUFNAME;
} else if (i == EXPAND_DIRECTORIES || i == EXPAND_FILES) {
*argt |= XFILE;
*argt |= EX_XFILE;
}
break;
}
@ -7849,7 +7872,7 @@ static void ex_copymove(exarg_T *eap)
* move or copy lines from 'eap->line1'-'eap->line2' to below line 'n'
*/
if (n == MAXLNUM || n < 0 || n > curbuf->b_ml.ml_line_count) {
EMSG(_(e_invaddr));
EMSG(_(e_invrange));
return;
}
@ -8697,6 +8720,7 @@ ssize_t find_cmdline_var(const char_u *src, size_t *usedlen)
* '#' to curwin->w_altfile
* '<cword>' to word under the cursor
* '<cWORD>' to WORD under the cursor
* '<cexpr>' to C-expression under the cursor
* '<cfile>' to path name under the cursor
* '<sfile>' to sourced file name
* '<slnum>' to sourced file line number
@ -9525,16 +9549,16 @@ Dictionary commands_array(buf_T *buf)
PUT(d, "name", STRING_OBJ(cstr_to_string((char *)cmd->uc_name)));
PUT(d, "definition", STRING_OBJ(cstr_to_string((char *)cmd->uc_rep)));
PUT(d, "script_id", INTEGER_OBJ(cmd->uc_script_ctx.sc_sid));
PUT(d, "bang", BOOLEAN_OBJ(!!(cmd->uc_argt & BANG)));
PUT(d, "bar", BOOLEAN_OBJ(!!(cmd->uc_argt & TRLBAR)));
PUT(d, "register", BOOLEAN_OBJ(!!(cmd->uc_argt & REGSTR)));
PUT(d, "bang", BOOLEAN_OBJ(!!(cmd->uc_argt & EX_BANG)));
PUT(d, "bar", BOOLEAN_OBJ(!!(cmd->uc_argt & EX_TRLBAR)));
PUT(d, "register", BOOLEAN_OBJ(!!(cmd->uc_argt & EX_REGSTR)));
switch (cmd->uc_argt & (EXTRA|NOSPC|NEEDARG)) {
switch (cmd->uc_argt & (EX_EXTRA | EX_NOSPC | EX_NEEDARG)) {
case 0: arg[0] = '0'; break;
case(EXTRA): arg[0] = '*'; break;
case(EXTRA|NOSPC): arg[0] = '?'; break;
case(EXTRA|NEEDARG): arg[0] = '+'; break;
case(EXTRA|NOSPC|NEEDARG): arg[0] = '1'; break;
case(EX_EXTRA): arg[0] = '*'; break;
case(EX_EXTRA | EX_NOSPC): arg[0] = '?'; break;
case(EX_EXTRA | EX_NEEDARG): arg[0] = '+'; break;
case(EX_EXTRA | EX_NOSPC | EX_NEEDARG): arg[0] = '1'; break;
}
PUT(d, "nargs", STRING_OBJ(cstr_to_string(arg)));
@ -9545,7 +9569,7 @@ Dictionary commands_array(buf_T *buf)
? NIL : STRING_OBJ(cstr_to_string((char *)cmd->uc_compl_arg)));
Object obj = NIL;
if (cmd->uc_argt & COUNT) {
if (cmd->uc_argt & EX_COUNT) {
if (cmd->uc_def >= 0) {
snprintf(str, sizeof(str), "%" PRId64, (int64_t)cmd->uc_def);
obj = STRING_OBJ(cstr_to_string(str)); // -count=N
@ -9556,8 +9580,8 @@ Dictionary commands_array(buf_T *buf)
PUT(d, "count", obj);
obj = NIL;
if (cmd->uc_argt & RANGE) {
if (cmd->uc_argt & DFLALL) {
if (cmd->uc_argt & EX_RANGE) {
if (cmd->uc_argt & EX_DFLALL) {
obj = STRING_OBJ(cstr_to_string("%")); // -range=%
} else if (cmd->uc_def >= 0) {
snprintf(str, sizeof(str), "%" PRId64, (int64_t)cmd->uc_def);

View File

@ -4780,7 +4780,7 @@ char_u *addstar(char_u *fname, size_t len, int context)
* EXPAND_COMMANDS Cursor is still touching the command, so complete
* it.
* EXPAND_BUFFERS Complete file names for :buf and :sbuf commands.
* EXPAND_FILES After command with XFILE set, or after setting
* EXPAND_FILES After command with EX_XFILE set, or after setting
* with P_EXPAND set. eg :e ^I, :w>>^I
* EXPAND_DIRECTORIES In some cases this is used instead of the latter
* when we know only directories are of interest. eg

View File

@ -866,7 +866,6 @@ EXTERN char_u e_failed[] INIT(= N_("E472: Command failed"));
EXTERN char_u e_internal[] INIT(= N_("E473: Internal error"));
EXTERN char_u e_intern2[] INIT(= N_("E685: Internal error: %s"));
EXTERN char_u e_interr[] INIT(= N_("Interrupted"));
EXTERN char_u e_invaddr[] INIT(= N_("E14: Invalid address"));
EXTERN char_u e_invarg[] INIT(= N_("E474: Invalid argument"));
EXTERN char_u e_invarg2[] INIT(= N_("E475: Invalid argument: %s"));
EXTERN char_u e_invargval[] INIT(= N_("E475: Invalid value for argument %s"));

View File

@ -143,6 +143,7 @@ struct efm_S {
// 'E' error message
// 'W' warning message
// 'I' informational message
// 'N' note message
// 'C' continuation line
// 'Z' end of multi-line message
// 'G' general, unspecific message
@ -457,7 +458,7 @@ static const char_u *efm_analyze_prefix(const char_u *efmp, efm_T *efminfo,
if (vim_strchr((char_u *)"+-", *efmp) != NULL) {
efminfo->flags = *efmp++;
}
if (vim_strchr((char_u *)"DXAEWICZGOPQ", *efmp) != NULL) {
if (vim_strchr((char_u *)"DXAEWINCZGOPQ", *efmp) != NULL) {
efminfo->prefix = *efmp;
} else {
snprintf((char *)errmsg, errmsglen,
@ -967,7 +968,7 @@ restofline:
fmt_start = fmt_ptr;
}
if (vim_strchr((char_u *)"AEWI", idx) != NULL) {
if (vim_strchr((char_u *)"AEWIN", idx) != NULL) {
qfl->qf_multiline = true; // start of a multi-line message
qfl->qf_multiignore = false; // reset continuation
} else if (vim_strchr((char_u *)"CZ", idx) != NULL) {
@ -1499,7 +1500,7 @@ static int qf_parse_match(char_u *linebuf, size_t linelen, efm_T *fmt_ptr,
if ((idx == 'C' || idx == 'Z') && !qf_multiline) {
return QF_FAIL;
}
if (vim_strchr((char_u *)"EWI", idx) != NULL) {
if (vim_strchr((char_u *)"EWIN", idx) != NULL) {
fields->type = idx;
} else {
fields->type = 0;
@ -3432,11 +3433,13 @@ bool qf_mark_adjust(win_T *wp, linenr_T line1, linenr_T line2, long amount,
// e or E 0 " error"
// w or W 0 " warning"
// i or I 0 " info"
// n or N 0 " note"
// 0 0 ""
// other 0 " c"
// e or E n " error n"
// w or W n " warning n"
// i or I n " info n"
// n or N n " note n"
// 0 n " error n"
// other n " c n"
// 1 x "" :helpgrep
@ -3446,15 +3449,17 @@ static char_u *qf_types(int c, int nr)
static char_u cc[3];
char_u *p;
if (c == 'W' || c == 'w')
if (c == 'W' || c == 'w') {
p = (char_u *)" warning";
else if (c == 'I' || c == 'i')
} else if (c == 'I' || c == 'i') {
p = (char_u *)" info";
else if (c == 'E' || c == 'e' || (c == 0 && nr > 0))
} else if (c == 'N' || c == 'n') {
p = (char_u *)" note";
} else if (c == 'E' || c == 'e' || (c == 0 && nr > 0)) {
p = (char_u *)" error";
else if (c == 0 || c == 1)
} else if (c == 0 || c == 1) {
p = (char_u *)"";
else {
} else {
cc[0] = ' ';
cc[1] = (char_u)c;
cc[2] = NUL;

View File

@ -4275,7 +4275,7 @@ static void syn_cmd_include(exarg_T *eap, int syncing)
* Everything that's left, up to the next command, should be the
* filename to include.
*/
eap->argt |= (XFILE | NOSPC);
eap->argt |= (EX_XFILE | EX_NOSPC);
separate_nextcmd(eap);
if (*eap->arg == '<' || *eap->arg == '$' || path_is_absolute(eap->arg)) {
// For an absolute path, "$VIM/..." or "<sfile>.." we ":source" the

View File

@ -11,6 +11,17 @@ func Test_ex_delete()
call assert_equal(['a', 'c'], getline(1, 2))
endfunc
func Test_range_error()
call assert_fails(':.echo 1', 'E481:')
call assert_fails(':$echo 1', 'E481:')
call assert_fails(':1,2echo 1', 'E481:')
call assert_fails(':+1echo 1', 'E481:')
call assert_fails(':/1/echo 1', 'E481:')
call assert_fails(':\/echo 1', 'E481:')
normal vv
call assert_fails(":'<,'>echo 1", 'E481:')
endfunc
func Test_buffers_lastused()
edit bufc " oldest

View File

@ -15,22 +15,22 @@ func Test_find_complete()
new
set path=
call assert_fails('call feedkeys(":find\t\n", "xt")', 'E345:')
call assert_fails('call feedkeys(":find \t\n", "xt")', 'E471:')
close
new
set path=.
call assert_fails('call feedkeys(":find\t\n", "xt")', 'E32:')
call assert_fails('call feedkeys(":find \t\n", "xt")', 'E471:')
close
new
set path=.,,
call assert_fails('call feedkeys(":find\t\n", "xt")', 'E32:')
call assert_fails('call feedkeys(":find \t\n", "xt")', 'E471:')
close
new
set path=./**
call assert_fails('call feedkeys(":find\t\n", "xt")', 'E32:')
call assert_fails('call feedkeys(":find \t\n", "xt")', 'E471:')
close
" We shouldn't find any file till this point

View File

@ -184,3 +184,46 @@ func Test_finddir_error()
call assert_fails('call finddir("x", "**x")', 'E343:')
call assert_fails('call finddir("x", repeat("x", 5000))', 'E854:')
endfunc
" Test for the :find, :sfind and :tabfind commands
func Test_find_cmd()
new
let save_path = &path
let save_dir = getcwd()
set path=.,./**/*
call CreateFiles()
cd Xdir1
" Test for :find
find foo
call assert_equal('foo', expand('%:.'))
2find foo
call assert_equal('Xdir2/foo', expand('%:.'))
call assert_fails('3find foo', 'E347:')
" Test for :sfind
enew
sfind barfoo
call assert_equal('Xdir2/Xdir3/barfoo', expand('%:.'))
call assert_equal(3, winnr('$'))
close
call assert_fails('sfind baz', 'E345:')
call assert_equal(2, winnr('$'))
" Test for :tabfind
enew
tabfind foobar
call assert_equal('Xdir2/foobar', expand('%:.'))
call assert_equal(2, tabpagenr('$'))
tabclose
call assert_fails('tabfind baz', 'E345:')
call assert_equal(1, tabpagenr('$'))
" call chdir(save_dir)
exe 'cd ' . save_dir
call CleanFiles()
let &path = save_path
close
call assert_fails('find', 'E471:')
call assert_fails('sfind', 'E471:')
call assert_fails('tabfind', 'E471:')
endfunc
" vim: shiftwidth=2 sts=2 expandtab

View File

@ -1260,6 +1260,36 @@ func Test_efm2()
let &efm = save_efm
endfunc
" Test for '%t' (error type) field in 'efm'
func Test_efm_error_type()
let save_efm = &efm
" error type
set efm=%f:%l:%t:%m
cexpr ["Xfile1:10:E:msg1", "Xfile1:20:W:msg2", "Xfile1:30:I:msg3",
\ "Xfile1:40:N:msg4", "Xfile1:50:R:msg5"]
let output = split(execute('clist'), "\n")
call assert_equal([
\ ' 1 Xfile1:10 error: msg1',
\ ' 2 Xfile1:20 warning: msg2',
\ ' 3 Xfile1:30 info: msg3',
\ ' 4 Xfile1:40 note: msg4',
\ ' 5 Xfile1:50 R: msg5'], output)
" error type and a error number
set efm=%f:%l:%t:%n:%m
cexpr ["Xfile1:10:E:2:msg1", "Xfile1:20:W:4:msg2", "Xfile1:30:I:6:msg3",
\ "Xfile1:40:N:8:msg4", "Xfile1:50:R:3:msg5"]
let output = split(execute('clist'), "\n")
call assert_equal([
\ ' 1 Xfile1:10 error 2: msg1',
\ ' 2 Xfile1:20 warning 4: msg2',
\ ' 3 Xfile1:30 info 6: msg3',
\ ' 4 Xfile1:40 note 8: msg4',
\ ' 5 Xfile1:50 R 3: msg5'], output)
let &efm = save_efm
endfunc
func XquickfixChangedByAutocmd(cchar)
call s:setup_commands(a:cchar)
if a:cchar == 'c'