Use the msg function to report errors wherever possible.
authorJohn Darrington <john@darrington.wattle.id.au>
Mon, 23 Sep 2013 14:46:53 +0000 (16:46 +0200)
committerJohn Darrington <john@darrington.wattle.id.au>
Wed, 25 Sep 2013 06:00:07 +0000 (08:00 +0200)
Previously, some errors were reported using the GNU "error" function from error.h
rather than the PSPP msg function.  This wasn't too bad for the terminal user interace,
but gui users could miss important messages (since they never see stderr).

The reason for not using msg in some instances, was twofold: 1) Some
errors might occur before the messaging system had been initialised. 2) If an
error occured whilst reporting an error, an infinite loop would occur.

This change overcomes these problems by detecting re-entrancy, and uninitialised
messaging system, and falling back to fwrite if either of these conditions occur.

30 files changed:
src/data/case-tmpfile.c
src/data/settings.c
src/libpspp/ext-array.c
src/libpspp/float-format.c
src/libpspp/message.c
src/libpspp/message.h
src/libpspp/zip-writer.c
src/output/ascii.c
src/output/cairo-chart.c
src/output/cairo.c
src/output/csv.c
src/output/driver.c
src/output/html.c
src/output/journal.c
src/output/measure.c
src/output/msglog.c
src/output/odt.c
src/output/options.c
src/output/tab.c
src/ui/gui/page-assistant.c
src/ui/gui/page-file.c
src/ui/gui/page-first-line.c
src/ui/gui/page-formats.c
src/ui/gui/page-intro.c
src/ui/gui/page-separators.c
src/ui/gui/page-sheet-spec.c
src/ui/gui/psppire-output-window.c
src/ui/gui/text-data-import-dialog.c
tests/automake.mk
tests/output/output.at

index 907a926f9ece6281de146af02adbd880a5570d23..2b124341b67820f8be89c6f3224c1a48a4fcae52 100644 (file)
@@ -26,7 +26,6 @@
 #include "libpspp/taint.h"
 #include "libpspp/ext-array.h"
 
-#include "gl/error.h"
 #include "gl/xalloc.h"
 
 /* A temporary file that stores an array of cases. */
index b1d4a80b9d2773b798fe432e2731aa215979865d..4c0fde083740ea483852acbaa56e1b53b07dbbb8 100644 (file)
@@ -29,7 +29,6 @@
 #include "libpspp/integer-format.h"
 #include "libpspp/message.h"
 
-#include "gl/error.h"
 #include "gl/minmax.h"
 #include "gl/xalloc.h"
 
index e5287fcc75d1637970cd0361ddddca4155d9a752..9129d365d6e10f66e1206432541cc2c492093dbc 100644 (file)
@@ -20,6 +20,7 @@
 #include <config.h>
 
 #include "libpspp/ext-array.h"
+#include "libpspp/message.h"
 
 #include <errno.h>
 #include <stdio.h>
@@ -29,7 +30,6 @@
 #include "libpspp/cast.h"
 #include "libpspp/temp-file.h"
 
-#include "gl/error.h"
 #include "gl/unlocked-io.h"
 #include "gl/xalloc.h"
 
@@ -63,7 +63,7 @@ ext_array_create (void)
   struct ext_array *ea = xmalloc (sizeof *ea);
   ea->file = create_temp_file ();
   if (ea->file == NULL)
-    error (0, errno, _("failed to create temporary file"));
+    msg_error (errno, _("failed to create temporary file"));
   ea->position = 0;
   ea->op = OP_WRITE;
   return ea;
@@ -103,7 +103,7 @@ do_seek (const struct ext_array *ea_, off_t offset, enum op op)
           return true;
         }
       else
-        error (0, errno, _("seeking in temporary file"));
+        msg_error (errno, _("seeking in temporary file"));
     }
 
   return false;
