0
0
mirror of https://github.com/vim/vim.git synced 2025-09-23 03:43:49 -04:00

patch 8.0.0074

Problem:    Cannot make Vim fail on an internal error.
Solution:   Add IEMSG() and IEMSG2(). (Domenique Pelle)  Avoid reporting an
            internal error without mentioning where.
This commit is contained in:
Bram Moolenaar
2016-11-10 20:01:45 +01:00
parent 459ca56312
commit 95f096030e
30 changed files with 159 additions and 91 deletions

View File

@@ -662,6 +662,7 @@ emsg(char_u *s)
return msg_attr(s, attr);
}
/*
* Print an error message with one "%s" and one string argument.
*/
@@ -671,6 +672,84 @@ emsg2(char_u *s, char_u *a1)
return emsg3(s, a1, NULL);
}
/*
* Print an error message with one or two "%s" and one or two string arguments.
* This is not in message.c to avoid a warning for prototypes.
*/
int
emsg3(char_u *s, char_u *a1, char_u *a2)
{
if (emsg_not_now())
return TRUE; /* no error messages at the moment */
vim_snprintf((char *)IObuff, IOSIZE, (char *)s, a1, a2);
return emsg(IObuff);
}
/*
* Print an error message with one "%ld" and one long int argument.
* This is not in message.c to avoid a warning for prototypes.
*/
int
emsgn(char_u *s, long n)
{
if (emsg_not_now())
return TRUE; /* no error messages at the moment */
vim_snprintf((char *)IObuff, IOSIZE, (char *)s, n);
return emsg(IObuff);
}
/*
* Same as emsg(...), but abort on error when ABORT_ON_INTERNAL_ERROR is
* defined. It is used for internal errors only, so that they can be
* detected when fuzzing vim.
*/
void
iemsg(char_u *s)
{
msg(s);
#ifdef ABORT_ON_INTERNAL_ERROR
abort();
#endif
}
/*
* Same as emsg2(...) but abort on error when ABORT_ON_INTERNAL_ERROR is
* defined. It is used for internal errors only, so that they can be
* detected when fuzzing vim.
*/
void
iemsg2(char_u *s, char_u *a1)
{
emsg2(s, a1);
#ifdef ABORT_ON_INTERNAL_ERROR
abort();
#endif
}
/*
* Same as emsgn(...) but abort on error when ABORT_ON_INTERNAL_ERROR is
* defined. It is used for internal errors only, so that they can be
* detected when fuzzing vim.
*/
void
iemsgn(char_u *s, long n)
{
emsgn(s, n);
#ifdef ABORT_ON_INTERNAL_ERROR
abort();
#endif
}
/*
* Give an "Internal error" message.
*/
void
internal_error(char *where)
{
IEMSG2(_(e_intern2), where);
}
/* emsg3() and emsgn() are in misc2.c to avoid warnings for the prototypes. */
void