mirror of
https://github.com/neovim/neovim.git
synced 2025-09-27 21:48:35 +00:00
vim-patch:8.1.0743: giving error messages is not flexible
Problem: Giving error messages is not flexible.
Solution: Add semsg(). Change argument from "char_u *" to "char *", also
for msg() and get rid of most MSG macros. (Ozaki Kiichi, closes
vim/vim#3302) Also make emsg() accept a "char *" argument. Get rid of
an enormous number of type casts.
f9e3e09fdc
This commit is contained in:
@@ -523,14 +523,14 @@ void ex_sort(exarg_T *eap)
|
||||
} else if (!ASCII_ISALPHA(*p) && regmatch.regprog == NULL) {
|
||||
s = skip_regexp(p + 1, *p, true, NULL);
|
||||
if (*s != *p) {
|
||||
EMSG(_(e_invalpat));
|
||||
emsg(_(e_invalpat));
|
||||
goto sortend;
|
||||
}
|
||||
*s = NUL;
|
||||
// Use last search pattern if sort pattern is empty.
|
||||
if (s == p + 1) {
|
||||
if (last_search_pat() == NULL) {
|
||||
EMSG(_(e_noprevre));
|
||||
emsg(_(e_noprevre));
|
||||
goto sortend;
|
||||
}
|
||||
regmatch.regprog = vim_regcomp(last_search_pat(), RE_MAGIC);
|
||||
@@ -543,14 +543,14 @@ void ex_sort(exarg_T *eap)
|
||||
p = s; // continue after the regexp
|
||||
regmatch.rm_ic = p_ic;
|
||||
} else {
|
||||
EMSG2(_(e_invarg2), p);
|
||||
semsg(_(e_invarg2), p);
|
||||
goto sortend;
|
||||
}
|
||||
}
|
||||
|
||||
// Can only have one of 'n', 'b', 'o' and 'x'.
|
||||
if (format_found > 1) {
|
||||
EMSG(_(e_invarg));
|
||||
emsg(_(e_invarg));
|
||||
goto sortend;
|
||||
}
|
||||
|
||||
@@ -720,7 +720,7 @@ sortend:
|
||||
xfree(sortbuf2);
|
||||
vim_regfree(regmatch.regprog);
|
||||
if (got_int) {
|
||||
EMSG(_(e_interr));
|
||||
emsg(_(e_interr));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -856,7 +856,7 @@ void ex_retab(exarg_T *eap)
|
||||
line_breakcheck();
|
||||
}
|
||||
if (got_int) {
|
||||
EMSG(_(e_interr));
|
||||
emsg(_(e_interr));
|
||||
}
|
||||
|
||||
// If a single value was given then it can be considered equal to
|
||||
@@ -914,7 +914,7 @@ int do_move(linenr_T line1, linenr_T line2, linenr_T dest)
|
||||
linenr_T last_line; // Last line in file after adding new text
|
||||
|
||||
if (dest >= line1 && dest < line2) {
|
||||
EMSG(_("E134: Cannot move a range of lines into itself"));
|
||||
emsg(_("E134: Cannot move a range of lines into itself"));
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
@@ -1160,7 +1160,7 @@ void do_bang(int addr_count, exarg_T *eap, bool forceit, bool do_in, bool do_out
|
||||
}
|
||||
if (ins_prevcmd) {
|
||||
if (prevcmd == NULL) {
|
||||
EMSG(_(e_noprev));
|
||||
emsg(_(e_noprev));
|
||||
xfree(newcmd);
|
||||
return;
|
||||
}
|
||||
@@ -1319,7 +1319,7 @@ static void do_filter(linenr_T line1, linenr_T line2, exarg_T *eap, char_u *cmd,
|
||||
curwin->w_cursor.lnum = line2;
|
||||
} else if ((do_in && (itmp = vim_tempname()) == NULL)
|
||||
|| (do_out && (otmp = vim_tempname()) == NULL)) {
|
||||
EMSG(_(e_notmp));
|
||||
emsg(_(e_notmp));
|
||||
goto filterend;
|
||||
}
|
||||
|
||||
@@ -1333,7 +1333,7 @@ static void do_filter(linenr_T line1, linenr_T line2, exarg_T *eap, char_u *cmd,
|
||||
msg_putchar('\n'); // Keep message from buf_write().
|
||||
no_wait_return--;
|
||||
if (!aborting()) {
|
||||
EMSG2(_("E482: Can't create file %s"), itmp); // Will call wait_return.
|
||||
semsg(_("E482: Can't create file %s"), itmp); // Will call wait_return.
|
||||
}
|
||||
goto filterend;
|
||||
}
|
||||
@@ -1377,7 +1377,7 @@ static void do_filter(linenr_T line1, linenr_T line2, exarg_T *eap, char_u *cmd,
|
||||
READ_FILTER) != OK) {
|
||||
if (!aborting()) {
|
||||
msg_putchar('\n');
|
||||
EMSG2(_(e_notread), otmp);
|
||||
semsg(_(e_notread), otmp);
|
||||
}
|
||||
goto error;
|
||||
}
|
||||
@@ -1458,7 +1458,7 @@ filterend:
|
||||
|
||||
if (curbuf != old_curbuf) {
|
||||
--no_wait_return;
|
||||
EMSG(_("E135: *Filter* Autocommands must not change current buffer"));
|
||||
emsg(_("E135: *Filter* Autocommands must not change current buffer"));
|
||||
}
|
||||
if (itmp != NULL) {
|
||||
os_remove((char *)itmp);
|
||||
@@ -1736,7 +1736,7 @@ void ex_file(exarg_T *eap)
|
||||
&& (*eap->arg != NUL
|
||||
|| eap->line2 > 0
|
||||
|| eap->addr_count > 1)) {
|
||||
EMSG(_(e_invarg));
|
||||
emsg(_(e_invarg));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1806,7 +1806,7 @@ int do_write(exarg_T *eap)
|
||||
ffname = eap->arg;
|
||||
if (*ffname == NUL) {
|
||||
if (eap->cmdidx == CMD_saveas) {
|
||||
EMSG(_(e_argreq));
|
||||
emsg(_(e_argreq));
|
||||
goto theend;
|
||||
}
|
||||
other = FALSE;
|
||||
@@ -1836,7 +1836,7 @@ int do_write(exarg_T *eap)
|
||||
if (alt_buf != NULL && alt_buf->b_ml.ml_mfp != NULL) {
|
||||
// Overwriting a file that is loaded in another buffer is not a
|
||||
// good idea.
|
||||
EMSG(_(e_bufloaded));
|
||||
emsg(_(e_bufloaded));
|
||||
goto theend;
|
||||
}
|
||||
}
|
||||
@@ -1868,7 +1868,7 @@ int do_write(exarg_T *eap)
|
||||
}
|
||||
eap->forceit = TRUE;
|
||||
} else {
|
||||
EMSG(_("E140: Use ! to write partial buffer"));
|
||||
emsg(_("E140: Use ! to write partial buffer"));
|
||||
goto theend;
|
||||
}
|
||||
}
|
||||
@@ -1976,7 +1976,7 @@ int check_overwrite(exarg_T *eap, buf_T *buf, char_u *fname, char_u *ffname, int
|
||||
#ifdef UNIX
|
||||
// It is possible to open a directory on Unix.
|
||||
if (os_isdir(ffname)) {
|
||||
EMSG2(_(e_isadir2), ffname);
|
||||
semsg(_(e_isadir2), ffname);
|
||||
return FAIL;
|
||||
}
|
||||
#endif
|
||||
@@ -1989,7 +1989,7 @@ int check_overwrite(exarg_T *eap, buf_T *buf, char_u *fname, char_u *ffname, int
|
||||
}
|
||||
eap->forceit = TRUE;
|
||||
} else {
|
||||
EMSG(_(e_exists));
|
||||
emsg(_(e_exists));
|
||||
return FAIL;
|
||||
}
|
||||
}
|
||||
@@ -2029,7 +2029,7 @@ int check_overwrite(exarg_T *eap, buf_T *buf, char_u *fname, char_u *ffname, int
|
||||
}
|
||||
eap->forceit = TRUE;
|
||||
} else {
|
||||
EMSG2(_("E768: Swap file exists: %s (:silent! overrides)"),
|
||||
semsg(_("E768: Swap file exists: %s (:silent! overrides)"),
|
||||
swapname);
|
||||
xfree(swapname);
|
||||
return FAIL;
|
||||
@@ -2093,7 +2093,7 @@ void do_wqall(exarg_T *eap)
|
||||
break;
|
||||
}
|
||||
if (buf->b_ffname == NULL) {
|
||||
EMSGN(_("E141: No file name for buffer %" PRId64), buf->b_fnum);
|
||||
semsg(_("E141: No file name for buffer %" PRId64), (int64_t)buf->b_fnum);
|
||||
++error;
|
||||
} else if (check_readonly(&eap->forceit, buf)
|
||||
|| check_overwrite(eap, buf, buf->b_fname, buf->b_ffname,
|
||||
@@ -2129,7 +2129,7 @@ int not_writing(void)
|
||||
if (p_write) {
|
||||
return FALSE;
|
||||
}
|
||||
EMSG(_("E142: File not written: Writing is disabled by 'write' option"));
|
||||
emsg(_("E142: File not written: Writing is disabled by 'write' option"));
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -2167,9 +2167,9 @@ static int check_readonly(int *forceit, buf_T *buf)
|
||||
return TRUE;
|
||||
}
|
||||
} else if (buf->b_p_ro) {
|
||||
EMSG(_(e_readonly));
|
||||
emsg(_(e_readonly));
|
||||
} else {
|
||||
EMSG2(_("E505: \"%s\" is read-only (add ! to override)"),
|
||||
semsg(_("E505: \"%s\" is read-only (add ! to override)"),
|
||||
buf->b_fname);
|
||||
}
|
||||
return TRUE;
|
||||
@@ -2898,7 +2898,7 @@ theend:
|
||||
|
||||
static void delbuf_msg(char_u *name)
|
||||
{
|
||||
EMSG2(_("E143: Autocommands unexpectedly deleted new buffer %s"),
|
||||
semsg(_("E143: Autocommands unexpectedly deleted new buffer %s"),
|
||||
name == NULL ? (char_u *)"" : name);
|
||||
xfree(name);
|
||||
au_new_curbuf.br_buf = NULL;
|
||||
@@ -3113,7 +3113,7 @@ void ex_z(exarg_T *eap)
|
||||
|
||||
if (*x != 0) {
|
||||
if (!ascii_isdigit(*x)) {
|
||||
EMSG(_("E144: non-numeric argument to :z"));
|
||||
emsg(_("E144: non-numeric argument to :z"));
|
||||
return;
|
||||
}
|
||||
bigness = atol((char *)x);
|
||||
@@ -3223,14 +3223,14 @@ int check_secure(void)
|
||||
{
|
||||
if (secure) {
|
||||
secure = 2;
|
||||
EMSG(_(e_curdir));
|
||||
emsg(_(e_curdir));
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// In the sandbox more things are not allowed, including the things
|
||||
// disallowed in secure mode.
|
||||
if (sandbox != 0) {
|
||||
EMSG(_(e_sandbox));
|
||||
emsg(_(e_sandbox));
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
@@ -3426,7 +3426,7 @@ static int check_regexp_delim(int c)
|
||||
FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT
|
||||
{
|
||||
if (isalpha(c)) {
|
||||
EMSG(_("E146: Regular expressions can't be delimited by letters"));
|
||||
emsg(_("E146: Regular expressions can't be delimited by letters"));
|
||||
return FAIL;
|
||||
}
|
||||
return OK;
|
||||
@@ -3505,7 +3505,7 @@ static buf_T *do_sub(exarg_T *eap, proftime_T timeout, bool do_buf_event, handle
|
||||
if (*cmd == '\\') {
|
||||
++cmd;
|
||||
if (vim_strchr((char_u *)"/?&", *cmd) == NULL) {
|
||||
EMSG(_(e_backslash));
|
||||
emsg(_(e_backslash));
|
||||
return NULL;
|
||||
}
|
||||
if (*cmd != '&') {
|
||||
@@ -3551,7 +3551,7 @@ static buf_T *do_sub(exarg_T *eap, proftime_T timeout, bool do_buf_event, handle
|
||||
}
|
||||
} else if (!eap->skip) { // use previous pattern and substitution
|
||||
if (old_sub.sub == NULL) { // there is no previous command
|
||||
EMSG(_(e_nopresub));
|
||||
emsg(_(e_nopresub));
|
||||
return NULL;
|
||||
}
|
||||
pat = NULL; // search_regcomp() will use previous pattern
|
||||
@@ -3576,7 +3576,7 @@ static buf_T *do_sub(exarg_T *eap, proftime_T timeout, bool do_buf_event, handle
|
||||
if (ascii_isdigit(*cmd)) {
|
||||
i = getdigits_long(&cmd, true, 0);
|
||||
if (i <= 0 && !eap->skip && subflags.do_error) {
|
||||
EMSG(_(e_zerocount));
|
||||
emsg(_(e_zerocount));
|
||||
return NULL;
|
||||
}
|
||||
eap->line1 = eap->line2;
|
||||
@@ -3593,7 +3593,7 @@ static buf_T *do_sub(exarg_T *eap, proftime_T timeout, bool do_buf_event, handle
|
||||
if (*cmd && *cmd != '"') { // if not end-of-line or comment
|
||||
eap->nextcmd = check_nextcmd(cmd);
|
||||
if (eap->nextcmd == NULL) {
|
||||
EMSG(_(e_trailing));
|
||||
emsg(_(e_trailing));
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
@@ -3604,14 +3604,14 @@ static buf_T *do_sub(exarg_T *eap, proftime_T timeout, bool do_buf_event, handle
|
||||
|
||||
if (!subflags.do_count && !MODIFIABLE(curbuf)) {
|
||||
// Substitution is not allowed in non-'modifiable' buffer
|
||||
EMSG(_(e_modifiable));
|
||||
emsg(_(e_modifiable));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (search_regcomp(pat, RE_SUBST, which_pat, (preview ? 0 : SEARCH_HIS),
|
||||
®match) == FAIL) {
|
||||
if (subflags.do_error) {
|
||||
EMSG(_(e_invcmd));
|
||||
emsg(_(e_invcmd));
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
@@ -4377,13 +4377,13 @@ skip:
|
||||
} else if (!global_busy) {
|
||||
if (got_int) {
|
||||
// interrupted
|
||||
EMSG(_(e_interr));
|
||||
emsg(_(e_interr));
|
||||
} else if (got_match) {
|
||||
// did find something but nothing substituted
|
||||
MSG("");
|
||||
} else if (subflags.do_error) {
|
||||
// nothing found
|
||||
EMSG2(_(e_patnotf2), get_search_pat());
|
||||
semsg(_(e_patnotf2), get_search_pat());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4473,7 +4473,7 @@ bool do_sub_msg(bool count_only)
|
||||
return true;
|
||||
}
|
||||
if (got_int) {
|
||||
EMSG(_(e_interr));
|
||||
emsg(_(e_interr));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -4524,7 +4524,7 @@ void ex_global(exarg_T *eap)
|
||||
if (global_busy && (eap->line1 != 1
|
||||
|| eap->line2 != curbuf->b_ml.ml_line_count)) {
|
||||
// will increment global_busy to break out of the loop
|
||||
EMSG(_("E147: Cannot do :global recursive with a range"));
|
||||
emsg(_("E147: Cannot do :global recursive with a range"));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -4544,7 +4544,7 @@ void ex_global(exarg_T *eap)
|
||||
if (*cmd == '\\') {
|
||||
++cmd;
|
||||
if (vim_strchr((char_u *)"/?&", *cmd) == NULL) {
|
||||
EMSG(_(e_backslash));
|
||||
emsg(_(e_backslash));
|
||||
return;
|
||||
}
|
||||
if (*cmd == '&') {
|
||||
@@ -4555,7 +4555,7 @@ void ex_global(exarg_T *eap)
|
||||
++cmd;
|
||||
pat = (char_u *)"";
|
||||
} else if (*cmd == NUL) {
|
||||
EMSG(_("E148: Regular expression missing from global"));
|
||||
emsg(_("E148: Regular expression missing from global"));
|
||||
return;
|
||||
} else if (check_regexp_delim(*cmd) == FAIL) {
|
||||
return;
|
||||
@@ -4572,7 +4572,7 @@ void ex_global(exarg_T *eap)
|
||||
}
|
||||
|
||||
if (search_regcomp(pat, RE_BOTH, which_pat, SEARCH_HIS, ®match) == FAIL) {
|
||||
EMSG(_(e_invcmd));
|
||||
emsg(_(e_invcmd));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -4755,7 +4755,7 @@ void ex_help(exarg_T *eap)
|
||||
arg = eap->arg;
|
||||
|
||||
if (eap->forceit && *arg == NUL && !curbuf->b_help) {
|
||||
EMSG(_("E478: Don't panic!"));
|
||||
emsg(_("E478: Don't panic!"));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -4799,9 +4799,9 @@ void ex_help(exarg_T *eap)
|
||||
}
|
||||
if (i >= num_matches || n == FAIL) {
|
||||
if (lang != NULL) {
|
||||
EMSG3(_("E661: Sorry, no '%s' help for %s"), lang, arg);
|
||||
semsg(_("E661: Sorry, no '%s' help for %s"), lang, arg);
|
||||
} else {
|
||||
EMSG2(_("E149: Sorry, no help for %s"), arg);
|
||||
semsg(_("E149: Sorry, no help for %s"), arg);
|
||||
}
|
||||
if (n != FAIL) {
|
||||
FreeWild(num_matches, matches);
|
||||
@@ -5343,7 +5343,7 @@ void fix_help_buffer(void)
|
||||
if (!add_pathsep((char *)NameBuff)
|
||||
|| STRLCAT(NameBuff, "doc/*.??[tx]",
|
||||
sizeof(NameBuff)) >= MAXPATHL) {
|
||||
EMSG(_(e_fnametoolong));
|
||||
emsg(_(e_fnametoolong));
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -5504,7 +5504,7 @@ static void helptags_one(char_u *dir, const char_u *ext, const char_u *tagfname,
|
||||
if (dirlen >= MAXPATHL
|
||||
|| STRLCAT(NameBuff, "/**/*", sizeof(NameBuff)) >= MAXPATHL // NOLINT
|
||||
|| STRLCAT(NameBuff, ext, sizeof(NameBuff)) >= MAXPATHL) {
|
||||
EMSG(_(e_fnametoolong));
|
||||
emsg(_(e_fnametoolong));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -5515,7 +5515,7 @@ static void helptags_one(char_u *dir, const char_u *ext, const char_u *tagfname,
|
||||
EW_FILE|EW_SILENT) == FAIL
|
||||
|| filecount == 0) {
|
||||
if (!got_int) {
|
||||
EMSG2(_("E151: No match: %s"), NameBuff);
|
||||
semsg(_("E151: No match: %s"), NameBuff);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -5527,14 +5527,14 @@ static void helptags_one(char_u *dir, const char_u *ext, const char_u *tagfname,
|
||||
memcpy(NameBuff, dir, dirlen + 1);
|
||||
if (!add_pathsep((char *)NameBuff)
|
||||
|| STRLCAT(NameBuff, tagfname, sizeof(NameBuff)) >= MAXPATHL) {
|
||||
EMSG(_(e_fnametoolong));
|
||||
emsg(_(e_fnametoolong));
|
||||
return;
|
||||
}
|
||||
|
||||
FILE *const fd_tags = os_fopen((char *)NameBuff, "w");
|
||||
if (fd_tags == NULL) {
|
||||
if (!ignore_writeerr) {
|
||||
EMSG2(_("E152: Cannot open %s for writing"), NameBuff);
|
||||
semsg(_("E152: Cannot open %s for writing"), NameBuff);
|
||||
}
|
||||
FreeWild(filecount, files);
|
||||
return;
|
||||
@@ -5556,7 +5556,7 @@ static void helptags_one(char_u *dir, const char_u *ext, const char_u *tagfname,
|
||||
for (int fi = 0; fi < filecount && !got_int; fi++) {
|
||||
FILE *const fd = os_fopen((char *)files[fi], "r");
|
||||
if (fd == NULL) {
|
||||
EMSG2(_("E153: Unable to open %s for reading"), files[fi]);
|
||||
semsg(_("E153: Unable to open %s for reading"), files[fi]);
|
||||
continue;
|
||||
}
|
||||
const char_u *const fname = files[fi] + dirlen + 1;
|
||||
@@ -5584,7 +5584,7 @@ static void helptags_one(char_u *dir, const char_u *ext, const char_u *tagfname,
|
||||
if (utf8 == kNone) { // first file
|
||||
utf8 = this_utf8;
|
||||
} else if (utf8 != this_utf8) {
|
||||
EMSG2(_("E670: Mix of help file encodings within a language: %s"),
|
||||
semsg(_("E670: Mix of help file encodings within a language: %s"),
|
||||
files[fi]);
|
||||
mix = !got_int;
|
||||
got_int = TRUE;
|
||||
@@ -5643,7 +5643,7 @@ static void helptags_one(char_u *dir, const char_u *ext, const char_u *tagfname,
|
||||
vim_snprintf((char *)NameBuff, MAXPATHL,
|
||||
_("E154: Duplicate tag \"%s\" in file %s/%s"),
|
||||
((char_u **)ga.ga_data)[i], dir, p2 + 1);
|
||||
EMSG(NameBuff);
|
||||
emsg((char *)NameBuff);
|
||||
*p2 = '\t';
|
||||
break;
|
||||
}
|
||||
@@ -5699,7 +5699,7 @@ static void do_helptags(char_u *dirname, bool add_help_tags, bool ignore_writeer
|
||||
STRLCPY(NameBuff, dirname, sizeof(NameBuff));
|
||||
if (!add_pathsep((char *)NameBuff)
|
||||
|| STRLCAT(NameBuff, "**", sizeof(NameBuff)) >= MAXPATHL) {
|
||||
EMSG(_(e_fnametoolong));
|
||||
emsg(_(e_fnametoolong));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -5709,7 +5709,7 @@ static void do_helptags(char_u *dirname, bool add_help_tags, bool ignore_writeer
|
||||
if (gen_expand_wildcards(1, buff_list, &filecount, &files,
|
||||
EW_FILE|EW_SILENT) == FAIL
|
||||
|| filecount == 0) {
|
||||
EMSG2(_("E151: No match: %s"), NameBuff);
|
||||
semsg(_("E151: No match: %s"), NameBuff);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -5804,7 +5804,7 @@ void ex_helptags(exarg_T *eap)
|
||||
dirname = ExpandOne(&xpc, eap->arg, NULL,
|
||||
WILD_LIST_NOTFOUND|WILD_SILENT, WILD_EXPAND_FREE);
|
||||
if (dirname == NULL || !os_isdir(dirname)) {
|
||||
EMSG2(_("E150: Not a directory: %s"), eap->arg);
|
||||
semsg(_("E150: Not a directory: %s"), eap->arg);
|
||||
} else {
|
||||
do_helptags(dirname, add_help_tags, false);
|
||||
}
|
||||
|
Reference in New Issue
Block a user