diff src/message.c @ 10359:66f1b5bf3fa6 v8.0.0074

commit https://github.com/vim/vim/commit/95f096030ed1a8afea028f2ea295d6f6a70f466f Author: Bram Moolenaar <Bram@vim.org> Date: Thu Nov 10 20:01:45 2016 +0100 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.
author Christian Brabandt <cb@256bit.org>
date Thu, 10 Nov 2016 20:15:05 +0100
parents dd0531938cb6
children acfc83aca8ee
line wrap: on
line diff
--- a/src/message.c
+++ b/src/message.c
@@ -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