summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2019-01-13 23:38:42 +0100
committerBram Moolenaar <Bram@vim.org>2019-01-13 23:38:42 +0100
commitf9e3e09fdc93be9f0d47afbc6c7df1188c2a5a0d (patch)
treea6b07005c19279a4f5d01be14f14861c2657fa95 /src
parent05500ece6282407f9f7227aaf564e24147326863 (diff)
patch 8.1.0743: giving error messages is not flexiblev8.1.0743
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 #3302) Also make emsg() accept a "char *" argument. Get rid of an enormous number of type casts.
Diffstat (limited to 'src')
-rw-r--r--src/blob.c2
-rw-r--r--src/blowfish.c10
-rw-r--r--src/buffer.c62
-rw-r--r--src/channel.c105
-rw-r--r--src/crypt.c2
-rw-r--r--src/dict.c12
-rw-r--r--src/diff.c33
-rw-r--r--src/digraph.c14
-rw-r--r--src/edit.c22
-rw-r--r--src/eval.c238
-rw-r--r--src/evalfunc.c262
-rw-r--r--src/ex_cmds.c134
-rw-r--r--src/ex_cmds.h2
-rw-r--r--src/ex_cmds2.c102
-rw-r--r--src/ex_docmd.c274
-rw-r--r--src/ex_eval.c106
-rw-r--r--src/ex_getln.c26
-rw-r--r--src/farsi.h2
-rw-r--r--src/fileio.c84
-rw-r--r--src/fold.c14
-rw-r--r--src/getchar.c22
-rw-r--r--src/globals.h248
-rw-r--r--src/gui.c16
-rw-r--r--src/gui_at_fs.c6
-rw-r--r--src/gui_at_sb.c2
-rw-r--r--src/gui_beval.c2
-rw-r--r--src/gui_gtk_x11.c8
-rw-r--r--src/gui_mac.c2
-rw-r--r--src/gui_photon.c2
-rw-r--r--src/gui_w32.c12
-rw-r--r--src/gui_x11.c32
-rw-r--r--src/hangulin.c2
-rw-r--r--src/hardcopy.c64
-rw-r--r--src/hashtab.c4
-rw-r--r--src/if_cscope.c60
-rw-r--r--src/if_lua.c10
-rw-r--r--src/if_mzsch.c16
-rw-r--r--src/if_perl.xs16
-rw-r--r--src/if_py_both.h20
-rw-r--r--src/if_python.c14
-rw-r--r--src/if_python3.c10
-rw-r--r--src/if_ruby.c24
-rw-r--r--src/if_tcl.c12
-rw-r--r--src/if_xcmdsrv.c8
-rw-r--r--src/json.c24
-rw-r--r--src/list.c8
-rw-r--r--src/main.c4
-rw-r--r--src/mark.c16
-rw-r--r--src/mbyte.c20
-rw-r--r--src/memfile.c10
-rw-r--r--src/memline.c74
-rw-r--r--src/menu.c48
-rw-r--r--src/message.c139
-rw-r--r--src/misc1.c14
-rw-r--r--src/misc2.c50
-rw-r--r--src/netbeans.c64
-rw-r--r--src/normal.c32
-rw-r--r--src/ops.c42
-rw-r--r--src/option.c181
-rw-r--r--src/os_amiga.c8
-rw-r--r--src/os_mswin.c29
-rw-r--r--src/os_unix.c28
-rw-r--r--src/os_win32.c14
-rw-r--r--src/popupmnu.c2
-rw-r--r--src/proto.h14
-rw-r--r--src/proto/buffer.pro2
-rw-r--r--src/proto/digraph.pro2
-rw-r--r--src/proto/ex_docmd.pro8
-rw-r--r--src/proto/ex_eval.pro2
-rw-r--r--src/proto/ex_getln.pro2
-rw-r--r--src/proto/hardcopy.pro4
-rw-r--r--src/proto/mbyte.pro2
-rw-r--r--src/proto/message.pro11
-rw-r--r--src/proto/misc2.pro2
-rw-r--r--src/proto/option.pro6
-rw-r--r--src/proto/spell.pro2
-rw-r--r--src/quickfix.c124
-rw-r--r--src/regexp.c48
-rw-r--r--src/regexp_nfa.c38
-rw-r--r--src/search.c32
-rw-r--r--src/sign.c44
-rw-r--r--src/spell.c23
-rw-r--r--src/spellfile.c190
-rw-r--r--src/structs.h6
-rw-r--r--src/syntax.c112
-rw-r--r--src/tag.c44
-rw-r--r--src/term.c28
-rw-r--r--src/terminal.c38
-rw-r--r--src/textprop.c48
-rw-r--r--src/ui.c2
-rw-r--r--src/undo.c88
-rw-r--r--src/userfunc.c74
-rw-r--r--src/version.c4
-rw-r--r--src/vim.h12
-rw-r--r--src/window.c52
95 files changed, 1967 insertions, 2022 deletions
diff --git a/src/blob.c b/src/blob.c
index 58acfc816a..6b771fed1f 100644
--- a/src/blob.c
+++ b/src/blob.c
@@ -161,7 +161,7 @@ write_blob(FILE *fd, blob_T *blob)
if (fwrite(blob->bv_ga.ga_data, 1, blob->bv_ga.ga_len, fd)
< (size_t)blob->bv_ga.ga_len)
{
- EMSG(_(e_write));
+ emsg(_(e_write));
return FAIL;
}
return OK;
diff --git a/src/blowfish.c b/src/blowfish.c
index e361d98cd4..8ca0e2848c 100644
--- a/src/blowfish.c
+++ b/src/blowfish.c
@@ -419,7 +419,7 @@ bf_key_init(
keylen = (int)STRLEN(key) / 2;
if (keylen == 0)
{
- IEMSG(_("E831: bf_key_init() called with empty password"));
+ iemsg(_("E831: bf_key_init() called with empty password"));
return;
}
for (i = 0; i < keylen; i++)
@@ -522,7 +522,7 @@ bf_self_test(void)
* warning. */
if (ui != 0xffffffffUL || ui + 1 != 0) {
err++;
- EMSG(_("E820: sizeof(uint32_t) != 4"));
+ emsg(_("E820: sizeof(uint32_t) != 4"));
}
if (!bf_check_tables(pax_init, sbx_init, 0x6ffa520a))
@@ -543,7 +543,7 @@ bf_self_test(void)
if (memcmp(bk.uc, bf_test_data[i].cryptxt, 8) != 0)
{
if (err == 0 && memcmp(bk.uc, bf_test_data[i].badcryptxt, 8) == 0)
- EMSG(_("E817: Blowfish big/little endian use wrong"));
+ emsg(_("E817: Blowfish big/little endian use wrong"));
err++;
}
}
@@ -669,12 +669,12 @@ blowfish_self_test(void)
{
if (sha256_self_test() == FAIL)
{
- EMSG(_("E818: sha256 test failed"));
+ emsg(_("E818: sha256 test failed"));
return FAIL;
}
if (bf_self_test() == FAIL)
{
- EMSG(_("E819: Blowfish test failed"));
+ emsg(_("E819: Blowfish test failed"));
return FAIL;
}
return OK;
diff --git a/src/buffer.c b/src/buffer.c
index b3bd2aa56b..fd29be7043 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -162,10 +162,10 @@ open_buffer(
*/
if (curbuf == NULL)
{
- EMSG(_("E82: Cannot allocate any buffer, exiting..."));
+ emsg(_("E82: Cannot allocate any buffer, exiting..."));
getout(2);
}
- EMSG(_("E83: Cannot allocate buffer, using other one..."));
+ emsg(_("E83: Cannot allocate buffer, using other one..."));
enter_buffer(curbuf);
#ifdef FEAT_SYN_HL
if (old_tw != curbuf->b_p_tw)
@@ -396,7 +396,7 @@ buf_hashtab_add(buf_T *buf)
{
sprintf((char *)buf->b_key, "%x", buf->b_fnum);
if (hash_add(&buf_hashtab, buf->b_key) == FAIL)
- EMSG(_("E931: Buffer cannot be registered"));
+ emsg(_("E931: Buffer cannot be registered"));
}
static void
@@ -430,7 +430,7 @@ can_unload_buffer(buf_T *buf)
}
}
if (!can_unload)
- EMSG(_("E937: Attempt to delete a buffer that is in use"));
+ emsg(_("E937: Attempt to delete a buffer that is in use"));
return can_unload;
}
@@ -548,7 +548,7 @@ close_buffer(
{
/* Autocommands deleted the buffer. */
aucmd_abort:
- EMSG(_(e_auabort));
+ emsg(_(e_auabort));
return;
}
--buf->b_locked;
@@ -1115,7 +1115,7 @@ handle_swap_exists(bufref_T *old_curbuf)
*
* Returns error message or NULL
*/
- char_u *
+ char *
do_bufdel(
int command,
char_u *arg, /* pointer to extra arguments */
@@ -1126,7 +1126,7 @@ do_bufdel(
{
int do_current = 0; /* delete current buffer? */
int deleted = 0; /* number of buffers deleted */
- char_u *errormsg = NULL; /* return value */
+ char *errormsg = NULL; /* return value */
int bnr; /* buffer number */
char_u *p;
@@ -1139,7 +1139,7 @@ do_bufdel(
if (addr_count == 2)
{
if (*arg) /* both range and argument is not allowed */
- return (char_u *)_(e_trailing);
+ return _(e_trailing);
bnr = start_bnr;
}
else /* addr_count == 1 */
@@ -1197,18 +1197,18 @@ do_bufdel(
STRCPY(IObuff, _("E516: No buffers were deleted"));
else
STRCPY(IObuff, _("E517: No buffers were wiped out"));
- errormsg = IObuff;
+ errormsg = (char *)IObuff;
}
else if (deleted >= p_report)
{
if (command == DOBUF_UNLOAD)
- smsg((char_u *)NGETTEXT("%d buffer unloaded",
+ smsg(NGETTEXT("%d buffer unloaded",
"%d buffers unloaded", deleted), deleted);
else if (command == DOBUF_DEL)
- smsg((char_u *)NGETTEXT("%d buffer deleted",
+ smsg(NGETTEXT("%d buffer deleted",
"%d buffers deleted", deleted), deleted);
else
- smsg((char_u *)NGETTEXT("%d buffer wiped out",
+ smsg(NGETTEXT("%d buffer wiped out",
"%d buffers wiped out", deleted), deleted);
}
}
@@ -1233,7 +1233,7 @@ empty_curbuf(
if (action == DOBUF_UNLOAD)
{
- EMSG(_("E90: Cannot unload last buffer"));
+ emsg(_("E90: Cannot unload last buffer"));
return FAIL;
}
@@ -1307,7 +1307,7 @@ do_buffer(
}
if (!bufIsChanged(buf))
{
- EMSG(_("E84: No modified buffer found"));
+ emsg(_("E84: No modified buffer found"));
return FAIL;
}
}
@@ -1346,7 +1346,7 @@ do_buffer(
if (bp == buf)
{
/* back where we started, didn't find anything. */
- EMSG(_("E85: There is no listed buffer"));
+ emsg(_("E85: There is no listed buffer"));
return FAIL;
}
}
@@ -1358,12 +1358,12 @@ do_buffer(
{
/* don't warn when deleting */
if (!unload)
- EMSGN(_(e_nobufnr), count);
+ semsg(_(e_nobufnr), count);
}
else if (dir == FORWARD)
- EMSG(_("E87: Cannot go beyond last buffer"));
+ emsg(_("E87: Cannot go beyond last buffer"));
else
- EMSG(_("E88: Cannot go before first buffer"));
+ emsg(_("E88: Cannot go before first buffer"));
return FAIL;
}
@@ -1407,7 +1407,7 @@ do_buffer(
else
#endif
{
- EMSGN(_("E89: No write since last change for buffer %ld (add ! to override)"),
+ semsg(_("E89: No write since last change for buffer %ld (add ! to override)"),
buf->b_fnum);
return FAIL;
}
@@ -1832,10 +1832,10 @@ no_write_message(void)
{
#ifdef FEAT_TERMINAL
if (term_job_running(curbuf->b_term))
- EMSG(_("E948: Job still running (add ! to end the job)"));
+ emsg(_("E948: Job still running (add ! to end the job)"));
else
#endif
- EMSG(_("E37: No write since last change (add ! to override)"));
+ emsg(_("E37: No write since last change (add ! to override)"));
}
void
@@ -1843,10 +1843,10 @@ no_write_message_nobang(buf_T *buf UNUSED)
{
#ifdef FEAT_TERMINAL
if (term_job_running(buf->b_term))
- EMSG(_("E948: Job still running"));
+ emsg(_("E948: Job still running"));
else
#endif
- EMSG(_("E37: No write since last change"));
+ emsg(_("E37: No write since last change"));
}
/*
@@ -2057,7 +2057,7 @@ buflist_new(
buf->b_fnum = top_file_num++;
if (top_file_num < 0) /* wrap around (may cause duplicates) */
{
- EMSG(_("W14: Warning: List of file names overflow"));
+ emsg(_("W14: Warning: List of file names overflow"));
if (emsg_silent == 0)
{
out_flush();
@@ -2281,9 +2281,9 @@ buflist_getfile(
if (buf == NULL)
{
if ((options & GETF_ALT) && n == 0)
- EMSG(_(e_noalt));
+ emsg(_(e_noalt));
else
- EMSGN(_("E92: Buffer %ld not found"), n);
+ semsg(_("E92: Buffer %ld not found"), n);
return FAIL;
}
@@ -2568,9 +2568,9 @@ buflist_findpat(
}
if (match == -2)
- EMSG2(_("E93: More than one match for %s"), pattern);
+ semsg(_("E93: More than one match for %s"), pattern);
else if (match < 0)
- EMSG2(_("E94: No matching buffer for %s"), pattern);
+ semsg(_("E94: No matching buffer for %s"), pattern);
return match;
}
@@ -3172,7 +3172,7 @@ setfname(
if (obuf->b_ml.ml_mfp != NULL) /* it's loaded, fail */
{
if (message)
- EMSG(_("E95: Buffer with this name already exists"));
+ emsg(_("E95: Buffer with this name already exists"));
vim_free(ffname);
return FAIL;
}
@@ -3298,7 +3298,7 @@ getaltfname(
if (buflist_name_nr(0, &fname, &dummy) == FAIL)
{
if (errmsg)
- EMSG(_(e_noalt));
+ emsg(_(e_noalt));
return NULL;
}
return fname;
@@ -5730,7 +5730,7 @@ bt_dontwrite_msg(buf_T *buf)
{
if (bt_dontwrite(buf))
{
- EMSG(_("E382: Cannot write, 'buftype' option is set"));
+ emsg(_("E382: Cannot write, 'buftype' option is set"));
return TRUE;
}
return FALSE;
diff --git a/src/channel.c b/src/channel.c
index e9615279a6..0cec71b432 100644
--- a/src/channel.c
+++ b/src/channel.c
@@ -116,7 +116,7 @@ ch_logfile(char_u *fname, char_u *opt)
file = fopen((char *)fname, *opt == 'w' ? "w" : "a");
if (file == NULL)
{
- EMSG2(_(e_notopen), fname);
+ semsg(_(e_notopen), fname);
return;
}
}
@@ -209,8 +209,7 @@ ch_error(channel_T *ch, const char *fmt, ...)
#ifdef _WIN32
# undef PERROR
-# define PERROR(msg) (void)emsg3((char_u *)"%s: %s", \
- (char_u *)msg, (char_u *)strerror_win32(errno))
+# define PERROR(msg) (void)semsg("%s: %s", msg, strerror_win32(errno))
static char *
strerror_win32(int eno)
@@ -942,7 +941,7 @@ channel_open_func(typval_T *argvars)
if (argvars[1].v_type != VAR_UNKNOWN
&& (argvars[1].v_type != VAR_DICT || argvars[1].vval.v_dict == NULL))
{
- EMSG(_(e_invarg));
+ emsg(_(e_invarg));
return NULL;
}
@@ -950,7 +949,7 @@ channel_open_func(typval_T *argvars)
p = vim_strchr(address, ':');
if (p == NULL)
{
- EMSG2(_(e_invarg2), address);
+ semsg(_(e_invarg2), address);
return NULL;
}
*p++ = NUL;
@@ -958,7 +957,7 @@ channel_open_func(typval_T *argvars)
if (*address == NUL || port <= 0 || *rest != NUL)
{
p[-1] = ':';
- EMSG2(_(e_invarg2), address);
+ semsg(_(e_invarg2), address);
return NULL;
}
@@ -971,7 +970,7 @@ channel_open_func(typval_T *argvars)
goto theend;
if (opt.jo_timeout < 0)
{
- EMSG(_(e_invarg));
+ emsg(_(e_invarg));
goto theend;
}
@@ -1233,7 +1232,7 @@ channel_set_options(channel_T *channel, jobopt_T *opt)
{
buf = buflist_findnr(opt->jo_io_buf[PART_OUT]);
if (buf == NULL)
- EMSGN(_(e_nobufnr), (long)opt->jo_io_buf[PART_OUT]);
+ semsg(_(e_nobufnr), (long)opt->jo_io_buf[PART_OUT]);
}
else
{
@@ -1251,7 +1250,7 @@ channel_set_options(channel_T *channel, jobopt_T *opt)
if (!buf->b_p_ma && !channel->ch_part[PART_OUT].ch_nomodifiable)
{
- EMSG(_(e_modifiable));
+ emsg(_(e_modifiable));
}
else
{
@@ -1280,7 +1279,7 @@ channel_set_options(channel_T *channel, jobopt_T *opt)
{
buf = buflist_findnr(opt->jo_io_buf[PART_ERR]);
if (buf == NULL)
- EMSGN(_(e_nobufnr), (long)opt->jo_io_buf[PART_ERR]);
+ semsg(_(e_nobufnr), (long)opt->jo_io_buf[PART_ERR]);
}
else
{
@@ -1297,7 +1296,7 @@ channel_set_options(channel_T *channel, jobopt_T *opt)
!opt->jo_modifiable[PART_ERR];
if (!buf->b_p_ma && !channel->ch_part[PART_ERR].ch_nomodifiable)
{
- EMSG(_(e_modifiable));
+ emsg(_(e_modifiable));
}
else
{
@@ -1619,7 +1618,7 @@ invoke_callback(channel_T *channel, char_u *callback, partial_T *partial,
int dummy;
if (safe_to_invoke_callback == 0)
- IEMSG("INTERNAL: Invoking callback when it is not safe");
+ iemsg("INTERNAL: Invoking callback when it is not safe");
argv[0].v_type = VAR_CHANNEL;
argv[0].vval.v_channel = channel;
@@ -2237,7 +2236,7 @@ channel_exe_cmd(channel_T *channel, ch_part_T part, typval_T *argv)
{
ch_error(channel, "received command with non-string argument");
if (p_verbose > 2)
- EMSG(_("E903: received command with non-string argument"));
+ emsg(_("E903: received command with non-string argument"));
return;
}
arg = argv[1].vval.v_string;
@@ -2289,13 +2288,13 @@ channel_exe_cmd(channel_T *channel, ch_part_T part, typval_T *argv