X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fdata%2Fpor-file-reader.c;h=fa3af602dc4a7d1bb30914c739d45455fdf32b94;hb=b74d09af5e07f954c18e7cdb8aca3af47fa10208;hp=db33acf035749b940a69c13ea04d9276beca101e;hpb=dcf9b154cbcaa35c3d8459a201b77eec8bcb30bd;p=pspp-builds.git diff --git a/src/data/por-file-reader.c b/src/data/por-file-reader.c index db33acf0..fa3af602 100644 --- a/src/data/por-file-reader.c +++ b/src/data/por-file-reader.c @@ -21,7 +21,7 @@ #include #include "por-file-reader.h" -#include "message.h" +#include #include #include #include @@ -29,25 +29,24 @@ #include #include #include -#include "alloc.h" +#include #include #include "case.h" +#include #include "dictionary.h" #include "file-handle-def.h" #include "format.h" -#include "hash.h" -#include "magic.h" -#include "misc.h" -#include "pool.h" -#include "str.h" +#include +#include +#include +#include +#include #include "value-labels.h" #include "variable.h" #include "gettext.h" #define _(msgid) gettext (msgid) -#include "debug-print.h" - /* portable_to_local[PORTABLE] translates the given portable character into the local character set. */ static const char portable_to_local[256] = @@ -78,30 +77,33 @@ struct pfm_reader static void error (struct pfm_reader *r, const char *msg,...) - PRINTF_FORMAT (2, 3); + PRINTF_FORMAT (2, 3) + NO_RETURN; /* Displays MSG as an error message and aborts reading the portable file via longjmp(). */ static void error (struct pfm_reader *r, const char *msg, ...) { - struct error e; - const char *filename; - char *title; + struct msg m; + struct string text; va_list args; - e.class = ME; - e.where.filename = NULL; - e.where.line_number = 0; - filename = fh_get_filename (r->fh); - e.title = title = pool_alloc (r->pool, strlen (filename) + 80); - sprintf (title, _("portable file %s corrupt at offset %ld: "), - filename, ftell (r->file)); - + ds_init_empty (&text); + ds_put_format (&text, _("portable file %s corrupt at offset %ld: "), + fh_get_file_name (r->fh), ftell (r->file)); va_start (args, msg); - err_vmsg (&e, msg, args); + ds_put_vformat (&text, msg, args); va_end (args); + m.category = MSG_GENERAL; + m.severity = MSG_ERROR; + m.where.file_name = NULL; + m.where.line_number = 0; + m.text = ds_cstr (&text); + + msg_emit (&m); + r->ok = false; longjmp (r->bail_out, 1); @@ -172,7 +174,7 @@ pfm_open_reader (struct file_handle *fh, struct dictionary **dict, if (setjmp (r->bail_out)) goto error; r->fh = fh; - r->file = pool_fopen (r->pool, fh_get_filename (r->fh), "rb"); + r->file = pool_fopen (r->pool, fh_get_file_name (r->fh), "rb"); r->weight_index = -1; r->trans = NULL; r->var_cnt = 0; @@ -185,7 +187,7 @@ pfm_open_reader (struct file_handle *fh, struct dictionary **dict, { msg (ME, _("An error occurred while opening \"%s\" for reading " "as a portable file: %s."), - fh_get_filename (r->fh), strerror (errno)); + fh_get_file_name (r->fh), strerror (errno)); goto error; } @@ -403,7 +405,7 @@ read_header (struct pfm_reader *r) for (i = 0; i < 8; i++) if (!match (r, "SPSSPORT"[i])) { - msg (SE, _("%s: Not a portable file."), fh_get_filename (r->fh)); + msg (SE, _("%s: Not a portable file."), fh_get_file_name (r->fh)); longjmp (r->bail_out, 1); } }