- static bool terminating = false;
- if (!terminating)
- {
- terminating = true;
-
- destroy_dataset (the_dataset);
-
- random_done ();
- settings_done ();
- fh_done ();
- lex_destroy (the_lexer);
- destroy_source_stream (the_source_stream);
- prompt_done ();
- readln_uninitialize ();
- output_close ();
- msg_ui_done ();
- i18n_done ();
- }
+ struct lexer *lexer = lexer_;
+ 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),
+ .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
+add_syntax_reader (struct lexer *lexer, const char *file_name,
+ const char *encoding, enum segmenter_mode syntax_mode)
+{
+ struct lex_reader *reader;
+
+ reader = (!strcmp (file_name, "-") && isatty (STDIN_FILENO)
+ ? terminal_reader_create ()
+ : lex_reader_for_file (file_name, encoding, syntax_mode,
+ LEX_ERROR_CONTINUE));
+
+ if (reader)
+ lex_append (lexer, reader);