Merge commit 'origin/stable'
[pspp-builds.git] / src / ui / terminal / msg-ui.c
index 93c3683f220f9d084a2e00defb97f23fefff073e..682d753d8fbd36200f68e33677c239e5ef5b6c17 100644 (file)
@@ -18,7 +18,8 @@
 
 #include "msg-ui.h"
 
-#include "linebreak.h"
+#include "unilbrk.h"
+#include "localcharset.h"
 
 #include <libpspp/msg-locator.h>
 #include <libpspp/getl.h>
@@ -31,6 +32,7 @@
 #include <errno.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <unistd.h>
 
 #include "gettext.h"
 #define _(msgid) gettext (msgid)
@@ -88,14 +90,14 @@ check_msg_count (struct source_stream *ss)
 {
   if (!getl_is_interactive (ss))
     {
-      if (get_errorbreak () && error_count)
+      if (settings_get_errorbreak () && error_count)
         msg (MN, _("Terminating execution of syntax file due to error."));
-      else if (error_count > get_mxerrs() )
+      else if (error_count > settings_get_mxerrs () )
         msg (MN, _("Errors (%d) exceeds limit (%d)."),
-             error_count, get_mxerrs());
-      else if (error_count + warning_count > get_mxwarns() )
+             error_count, settings_get_mxerrs ());
+      else if (error_count + warning_count > settings_get_mxwarns () )
         msg (MN, _("Warnings (%d) exceed limit (%d)."),
-             error_count + warning_count, get_mxwarns() );
+             error_count + warning_count, settings_get_mxwarns () );
       else
         return;
 
@@ -173,13 +175,14 @@ 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,
+  if (msg_file != stdout || settings_get_error_routing_to_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 (settings_get_error_routing_to_listing ())
     {
       /* Disable screen output devices, because the error should
          already have been reported to the screen with the
@@ -221,7 +224,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 +267,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);