diff options
author | Michael Schupikov <michael@schupikov.de> | 2017-09-23 09:56:44 +0200 |
---|---|---|
committer | James McCoy <jamessan@jamessan.com> | 2017-12-15 15:50:58 -0500 |
commit | d5bce42b524708a54243658e87b1e3bd9c7acdf3 (patch) | |
tree | 2707be6b36b8b5a920bfd73f1b60da011b7e1ced /src/nvim/message.c | |
parent | 6ff13d78b7eb0a1fae2e2e8cdd054072e1467158 (diff) | |
download | rneovim-d5bce42b524708a54243658e87b1e3bd9c7acdf3.tar.gz rneovim-d5bce42b524708a54243658e87b1e3bd9c7acdf3.tar.bz2 rneovim-d5bce42b524708a54243658e87b1e3bd9c7acdf3.zip |
vim-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.
https://github.com/vim/vim/commit/95f096030ed1a8afea028f2ea295d6f6a70f466f
Signed-off-by: Michael Schupikov <michael@schupikov.de>
Diffstat (limited to 'src/nvim/message.c')
-rw-r--r-- | src/nvim/message.c | 47 |
1 files changed, 44 insertions, 3 deletions
diff --git a/src/nvim/message.c b/src/nvim/message.c index 5c8f0655bf..1d9a4de9c0 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -583,19 +583,60 @@ void emsg_invreg(int name) /// Print an error message with unknown number of arguments bool emsgf(const char *const fmt, ...) { + bool ret; + + va_list ap; + va_start(ap, fmt); + ret = emsgfv(fmt, ap); + va_end(ap); + + return ret; +} + +/// Print an error message with unknown number of arguments +static bool emsgfv(const char *fmt, va_list ap) +{ static char errbuf[IOSIZE]; if (emsg_not_now()) { return true; } - va_list ap; - va_start(ap, fmt); vim_vsnprintf(errbuf, sizeof(errbuf), fmt, ap, NULL); - va_end(ap); return emsg((const char_u *)errbuf); } +/// 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(const char *s) +{ + msg((char_u *)s); +#ifdef ABORT_ON_INTERNAL_ERROR + abort(); +#endif +} + +/// Same as emsgf(...) 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 iemsgf(const char *s, ...) +{ + va_list ap; + va_start(ap, s); + (void)emsgfv(s, ap); + va_end(ap); +#ifdef ABORT_ON_INTERNAL_ERROR + abort(); +#endif +} + +/// Give an "Internal error" message. +void internal_error(char *where) +{ + IEMSG2(_(e_intern2), where); +} + static void msg_emsgf_event(void **argv) { char *s = argv[0]; |