@@ -122,9 +122,9 @@ do_read (const struct ext_array *ea_, void *buffer, size_t bytes)
   if (bytes > 0 && fread (buffer, bytes, 1, ea->file) != 1)
     {
       if (ferror (ea->file))
-        error (0, errno, _("reading temporary file"));
+        msg_error (errno, _("reading temporary file"));
       else if (feof (ea->file))
-        error (0, 0, _("unexpected end of file reading temporary file"));
+        msg_error ( 0, _("unexpected end of file reading temporary file"));
       else
         NOT_REACHED ();
       return false;
@@ -144,7 +144,7 @@ do_write (struct ext_array *ea, const void *buffer, size_t bytes)
   assert (!ext_array_error (ea));
   if (bytes > 0 && fwrite (buffer, bytes, 1, ea->file) != 1)
     {
-      error (0, errno, _("writing to temporary file"));
+      msg_error (errno, _("writing to temporary file"));
       return false;
     }
   ea->position += bytes;
index 4ba4c9375b6efd410f5362b6e48209838e7688ab..36cc0af3c8c3119fe7a13e13e1f35e2141460dd8 100644 (file)
@@ -27,7 +27,6 @@
 #include "libpspp/assertion.h"
 #include "libpspp/integer-format.h"
 
-#include "gl/error.h"
 \f
 /* Neutral intermediate representation for binary floating-point numbers. */
 struct fp
index 4d95ba43acb61e522c84ec2e2b775ba430ab9146..65432da65226ae0ad7eeff2d17ee3ca4383818c8 100644 (file)
@@ -1,5 +1,6 @@
 /* PSPP - a program for statistical analysis.
-   Copyright (C) 1997-9, 2000, 2006, 2009, 2010, 2011 Free Software Foundation, Inc.
+   Copyright (C) 1997-9, 2000, 2006, 2009, 2010, 
+   2011, 2013 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
@@ -47,26 +48,60 @@ static int messages_disabled;
 
 /* Public functions. */
 
-/* Writes error message in CLASS, with text FORMAT, formatted with
-   printf, to the standard places. */
+
 void
-msg (enum msg_class class, const char *format, ...)
+vmsg (enum msg_class class, const char *format, va_list args)
 {
   struct msg m;
-  va_list args;
 
   m.category = msg_class_to_category (class);
   m.severity = msg_class_to_severity (class);
-  va_start (args, format);
   m.text = xvasprintf (format, args);
   m.file_name = NULL;
   m.first_line = m.last_line = 0;
   m.first_column = m.last_column = 0;
+
+  msg_emit (&m);
+}
+
+/* Writes error message in CLASS, with text FORMAT, formatted with
+   printf, to the standard places. */
+void
+msg (enum msg_class class, const char *format, ...)
+{
+  va_list args;
+  va_start (args, format);
+  vmsg (class, format, args);
+  va_end (args);
+}
+
+
+
+void
+msg_error (int errnum, const char *format, ...)
+{
+  va_list args;
+  char *e;
+  struct msg m;
+
+  m.category = MSG_C_GENERAL;
+  m.severity = MSG_S_ERROR;
+
+  va_start (args, format);
+  e = xvasprintf (format, args);
   va_end (args);
 
+  m.file_name = NULL;
+  m.first_line = m.last_line = 0;
+  m.first_column = m.last_column = 0;
+  m.text = xasprintf (_("%s: %s"), e, strerror (errnum));
+  free (e);
+
   msg_emit (&m);
 }
 
+
+
 void
 msg_set_handler (void (*handler) (const struct msg *, void *aux), void *aux)
 {
@@ -235,6 +270,27 @@ msg_ui_any_errors (void)
   return counts[MSG_S_ERROR] > 0;
 }
 
+
+static int entrances = 0;
+
+static void
+ship_message (struct msg *m)
+{
+  entrances++;
+  if ( ! m->shipped )
+    {
+      if (msg_handler && entrances <= 1)
+       msg_handler (m, msg_aux);
+      else
+       {
+         fwrite (m->text, 1, strlen (m->text), stderr);
+         fwrite ("\n", 1, 1, stderr);
+       }
+    }
+  m->shipped = true;
+  entrances--;
+}
+
 static void
 submit_note (char *s)
 {
@@ -248,24 +304,26 @@ submit_note (char *s)
   m.first_column = 0;
   m.last_column = 0;
   m.text = s;
-  msg_handler (&m, msg_aux);
+  m.shipped = false;
+
+  ship_message (&m);
+
   free (s);
 }
 
 
 
 static void
-process_msg (const struct msg *m)
+process_msg (struct msg *m)
 {
   int n_msgs, max_msgs;
 
-
   if (too_many_errors
       || (too_many_notes && m->severity == MSG_S_NOTE)
       || (warnings_off && m->severity == MSG_S_WARNING) )
     return;
 
-  msg_handler (m, msg_aux);
+  ship_message (m);
 
   counts[m->severity]++;
   max_msgs = settings_get_max_messages (m->severity);
@@ -300,6 +358,7 @@ process_msg (const struct msg *m)
 void
 msg_emit (struct msg *m)
 {
+  m->shipped = false;
   if (!messages_disabled)
      process_msg (m);
 
index 3856ee5b812a895420886e87f7c41ce5a2f7af3e..32342f40e993501c56ba7e3245f5e45866b3acad 100644 (file)
@@ -80,6 +80,7 @@ struct msg
     int first_column;           /* 1-based first column, or 0 if none. */
     int last_column;            /* 1-based exclusive last column (0=none). */
     char *text;                 /* Error text. */
+    bool shipped;               /* True if this message has been emitted */
   };
 
 /* Initialization. */
@@ -96,6 +97,9 @@ void msg (enum msg_class, const char *format, ...)
      PRINTF_FORMAT (2, 3);
 void msg_emit (struct msg *);
 
+void msg_error (int errnum, const char *format, ...);
+
+
 /* Enable and disable messages. */
 void msg_enable (void);
 void msg_disable (void);
index d626d929b374776d8574318a995ba92de80dcce1..e286a7eb1c5f281ddc739d88ab9c3a33e57c512b 100644 (file)
 #include <time.h>
 
 #include "gl/crc.h"
-#include "gl/error.h"
 #include "gl/fwriteerror.h"
 #include "gl/xalloc.h"
 
+#include "libpspp/message.h"
+
 #include "gettext.h"
 #define _(msgid) gettext (msgid)
 
@@ -90,7 +91,7 @@ zip_writer_create (const char *file_name)
   file = fopen (file_name, "wb");
   if (file == NULL)
     {
-      error (0, errno, _("%s: error opening output file"), file_name);
+      msg_error (errno, _("%s: error opening output file"), file_name);
       return NULL;
     }
 
@@ -223,7 +224,7 @@ zip_writer_close (struct zip_writer *zw)
     ok = true;
   else
     {
-      error (0, errno, _("%s: write failed"), zw->file_name);
+      msg_error (errno, _("%s: write failed"), zw->file_name);
       ok = false;
     }
 
index 78626cf13ff45912d7d0c5b689fefc1ba35a512f..8f69dfd883e99be0cb630b098beee3cd813fdc51 100644 (file)
@@ -48,7 +48,6 @@
 #include "output/table-item.h"
 #include "output/text-item.h"
 
-#include "gl/error.h"
 #include "gl/minmax.h"
 #include "gl/xalloc.h"
 
@@ -304,7 +303,7 @@ parse_page_size (struct driver_option *option)
           if (dim >= 1 && errno != ERANGE && *tail == '\0')
             dim = value;
           else
-            error (0, 0, _("%s: %s must be positive integer or `auto'"),
+            msg (MW, _("%s: %s must be positive integer or `auto'"),
                    option->driver_name, option->name);
         }
     }
@@ -336,7 +335,7 @@ update_page_size (struct ascii_driver *a, bool issue_error)
   if (a->width < MIN_WIDTH || a->length < MIN_LENGTH)
     {
       if (issue_error)
-        error (0, 0,
+        msg (ME,
                _("ascii: page excluding margins and headers "
                  "must be at least %d characters wide by %d lines long, but "
                  "as configured is only %d characters by %d lines"),
@@ -385,7 +384,7 @@ ascii_flush (struct output_driver *driver)
       ascii_close_page (a);
 
       if (fn_close (a->file_name, a->file) != 0)
-        error (0, errno, _("ascii: closing output file `%s'"),
+        msg_error (ME, errno, _("ascii: closing output file `%s'"),
                a->file_name);
       a->file = NULL;
     }
@@ -1002,7 +1001,7 @@ ascii_open_page (struct ascii_driver *a)
         }
       else
         {
-          error (0, errno, _("ascii: opening output file `%s'"),
+          msg_error (errno, _("ascii: opening output file `%s'"),
                  a->file_name);
           a->error = true;
           return false;
index 78f5fabab7249ae2fdfff448be9891f120cb40f1..dd0cd0563b42e5854cbc1908426681528f60770a 100644 (file)
@@ -22,7 +22,6 @@
 #include <cairo/cairo.h>
 #include <pango/pango.h>
 #include <pango/pangocairo.h>
-#include <errno.h>
 #include <float.h>
 #include <math.h>
 #include <stdarg.h>
@@ -35,7 +34,6 @@
 #include "output/cairo.h"
 #include "output/chart-item.h"
 
-#include "gl/error.h"
 #include "gl/xalloc.h"
 #include "gl/xvasprintf.h"
 
index 4bb601be22f4c66495e9e67a88af6b4e8fdc8ff4..516ac7616392b8a903a5c17a6068bf5cc61160d6 100644 (file)
@@ -53,7 +53,6 @@
 #include <pango/pangocairo.h>
 #include <stdlib.h>
 
-#include "gl/error.h"
 #include "gl/intprops.h"
 #include "gl/minmax.h"
 #include "gl/xalloc.h"
@@ -224,7 +223,7 @@ parse_font (struct output_driver *d, struct string_map *options,
   desc = pango_font_description_from_string (string);
   if (desc == NULL)
     {
-      error (0, 0, _("`%s': bad font specification"), string);
+      msg (MW, _("`%s': bad font specification"), string);
 
       /* Fall back to DEFAULT_VALUE, which had better be a valid font
          description. */
@@ -379,7 +378,7 @@ xr_create (const char *file_name, enum settings_output_devices device_type,
   status = cairo_surface_status (surface);
   if (status != CAIRO_STATUS_SUCCESS)
     {
-      error (0, 0, _("error opening output file `%s': %s"),
+      msg (ME, _("error opening output file `%s': %s"),
              file_name, cairo_status_to_string (status));
       cairo_surface_destroy (surface);
       goto error;
@@ -396,7 +395,7 @@ xr_create (const char *file_name, enum settings_output_devices device_type,
 
   if (xr->width / xr->char_width < MIN_WIDTH)
     {
-      error (0, 0, _("The defined page is not wide enough to hold at least %d "
+      msg (ME, _("The defined page is not wide enough to hold at least %d "
                      "characters in the default font.  In fact, there's only "
                      "room for %d characters."),
              MIN_WIDTH,
@@ -406,7 +405,7 @@ xr_create (const char *file_name, enum settings_output_devices device_type,
 
   if (xr->length / xr->char_height < MIN_LENGTH)
     {
-      error (0, 0, _("The defined page is not long enough to hold at least %d "
+      msg (ME, _("The defined page is not long enough to hold at least %d "
                      "lines in the default font.  In fact, there's only "
                      "room for %d lines."),
              MIN_LENGTH,
@@ -457,7 +456,7 @@ xr_destroy (struct output_driver *driver)
       cairo_surface_finish (cairo_get_target (xr->cairo));
       status = cairo_status (xr->cairo);
       if (status != CAIRO_STATUS_SUCCESS)
-        error (0, 0, _("error drawing output for %s driver: %s"),
+        msg (ME, _("error drawing output for %s driver: %s"),
                output_driver_get_name (driver),
                cairo_status_to_string (status));
       cairo_destroy (xr->cairo);
@@ -1117,7 +1116,7 @@ xr_draw_png_chart (const struct chart_item *item,
 
   status = cairo_surface_write_to_png (surface, file_name);
   if (status != CAIRO_STATUS_SUCCESS)
-    error (0, 0, _("error writing output file `%s': %s"),
+    msg (ME, _("error writing output file `%s': %s"),
            file_name, cairo_status_to_string (status));
 
   cairo_destroy (cr);
index b57eb7c2d04eb7cdfb0e478a771d0495288de362..9b51ed79d34de5e959876367bb0ca5bae59d3217 100644 (file)
@@ -31,7 +31,6 @@
 #include "output/table-item.h"
 #include "output/table-provider.h"
 
-#include "gl/error.h"
 #include "gl/xalloc.h"
 #include "gl/xvasprintf.h"
 
@@ -94,7 +93,7 @@ csv_create (const char *file_name, enum settings_output_devices device_type,
 
   if (csv->file == NULL)
     {
-      error (0, errno, _("error opening output file `%s'"), csv->file_name);
+      msg_error (errno, _("error opening output file `%s'"), csv->file_name);
       output_driver_destroy (d);
       return NULL;
     }
index f656845527f4603937ebd02d6698a37865b041cf..0a6afba98a5d7eeec20b1060217a1ea65e643296 100644 (file)
@@ -38,7 +38,6 @@
 #include "output/output-item.h"
 #include "output/text-item.h"
 
-#include "gl/error.h"
 #include "gl/xalloc.h"
 #include "gl/xmemdup0.h"
 
@@ -322,7 +321,7 @@ output_driver_create (struct string_map *options)
     device_type = SETTINGS_DEVICE_LISTING;
   else
     {
-      error (0, 0, _("%s is not a valid device type (the choices are `%s' and `%s')"),
+      msg (MW, _("%s is not a valid device type (the choices are `%s' and `%s')"),
                      device_string, "terminal", "listing");
       device_type = default_device_type (file_name);
     }
@@ -334,7 +333,7 @@ output_driver_create (struct string_map *options)
       const char *key;
 
       STRING_MAP_FOR_EACH_KEY (key, node, options)
-        error (0, 0, _("%s: unknown option `%s'"), file_name, key);
+        msg (MW, _("%s: unknown option `%s'"), file_name, key);
     }
   string_map_clear (options);
 
index 29a44721d455ae3f0336e1f95d52610e9c5df1c1..cf9b2da3c11cc8077850fd6c5aeabd085b38beed 100644 (file)
@@ -39,7 +39,6 @@
 #include "output/table-item.h"
 #include "output/text-item.h"
 
-#include "error.h"
 #include "xalloc.h"
 
 #include "gettext.h"
@@ -106,7 +105,7 @@ html_create (const char *file_name, enum settings_output_devices device_type,
   html->file = fn_open (html->file_name, "w");
   if (html->file == NULL)
     {
-      error (0, errno, _("error opening output file `%s'"), html->file_name);
+      msg_error (errno, _("error opening output file `%s'"), html->file_name);
       goto error;
     }
 
index 2b5835052029dbfda9ecf19fb27702be354d9be8..5c84a5f84ee5b1fffa5e37d67a8667d6199076f5 100644 (file)
 
 #include "data/file-name.h"
 #include "libpspp/cast.h"
+#include "libpspp/message.h"
 #include "libpspp/str.h"
 #include "output/driver-provider.h"
 #include "output/message-item.h"
 #include "output/text-item.h"
 
-#include "gl/error.h"
 #include "gl/fwriteerror.h"
 #include "gl/xalloc.h"
 
@@ -64,7 +64,7 @@ journal_close (void)
   if (journal != NULL && journal->file != NULL)
     {
       if (fwriteerror (journal->file))
-        error (0, errno, _("error writing output file `%s'"),
+        msg_error (errno, _("error writing output file `%s'"),
                journal_file_name);
       journal->file = NULL;
     }
@@ -90,7 +90,7 @@ journal_output (struct journal_driver *j, const char *s)
       j->file = fopen (journal_get_file_name (), "a");
       if (j->file == NULL)
         {
-          error (0, errno, _("error opening output file `%s'"),
+          msg_error (errno, _("error opening output file `%s'"),
                  journal_get_file_name ());
           output_driver_destroy (&j->driver);
           return;
index faeef969b09b247e4b4d3a7f468e35a2039bccbe..3376de8fbd05c4be2b134a1d73f2ddc859e701b2 100644 (file)
@@ -30,7 +30,7 @@
 #include "libpspp/str.h"
 
 #include "gl/c-strcase.h"
-#include "gl/error.h"
+#include "libpspp/message.h"
 
 #include "gettext.h"
 #define _(msgid) gettext (msgid)
@@ -64,7 +64,7 @@ measure_dimension (const char *dimen)
   return raw * factor;
 
 syntax_error:
-  error (0, 0, _("`%s' is not a valid length."), dimen);
+  msg (ME, _("`%s' is not a valid length."), dimen);
   return -1;
 }
 
@@ -92,7 +92,7 @@ measure_paper (const char *size, int *h, int *v)
       /* Treat string that starts with digit as explicit size. */
       ok = parse_paper_size (size, h, v);
       if (!ok)
-        error (0, 0, _("syntax error in paper size `%s'"), size);
+        msg (ME, _("syntax error in paper size `%s'"), size);
     }
   else
     {
@@ -229,7 +229,7 @@ get_standard_paper_size (struct substring name, int *h, int *v)
         assert (ok);
         return ok;
       }
-  error (0, 0, _("unknown paper type `%.*s'"),
+  msg (ME, _("unknown paper type `%.*s'"),
          (int) ss_length (name), ss_data (name));
   return false;
 }
@@ -247,7 +247,7 @@ read_paper_conf (const char *file_name, int *h, int *v)
   file = fopen (file_name, "r");
   if (file == NULL)
     {
-      error (0, errno, _("error opening input file `%s'"), file_name);
+      msg_error (errno, _("error opening input file `%s'"), file_name);
       return false;
     }
 
@@ -258,7 +258,7 @@ read_paper_conf (const char *file_name, int *h, int *v)
       if (!ds_read_config_line (&line, &line_number, file))
        {
          if (ferror (file))
-           error (0, errno, _("error reading file `%s'"), file_name);
+           msg_error (errno, _("error reading file `%s'"), file_name);
          break;
        }
 
@@ -275,7 +275,7 @@ read_paper_conf (const char *file_name, int *h, int *v)
 
   fclose (file);
   ds_destroy (&line);
-  error (0, 0, _("paper size file `%s' does not state a paper size"),
+  msg (ME, _("paper size file `%s' does not state a paper size"),
          file_name);
   return false;
 }
index 4042b460e7e9e2b701195240cc1341d41723621b..a3f195410406b70c6f18c00d57578d9cf6cf8fd6 100644 (file)
 #include "data/file-name.h"
 #include "data/settings.h"
 #include "libpspp/cast.h"
+#include "libpspp/message.h"
 #include "output/driver-provider.h"
 #include "output/message-item.h"
 
-#include "gl/error.h"
 #include "gl/fwriteerror.h"
 #include "gl/xalloc.h"
 
@@ -63,7 +63,7 @@ msglog_create (const char *file_name)
   file = fn_open (file_name, "w");
   if (file == NULL)
     {
-      error (0, errno, _("error opening output file `%s'"), file_name);
+      msg_error (errno, _("error opening output file `%s'"), file_name);
       return NULL;
     }
 
index a02506c1e9eeacbae9528aa663e55044e8194055..2bf1f2956e47a8e498ce4d0e2be17da1a4529b76 100644 (file)
@@ -31,6 +31,7 @@
 
 #include "libpspp/assertion.h"
 #include "libpspp/cast.h"
+#include "libpspp/message.h"
 #include "libpspp/str.h"
 #include "libpspp/temp-file.h"
 #include "libpspp/version.h"
@@ -44,7 +45,6 @@
 #include "output/text-item.h"
 
 #include "gl/xalloc.h"
-#include "gl/error.h"
 
 #include "gettext.h"
 #define _(msgid) gettext (msgid)
@@ -91,7 +91,7 @@ create_mimetype (struct zip_writer *zip)
   fp = create_temp_file ();
   if (fp == NULL)
     {
-      error (0, errno, _("error creating temporary file"));
+      msg_error (errno, _("error creating temporary file"));
       return false;
     }
 
index 694ffc233ebe86aea4b5ba4bcf2b12e4a54f4929..b8921255d3b08e59b592021b7a025f59f7af1e38 100644 (file)
@@ -29,7 +29,6 @@
 #include "output/driver-provider.h"
 #include "output/measure.h"
 
-#include "gl/error.h"
 #include "gl/xalloc.h"
 
 #include "gettext.h"
@@ -110,7 +109,7 @@ do_parse_boolean (const char *driver_name, const char *key,
     return false;
   else
     {
-      error (0, 0, _("%s: `%s' is `%s' but a Boolean value is required"),
+      msg (MW, _("%s: `%s' is `%s' but a Boolean value is required"),
              driver_name, value, key);
       return -1;
     }
@@ -185,7 +184,7 @@ parse_enum (struct driver_option *o, ...)
                   ds_put_format (&choices, "`%s'", s);
                 }
 
-              error (0, 0, _("%s: `%s' is `%s' but one of the following "
+              msg (MW, _("%s: `%s' is `%s' but one of the following "
                              "is required: %s"),
                      o->driver_name, o->name, o->value, ds_cstr (&choices));
               ds_destroy (&choices);
@@ -229,22 +228,22 @@ parse_int (struct driver_option *o, int min_value, int max_value)
       else if (max_value == INT_MAX)
         {
           if (min_value == 0)
-            error (0, 0, _("%s: `%s' is `%s' but a nonnegative integer "
+            msg (MW, _("%s: `%s' is `%s' but a nonnegative integer "
                            "is required"),
                    o->driver_name, o->name, o->value);
           else if (min_value == 1)
-            error (0, 0, _("%s: `%s' is `%s' but a positive integer is "
+            msg (MW, _("%s: `%s' is `%s' but a positive integer is "
                            "required"), o->driver_name, o->name, o->value);
           else if (min_value == INT_MIN)
-            error (0, 0, _("%s: `%s' is `%s' but an integer is required"),
+            msg (MW, _("%s: `%s' is `%s' but an integer is required"),
                    o->driver_name, o->name, o->value);
           else
-            error (0, 0, _("%s: `%s' is `%s' but an integer greater "
+            msg (MW, _("%s: `%s' is `%s' but an integer greater "
                            "than %d is required"),
                    o->driver_name, o->name, o->value, min_value - 1);
         }
       else
-        error (0, 0, _("%s: `%s' is `%s'  but an integer between %d and "
+        msg (MW, _("%s: `%s' is `%s'  but an integer between %d and "
                        "%d is required"),
                o->driver_name, o->name, o->value, min_value, max_value);
     }
@@ -323,7 +322,7 @@ parse_chart_file_name (struct driver_option *o)
         chart_file_name = xstrdup (o->value);
       else
         {
-          error (0, 0, _("%s: `%s' is `%s' but a file name that contains "
+          msg (MW, _("%s: `%s' is `%s' but a file name that contains "
                          "`#' is required."),
                  o->name, o->value, o->driver_name);
           chart_file_name = default_chart_file_name (o->default_value);
index 6f2a0051bb7c7bdcb4da666820d2237a8cd3780c..5bde1b7c418c57d05bdbb78d42dae37ec32e09ef 100644 (file)
@@ -38,7 +38,6 @@
 #include "output/table-provider.h"
 #include "output/text-item.h"
 
-#include "gl/error.h"
 #include "gl/minmax.h"
 #include "gl/xalloc.h"
 
index b87584de71b44b75cf71abca784aa835754beae1..683494b947165a815a7a4e441fdca6cb0edeb096 100644 (file)
@@ -46,7 +46,6 @@
 #include "ui/gui/psppire-empty-list-store.h"
 #include "ui/gui/psppire-var-sheet.h"
 
-#include "gl/error.h"
 #include "gl/intprops.h"
 #include "gl/xalloc.h"
 
index fdbda325f8ffdc0771cfb647a108a6124865874d..3d26b1d473bfeb98fb0ed2eb0b808f61c1fc1a4b 100644 (file)
@@ -52,7 +52,6 @@
 #include "ui/gui/psppire-scanf.h"
 #include "ui/syntax-gen.h"
 
-#include "gl/error.h"
 #include "gl/intprops.h"
 #include "gl/xalloc.h"
 
@@ -97,8 +96,8 @@ init_file (struct import_assistant *ia, GtkWindow *parent_window)
     struct line_reader *reader = line_reader_for_file (file->encoding, file->file_name, O_RDONLY);
     if (reader == NULL)
       {
-       msg (ME, _("Could not open `%s': %s"),
-            file->file_name, strerror (errno));
+       msg_error (errno, _("Could not open `%s'"),
+            file->file_name);
        return false;
       }
 
index 8d21e7c55c936e6d74a3a404d4e45205ed129803..ca6f4240144e74dd47c953540f6d150d3bc2ac95 100644 (file)
@@ -52,7 +52,6 @@
 #include "ui/gui/psppire-var-sheet.h"
 #include "ui/gui/psppire-scanf.h"
 
-#include "gl/error.h"
 #include "gl/intprops.h"
 #include "gl/xalloc.h"
 
index d1ac9b23b1b2208e2ecfcf7300013d03d87c7b00..7b2ad558c924119567595af247e5f0353cc5e972 100644 (file)
@@ -47,7 +47,6 @@
 #include "ui/gui/psppire-var-sheet.h"
 #include "ui/gui/psppire-scanf.h"
 
-#include "gl/error.h"
 #include "gl/intprops.h"
 #include "gl/xalloc.h"
 
index 59c252b46cb2ade898b2808b2db41543a9e08c9f..428465d63aebef6caf9b3135b518c6162377b757 100644 (file)
@@ -50,7 +50,6 @@
 #include "ui/gui/psppire-scanf.h"
 #include "ui/syntax-gen.h"
 
-#include "gl/error.h"
 #include "gl/intprops.h"
 #include "gl/xalloc.h"
 
index f1e08a6b594b3e74731faa51fbb5d5acc80432a2..2ab085ffa023ba74e0a41c15e8e03e9abe585453 100644 (file)
@@ -50,7 +50,6 @@
 #include "ui/gui/psppire-scanf.h"
 #include "ui/syntax-gen.h"
 
-#include "gl/error.h"
 #include "gl/intprops.h"
 #include "gl/xalloc.h"
 
index 451f0b1a2e5bea99b9a9ee90a10fd7e18b6c1621..8d9cd744096480a11c8cb7e8322f9a169a3dbcc3 100644 (file)
@@ -57,7 +57,6 @@
 
 #include <data/casereader.h>
 
-#include "gl/error.h"
 #include "gl/intprops.h"
 #include "gl/xalloc.h"
 
index 4bad5b5efbaa6079ed348b2dc1e88c25f6c13429..8a29fab18cbc1bf4ae38e87c35156687f6b7d736 100644 (file)
@@ -38,7 +38,6 @@
 #include "ui/gui/builder-wrapper.h"
 #include "ui/gui/psppire-output-window.h"
 
-#include "gl/error.h"
 #include "gl/tmpdir.h"
 #include "gl/xalloc.h"
 #include "gl/c-xvasprintf.h"
@@ -770,7 +769,7 @@ clipboard_get_cb (GtkClipboard     *clipboard,
   if (path_search (dirname, sizeof dirname, NULL, NULL, true)
       || mkdtemp (dirname) == NULL)
     {
-      error (0, errno, _("failed to create temporary directory"));
+      msg_error (errno, _("failed to create temporary directory during clipboard operation"));
       return;
     }
   filename = xasprintf ("%s/clip.tmp", dirname);
index 6214d5ebae4fc05d51df3d3293b3658f4c508faa..4bfbee005236f5bde36b755f852a4c71264cd424 100644 (file)
@@ -56,7 +56,6 @@
 #include "ui/gui/psppire-scanf.h"
 #include "ui/syntax-gen.h"
 
-#include "gl/error.h"
 #include "gl/intprops.h"
 #include "gl/xalloc.h"
 
index efca9d29795eeb513cfd18acecf8d0125de6c5e2..c104ecca4774828371124ae443d3195cb5f88928 100644 (file)
@@ -151,7 +151,9 @@ tests_libpspp_sparse_array_test_LDADD = src/libpspp/liblibpspp.la gl/libgl.la
 tests_libpspp_sparse_xarray_test_SOURCES = \
        tests/libpspp/sparse-xarray-test.c
 tests_libpspp_sparse_xarray_test_CPPFLAGS = $(AM_CPPFLAGS) -DASSERT_LEVEL=10
-tests_libpspp_sparse_xarray_test_LDADD = src/libpspp/liblibpspp.la gl/libgl.la
+tests_libpspp_sparse_xarray_test_LDADD = src/libpspp/liblibpspp.la \
+       src/libpspp-core.la \
+       gl/libgl.la 
 
 tests_data_inexactify_SOURCES = tests/data/inexactify.c
 
@@ -192,12 +194,13 @@ tests_language_lexer_segment_test_LDADD = \
 check_PROGRAMS += tests/libpspp/zip-test
 tests_libpspp_zip_test_SOURCES = \
        tests/libpspp/zip-test.c
+
 tests_libpspp_zip_test_CFLAGS = $(AM_CFLAGS)
 tests_libpspp_zip_test_LDADD = \
        src/libpspp/liblibpspp.la \
+       src/libpspp-core.la \
        gl/libgl.la 
 
-
 check_PROGRAMS += tests/output/render-test
 tests_output_render_test_SOURCES = tests/output/render-test.c
 tests_output_render_test_LDADD = \
index 919927de128b9214e94a32206454c3311f0fe33b..f6351a4e9bca09436da57785856361b67f5138c7 100644 (file)
@@ -14,10 +14,9 @@ begin data.
 end data.
 frequencies x/histogram.
 ])
-   dnl PSPP will fail to create the output file.  Currently this doesn't cause
-   dnl PSPP's exit status to be nonzero, although this is arguably incorrect.
-   dnl At any rate, PSPP should not crash.
-   AT_CHECK([cd unwritable && pspp -o pspp.$1 ../unwritable.sps], [0],
+   dnl PSPP will fail to create the output file.  Thus, the exit status is 
+   dnl non zero
+   AT_CHECK([cd unwritable && pspp -o pspp.$1 ../unwritable.sps], [1],
             [ignore], [ignore])
    AT_CLEANUP])