summaryrefslogtreecommitdiff
path: root/src/fileio.c
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/fileio.c
parent05500ece6282407f9f7227aaf564e24147326863 (diff)
downloadvim-git-f9e3e09fdc93be9f0d47afbc6c7df1188c2a5a0d.tar.gz
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/fileio.c')
-rw-r--r--src/fileio.c84
1 files changed, 42 insertions, 42 deletions
diff --git a/src/fileio.c b/src/fileio.c
index 929cc1530..ae70caf97 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -595,7 +595,7 @@ readfile(
|| (using_b_fname
&& (old_b_fname != curbuf->b_fname)))
{
- EMSG(_(e_auchangedbuf));
+ emsg(_(e_auchangedbuf));
return FAIL;
}
}
@@ -676,7 +676,7 @@ readfile(
|| (using_b_ffname && (old_b_ffname != curbuf->b_ffname))
|| (using_b_fname && (old_b_fname != curbuf->b_fname))))
{
- EMSG(_(e_auchangedbuf));
+ emsg(_(e_auchangedbuf));
if (!read_buffer)
close(fd);
return FAIL;
@@ -798,9 +798,9 @@ readfile(
--no_wait_return;
msg_scroll = msg_save;
if (fd < 0)
- EMSG(_("E200: *ReadPre autocommands made the file unreadable"));
+ emsg(_("E200: *ReadPre autocommands made the file unreadable"));
else
- EMSG(_("E201: *ReadPre autocommands must not change current buffer"));
+ emsg(_("E201: *ReadPre autocommands must not change current buffer"));
curbuf->b_p_ro = TRUE; /* must use "w!" now */
return FAIL;
}
@@ -1128,7 +1128,7 @@ retry:
if (fd < 0)
{
/* Re-opening the original file failed! */
- EMSG(_("E202: Conversion made file unreadable!"));
+ emsg(_("E202: Conversion made file unreadable!"));
error = TRUE;
goto failed;
}
@@ -2993,7 +2993,7 @@ check_for_cryptkey(
* option and don't free it. bf needs hash of the key saved.
* Don't ask for the key again when first time Enter was hit.
* Happens when retrying to detect encoding. */
- smsg((char_u *)_(need_key_msg), fname);
+ smsg(_(need_key_msg), fname);
msg_scroll = TRUE;
crypt_check_method(method);
cryptkey = crypt_get_key(newfile, FALSE);
@@ -3197,7 +3197,7 @@ buf_write(
{
/* This can happen during startup when there is a stray "w" in the
* vimrc file. */
- EMSG(_(e_emptybuf));
+ emsg(_(e_emptybuf));
return FAIL;
}
@@ -3211,7 +3211,7 @@ buf_write(
/* Avoid a crash for a long name. */
if (STRLEN(fname) >= MAXPATHL)
{
- EMSG(_(e_longname));
+ emsg(_(e_longname));
return FAIL;
}
@@ -3399,7 +3399,7 @@ buf_write(
--no_wait_return;
msg_scroll = msg_save;
if (nofile_err)
- EMSG(_("E676: No matching autocommands for acwrite buffer"));
+ emsg(_("E676: No matching autocommands for acwrite buffer"));
if (nofile_err
#ifdef FEAT_EVAL
@@ -3434,7 +3434,7 @@ buf_write(
#ifdef FEAT_EVAL
if (!aborting())
#endif
- EMSG(_("E203: Autocommands deleted or unloaded buffer to be written"));
+ emsg(_("E203: Autocommands deleted or unloaded buffer to be written"));
return FAIL;
}
@@ -3457,7 +3457,7 @@ buf_write(
{
--no_wait_return;
msg_scroll = msg_save;
- EMSG(_("E204: Autocommand changed number of lines in unexpected way"));
+ emsg(_("E204: Autocommand changed number of lines in unexpected way"));
return FAIL;
}
}
@@ -5055,7 +5055,7 @@ restore_backup:
* the current backup file becomes the original file
*/
if (org == NULL)
- EMSG(_("E205: Patchmode: can't save original file"));
+ emsg(_("E205: Patchmode: can't save original file"));
else if (mch_stat(org, &st) < 0)
{
vim_rename(backup, (char_u *)org);
@@ -5077,7 +5077,7 @@ restore_backup:
|| (empty_fd = mch_open(org,
O_CREAT | O_EXTRA | O_EXCL | O_NOFOLLOW,
perm < 0 ? 0666 : (perm & 0777))) < 0)
- EMSG(_("E206: patchmode: can't touch empty original file"));
+ emsg(_("E206: patchmode: can't touch empty original file"));
else
close(empty_fd);
}
@@ -5092,7 +5092,7 @@ restore_backup:
* Remove the backup unless 'backup' option is set
*/
if (!p_bk && backup != NULL && mch_remove(backup) != 0)
- EMSG(_("E207: Can't delete backup file"));
+ emsg(_("E207: Can't delete backup file"));
#ifdef FEAT_SUN_WORKSHOP
if (usingSunWorkShop)
@@ -5151,7 +5151,7 @@ nofail:
mch_memmove(IObuff, errnum, (size_t)numlen);
}
STRCAT(IObuff, errmsg);
- emsg(IObuff);
+ emsg((char *)IObuff);
if (errmsg_allocated)
vim_free(errmsg);
@@ -5251,7 +5251,7 @@ set_rw_fname(char_u *fname, char_u *sfname)
if (curbuf != buf)
{
/* We are in another buffer now, don't do the renaming. */
- EMSG(_(e_auchangedbuf));
+ emsg(_(e_auchangedbuf));
return FAIL;
}
@@ -6732,7 +6732,7 @@ vim_rename(char_u *from, char_u *to)
#endif
if (errmsg != NULL)
{
- EMSG2(errmsg, to);
+ semsg(errmsg, to);
return -1;
}
mch_remove(from);
@@ -6872,7 +6872,7 @@ buf_check_timestamp(
int stat_res;
int retval = 0;
char_u *path;
- char_u *tbuf;
+ char *tbuf;
char *mesg = NULL;
char *mesg2 = "";
int helpmesg = FALSE;
@@ -6983,7 +6983,7 @@ buf_check_timestamp(
if (n)
{
if (!bufref_valid(&bufref))
- EMSG(_("E246: FileChangedShell autocommand deleted buffer"));
+ emsg(_("E246: FileChangedShell autocommand deleted buffer"));
#ifdef FEAT_EVAL
s = get_vim_var_str(VV_FCS_CHOICE);
if (STRCMP(s, "reload") == 0 && *reason != 'd')
@@ -7052,13 +7052,13 @@ buf_check_timestamp(
{
if (!helpmesg)
mesg2 = "";
- tbuf = alloc((unsigned)(STRLEN(path) + STRLEN(mesg)
+ tbuf = (char *)alloc((unsigned)(STRLEN(path) + STRLEN(mesg)
+ STRLEN(mesg2) + 2));
- sprintf((char *)tbuf, mesg, path);
+ sprintf(tbuf, mesg, path);
#ifdef FEAT_EVAL
/* Set warningmsg here, before the unimportant and output-specific
* mesg2 has been appended. */
- set_vim_var_string(VV_WARNINGMSG, tbuf, -1);
+ set_vim_var_string(VV_WARNINGMSG, (char_u *)tbuf, -1);
#endif
#if defined(FEAT_CON_DIALOG) || defined(FEAT_GUI_DIALOG)
if (can_reload)
@@ -7068,7 +7068,8 @@ buf_check_timestamp(
STRCAT(tbuf, "\n");
STRCAT(tbuf, mesg2);
}
- if (do_dialog(VIM_WARNING, (char_u *)_("Warning"), tbuf,
+ if (do_dialog(VIM_WARNING, (char_u *)_("Warning"),
+ (char_u *)tbuf,
(char_u *)_("&OK\n&Load File"), 1, NULL, TRUE) == 2)
reload = TRUE;
}
@@ -7081,7 +7082,7 @@ buf_check_timestamp(
STRCAT(tbuf, "; ");
STRCAT(tbuf, mesg2);
}
- EMSG(tbuf);
+ emsg(tbuf);
retval = 2;
}
else
@@ -7089,7 +7090,7 @@ buf_check_timestamp(
if (!autocmd_busy)
{
msg_start();
- msg_puts_attr(tbuf, HL_ATTR(HLF_E) + MSG_HIST);
+ msg_puts_attr((char_u *)tbuf, HL_ATTR(HLF_E) + MSG_HIST);
if (*mesg2 != NUL)
msg_puts_attr((char_u *)mesg2,
HL_ATTR(HLF_W) + MSG_HIST);
@@ -7213,7 +7214,7 @@ buf_reload(buf_T *buf, int orig_mode)
if (savebuf == NULL || saved == FAIL || buf != curbuf
|| move_lines(buf, savebuf) == FAIL)
{
- EMSG2(_("E462: Could not prepare for reloading \"%s\""),
+ semsg(_("E462: Could not prepare for reloading \"%s\""),
buf->b_fname);
saved = FAIL;
}
@@ -7230,7 +7231,7 @@ buf_reload(buf_T *buf, int orig_mode)
#if defined(FEAT_EVAL)
if (!aborting())
#endif
- EMSG2(_("E321: Could not reload \"%s\""), buf->b_fname);
+ semsg(_("E321: Could not reload \"%s\""), buf->b_fname);
if (savebuf != NULL && bufref_valid(&bufref) && buf == curbuf)
{
/* Put the text back from the save buffer. First
@@ -8076,8 +8077,7 @@ aubuflocal_remove(buf_T *buf)
if (p_verbose >= 6)
{
verbose_enter();
- smsg((char_u *)
- _("auto-removing autocommand: %s <buffer=%d>"),
+ smsg(_("auto-removing autocommand: %s <buffer=%d>"),
event_nr2name(event), buf->b_fnum);
verbose_leave();
}
@@ -8121,9 +8121,9 @@ au_del_group(char_u *name)
i = au_find_group(name);
if (i == AUGROUP_ERROR) /* the group doesn't exist */
- EMSG2(_("E367: No such group: \"%s\""), name);
+ semsg(_("E367: No such group: \"%s\""), name);
else if (i == current_augroup)
- EMSG(_("E936: Cannot delete the current group"));
+ emsg(_("E936: Cannot delete the current group"));
else
{
event_T event;
@@ -8188,7 +8188,7 @@ do_augroup(char_u *arg, int del_group)
if (del_group)
{
if (*arg == NUL)
- EMSG(_(e_argreq));
+ emsg(_(e_argreq));
else
au_del_group(arg);
}
@@ -8295,7 +8295,7 @@ find_end_event(
{
if (arg[1] && !VIM_ISWHITE(arg[1]))
{
- EMSG2(_("E215: Illegal character after *: %s"), arg);
+ semsg(_("E215: Illegal character after *: %s"), arg);
return NULL;
}
pat = arg + 1;
@@ -8307,9 +8307,9 @@ find_end_event(
if ((int)event_name2nr(pat, &p) >= (int)NUM_EVENTS)
{
if (have_group)
- EMSG2(_("E216: No such event: %s"), pat);
+ semsg(_("E216: No such event: %s"), pat);
else
- EMSG2(_("E216: No such group or event: %s"), pat);
+ semsg(_("E216: No such group or event: %s"), pat);
return NULL;
}
}
@@ -8773,7 +8773,7 @@ do_autocmd_event(
if (is_buflocal && (buflocal_nr == 0
|| buflist_findnr(buflocal_nr) == NULL))
{
- EMSGN(_("E680: <buffer=%d>: invalid buffer number "),
+ semsg(_("E680: <buffer=%d>: invalid buffer number "),
buflocal_nr);
return FAIL;
}
@@ -8876,7 +8876,7 @@ do_doautocmd(
if (*arg == '*')
{
- EMSG(_("E217: Can't execute autocommands for ALL events"));
+ emsg(_("E217: Can't execute autocommands for ALL events"));
return FAIL;
}
@@ -9461,7 +9461,7 @@ apply_autocmds_group(
*/
if (nesting == 10)
{
- EMSG(_("E218: autocommand nesting too deep"));
+ emsg(_("E218: autocommand nesting too deep"));
goto BYPASS_AU;
}
@@ -9869,7 +9869,7 @@ auto_next_pat(
if (p_verbose >= 8)
{
verbose_enter();
- smsg((char_u *)_("Executing %s"), sourcing_name);
+ smsg(_("Executing %s"), sourcing_name);
verbose_leave();
}
}
@@ -9935,7 +9935,7 @@ getnextac(int c UNUSED, void *cookie, int indent UNUSED)
if (p_verbose >= 9)
{
verbose_enter_scroll();
- smsg((char_u *)_("autocommand %s"), ac->cmd);
+ smsg(_("autocommand %s"), ac->cmd);
msg_puts((char_u *)"\n"); /* don't overwrite this either */
verbose_leave_scroll();
}
@@ -10483,9 +10483,9 @@ file_pat_to_reg_pat(
if (nested != 0)
{
if (nested < 0)
- EMSG(_("E219: Missing {."));
+ emsg(_("E219: Missing {."));
else
- EMSG(_("E220: Missing }."));
+ emsg(_("E220: Missing }."));
VIM_CLEAR(reg_pat);
}
return reg_pat;