X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fpfm-read.c;h=c3fbd90a5f98bcfc5f0c8dbed3fe12854888910b;hb=e32e05bf60402d3229e45adcc9b4c8d5bb27d174;hp=e82fa00f80c2843b924c4ab6d3ff72e3ea9b0b72;hpb=b321086267ad1014dc5d09886396cde30f094437;p=pspp-builds.git diff --git a/src/pfm-read.c b/src/pfm-read.c index e82fa00f..c3fbd90a 100644 --- a/src/pfm-read.c +++ b/src/pfm-read.c @@ -70,37 +70,29 @@ corrupt_msg (struct pfm_reader *r, const char *format,...) static int corrupt_msg (struct pfm_reader *r, const char *format, ...) { - char buf[1024]; - - { - va_list args; + char *title; + struct error e; + const char *filename; + va_list args; - va_start (args, format); - vsnprintf (buf, 1024, format, args); - va_end (args); - } - - { - char *title; - struct error e; - const char *filename; + e.class = ME; + getl_location (&e.where.filename, &e.where.line_number); + filename = handle_get_filename (r->fh); + e.title = title = local_alloc (strlen (filename) + 80); + sprintf (title, _("portable file %s corrupt at offset %ld: "), + filename, ftell (r->file) - (82 - (long) (r->bp - r->buf))); - e.class = ME; - getl_location (&e.where.filename, &e.where.line_number); - filename = handle_get_filename (r->fh); - e.title = title = local_alloc (strlen (filename) + 80); - sprintf (title, _("portable file %s corrupt at offset %ld: "), - filename, ftell (r->file) - (82 - (long) (r->bp - r->buf))); - e.text = buf; + va_start (args, format); + err_vmsg (&e, format, args); + va_end (args); - err_vmsg (&e); + local_free (title); - local_free (title); - } - return 0; } +static unsigned char * read_string (struct pfm_reader *r); + /* Closes a portable file after we're done with it. */ void pfm_close_reader (struct pfm_reader *r) @@ -108,12 +100,15 @@ pfm_close_reader (struct pfm_reader *r) if (r == NULL) return; + read_string (NULL); + if (r->fh != NULL) fh_close (r->fh, "portable file", "rs"); if (fclose (r->file) == EOF) msg (ME, _("%s: Closing portable file: %s."), handle_get_filename (r->fh), strerror (errno)); free (r->trans); + free (r->widths); free (r); } @@ -742,8 +737,6 @@ read_variables (struct pfm_reader *r, struct dictionary *dict) lose ((r, "Bad width %d for variable %s.", width, name)); v = dict_create_var (dict, name, width); - v->aux = xmalloc (sizeof (int)); - *(int *) v->aux = v->fv; if (v == NULL) lose ((r, _("Duplicate variable name %s."), name)); if (!convert_format (r, &fmt[0], &v->print, v))