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. */
break;
else if (cmd_result_is_failure (result) && lex_token (lexer) != T_STOP)
{
- if (lex_get_error_mode (lexer) == LEX_ERROR_STOP)
+ switch (lex_get_error_mode (lexer))
{
+ case LEX_ERROR_STOP:
msg (MW, _("Error encountered while ERROR=STOP is effective."));
lex_discard_noninteractive (lexer);
- }
- else if (result == CMD_CASCADING_FAILURE
- && lex_get_error_mode (lexer) != LEX_ERROR_TERMINAL)
- {
- msg (SE, _("Stopping syntax file processing here to avoid "
- "a cascade of dependent command failures."));
- lex_discard_noninteractive (lexer);
+ break;
+
+ case LEX_ERROR_CONTINUE:
+ if (result == CMD_CASCADING_FAILURE)
+ {
+ msg (SE, _("Stopping syntax file processing here to avoid "
+ "a cascade of dependent command failures."));
+ lex_discard_noninteractive (lexer);
+ }
+ break;
+
+ case LEX_ERROR_TERMINAL:
+ case LEX_ERROR_IGNORE:
+ break;
}
}
}
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_location *location = m_->location;
+ if (!location && lexer)
+ {
+ location = lex_get_location (lexer, 0, 0);
+ msg_location_remove_columns (location);
+ }
+
struct msg m = {
.category = m_->category,
.severity = m_->severity,
.stack = m_->stack,
.n_stack = m_->n_stack,
- .location = (m_->location ? m_->location
- : lexer ? lex_get_lines (lexer, 0, 0)
- : NULL),
+ .location = location,
.command_name = output_get_uppercase_command_name (),
.text = m_->text,
};