-
- if ( msg_file ) /* FIXME: do we really want to close stdout ?? */
- fclose (msg_file);
-}
-
-/* Checks whether we've had so many errors that it's time to quit
- processing this syntax file. */
-void
-check_msg_count (struct source_stream *ss)
-{
- if (!getl_is_interactive (ss))
- {
- if (get_errorbreak () && error_count)
- msg (MN, _("Terminating execution of syntax file due to error."));
- else if (error_count > get_mxerrs() )
- msg (MN, _("Errors (%d) exceeds limit (%d)."),
- error_count, get_mxerrs());
- else if (error_count + warning_count > get_mxwarns() )
- msg (MN, _("Warnings (%d) exceed limit (%d)."),
- error_count + warning_count, get_mxwarns() );
- else
- return;
-
- getl_abort_noninteractive (ss);
- }
-}
-
-void
-reset_msg_count (void)
-{
- error_count = warning_count = 0;
-}
-
-bool
-any_errors (void)
-{
- return error_count > 0;
-}
-\f
-static void dump_message (char *msg, unsigned width, unsigned indent, FILE *);
-static void dump_line (int line_indent, const char *line, size_t length,
- FILE *);
-
-static void
-handle_msg (const struct msg *m)
-{
- struct category
- {
- bool show_command_name; /* Show command name with error? */
- bool show_file_location; /* Show syntax file location? */
- };
-
- static const struct category categories[] =
- {
- {false, false}, /* MSG_GENERAL. */
- {true, true}, /* MSG_SYNTAX. */
- {false, true}, /* MSG_DATA. */
- };
-
- struct severity
- {
- const char *name; /* How to identify this severity. */
- int *count; /* Number of msgs with this severity so far. */
- };
-
- static struct severity severities[] =
- {
- {N_("error"), &error_count}, /* MSG_ERROR. */
- {N_("warning"), &warning_count}, /* MSG_WARNING. */
- {NULL, NULL}, /* MSG_NOTE. */
- };
-
- const struct category *category = &categories[m->category];
- const struct severity *severity = &severities[m->severity];
- struct string string = DS_EMPTY_INITIALIZER;
-
- if (category->show_file_location && m->where.file_name)
- {
- ds_put_format (&string, "%s:", m->where.file_name);
- if (m->where.line_number != -1)
- ds_put_format (&string, "%d:", m->where.line_number);
- ds_put_char (&string, ' ');
- }
-
- if (severity->name != NULL)
- ds_put_format (&string, "%s: ", gettext (severity->name));
-
- if (severity->count != NULL)
- ++*severity->count;
-
- if (category->show_command_name && msg_get_command_name () != NULL)
- ds_put_format (&string, "%s: ", msg_get_command_name ());
-
- ds_put_cstr (&string, m->text);
-
- if (msg_file != stdout || get_error_routing_to_terminal ())
- dump_message (ds_cstr (&string), get_viewwidth (), 8, msg_file);
-
- ds_destroy (&string);