aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2022-08-07 13:47:46 +0800
committerzeertzjq <zeertzjq@outlook.com>2022-08-07 14:38:57 +0800
commitd0686540f56154e269e11eb0cc6cd3eb759f2b77 (patch)
treefc84d19f4d10405415740835010eb79eb7e03c59 /src
parent3b7fc5f793e9e9926237f2d6e744b4f6d4ccf12f (diff)
downloadrneovim-d0686540f56154e269e11eb0cc6cd3eb759f2b77.tar.gz
rneovim-d0686540f56154e269e11eb0cc6cd3eb759f2b77.tar.bz2
rneovim-d0686540f56154e269e11eb0cc6cd3eb759f2b77.zip
vim-patch:8.2.1280: Ex command error cannot contain an argument
Problem: Ex command error cannot contain an argument. Solution: Add ex_errmsg() and translate earlier. Use e_trailing_arg where possible. https://github.com/vim/vim/commit/8930caaa1a283092aca81fdbc3fcf15c7eadb197 Remove duplicate test file 062_tab_pages_spec.lua
Diffstat (limited to 'src')
-rw-r--r--src/nvim/buffer.c2
-rw-r--r--src/nvim/ex_docmd.c30
-rw-r--r--src/nvim/ex_eval.c44
-rw-r--r--src/nvim/match.c2
-rw-r--r--src/nvim/testdir/test_tabpage.vim46
5 files changed, 62 insertions, 62 deletions
diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c
index b5e100edcb..f23a1caf8b 100644
--- a/src/nvim/buffer.c
+++ b/src/nvim/buffer.c
@@ -969,7 +969,7 @@ char *do_bufdel(int command, char *arg, int addr_count, int start_bnr, int end_b
} else {
if (addr_count == 2) {
if (*arg) { // both range and argument is not allowed
- return _(e_trailing);
+ return ex_errmsg(e_trailing_arg, arg);
}
bnr = start_bnr;
} else { // addr_count == 1
diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c
index b1130cd4dd..70d729963c 100644
--- a/src/nvim/ex_docmd.c
+++ b/src/nvim/ex_docmd.c
@@ -1635,7 +1635,7 @@ static int execute_cmd0(int *retv, exarg_T *eap, char **errormsg, bool preview)
(cmdnames[eap->cmdidx].cmd_func)(eap);
}
if (eap->errmsg != NULL) {
- *errormsg = _(eap->errmsg);
+ *errormsg = eap->errmsg;
}
}
@@ -4381,7 +4381,7 @@ static void get_flags(exarg_T *eap)
void ex_ni(exarg_T *eap)
{
if (!eap->skip) {
- eap->errmsg = N_("E319: The command is not available in this version");
+ eap->errmsg = _("E319: The command is not available in this version");
}
}
@@ -5018,7 +5018,7 @@ static int get_tabpage_arg(exarg_T *eap)
} else if (p == p_save || *p_save == '-' || *p != NUL
|| tab_number > LAST_TAB_NR) {
// No numbers as argument.
- eap->errmsg = e_invarg;
+ eap->errmsg = ex_errmsg(e_invarg2, eap->arg);
goto theend;
}
} else {
@@ -5026,20 +5026,20 @@ static int get_tabpage_arg(exarg_T *eap)
tab_number = 1;
} else if (p == p_save || *p_save == '-' || *p != NUL || tab_number == 0) {
// No numbers as argument.
- eap->errmsg = e_invarg;
+ eap->errmsg = ex_errmsg(e_invarg2, eap->arg);
goto theend;
}
tab_number = tab_number * relative + tabpage_index(curtab);
if (!unaccept_arg0 && relative == -1) {
- --tab_number;
+ tab_number--;
}
}
if (tab_number < unaccept_arg0 || tab_number > LAST_TAB_NR) {
- eap->errmsg = e_invarg;
+ eap->errmsg = ex_errmsg(e_invarg2, eap->arg);
}
} else if (eap->addr_count > 0) {
if (unaccept_arg0 && eap->line2 == 0) {
- eap->errmsg = e_invrange;
+ eap->errmsg = _(e_invrange);
tab_number = 0;
} else {
tab_number = (int)eap->line2;
@@ -5048,7 +5048,7 @@ static int get_tabpage_arg(exarg_T *eap)
if (!unaccept_arg0 && *cmdp == '-') {
tab_number--;
if (tab_number < unaccept_arg0) {
- eap->errmsg = e_invarg;
+ eap->errmsg = _(e_invrange);
}
}
}
@@ -5078,7 +5078,7 @@ static void ex_autocmd(exarg_T *eap)
// directory for security reasons.
if (secure) {
secure = 2;
- eap->errmsg = e_curdir;
+ eap->errmsg = _(e_curdir);
} else if (eap->cmdidx == CMD_autocmd) {
do_autocmd(eap->arg, eap->forceit);
} else {
@@ -5119,7 +5119,7 @@ static void ex_bunload(exarg_T *eap)
static void ex_buffer(exarg_T *eap)
{
if (*eap->arg) {
- eap->errmsg = e_trailing;
+ eap->errmsg = ex_errmsg(e_trailing_arg, eap->arg);
} else {
if (eap->addr_count == 0) { // default is current buffer
goto_buffer(eap, DOBUF_CURRENT, FORWARD, 0);
@@ -5943,7 +5943,7 @@ static void ex_recover(exarg_T *eap)
/// Command modifier used in a wrong way.
static void ex_wrongmodifier(exarg_T *eap)
{
- eap->errmsg = e_invcmd;
+ eap->errmsg = _(e_invcmd);
}
/// :sview [+command] file split window with new file, read-only
@@ -6052,7 +6052,7 @@ static void ex_tabnext(exarg_T *eap)
if (p == p_save || *p_save == '-' || *p_save == '+' || *p != NUL
|| tab_number == 0) {
// No numbers as argument.
- eap->errmsg = e_invarg;
+ eap->errmsg = ex_errmsg(e_invarg2, eap->arg);
return;
}
} else {
@@ -6061,7 +6061,7 @@ static void ex_tabnext(exarg_T *eap)
} else {
tab_number = (int)eap->line2;
if (tab_number < 1) {
- eap->errmsg = e_invrange;
+ eap->errmsg = _(e_invrange);
return;
}
}
@@ -6339,7 +6339,7 @@ void do_exedit(exarg_T *eap, win_T *old_curwin)
/// ":gui" and ":gvim" when there is no GUI.
static void ex_nogui(exarg_T *eap)
{
- eap->errmsg = N_("E25: Nvim does not have a built-in GUI");
+ eap->errmsg = _("E25: Nvim does not have a built-in GUI");
}
static void ex_popup(exarg_T *eap)
@@ -7559,7 +7559,7 @@ static void ex_findpat(exarg_T *eap)
// Check for trailing illegal characters.
if (!ends_excmd(*p)) {
- eap->errmsg = e_trailing;
+ eap->errmsg = ex_errmsg(e_trailing_arg, p);
} else {
eap->nextcmd = (char *)check_nextcmd((char_u *)p);
}
diff --git a/src/nvim/ex_eval.c b/src/nvim/ex_eval.c
index 46b9528546..186c1d6ef5 100644
--- a/src/nvim/ex_eval.c
+++ b/src/nvim/ex_eval.c
@@ -812,7 +812,7 @@ void ex_if(exarg_T *eap)
cstack_T *const cstack = eap->cstack;
if (cstack->cs_idx == CSTACK_LEN - 1) {
- eap->errmsg = N_("E579: :if nesting too deep");
+ eap->errmsg = _("E579: :if nesting too deep");
} else {
++cstack->cs_idx;
cstack->cs_flags[cstack->cs_idx] = 0;
@@ -840,7 +840,7 @@ void ex_endif(exarg_T *eap)
if (eap->cstack->cs_idx < 0
|| (eap->cstack->cs_flags[eap->cstack->cs_idx]
& (CSF_WHILE | CSF_FOR | CSF_TRY))) {
- eap->errmsg = N_("E580: :endif without :if");
+ eap->errmsg = _("E580: :endif without :if");
} else {
// When debugging or a breakpoint was encountered, display the debug
// prompt (if not already done). This shows the user that an ":endif"
@@ -870,17 +870,17 @@ void ex_else(exarg_T *eap)
|| (cstack->cs_flags[cstack->cs_idx]
& (CSF_WHILE | CSF_FOR | CSF_TRY))) {
if (eap->cmdidx == CMD_else) {
- eap->errmsg = N_("E581: :else without :if");
+ eap->errmsg = _("E581: :else without :if");
return;
}
- eap->errmsg = N_("E582: :elseif without :if");
+ eap->errmsg = _("E582: :elseif without :if");
skip = true;
} else if (cstack->cs_flags[cstack->cs_idx] & CSF_ELSE) {
if (eap->cmdidx == CMD_else) {
- eap->errmsg = N_("E583: multiple :else");
+ eap->errmsg = _("E583: multiple :else");
return;
}
- eap->errmsg = N_("E584: :elseif after :else");
+ eap->errmsg = _("E584: :elseif after :else");
skip = true;
}
@@ -940,7 +940,7 @@ void ex_while(exarg_T *eap)
cstack_T *const cstack = eap->cstack;
if (cstack->cs_idx == CSTACK_LEN - 1) {
- eap->errmsg = N_("E585: :while/:for nesting too deep");
+ eap->errmsg = _("E585: :while/:for nesting too deep");
} else {
/*
* The loop flag is set when we have jumped back from the matching
@@ -1019,7 +1019,7 @@ void ex_continue(exarg_T *eap)
cstack_T *const cstack = eap->cstack;
if (cstack->cs_looplevel <= 0 || cstack->cs_idx < 0) {
- eap->errmsg = N_("E586: :continue without :while or :for");
+ eap->errmsg = _("E586: :continue without :while or :for");
} else {
// Try to find the matching ":while". This might stop at a try
// conditional not in its finally clause (which is then to be executed
@@ -1051,7 +1051,7 @@ void ex_break(exarg_T *eap)
cstack_T *const cstack = eap->cstack;
if (cstack->cs_looplevel <= 0 || cstack->cs_idx < 0) {
- eap->errmsg = N_("E587: :break without :while or :for");
+ eap->errmsg = _("E587: :break without :while or :for");
} else {
// Deactivate conditionals until the matching ":while" or a try
// conditional not in its finally clause (which is then to be
@@ -1083,7 +1083,7 @@ void ex_endwhile(exarg_T *eap)
}
if (cstack->cs_looplevel <= 0 || cstack->cs_idx < 0) {
- eap->errmsg = err;
+ eap->errmsg = _(err);
} else {
fl = cstack->cs_flags[cstack->cs_idx];
if (!(fl & csf)) {
@@ -1097,9 +1097,9 @@ void ex_endwhile(exarg_T *eap)
}
if (!(fl & (CSF_WHILE | CSF_FOR))) {
if (!(fl & CSF_TRY)) {
- eap->errmsg = e_endif;
+ eap->errmsg = _(e_endif);
} else if (fl & CSF_FINALLY) {
- eap->errmsg = e_endtry;
+ eap->errmsg = _(e_endtry);
}
// Try to find the matching ":while" and report what's missing.
for (idx = cstack->cs_idx; idx > 0; --idx) {
@@ -1107,7 +1107,7 @@ void ex_endwhile(exarg_T *eap)
if ((fl & CSF_TRY) && !(fl & CSF_FINALLY)) {
// Give up at a try conditional not in its finally clause.
// Ignore the ":endwhile"/":endfor".
- eap->errmsg = err;
+ eap->errmsg = _(err);
return;
}
if (fl & csf) {
@@ -1230,7 +1230,7 @@ void ex_try(exarg_T *eap)
cstack_T *const cstack = eap->cstack;
if (cstack->cs_idx == CSTACK_LEN - 1) {
- eap->errmsg = N_("E601: :try nesting too deep");
+ eap->errmsg = _("E601: :try nesting too deep");
} else {
++cstack->cs_idx;
++cstack->cs_trylevel;
@@ -1289,7 +1289,7 @@ void ex_catch(exarg_T *eap)
char *pat;
if (cstack->cs_trylevel <= 0 || cstack->cs_idx < 0) {
- eap->errmsg = N_("E603: :catch without :try");
+ eap->errmsg = _("E603: :catch without :try");
give_up = true;
} else {
if (!(cstack->cs_flags[cstack->cs_idx] & CSF_TRY)) {
@@ -1306,7 +1306,7 @@ void ex_catch(exarg_T *eap)
if (cstack->cs_flags[idx] & CSF_FINALLY) {
// Give up for a ":catch" after ":finally" and ignore it.
// Just parse.
- eap->errmsg = N_("E604: :catch after :finally");
+ eap->errmsg = _("E604: :catch after :finally");
give_up = true;
} else {
rewind_conditionals(cstack, idx, CSF_WHILE | CSF_FOR,
@@ -1436,7 +1436,7 @@ void ex_finally(exarg_T *eap)
cstack_T *const cstack = eap->cstack;
if (cstack->cs_trylevel <= 0 || cstack->cs_idx < 0) {
- eap->errmsg = N_("E606: :finally without :try");
+ eap->errmsg = _("E606: :finally without :try");
} else {
if (!(cstack->cs_flags[cstack->cs_idx] & CSF_TRY)) {
eap->errmsg = get_end_emsg(cstack);
@@ -1455,7 +1455,7 @@ void ex_finally(exarg_T *eap)
if (cstack->cs_flags[idx] & CSF_FINALLY) {
// Give up for a multiple ":finally" and ignore it.
- eap->errmsg = N_("E607: multiple :finally");
+ eap->errmsg = _("E607: multiple :finally");
return;
}
rewind_conditionals(cstack, idx, CSF_WHILE | CSF_FOR,
@@ -1559,7 +1559,7 @@ void ex_endtry(exarg_T *eap)
cstack_T *const cstack = eap->cstack;
if (cstack->cs_trylevel <= 0 || cstack->cs_idx < 0) {
- eap->errmsg = N_("E602: :endtry without :try");
+ eap->errmsg = _("E602: :endtry without :try");
} else {
// Don't do something after an error, interrupt or throw in the try
// block, catch clause, or finally clause preceding this ":endtry" or
@@ -1998,12 +1998,12 @@ int cleanup_conditionals(cstack_T *cstack, int searched_cond, int inclusive)
static char *get_end_emsg(cstack_T *cstack)
{
if (cstack->cs_flags[cstack->cs_idx] & CSF_WHILE) {
- return e_endwhile;
+ return _(e_endwhile);
}
if (cstack->cs_flags[cstack->cs_idx] & CSF_FOR) {
- return e_endfor;
+ return _(e_endfor);
}
- return e_endif;
+ return _(e_endif);
}
/// Rewind conditionals until index "idx" is reached. "cond_type" and
diff --git a/src/nvim/match.c b/src/nvim/match.c
index 8c72b13bc2..ba587c4141 100644
--- a/src/nvim/match.c
+++ b/src/nvim/match.c
@@ -1193,7 +1193,7 @@ void ex_match(exarg_T *eap)
if (!eap->skip) {
if (*end != NUL && !ends_excmd(*skipwhite((char *)end + 1))) {
xfree(g);
- eap->errmsg = e_trailing;
+ eap->errmsg = ex_errmsg(e_trailing_arg, (const char *)end);
return;
}
if (*end != *p) {
diff --git a/src/nvim/testdir/test_tabpage.vim b/src/nvim/testdir/test_tabpage.vim
index d891684ecb..07f35ddb4f 100644
--- a/src/nvim/testdir/test_tabpage.vim
+++ b/src/nvim/testdir/test_tabpage.vim
@@ -133,18 +133,18 @@ function Test_tabpage()
call assert_fails("99tabmove", 'E16:')
call assert_fails("+99tabmove", 'E16:')
call assert_fails("-99tabmove", 'E16:')
- call assert_fails("tabmove foo", 'E474:')
- call assert_fails("tabmove 99", 'E474:')
- call assert_fails("tabmove +99", 'E474:')
- call assert_fails("tabmove -99", 'E474:')
- call assert_fails("tabmove -3+", 'E474:')
- call assert_fails("tabmove $3", 'E474:')
+ call assert_fails("tabmove foo", 'E475:')
+ call assert_fails("tabmove 99", 'E475:')
+ call assert_fails("tabmove +99", 'E475:')
+ call assert_fails("tabmove -99", 'E475:')
+ call assert_fails("tabmove -3+", 'E475:')
+ call assert_fails("tabmove $3", 'E475:')
call assert_fails("%tabonly", 'E16:')
1tabonly!
tabmove 1
call assert_equal(1, tabpagenr())
tabnew
- call assert_fails("-2tabmove", 'E474:')
+ call assert_fails("-2tabmove", 'E16:')
tabonly!
endfunc
@@ -320,14 +320,14 @@ function Test_tabpage_with_tabnext()
call Check_tab_count(4, 'tabnext -', 3)
call Check_tab_count(4, 'tabnext -2', 2)
call Check_tab_count(3, 'tabnext $', 5)
- call assert_fails('tabnext 0', 'E474:')
- call assert_fails('tabnext .', 'E474:')
- call assert_fails('tabnext -+', 'E474:')
- call assert_fails('tabnext +2-', 'E474:')
- call assert_fails('tabnext $3', 'E474:')
- call assert_fails('tabnext 99', 'E474:')
- call assert_fails('tabnext +99', 'E474:')
- call assert_fails('tabnext -99', 'E474:')
+ call assert_fails('tabnext 0', 'E475:')
+ call assert_fails('tabnext .', 'E475:')
+ call assert_fails('tabnext -+', 'E475:')
+ call assert_fails('tabnext +2-', 'E475:')
+ call assert_fails('tabnext $3', 'E475:')
+ call assert_fails('tabnext 99', 'E475:')
+ call assert_fails('tabnext +99', 'E475:')
+ call assert_fails('tabnext -99', 'E475:')
1tabonly!
endfunction
@@ -352,7 +352,7 @@ function Test_tabpage_with_tabprevious()
let err_code = 'E16:'
else
let entire_cmd = cmd . ' ' . c
- let err_code = 'E474:'
+ let err_code = 'E475:'
endif
call assert_fails(entire_cmd, err_code)
endfor
@@ -451,7 +451,7 @@ function Test_tabpage_with_tabclose()
let err_code = 'E16:'
else
let entire_cmd = 'tabclose ' . c
- let err_code = 'E474:'
+ let err_code = 'E475:'
endif
call assert_fails(entire_cmd, err_code)
call assert_equal(6, tabpagenr('$'))
@@ -460,8 +460,8 @@ function Test_tabpage_with_tabclose()
call assert_fails('3tabclose', 'E37:')
call assert_fails('tabclose 3', 'E37:')
- call assert_fails('tabclose -+', 'E474:')
- call assert_fails('tabclose +2-', 'E474:')
+ call assert_fails('tabclose -+', 'E475:')
+ call assert_fails('tabclose +2-', 'E475:')
call assert_equal(6, tabpagenr('$'))
1tabonly!
@@ -506,7 +506,7 @@ function Test_tabpage_with_tabonly()
let err_code = 'E16:'
else
let entire_cmd = 'tabonly ' . c
- let err_code = 'E474:'
+ let err_code = 'E475:'
endif
call assert_fails(entire_cmd, err_code)
call assert_equal(6, tabpagenr('$'))
@@ -517,13 +517,13 @@ function Test_tabpage_with_tabonly()
for c in tc
call s:reconstruct_tabpage_for_test(6)
let entire_cmd = 'tabonly' . c[2] . ' ' . c[1]
- let err_code = 'E474:'
+ let err_code = 'E475:'
call assert_fails(entire_cmd, err_code)
call assert_equal(6, tabpagenr('$'))
endfor
- call assert_fails('tabonly -+', 'E474:')
- call assert_fails('tabonly +2-', 'E474:')
+ call assert_fails('tabonly -+', 'E475:')
+ call assert_fails('tabonly +2-', 'E475:')
call assert_equal(6, tabpagenr('$'))
1tabonly!