const char *encoding, enum segmenter_mode);
static void bug_handler(int sig);
static void fpu_init (void);
-static void output_msg (const struct msg *, void *);
+static void output_msg (const struct msg *, struct lexer *);
/* Program entry point. */
int
terminal_opts_done (terminal_opts, argc, argv);
argv_parser_destroy (parser);
- msg_set_handler (output_msg, lexer);
+ lex_set_message_handler (lexer, output_msg);
session_set_default_syntax_encoding (the_session, syntax_encoding);
/* Add syntax files to source stream. */
}
static void
-output_msg (const struct msg *m_, void *lexer_)
+output_msg (const struct msg *m_, struct lexer *lexer)
{
- struct lexer *lexer = lexer_;
- struct msg m = *m_;
-
- if (m.file_name == NULL)
+ struct msg_location *location = m_->location;
+ if (!location && lexer)
{
- m.file_name = CONST_CAST (char *, lex_get_file_name (lexer));
- m.first_line = lex_get_first_line_number (lexer, 0);
- m.last_line = lex_get_last_line_number (lexer, 0);
+ location = lex_get_location (lexer, 0, 0);
+ msg_location_remove_columns (location);
}
- m.command_name = output_get_uppercase_command_name ();
+ struct msg m = {
+ .category = m_->category,
+ .severity = m_->severity,
+ .stack = m_->stack,
+ .n_stack = m_->n_stack,
+ .location = location,
+ .command_name = output_get_uppercase_command_name (),
+ .text = m_->text,
+ };
output_item_submit (message_item_create (&m));
free (m.command_name);
+ if (m.location != m_->location)
+ msg_location_destroy (m.location);
}
static void