pcp_msg (struct pcp_reader *r, off_t offset,
int class, const char *format, va_list args)
{
- struct msg m;
struct string text;
-
ds_init_empty (&text);
if (offset >= 0)
ds_put_format (&text, _("`%s' near offset 0x%llx: "),
ds_put_format (&text, _("`%s': "), fh_get_file_name (r->fh));
ds_put_vformat (&text, format, args);
- m.category = msg_class_to_category (class);
- m.severity = msg_class_to_severity (class);
- m.file_name = NULL;
- m.first_line = 0;
- m.last_line = 0;
- m.first_column = 0;
- m.last_column = 0;
- m.text = ds_cstr (&text);
-
+ struct msg m = {
+ .category = msg_class_to_category (class),
+ .severity = msg_class_to_severity (class),
+ .text = ds_cstr (&text),
+ };
msg_emit (&m);
}
static void
error (struct pfm_reader *r, const char *msg, ...)
{
- struct msg m;
struct string text;
va_list args;
ds_put_vformat (&text, msg, args);
va_end (args);
- m.category = MSG_C_GENERAL;
- m.severity = MSG_S_ERROR;
- m.file_name = NULL;
- m.first_line = 0;
- m.last_line = 0;
- m.first_column = 0;
- m.last_column = 0;
- m.text = ds_cstr (&text);
-
+ struct msg m = {
+ .category = MSG_C_GENERAL,
+ .severity = MSG_S_ERROR,
+ .text = ds_cstr (&text),
+ };
msg_emit (&m);
r->ok = false;
static void
warning (struct pfm_reader *r, const char *msg, ...)
{
- struct msg m;
struct string text;
va_list args;
ds_put_vformat (&text, msg, args);
va_end (args);
- m.category = MSG_C_GENERAL;
- m.severity = MSG_S_WARNING;
- m.file_name = NULL;
- m.first_line = 0;
- m.last_line = 0;
- m.first_column = 0;
- m.last_column = 0;
- m.text = ds_cstr (&text);
-
+ struct msg m = {
+ .category = MSG_C_GENERAL,
+ .severity = MSG_S_WARNING,
+ .text = ds_cstr (&text),
+ };
msg_emit (&m);
}
sys_msg (struct sfm_reader *r, off_t offset,
int class, const char *format, va_list args)
{
- struct msg m;
struct string text;
ds_init_empty (&text);
ds_put_format (&text, _("`%s': "), fh_get_file_name (r->fh));
ds_put_vformat (&text, format, args);
- m.category = msg_class_to_category (class);
- m.severity = msg_class_to_severity (class);
- m.file_name = NULL;
- m.first_line = 0;
- m.last_line = 0;
- m.first_column = 0;
- m.last_column = 0;
- m.text = ds_cstr (&text);
-
+ struct msg m = {
+ .category = msg_class_to_category (class),
+ .severity = msg_class_to_severity (class),
+ .text = ds_cstr (&text),
+ };
msg_emit (&m);
}
parse_error (const struct dfm_reader *reader, const struct field *field,
int first_column, int last_column, char *error)
{
- struct msg m;
-
- m.category = MSG_C_DATA;
- m.severity = MSG_S_WARNING;
- m.file_name = CONST_CAST (char *, dfm_get_file_name (reader));
- m.first_line = dfm_get_line_number (reader);
- m.last_line = m.first_line + 1;
- m.first_column = first_column;
- m.last_column = last_column;
- m.text = xasprintf (_("Data for variable %s is not valid as format %s: %s"),
- field->name, fmt_name (field->format.type), error);
+ struct msg m = {
+ .category = MSG_C_DATA,
+ .severity = MSG_S_WARNING,
+ .file_name = CONST_CAST (char *, dfm_get_file_name (reader)),
+ .first_line = dfm_get_line_number (reader),
+ .last_line = m.first_line + 1,
+ .first_column = first_column,
+ .last_column = last_column,
+ .text = xasprintf (_("Data for variable %s is not valid as format %s: %s"),
+ field->name, fmt_name (field->format.type), error),
+ };
msg_emit (&m);
free (error);
{
const struct lex_token *token;
struct string s;
- struct msg m;
ds_init_empty (&s);
}
ds_put_byte (&s, '.');
- m.category = MSG_C_SYNTAX;
- m.severity = MSG_S_ERROR;
- m.file_name = src->reader->file_name;
- m.first_line = lex_source_get_first_line_number (src, n0);
- m.last_line = lex_source_get_last_line_number (src, n1);
- m.first_column = lex_source_get_first_column (src, n0);
- m.last_column = lex_source_get_last_column (src, n1);
- m.text = ds_steal_cstr (&s);
+ struct msg m = {
+ .category = MSG_C_SYNTAX,
+ .severity = MSG_S_ERROR,
+ .file_name = src->reader->file_name,
+ .first_line = lex_source_get_first_line_number (src, n0),
+ .last_line = lex_source_get_last_line_number (src, n1),
+ .first_column = lex_source_get_first_column (src, n0),
+ .last_column = lex_source_get_last_column (src, n1),
+ .text = ds_steal_cstr (&s),
+ };
msg_emit (&m);
}
void
vmsg (enum msg_class class, const char *format, va_list args)
{
- struct msg m;
-
- m.category = msg_class_to_category (class);
- m.severity = msg_class_to_severity (class);
- m.text = xvasprintf (format, args);
- m.file_name = NULL;
- m.first_line = m.last_line = 0;
- m.first_column = m.last_column = 0;
+ struct msg m = {
+ .category = msg_class_to_category (class),
+ .severity = msg_class_to_severity (class),
+ .text = xvasprintf (format, args),
+ };
msg_emit (&m);
}
msg_error (int errnum, const char *format, ...)
{
va_list args;
- char *e;
- struct msg m;
-
- m.category = MSG_C_GENERAL;
- m.severity = MSG_S_ERROR;
-
va_start (args, format);
- e = xvasprintf (format, args);
+ char *e = xvasprintf (format, args);
va_end (args);
- m.file_name = NULL;
- m.first_line = m.last_line = 0;
- m.first_column = m.last_column = 0;
- m.text = xasprintf (_("%s: %s"), e, strerror (errnum));
- free (e);
-
+ struct msg m = {
+ .category = MSG_C_GENERAL,
+ .severity = MSG_S_ERROR,
+ .file_name = NULL,
+ .text = xasprintf (_("%s: %s"), e, strerror (errnum)),
+ };
msg_emit (&m);
+
+ free (e);
}
static void
submit_note (char *s)
{
- struct msg m;
-
- m.category = MSG_C_GENERAL;
- m.severity = MSG_S_NOTE;
- m.file_name = NULL;
- m.first_line = 0;
- m.last_line = 0;
- m.first_column = 0;
- m.last_column = 0;
- m.text = s;
- m.shipped = false;
-
+ struct msg m = {
+ .category = MSG_C_GENERAL,
+ .severity = MSG_S_NOTE,
+ .text = s,
+ };
ship_message (&m);
free (s);