X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fui%2Fterminal%2Fmsg-ui.c;h=b5280fe6bba980949083151ddefc99c82b544dab;hb=f51ecb48027e6b1eb46840ae25888a25b429f012;hp=93c3683f220f9d084a2e00defb97f23fefff073e;hpb=f2ccb1b5f0ad814c1e6fcbc8f1ecaa62913b7e53;p=pspp-builds.git diff --git a/src/ui/terminal/msg-ui.c b/src/ui/terminal/msg-ui.c index 93c3683f..b5280fe6 100644 --- a/src/ui/terminal/msg-ui.c +++ b/src/ui/terminal/msg-ui.c @@ -1,5 +1,5 @@ /* 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 @@ -18,19 +18,23 @@ #include "msg-ui.h" -#include "linebreak.h" - -#include -#include #include +#include #include +#include #include #include -#include -#include +#include +#include + #include +#include #include #include +#include + +#include "unilbrk.h" +#include "localcharset.h" #include "gettext.h" #define _(msgid) gettext (msgid) @@ -88,14 +92,15 @@ 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() ) + 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; @@ -139,20 +144,22 @@ handle_msg (const struct msg *m) 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) { @@ -173,20 +180,22 @@ handle_msg (const struct msg *m) 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 (get_error_routing_to_listing ()) + if (routing & SETTINGS_DEVICE_LISTING) { - /* Disable screen output devices, because the error should - already have been reported to the screen with the - dump_message call above. */ - outp_enable_device (false, OUTP_DEV_SCREEN); + /* 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)); - outp_enable_device (true, OUTP_DEV_SCREEN); + settings_set_output_routing (severity->type, routing); } ds_destroy (&string); @@ -221,7 +230,7 @@ dump_message (char *msg, unsigned width, unsigned indent, /* 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); @@ -264,7 +273,7 @@ write_stream (int line_indent, struct substring line, void *stream_) /* 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);