/* PSPP - a program for statistical analysis.
- Copyright (C) 1997-9, 2000, 2006 Free Software Foundation, Inc.
+ Copyright (C) 1997-9, 2000, 2006, 2010 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
#include "msg-ui.h"
-#include "linebreak.h"
-
-#include <libpspp/msg-locator.h>
-#include <libpspp/getl.h>
#include <data/settings.h>
+#include <libpspp/getl.h>
#include <libpspp/message.h>
+#include <libpspp/msg-locator.h>
#include <libpspp/str.h>
#include <output/journal.h>
+#include <output/driver.h>
+#include <output/tab.h>
+
#include <errno.h>
+#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
+#include <unistd.h>
+
+#include "unilbrk.h"
+#include "localcharset.h"
#include "gettext.h"
#define _(msgid) gettext (msgid)
{
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() )
+ int max_errors = settings_get_max_messages (MSG_S_ERROR);
+ int max_warnings = settings_get_max_messages (MSG_S_WARNING);
+
+ if (error_count > max_errors)
+ msg (MN, _("Errors (%d) exceed limit (%d)."),
+ error_count, max_errors);
+ else if (error_count + warning_count > max_warnings)
msg (MN, _("Warnings (%d) exceed limit (%d)."),
- error_count + warning_count, get_mxwarns() );
+ error_count + warning_count, max_warnings);
else
return;
struct severity
{
+ enum settings_output_type type;
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. */
+ { SETTINGS_OUTPUT_ERROR, N_("error"), &error_count },
+ { SETTINGS_OUTPUT_ERROR, N_("warning"), &warning_count },
+ { SETTINGS_OUTPUT_NOTE, NULL, NULL},
};
const struct category *category = &categories[m->category];
const struct severity *severity = &severities[m->severity];
struct string string = DS_EMPTY_INITIALIZER;
+ enum settings_output_devices routing;
if (category->show_file_location && m->where.file_name)
{
ds_put_cstr (&string, m->text);
- if (msg_file != stdout || get_error_routing_to_terminal ())
- dump_message (ds_cstr (&string), get_viewwidth (), 8,
+ routing = settings_get_output_routing (severity->type);
+ if (msg_file != stdout || routing & SETTINGS_DEVICE_TERMINAL)
+ dump_message (ds_cstr (&string),
+ isatty (fileno (msg_file)) ? settings_get_viewwidth () : INT_MAX, 8,
write_stream, msg_file);
dump_message (ds_cstr (&string), 78, 0, write_journal, NULL);
+ if (routing & SETTINGS_DEVICE_LISTING)
+ {
+ /* Disable terminal output devices, because the error should already have
+ been reported to the terminal with the dump_message call above. */
+ settings_set_output_routing (severity->type,
+ routing & ~SETTINGS_DEVICE_TERMINAL);
+ tab_output_text (TAB_LEFT, ds_cstr (&string));
+ settings_set_output_routing (severity->type, routing);
+ }
+
ds_destroy (&string);
}
/* Break into lines. */
if (indent > width / 3)
indent = width / 3;
- mbs_width_linebreaks (string, length,
+ ulc_width_linebreaks (string, length,
width - indent, -indent, 0,
NULL, locale_charset (), breaks);
/* Writes LINE to the journal. */
static void
-write_journal (int line_indent, struct substring line, void *unused UNUSED)
+write_journal (int line_indent UNUSED, struct substring line, void *unused UNUSED)
{
char *s = xstrndup (ss_data (line), ss_length (line));
journal_write (true, s);