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
#3302) Also make emsg() accept a "char *" argument. Get rid of
an enormous number of type casts.
diff --git a/src/window.c b/src/window.c
index 5989aed..995debe 100644
--- a/src/window.c
+++ b/src/window.c
@@ -101,7 +101,7 @@
do { \
if (cmdwin_type != 0) \
{ \
- EMSG(_(e_cmdwin)); \
+ emsg(_(e_cmdwin)); \
return; \
} \
} while (0)
@@ -156,9 +156,9 @@
? curwin->w_alt_fnum : Prenum) == NULL)
{
if (Prenum == 0)
- EMSG(_(e_noalt));
+ emsg(_(e_noalt));
else
- EMSGN(_("E92: Buffer %ld not found"), Prenum);
+ semsg(_("E92: Buffer %ld not found"), Prenum);
break;
}
@@ -220,7 +220,7 @@
if (wp->w_p_pvw)
break;
if (wp == NULL)
- EMSG(_("E441: There is no preview window"));
+ emsg(_("E441: There is no preview window"));
else
win_goto(wp);
break;
@@ -739,7 +739,7 @@
flags |= cmdmod.split;
if ((flags & WSP_TOP) && (flags & WSP_BOT))
{
- EMSG(_("E442: Can't split topleft and botright at the same time"));
+ emsg(_("E442: Can't split topleft and botright at the same time"));
return FAIL;
}
@@ -794,7 +794,7 @@
{
if (VISIBLE_HEIGHT(oldwin) <= p_wmh && new_wp == NULL)
{
- EMSG(_(e_noroom));
+ emsg(_(e_noroom));
return FAIL;
}
need_status = STATUS_HEIGHT;
@@ -852,7 +852,7 @@
}
if (available < needed && new_wp == NULL)
{
- EMSG(_(e_noroom));
+ emsg(_(e_noroom));
return FAIL;
}
if (new_size == 0)
@@ -935,7 +935,7 @@
}
if (available < needed && new_wp == NULL)
{
- EMSG(_(e_noroom));
+ emsg(_(e_noroom));
return FAIL;
}
oldwin_height = oldwin->w_height;
@@ -1606,7 +1606,7 @@
FOR_ALL_FRAMES(frp, curwin->w_frame->fr_parent->fr_child)
if (frp->fr_win == NULL)
{
- EMSG(_("E443: Cannot rotate when another window is split"));
+ emsg(_("E443: Cannot rotate when another window is split"));
return;
}
@@ -2309,7 +2309,7 @@
if (last_window())
{
- EMSG(_("E444: Cannot close last window"));
+ emsg(_("E444: Cannot close last window"));
return FAIL;
}
@@ -2318,12 +2318,12 @@
return FAIL; /* window is already being closed */
if (win == aucmd_win)
{
- EMSG(_("E813: Cannot close autocmd window"));
+ emsg(_("E813: Cannot close autocmd window"));
return FAIL;
}
if ((firstwin == aucmd_win || lastwin == aucmd_win) && one_window())
{
- EMSG(_("E814: Cannot close window, only autocmd window would remain"));
+ emsg(_("E814: Cannot close window, only autocmd window would remain"));
return FAIL;
}
@@ -3419,7 +3419,7 @@
}
if (message && !ONE_WINDOW)
- EMSG(_("E445: Other window contains changes"));
+ emsg(_("E445: Other window contains changes"));
}
/*
@@ -5447,7 +5447,7 @@
--p_wmh;
if (first)
{
- EMSG(_(e_noroom));
+ emsg(_(e_noroom));
first = FALSE;
}
}
@@ -5473,7 +5473,7 @@
--p_wmw;
if (first)
{
- EMSG(_(e_noroom));
+ emsg(_(e_noroom));
first = FALSE;
}
}
@@ -5950,7 +5950,7 @@
{
if (frp == NULL)
{
- EMSG(_(e_noroom));
+ emsg(_(e_noroom));
p_ch = old_p_ch;
curtab->tp_ch_used = p_ch;
cmdline_row = Rows - p_ch;
@@ -6041,7 +6041,7 @@
{
if (fp == topframe)
{
- EMSG(_(e_noroom));
+ emsg(_(e_noroom));
return;
}
/* In a column of frames: go to frame above. If already at
@@ -6170,7 +6170,7 @@
if (*ptr == NUL) /* nothing found */
{
if (options & FNAME_MESS)
- EMSG(_("E446: No file name under cursor"));
+ emsg(_("E446: No file name under cursor"));
return NULL;
}
@@ -6319,7 +6319,7 @@
{
c = ptr[len];
ptr[len] = NUL;
- EMSG2(_("E447: Can't find file \"%s\" in path"), ptr);
+ semsg(_("E447: Can't find file \"%s\" in path"), ptr);
ptr[len] = c;
}
@@ -6782,7 +6782,7 @@
return -1;
if (id < -1 || id == 0)
{
- EMSGN(_("E799: Invalid ID: %ld (must be greater than or equal to 1)"), id);
+ semsg(_("E799: Invalid ID: %ld (must be greater than or equal to 1)"), id);
return -1;
}
if (id != -1)
@@ -6792,7 +6792,7 @@
{
if (cur->id == id)
{
- EMSGN(_("E801: ID already taken: %ld"), id);
+ semsg(_("E801: ID already taken: %ld"), id);
return -1;
}
cur = cur->next;
@@ -6800,12 +6800,12 @@
}
if ((hlg_id = syn_namen2id(grp, (int)STRLEN(grp))) == 0)
{
- EMSG2(_(e_nogroup), grp);
+ semsg(_(e_nogroup), grp);
return -1;
}
if (pat != NULL && (regprog = vim_regcomp(pat, RE_MAGIC)) == NULL)
{
- EMSG2(_(e_invarg2), pat);
+ semsg(_(e_invarg2), pat);
return -1;
}
@@ -6900,7 +6900,7 @@
}
else
{
- EMSG(_("List or number required"));
+ emsg(_("List or number required"));
goto fail;
}
if (toplnum == 0 || lnum < toplnum)
@@ -6969,7 +6969,7 @@
if (id < 1)
{
if (perr == TRUE)
- EMSGN(_("E802: Invalid ID: %ld (must be greater than or equal to 1)"),
+ semsg(_("E802: Invalid ID: %ld (must be greater than or equal to 1)"),
id);
return -1;
}
@@ -6981,7 +6981,7 @@
if (cur == NULL)
{
if (perr == TRUE)
- EMSGN(_("E803: ID not found: %ld"), id);
+ semsg(_("E803: ID not found: %ld"), id);
return -1;
}
if (cur == prev)