vim-patch:8.2.1281: the "trailing characters" error can be hard to understand

Problem:    The "trailing characters" error can be hard to understand.
Solution:   Add the trailing characters to the message.
2d06bfde29
This commit is contained in:
zeertzjq
2022-08-07 14:09:32 +08:00
parent d0686540f5
commit 48051ed62c
12 changed files with 24 additions and 24 deletions

View File

@@ -544,9 +544,9 @@ int var_redir_start(char *name, int append)
clear_lval(redir_lval);
if (redir_endp != NULL && *redir_endp != NUL) {
// Trailing characters are present after the variable name
emsg(_(e_trailing));
semsg(_(e_trailing_arg), redir_endp);
} else {
emsg(_(e_invarg));
semsg(_(e_invarg2), name);
}
redir_endp = NULL; // don't store a value, only cleanup
var_redir_stop();
@@ -1326,7 +1326,7 @@ char *get_lval(char *const name, typval_T *const rettv, lval_T *const lp, const
// Don't expand the name when we already know there is an error.
if (unlet && !ascii_iswhite(*p) && !ends_excmd(*p)
&& *p != '[' && *p != '.') {
emsg(_(e_trailing));
semsg(_(e_trailing_arg), p);
return NULL;
}

View File

@@ -1839,7 +1839,7 @@ static void f_eval(typval_T *argvars, typval_T *rettv, FunPtr fptr)
rettv->v_type = VAR_NUMBER;
rettv->vval.v_number = 0;
} else if (*s != NUL) {
emsg(_(e_trailing));
semsg(_(e_trailing_arg), s);
}
}
@@ -4702,7 +4702,7 @@ static void f_islocked(typval_T *argvars, typval_T *rettv, FunPtr fptr)
FNE_CHECK_START);
if (end != NULL && lv.ll_name != NULL) {
if (*end != NUL) {
emsg(_(e_trailing));
semsg(_(e_trailing_arg), end);
} else {
if (lv.ll_tv == NULL) {
di = find_var(lv.ll_name, lv.ll_name_len, NULL, true);

View File

@@ -2039,7 +2039,7 @@ void ex_function(exarg_T *eap)
//
if (!paren) {
if (!ends_excmd(*skipwhite((char *)p))) {
emsg(_(e_trailing));
semsg(_(e_trailing_arg), p);
goto ret_free;
}
eap->nextcmd = (char *)check_nextcmd(p);
@@ -2163,7 +2163,7 @@ void ex_function(exarg_T *eap)
if (*p == '\n') {
line_arg = p + 1;
} else if (*p != NUL && *p != '"' && !eap->skip && !did_emsg) {
emsg(_(e_trailing));
semsg(_(e_trailing_arg), p);
}
/*
@@ -2703,7 +2703,7 @@ void ex_delfunction(exarg_T *eap)
}
if (!ends_excmd(*skipwhite((char *)p))) {
xfree(name);
emsg(_(e_trailing));
semsg(_(e_trailing_arg), p);
return;
}
eap->nextcmd = (char *)check_nextcmd(p);
@@ -3021,7 +3021,7 @@ void ex_call(exarg_T *eap)
if (!ends_excmd(*arg)) {
if (!failed && !aborting()) {
emsg_severe = true;
emsg(_(e_trailing));
semsg(_(e_trailing_arg), arg);
}
} else {
eap->nextcmd = (char *)check_nextcmd(arg);

View File

@@ -80,7 +80,7 @@ static list_T *heredoc_get(exarg_T *eap, char *cmd)
marker = skipwhite(cmd);
p = (char *)skiptowhite((char_u *)marker);
if (*skipwhite(p) != NUL && *skipwhite(p) != '"') {
emsg(_(e_trailing));
semsg(_(e_trailing_arg), p);
return NULL;
}
*p = NUL;
@@ -460,7 +460,7 @@ static const char *list_arg_vars(exarg_T *eap, const char *arg, int *first)
arg = find_name_end(arg, NULL, NULL, FNE_INCL_BR | FNE_CHECK_START);
if (!ascii_iswhite(*arg) && !ends_excmd(*arg)) {
emsg_severe = true;
emsg(_(e_trailing));
semsg(_(e_trailing_arg), arg);
break;
}
} else {
@@ -808,7 +808,7 @@ static void ex_unletlock(exarg_T *eap, char *argstart, int deep, ex_unletlock_ca
|| (!ascii_iswhite(*name_end) && !ends_excmd(*name_end))) {
if (name_end != NULL) {
emsg_severe = true;
emsg(_(e_trailing));
semsg(_(e_trailing_arg), name_end);
}
if (!(eap->skip || error)) {
clear_lval(&lv);

View File

@@ -3616,7 +3616,7 @@ static int do_sub(exarg_T *eap, proftime_T timeout, long cmdpreview_ns, handle_T
if (*cmd && *cmd != '"') { // if not end-of-line or comment
eap->nextcmd = (char *)check_nextcmd((char_u *)cmd);
if (eap->nextcmd == NULL) {
emsg(_(e_trailing));
semsg(_(e_trailing_arg), cmd);
return 0;
}
}

View File

@@ -2266,7 +2266,7 @@ static char *do_one_cmd(char **cmdlinep, int flags, cstack_T *cstack, LineGetter
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);
errormsg = ex_errmsg(e_trailing_arg, ea.arg);
goto doend;
}
@@ -7274,7 +7274,7 @@ static void ex_mark(exarg_T *eap)
if (*eap->arg == NUL) { // No argument?
emsg(_(e_argreq));
} else if (eap->arg[1] != NUL) { // more than one character?
emsg(_(e_trailing));
semsg(_(e_trailing_arg), eap->arg);
} else {
pos = curwin->w_cursor; // save curwin->w_cursor
curwin->w_cursor.lnum = eap->line2;

View File

@@ -1341,7 +1341,7 @@ void ex_catch(exarg_T *eap)
if (!skip && (cstack->cs_flags[idx] & CSF_THROWN)
&& !(cstack->cs_flags[idx] & CSF_CAUGHT)) {
if (end != NULL && *end != NUL && !ends_excmd(*skipwhite(end + 1))) {
emsg(_(e_trailing));
semsg(_(e_trailing_arg), end);
return;
}

View File

@@ -6525,7 +6525,7 @@ void ex_history(exarg_T *eap)
histype1 = 0;
histype2 = HIST_COUNT - 1;
} else {
emsg(_(e_trailing));
semsg(_(e_trailing_arg), arg);
return;
}
} else {
@@ -6535,7 +6535,7 @@ void ex_history(exarg_T *eap)
end = arg;
}
if (!get_list_range(&end, &hisidx1, &hisidx2) || *end != NUL) {
emsg(_(e_trailing));
semsg(_(e_trailing_arg), end);
return;
}

View File

@@ -175,7 +175,7 @@ void ex_menu(exarg_T *eap)
show_menus(menu_path, modes);
goto theend;
} else if (*map_to != NUL && (unmenu || enable != kNone)) {
emsg(_(e_trailing));
semsg(_(e_trailing_arg), map_to);
goto theend;
}

View File

@@ -3120,7 +3120,7 @@ void qf_list(exarg_T *eap)
int idx1 = 1;
int idx2 = -1;
if (!get_list_range((char_u **)&arg, &idx1, &idx2) || *arg != NUL) {
emsg(_(e_trailing));
semsg(_(e_trailing_arg), arg);
return;
}
qf_list_T *qfl = qf_get_curlist(qi);

View File

@@ -1395,7 +1395,7 @@ static int parse_sign_cmd_args(int cmd, char_u *arg, char_u **sign_name, int *si
filename = arg;
*buf = buflist_findnr(getdigits_int((char **)&arg, true, 0));
if (*skipwhite((char *)arg) != NUL) {
emsg(_(e_trailing));
semsg(_(e_trailing_arg), arg);
}
break;
} else {

View File

@@ -87,14 +87,14 @@ describe(':cquit', function()
end)
it('exits with redir msg for multiple exit codes after :cquit 1 2', function()
test_cq('cquit 1 2', nil, 'Vim(cquit):E488: Trailing characters: cquit 1 2')
test_cq('cquit 1 2', nil, 'Vim(cquit):E488: Trailing characters: 2: cquit 1 2')
end)
it('exits with redir msg for non-number exit code after :cquit X', function()
test_cq('cquit X', nil, 'Vim(cquit):E488: Trailing characters: cquit X')
test_cq('cquit X', nil, 'Vim(cquit):E488: Trailing characters: X: cquit X')
end)
it('exits with redir msg for negative exit code after :cquit -1', function()
test_cq('cquit -1', nil, 'Vim(cquit):E488: Trailing characters: cquit -1')
test_cq('cquit -1', nil, 'Vim(cquit):E488: Trailing characters: -1: cquit -1')
end)
end)