+char *
+msg_to_string (const struct msg *m, const char *command_name)
+{
+ const char *label;
+ struct string s;
+
+ ds_init_empty (&s);
+
+ if (m->category != MSG_C_GENERAL
+ && (m->where.file_name || m->where.line_number != -1))
+ {
+ if (m->where.file_name)
+ ds_put_format (&s, "%s:", m->where.file_name);
+ if (m->where.line_number != -1)
+ ds_put_format (&s, "%d:", m->where.line_number);
+ ds_put_char (&s, ' ');
+ }
+
+ switch (m->severity)
+ {
+ case MSG_S_ERROR:
+ label = _("error");
+ break;
+ case MSG_S_WARNING:
+ label = _("warning");
+ break;
+ case MSG_S_NOTE:
+ default:
+ label = _("note");
+ break;
+ }
+ ds_put_format (&s, "%s: ", label);
+
+ 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