From: John Darrington Date: Mon, 23 Sep 2013 14:46:53 +0000 (+0200) Subject: Use the msg function to report errors wherever possible. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fce028c380d496e42823fd24774e0159ed7cc110;p=pspp Use the msg function to report errors wherever possible. 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. --- diff --git a/src/data/case-tmpfile.c b/src/data/case-tmpfile.c index 907a926f9e..2b124341b6 100644 --- a/src/data/case-tmpfile.c +++ b/src/data/case-tmpfile.c @@ -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. */ diff --git a/src/data/settings.c b/src/data/settings.c index b1d4a80b9d..4c0fde0837 100644 --- a/src/data/settings.c +++ b/src/data/settings.c @@ -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" diff --git a/src/libpspp/ext-array.c b/src/libpspp/ext-array.c index e5287fcc75..9129d365d6 100644 --- a/src/libpspp/ext-array.c +++ b/src/libpspp/ext-array.c @@ -20,6 +20,7 @@ #include #include "libpspp/ext-array.h" +#include "libpspp/message.h" #include #include @@ -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; diff --git a/src/libpspp/float-format.c b/src/libpspp/float-format.c index 4ba4c9375b..36cc0af3c8 100644 --- a/src/libpspp/float-format.c +++ b/src/libpspp/float-format.c @@ -27,7 +27,6 @@ #include "libpspp/assertion.h" #include "libpspp/integer-format.h" -#include "gl/error.h" /* Neutral intermediate representation for binary floating-point numbers. */ struct fp diff --git a/src/libpspp/message.c b/src/libpspp/message.c index 4d95ba43ac..65432da652 100644 --- a/src/libpspp/message.c +++ b/src/libpspp/message.c @@ -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); diff --git a/src/libpspp/message.h b/src/libpspp/message.h index 3856ee5b81..32342f40e9 100644 --- a/src/libpspp/message.h +++ b/src/libpspp/message.h @@ -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); diff --git a/src/libpspp/zip-writer.c b/src/libpspp/zip-writer.c index d626d929b3..e286a7eb1c 100644 --- a/src/libpspp/zip-writer.c +++ b/src/libpspp/zip-writer.c @@ -25,10 +25,11 @@ #include #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; } diff --git a/src/output/ascii.c b/src/output/ascii.c index 78626cf13f..8f69dfd883 100644 --- a/src/output/ascii.c +++ b/src/output/ascii.c @@ -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; diff --git a/src/output/cairo-chart.c b/src/output/cairo-chart.c index 78f5fabab7..dd0cd0563b 100644 --- a/src/output/cairo-chart.c +++ b/src/output/cairo-chart.c @@ -22,7 +22,6 @@ #include #include #include -#include #include #include #include @@ -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" diff --git a/src/output/cairo.c b/src/output/cairo.c index 4bb601be22..516ac76163 100644 --- a/src/output/cairo.c +++ b/src/output/cairo.c @@ -53,7 +53,6 @@ #include #include -#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); diff --git a/src/output/csv.c b/src/output/csv.c index b57eb7c2d0..9b51ed79d3 100644 --- a/src/output/csv.c +++ b/src/output/csv.c @@ -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; } diff --git a/src/output/driver.c b/src/output/driver.c index f656845527..0a6afba98a 100644 --- a/src/output/driver.c +++ b/src/output/driver.c @@ -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); diff --git a/src/output/html.c b/src/output/html.c index 29a44721d4..cf9b2da3c1 100644 --- a/src/output/html.c +++ b/src/output/html.c @@ -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; } diff --git a/src/output/journal.c b/src/output/journal.c index 2b58350520..5c84a5f84e 100644 --- a/src/output/journal.c +++ b/src/output/journal.c @@ -24,12 +24,12 @@ #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; diff --git a/src/output/measure.c b/src/output/measure.c index faeef969b0..3376de8fbd 100644 --- a/src/output/measure.c +++ b/src/output/measure.c @@ -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; } diff --git a/src/output/msglog.c b/src/output/msglog.c index 4042b460e7..a3f1954104 100644 --- a/src/output/msglog.c +++ b/src/output/msglog.c @@ -26,10 +26,10 @@ #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; } diff --git a/src/output/odt.c b/src/output/odt.c index a02506c1e9..2bf1f2956e 100644 --- a/src/output/odt.c +++ b/src/output/odt.c @@ -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; } diff --git a/src/output/options.c b/src/output/options.c index 694ffc233e..b8921255d3 100644 --- a/src/output/options.c +++ b/src/output/options.c @@ -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); diff --git a/src/output/tab.c b/src/output/tab.c index 6f2a0051bb..5bde1b7c41 100644 --- a/src/output/tab.c +++ b/src/output/tab.c @@ -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" diff --git a/src/ui/gui/page-assistant.c b/src/ui/gui/page-assistant.c index b87584de71..683494b947 100644 --- a/src/ui/gui/page-assistant.c +++ b/src/ui/gui/page-assistant.c @@ -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" diff --git a/src/ui/gui/page-file.c b/src/ui/gui/page-file.c index fdbda325f8..3d26b1d473 100644 --- a/src/ui/gui/page-file.c +++ b/src/ui/gui/page-file.c @@ -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; } diff --git a/src/ui/gui/page-first-line.c b/src/ui/gui/page-first-line.c index 8d21e7c55c..ca6f424014 100644 --- a/src/ui/gui/page-first-line.c +++ b/src/ui/gui/page-first-line.c @@ -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" diff --git a/src/ui/gui/page-formats.c b/src/ui/gui/page-formats.c index d1ac9b23b1..7b2ad558c9 100644 --- a/src/ui/gui/page-formats.c +++ b/src/ui/gui/page-formats.c @@ -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" diff --git a/src/ui/gui/page-intro.c b/src/ui/gui/page-intro.c index 59c252b46c..428465d63a 100644 --- a/src/ui/gui/page-intro.c +++ b/src/ui/gui/page-intro.c @@ -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" diff --git a/src/ui/gui/page-separators.c b/src/ui/gui/page-separators.c index f1e08a6b59..2ab085ffa0 100644 --- a/src/ui/gui/page-separators.c +++ b/src/ui/gui/page-separators.c @@ -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" diff --git a/src/ui/gui/page-sheet-spec.c b/src/ui/gui/page-sheet-spec.c index 451f0b1a2e..8d9cd74409 100644 --- a/src/ui/gui/page-sheet-spec.c +++ b/src/ui/gui/page-sheet-spec.c @@ -57,7 +57,6 @@ #include -#include "gl/error.h" #include "gl/intprops.h" #include "gl/xalloc.h" diff --git a/src/ui/gui/psppire-output-window.c b/src/ui/gui/psppire-output-window.c index 4bad5b5efb..8a29fab18c 100644 --- a/src/ui/gui/psppire-output-window.c +++ b/src/ui/gui/psppire-output-window.c @@ -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); diff --git a/src/ui/gui/text-data-import-dialog.c b/src/ui/gui/text-data-import-dialog.c index 6214d5ebae..4bfbee0052 100644 --- a/src/ui/gui/text-data-import-dialog.c +++ b/src/ui/gui/text-data-import-dialog.c @@ -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" diff --git a/tests/automake.mk b/tests/automake.mk index efca9d2979..c104ecca47 100644 --- a/tests/automake.mk +++ b/tests/automake.mk @@ -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 = \ diff --git a/tests/output/output.at b/tests/output/output.at index 919927de12..f6351a4e9b 100644 --- a/tests/output/output.at +++ b/tests/output/output.at @@ -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])