+/* Frees a message created by msg_dup().
+
+ (Messages not created by msg_dup(), as well as their file_name
+ members, are typically not dynamically allocated, so this function should
+ not be used to destroy them.) */
+void
+msg_destroy (struct msg *m)
+{
+ free (m->file_name);
+ free (m->text);
+ free (m);
+}
+
+char *
+msg_to_string (const struct msg *m, const char *command_name)
+{
+ struct string s;
+
+ ds_init_empty (&s);
+
+ if (m->category != MSG_C_GENERAL
+ && (m->file_name || m->first_line > 0 || m->first_column > 0))
+ {
+ int l1 = m->first_line;
+ int l2 = MAX (m->first_line, m->last_line - 1);
+ int c1 = m->first_column;
+ int c2 = MAX (m->first_column, m->last_column - 1);
+
+ if (m->file_name)
+ ds_put_format (&s, "%s", m->file_name);
+
+ if (l1 > 0)
+ {
+ if (!ds_is_empty (&s))
+ ds_put_byte (&s, ':');
+
+ if (l2 > l1)
+ {
+ if (c1 > 0)
+ ds_put_format (&s, "%d.%d-%d.%d", l1, c1, l2, c2);
+ else
+ ds_put_format (&s, "%d-%d", l1, l2);
+ }
+ else
+ {
+ if (c1 > 0)
+ {
+ if (c2 > c1)
+ {
+ /* The GNU coding standards say to use
+ LINENO-1.COLUMN-1-COLUMN-2 for this case, but GNU
+ Emacs interprets COLUMN-2 as LINENO-2 if I do that.
+ I've submitted an Emacs bug report:
+ http://debbugs.gnu.org/cgi/bugreport.cgi?bug=7725.
+
+ For now, let's be compatible. */
+ ds_put_format (&s, "%d.%d-%d.%d", l1, c1, l1, c2);
+ }
+ else
+ ds_put_format (&s, "%d.%d", l1, c1);
+ }
+ else
+ ds_put_format (&s, "%d", l1);
+ }
+ }
+ else if (c1 > 0)
+ {
+ if (c2 > c1)
+ ds_put_format (&s, ".%d-%d", c1, c2);
+ else
+ ds_put_format (&s, ".%d", c1);
+ }
+ ds_put_cstr (&s, ": ");
+ }
+
+ ds_put_format (&s, "%s: ", msg_severity_to_string (m->severity));
+
+ if (m->category == MSG_C_SYNTAX && command_name != NULL)
+ ds_put_format (&s, "%s: ", command_name);
+
+ ds_put_cstr (&s, m->text);
+
+ return ds_cstr (&s);
+}
+\f
+
+/* Number of messages reported, by severity level. */
+static int counts[MSG_N_SEVERITIES];
+
+/* True after the maximum number of errors or warnings has been exceeded. */
+static bool too_many_errors;
+
+/* True after the maximum number of notes has been exceeded. */
+static bool too_many_notes;
+
+/* True iff warnings have been explicitly disabled (MXWARNS = 0) */
+static bool warnings_off = false;
+
+/* Checks whether we've had so many errors that it's time to quit
+ processing this syntax file. */
+bool
+msg_ui_too_many_errors (void)
+{
+ return too_many_errors;
+}
+
+void
+msg_ui_disable_warnings (bool x)
+{
+ warnings_off = x;
+}
+
+