1
0
forked from aniani/vim

patch 8.1.1667: flags for Ex commands may clash with other symbols

Problem:    Flags for Ex commands may clash with other symbols.
Solution:   Prepend with EX_.
This commit is contained in:
Bram Moolenaar
2019-07-12 17:58:01 +02:00
parent bd42b31780
commit 8071cb2c64
7 changed files with 1234 additions and 1236 deletions

View File

@@ -3547,7 +3547,7 @@ f_expandcmd(typval_T *argvars, typval_T *rettv)
memset(&eap, 0, sizeof(eap));
eap.cmd = cmdstr;
eap.arg = cmdstr;
eap.argt |= NOSPC;
eap.argt |= EX_NOSPC;
eap.usefilter = FALSE;
eap.nextcmd = NULL;
eap.cmdidx = CMD_USER;

File diff suppressed because it is too large Load Diff

View File

@@ -1844,7 +1844,7 @@ do_one_cmd(
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);
@@ -1976,26 +1976,26 @@ do_one_cmd(
if (!ea.skip)
{
#ifdef HAVE_SANDBOX
if (sandbox != 0 && !(ea.argt & SBOXOK))
if (sandbox != 0 && !(ea.argt & EX_SBOXOK))
{
// Command not allowed in sandbox.
errormsg = _(e_sandbox);
goto doend;
}
#endif
if (restricted != 0 && (ea.argt & RESTRICT))
if (restricted != 0 && (ea.argt & EX_RESTRICT))
{
errormsg = _("E981: Command not allowed in rvim");
goto doend;
}
if (!curbuf->b_p_ma && (ea.argt & MODIFY))
if (!curbuf->b_p_ma && (ea.argt & EX_MODIFY))
{
/* Command not allowed in non-'modifiable' buffer */
errormsg = _(e_modifiable);
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. */
@@ -2007,7 +2007,7 @@ do_one_cmd(
* 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
@@ -2015,7 +2015,7 @@ do_one_cmd(
&& curbuf_locked())
goto doend;
if (!ni && !(ea.argt & RANGE) && ea.addr_count > 0)
if (!ni && !(ea.argt & EX_RANGE) && ea.addr_count > 0)
{
/* no range allowed */
errormsg = _(e_norange);
@@ -2023,7 +2023,7 @@ do_one_cmd(
}
}
if (!ni && !(ea.argt & BANG) && ea.forceit) /* no <!> allowed */
if (!ni && !(ea.argt & EX_BANG) && ea.forceit) // no <!> allowed
{
errormsg = _(e_nobang);
goto doend;
@@ -2033,7 +2033,7 @@ do_one_cmd(
* 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
@@ -2068,7 +2068,7 @@ do_one_cmd(
correct_range(&ea);
#ifdef FEAT_FOLDING
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
@@ -2105,7 +2105,7 @@ do_one_cmd(
* Check for "++opt=val" argument.
* Must be first, allow ":w ++enc=utf8 !cmd"
*/
if (ea.argt & ARGOPT)
if (ea.argt & EX_ARGOPT)
while (ea.arg[0] == '+' && ea.arg[1] == '+')
if (getargopt(&ea) == FAIL && !ni)
{
@@ -2161,14 +2161,14 @@ do_one_cmd(
* 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);
/*
@@ -2201,7 +2201,7 @@ do_one_cmd(
}
}
if ((ea.argt & DFLALL) && ea.addr_count == 0)
if ((ea.argt & EX_DFLALL) && ea.addr_count == 0)
{
buf_T *buf;
@@ -2251,17 +2251,17 @@ do_one_cmd(
case ADDR_NONE:
case ADDR_UNSIGNED:
case ADDR_QUICKFIX:
iemsg(_("INTERNAL: Cannot use DFLALL with ADDR_NONE, ADDR_UNSIGNED or ADDR_QUICKFIX"));
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)
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) && VIM_ISDIGIT(*ea.arg)))
&& !((ea.argt & EX_COUNT) && VIM_ISDIGIT(*ea.arg)))
{
#ifndef FEAT_CLIPBOARD
/* check these explicitly for a more specific error message */
@@ -2288,16 +2288,16 @@ do_one_cmd(
}
/*
* 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) && VIM_ISDIGIT(*ea.arg)
&& (!(ea.argt & BUFNAME) || *(p = skipdigits(ea.arg)) == NUL
if ((ea.argt & EX_COUNT) && VIM_ISDIGIT(*ea.arg)
&& (!(ea.argt & EX_BUFNAME) || *(p = skipdigits(ea.arg)) == NUL
|| VIM_ISWHITE(*p)))
{
n = getdigits(&ea.arg);
ea.arg = skipwhite(ea.arg);
if (n <= 0 && !ni && (ea.argt & ZEROR) == 0)
if (n <= 0 && !ni && (ea.argt & EX_ZEROR) == 0)
{
errormsg = _(e_zerocount);
goto doend;
@@ -2324,17 +2324,17 @@ do_one_cmd(
/*
* 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 = _(e_trailing);
goto doend;
}
if (!ni && (ea.argt & NEEDARG) && *ea.arg == NUL)
if (!ni && (ea.argt & EX_NEEDARG) && *ea.arg == NUL)
{
errormsg = _(e_argreq);
goto doend;
@@ -2368,7 +2368,7 @@ do_one_cmd(
break;
/* Commands that handle '|' themselves. Check: A command should
* either have the TRLBAR flag, appear in this list or appear in
* either have the EX_TRLBAR flag, appear in this list or appear in
* the list at ":help :bar". */
case CMD_aboveleft:
case CMD_and:
@@ -2435,7 +2435,7 @@ do_one_cmd(
}
#endif
if (ea.argt & XFILE)
if (ea.argt & EX_XFILE)
{
if (expand_filename(&ea, cmdlinep, &errormsg) == FAIL)
goto doend;
@@ -2445,7 +2445,7 @@ do_one_cmd(
* 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))
{
/*
@@ -2462,7 +2462,7 @@ do_one_cmd(
while (p > ea.arg && VIM_ISWHITE(p[-1]))
--p;
}
ea.line2 = buflist_findpat(ea.arg, p, (ea.argt & BUFUNL) != 0,
ea.line2 = buflist_findpat(ea.arg, p, (ea.argt & EX_BUFUNL) != 0,
FALSE, FALSE);
if (ea.line2 < 0) /* failed */
goto doend;
@@ -3528,7 +3528,7 @@ set_one_cmd_context(
}
/* Does command allow "+command"? */
if ((ea.argt & EDITCMD) && !usefilter && *arg == '+')
if ((ea.argt & EX_CMDARG) && !usefilter && *arg == '+')
{
/* Check if we're in the +command */
p = arg + 1;
@@ -3546,7 +3546,7 @@ 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 */
@@ -3559,7 +3559,7 @@ set_one_cmd_context(
if (p[1] != NUL)
++p;
}
else if ( (*p == '"' && !(ea.argt & NOTRLCOM))
else if ( (*p == '"' && !(ea.argt & EX_NOTRLCOM))
|| *p == '|' || *p == '\n')
{
if (*(p - 1) != '\\')
@@ -3573,9 +3573,9 @@ set_one_cmd_context(
}
}
/* no arguments allowed */
if (!(ea.argt & EXTRA) && *arg != NUL &&
vim_strchr((char_u *)"|\"", *arg) == NULL)
if (!(ea.argt & EX_EXTRA) && *arg != NUL
&& vim_strchr((char_u *)"|\"", *arg) == NULL)
// no arguments allowed but there is something
return NULL;
/* Find start of last argument (argument just before cursor): */
@@ -3597,7 +3597,7 @@ set_one_cmd_context(
}
}
if (ea.argt & XFILE)
if (ea.argt & EX_XFILE)
{
int c;
int in_quote = FALSE;
@@ -3630,7 +3630,7 @@ set_one_cmd_context(
* characters that end the command and white space. */
else if (c == '|' || c == '\n' || c == '"' || (VIM_ISWHITE(c)
#ifdef SPACE_IN_FILENAME
&& (!(ea.argt & NOSPC) || usefilter)
&& (!(ea.argt & EX_NOSPC) || usefilter)
#endif
))
{
@@ -4001,8 +4001,8 @@ set_one_cmd_context(
case CMD_USER_BUF:
if (compl != EXPAND_NOTHING)
{
// XFILE: file names are handled above
if (!(ea.argt & XFILE))
// EX_XFILE: file names are handled above
if (!(ea.argt & EX_XFILE))
{
#ifdef FEAT_MENU
if (compl == EXPAND_MENUS)
@@ -4652,7 +4652,7 @@ invalid_range(exarg_T *eap)
|| eap->line1 > eap->line2)
return _(e_invrange);
if (eap->argt & RANGE)
if (eap->argt & EX_RANGE)
{
switch (eap->addr_type)
{
@@ -4738,7 +4738,7 @@ invalid_range(exarg_T *eap)
static void
correct_range(exarg_T *eap)
{
if (!(eap->argt & ZEROR)) /* zero in range not allowed */
if (!(eap->argt & EX_ZEROR)) // zero in range not allowed
{
if (eap->line1 == 0)
eap->line1 = 1;
@@ -4947,7 +4947,7 @@ expand_filename(
&& eap->cmdidx != CMD_make
&& eap->cmdidx != CMD_terminal
#ifndef UNIX
&& !(eap->argt & NOSPC)
&& !(eap->argt & EX_NOSPC)
#endif
)
{
@@ -4999,7 +4999,7 @@ expand_filename(
* 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)
{
/*
* May do this twice:
@@ -5150,7 +5150,7 @@ separate_nextcmd(exarg_T *eap)
{
if (*p == Ctrl_V)
{
if (eap->argt & (USECTRLV | XFILE))
if (eap->argt & (EX_CTRLV | EX_XFILE))
++p; /* skip CTRL-V and next char */
else
/* remove CTRL-V and skip next char */
@@ -5161,7 +5161,7 @@ separate_nextcmd(exarg_T *eap)
#ifdef FEAT_EVAL
/* 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))
{
p += 2;
(void)skip_expr(&p);
@@ -5171,7 +5171,7 @@ separate_nextcmd(exarg_T *eap)
/* Check for '"': start of comment or '|': next command */
/* :@" and :*" do not start a comment!
* :redir @" doesn't either. */
else if ((*p == '"' && !(eap->argt & NOTRLCOM)
else if ((*p == '"' && !(eap->argt & EX_NOTRLCOM)
&& ((eap->cmdidx != CMD_at && eap->cmdidx != CMD_star)
|| p != eap->arg)
&& (eap->cmdidx != CMD_redir
@@ -5179,11 +5179,11 @@ separate_nextcmd(exarg_T *eap)
|| *p == '|' || *p == '\n')
{
/*
* We remove the '\' before the '|', unless USECTRLV is used
* 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) == '\\')
|| !(eap->argt & EX_CTRLV)) && *(p - 1) == '\\')
{
STRMOVE(p - 1, p); /* remove the '\' */
--p;
@@ -5197,7 +5197,7 @@ 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);
}
@@ -9276,6 +9276,7 @@ find_cmdline_var(char_u *src, int *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

View File

@@ -4834,7 +4834,7 @@ addstar(
* 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

@@ -4809,7 +4809,7 @@ syn_cmd_include(exarg_T *eap, int syncing UNUSED)
* 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 == '$' || mch_isFullName(eap->arg))
{

View File

@@ -419,12 +419,12 @@ uc_list(char_u *name, size_t name_len)
// Special cases
len = 4;
if (a & BANG)
if (a & EX_BANG)
{
msg_putchar('!');
--len;
}
if (a & REGSTR)
if (a & EX_REGSTR)
{
msg_putchar('"');
--len;
@@ -434,7 +434,7 @@ uc_list(char_u *name, size_t name_len)
msg_putchar('b');
--len;
}
if (a & TRLBAR)
if (a & EX_TRLBAR)
{
msg_putchar('|');
--len;
@@ -456,13 +456,13 @@ uc_list(char_u *name, size_t name_len)
len = 0;
// Arguments
switch ((int)(a & (EXTRA|NOSPC|NEEDARG)))
switch ((int)(a & (EX_EXTRA|EX_NOSPC|EX_NEEDARG)))
{
case 0: IObuff[len++] = '0'; break;
case (EXTRA): IObuff[len++] = '*'; break;
case (EXTRA|NOSPC): IObuff[len++] = '?'; break;
case (EXTRA|NEEDARG): IObuff[len++] = '+'; break;
case (EXTRA|NOSPC|NEEDARG): IObuff[len++] = '1'; break;
case 0: IObuff[len++] = '0'; break;
case (EX_EXTRA): IObuff[len++] = '*'; break;
case (EX_EXTRA|EX_NOSPC): IObuff[len++] = '?'; break;
case (EX_EXTRA|EX_NEEDARG): IObuff[len++] = '+'; break;
case (EX_EXTRA|EX_NOSPC|EX_NEEDARG): IObuff[len++] = '1'; break;
}
do {
@@ -470,15 +470,15 @@ uc_list(char_u *name, size_t name_len)
} while (len < 5 - over);
// Address / Range
if (a & (RANGE|COUNT))
if (a & (EX_RANGE|EX_COUNT))
{
if (a & COUNT)
if (a & EX_COUNT)
{
// -count=N
sprintf((char *)IObuff + len, "%ldc", 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)
{
@@ -638,10 +638,10 @@ parse_compl_arg(
{
*complp = command_complete[i].expand;
if (command_complete[i].expand == EXPAND_BUFFERS)
*argt |= BUFNAME;
*argt |= EX_BUFNAME;
else if (command_complete[i].expand == EXPAND_DIRECTORIES
|| command_complete[i].expand == EXPAND_FILES)
*argt |= XFILE;
*argt |= EX_XFILE;
break;
}
}
@@ -702,13 +702,13 @@ uc_scan_attr(
// First, try the simple attributes (no arguments)
if (STRNICMP(attr, "bang", len) == 0)
*argt |= BANG;
*argt |= EX_BANG;
else if (STRNICMP(attr, "buffer", len) == 0)
*flags |= UC_BUFFER;
else if (STRNICMP(attr, "register", len) == 0)
*argt |= REGSTR;
*argt |= EX_REGSTR;
else if (STRNICMP(attr, "bar", len) == 0)
*argt |= TRLBAR;
*argt |= EX_TRLBAR;
else
{
int i;
@@ -736,13 +736,13 @@ uc_scan_attr(
// Do nothing - this is the default
;
else if (*val == '1')
*argt |= (EXTRA | NOSPC | NEEDARG);
*argt |= (EX_EXTRA | EX_NOSPC | EX_NEEDARG);
else if (*val == '*')
*argt |= EXTRA;
*argt |= EX_EXTRA;
else if (*val == '?')
*argt |= (EXTRA | NOSPC);
*argt |= (EX_EXTRA | EX_NOSPC);
else if (*val == '+')
*argt |= (EXTRA | NEEDARG);
*argt |= (EX_EXTRA | EX_NEEDARG);
else
goto wrong_nargs;
}
@@ -755,9 +755,9 @@ wrong_nargs:
}
else if (STRNICMP(attr, "range", attrlen) == 0)
{
*argt |= RANGE;
*argt |= EX_RANGE;
if (vallen == 1 && *val == '%')
*argt |= DFLALL;
*argt |= EX_DFLALL;
else if (val != NULL)
{
p = val;
@@ -769,7 +769,7 @@ two_count:
}
*def = getdigits(&p);
*argt |= ZEROR;
*argt |= EX_ZEROR;
if (p != val + vallen || vallen == 0)
{
@@ -784,7 +784,7 @@ invalid_count:
}
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;
@@ -818,7 +818,7 @@ invalid_count:
}
else if (STRNICMP(attr, "addr", attrlen) == 0)
{
*argt |= RANGE;
*argt |= EX_RANGE;
if (val == NULL)
{
emsg(_("E179: argument required for -addr"));
@@ -827,7 +827,7 @@ invalid_count:
if (parse_addr_type_arg(val, (int)vallen, addr_type_arg) == FAIL)
return FAIL;
if (*addr_type_arg != ADDR_LINES)
*argt |= ZEROR;
*argt |= EX_ZEROR;
}
else
{
@@ -1315,7 +1315,7 @@ 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)

View File

@@ -777,6 +777,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
1667,
/**/
1666,
/**/