projects
/
pspp
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Make the expression code a little nicer and fix bugs found
[pspp]
/
src
/
pfm-read.c
diff --git
a/src/pfm-read.c
b/src/pfm-read.c
index 0a13086281c757ecc4733fa764e6a679436731a7..ab33e700f724ab2c5c6562593be0351a673a3e17 100644
(file)
--- a/
src/pfm-read.c
+++ b/
src/pfm-read.c
@@
-19,7
+19,7
@@
#include <config.h>
#include "pfm.h"
#include <config.h>
#include "pfm.h"
-#include
<assert.h>
+#include
"error.h"
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
@@
-62,7
+62,7
@@
static struct fh_ext_class pfm_r_class;
static int
corrupt_msg (struct file_handle *h, const char *format,...)
static int
corrupt_msg (struct file_handle *h, const char *format,...)
-
__attribute__ ((format (printf, 2, 3))
);
+
PRINTF_FORMAT (2, 3
);
/* Displays a corruption error. */
static int
/* Displays a corruption error. */
static int
@@
-82,12
+82,14
@@
corrupt_msg (struct file_handle *h, const char *format, ...)
{
char *title;
struct error e;
{
char *title;
struct error e;
+ const char *filename;
e.class = ME;
getl_location (&e.where.filename, &e.where.line_number);
e.class = ME;
getl_location (&e.where.filename, &e.where.line_number);
- e.title = title = local_alloc (strlen (h->fn) + 80);
+ filename = handle_get_filename (h);
+ e.title = title = local_alloc (strlen (filename) + 80);
sprintf (title, _("portable file %s corrupt at offset %ld: "),
sprintf (title, _("portable file %s corrupt at offset %ld: "),
-
h->fn
, ftell (ext->file) - (82 - (long) (ext->bp - ext->buf)));
+
filename
, ftell (ext->file) - (82 - (long) (ext->bp - ext->buf)));
e.text = buf;
err_vmsg (&e);
e.text = buf;
err_vmsg (&e);
@@
-100,12
+102,13
@@
corrupt_msg (struct file_handle *h, const char *format, ...)
/* Closes a portable file after we're done with it. */
static void
/* Closes a portable file after we're done with it. */
static void
-pfm_close (struct file_handle *
h)
+pfm_close (struct file_handle *h)
{
struct pfm_fhuser_ext *ext = h->ext;
if (EOF == fclose (ext->file))
{
struct pfm_fhuser_ext *ext = h->ext;
if (EOF == fclose (ext->file))
- msg (ME, _("%s: Closing portable file: %s."), h->fn, strerror (errno));
+ msg (ME, _("%s: Closing portable file: %s."),
+ handle_get_filename (h), strerror (errno));
free (ext->vars);
free (ext->trans);
free (h->ext);
free (ext->vars);
free (ext->trans);
free (h->ext);
@@
-220,20
+223,21
@@
pfm_read_dictionary (struct file_handle *h, struct pfm_read_info *inf)
{
msg (ME, _("Cannot read file %s as portable file: already opened "
"for %s."),
{
msg (ME, _("Cannot read file %s as portable file: already opened "
"for %s."),
-
fh_handle
_name (h), h->class->name);
+
handle_get
_name (h), h->class->name);
return NULL;
}
msg (VM (1), _("%s: Opening portable-file handle %s for reading."),
return NULL;
}
msg (VM (1), _("%s: Opening portable-file handle %s for reading."),
-
fh_handle_filename (h), fh_handle
_name (h));
+
handle_get_filename (h), handle_get
_name (h));
/* Open the physical disk file. */
ext = xmalloc (sizeof (struct pfm_fhuser_ext));
/* Open the physical disk file. */
ext = xmalloc (sizeof (struct pfm_fhuser_ext));
- ext->file = fopen (h
->norm_fn
, "rb");
+ ext->file = fopen (h
andle_get_filename (h)
, "rb");
if (ext->file == NULL)
{
msg (ME, _("An error occurred while opening \"%s\" for reading "
if (ext->file == NULL)
{
msg (ME, _("An error occurred while opening \"%s\" for reading "
- "as a portable file: %s."), h->fn, strerror (errno));
+ "as a portable file: %s."),
+ handle_get_filename (h), strerror (errno));
err_cond_fail ();
free (ext);
return NULL;
err_cond_fail ();
free (ext);
return NULL;
@@
-617,11
+621,9
@@
static int
convert_format (struct file_handle *h, int fmt[3], struct fmt_spec *v,
struct variable *vv)
{
convert_format (struct file_handle *h, int fmt[3], struct fmt_spec *v,
struct variable *vv)
{
- if (fmt[0] < 0
-
|| (size_t) fmt[0] >= sizeof translate_fmt / sizeof *translate_fmt
)
+ v->type = translate_fmt (fmt[0]);
+
if (v->type == -1
)
lose ((h, _("%s: Bad format specifier byte (%d)."), vv->name, fmt[0]));
lose ((h, _("%s: Bad format specifier byte (%d)."), vv->name, fmt[0]));
-
- v->type = translate_fmt[fmt[0]];
v->w = fmt[1];
v->d = fmt[2];
v->w = fmt[1];
v->d = fmt[2];