Continue reforming error message support. In this phase, get rid of
[pspp-builds.git] / src / data / por-file-reader.c
index 0824bb311147993a0ad6795abfd654bea54f2ee9..c137a0507778d0df8085f158b20f2219148dc467 100644 (file)
@@ -86,22 +86,24 @@ static void
 error (struct pfm_reader *r, const char *msg, ...)
 {
   struct error e;
-  const char *file_name;
-  char *title;
+  struct string text;
   va_list args;
 
-  e.class = ME;
-  e.where.file_name = NULL;
-  e.where.line_number = 0;
-  file_name = fh_get_file_name (r->fh);
-  e.title = title = pool_alloc (r->pool, strlen (file_name) + 80);
-  sprintf (title, _("portable file %s corrupt at offset %ld: "),
-           file_name, ftell (r->file));
-
+  ds_init (&text, 64);
+  ds_printf (&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_vprintf (&text, msg, args);
   va_end (args);
 
+  e.category = MSG_GENERAL;
+  e.severity = MSG_ERROR;
+  e.where.file_name = NULL;
+  e.where.line_number = 0;
+  e.text = ds_c_str (&text);
+  
+  err_msg (&e);
+
   r->ok = false;
 
   longjmp (r->bail_out, 1);