X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fpfm-read.c;h=3dd939ddae25dc1564eefba3fb410e09bbeb8416;hb=6d2a8977cc6a54e9e2278467f2af3d5ae277cd43;hp=1999628c462ae7fdde3c15048d22995d37dcf464;hpb=933b760efccdfa26f14254f1fae002ea3b0a1495;p=pspp diff --git a/src/pfm-read.c b/src/pfm-read.c index 1999628c46..3dd939ddae 100644 --- a/src/pfm-read.c +++ b/src/pfm-read.c @@ -59,8 +59,7 @@ struct pfm_reader struct file_handle *fh; /* File handle. */ FILE *file; /* File stream. */ char cc; /* Current character. */ - unsigned char *trans; /* 256-byte character set translation table. */ - + char *trans; /* 256-byte character set translation table. */ int var_cnt; /* Number of variables. */ int weight_index; /* 0-based index of weight variable, or -1. */ int *widths; /* Variable widths, 0 for numeric. */ @@ -83,7 +82,7 @@ error (struct pfm_reader *r, const char *msg, ...) e.class = ME; getl_location (&e.where.filename, &e.where.line_number); - filename = handle_get_filename (r->fh); + 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)); @@ -160,7 +159,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, handle_get_filename (r->fh), "rb"); + r->file = pool_fopen (r->pool, fh_get_filename (r->fh), "rb"); r->weight_index = -1; r->trans = NULL; r->var_cnt = 0; @@ -172,7 +171,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."), - handle_get_filename (r->fh), strerror (errno)); + fh_get_filename (r->fh), strerror (errno)); err_cond_fail (); goto error; } @@ -342,7 +341,7 @@ read_string (struct pfm_reader *r, char *buf) /* Reads a string and returns a copy of it allocated from R's pool. */ -static unsigned char * +static char * read_pool_string (struct pfm_reader *r) { char string[256]; @@ -356,7 +355,7 @@ read_header (struct pfm_reader *r) { /* portable_to_local[PORTABLE] translates the given portable character into the local character set. */ - static const unsigned char portable_to_local[256] = + static const char portable_to_local[256] = { " " "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz ." @@ -364,7 +363,7 @@ read_header (struct pfm_reader *r) " " }; - unsigned char *trans; + char *trans; int i; /* Read and ignore vanity splash strings. */ @@ -401,7 +400,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."), handle_get_filename (r->fh)); + msg (SE, _("%s: Not a portable file."), fh_get_filename (r->fh)); longjmp (r->bail_out, 1); } } @@ -411,6 +410,7 @@ read_header (struct pfm_reader *r) static void read_version_data (struct pfm_reader *r, struct pfm_read_info *info) { + static char empty_string[] = ""; char *date, *time, *product, *author, *subproduct; int i; @@ -419,10 +419,9 @@ read_version_data (struct pfm_reader *r, struct pfm_read_info *info) error (r, "Unrecognized version code `%c'.", r->cc); date = read_pool_string (r); time = read_pool_string (r); - product = match (r, '1') ? read_pool_string (r) : (unsigned char *) ""; - author = match (r, '2') ? read_pool_string (r) : (unsigned char *) ""; - subproduct - = match (r, '3') ? read_pool_string (r) : (unsigned char *) ""; + product = match (r, '1') ? read_pool_string (r) : empty_string; + author = match (r, '2') ? read_pool_string (r) : empty_string; + subproduct = match (r, '3') ? read_pool_string (r) : empty_string; /* Validate file. */ if (strlen (date) != 8) @@ -493,7 +492,7 @@ read_variables (struct pfm_reader *r, struct dictionary *dict) r->var_cnt = read_int (r); if (r->var_cnt <= 0 || r->var_cnt == NOT_INT) error (r, _("Invalid number of variables %d."), r->var_cnt); - r->widths = pool_alloc (r->pool, sizeof *r->widths * r->var_cnt); + r->widths = pool_nalloc (r->pool, r->var_cnt, sizeof *r->widths); /* Purpose of this value is unknown. It is typically 161. */ read_int (r); @@ -609,7 +608,7 @@ read_value_label (struct pfm_reader *r, struct dictionary *dict) int i; nv = read_int (r); - v = pool_alloc (r->pool, sizeof *v * nv); + v = pool_nalloc (r->pool, nv, sizeof *v); for (i = 0; i < nv; i++) { char name[256];