+Sat Apr 15 19:51:22 2006 Ben Pfaff <blp@gnu.org>
+
+ Get rid of our own int32 type in favor of the standard int32_t
+ type.
+
+ * configure.ac: Don't need to check the sizes of integer types
+ anymore.
+
Sat Apr 15 19:13:59 2006 Ben Pfaff <blp@gnu.org>
* configure.ac, acinclude.m4: Complain about missing prerequisites
dnl Dont use AC_TYPE_OFF_T --- it doesnt generate the HAVE_TYPE macro
AC_CHECK_TYPES(off_t)
-AC_CHECK_SIZEOF(short, 2)
-AC_CHECK_SIZEOF(int, 4)
-AC_CHECK_SIZEOF(long, 4)
-AC_CHECK_SIZEOF(long long, 0)
AC_CHECK_SIZEOF(float, 0)
AC_CHECK_SIZEOF(double, 8)
AC_CHECK_SIZEOF(long double, 0)
+Sat Apr 15 19:48:57 2006 Ben Pfaff <blp@gnu.org>
+
+ Get rid of our own int32 type in favor of the standard int32_t
+ type.
+
+ * sfm-private.h: (int32 macro) Don't define this anymore. Do
+ include <stdint.h>.
+
+ * sys-file-reader.c: Use int32_t instead of int32 throughout.
+
+ * sys-file-writer.c: Use int32_t instead of int32 throughout.
+
Sat Apr 15 19:36:47 2006 Ben Pfaff <blp@gnu.org>
Remove ill-considered file routines that are no longer used.
structures. */
#include <libpspp/compiler.h>
+#include <stdint.h>
#include "variable.h"
/* This attribute might avoid some problems. On the other hand... */
#pragma option -a- /* Turn off alignment. */
#endif
-/* Find 32-bit signed integer type. */
-#if SIZEOF_SHORT == 4
- #define int32 short
-#elif SIZEOF_INT == 4
- #define int32 int
-#elif SIZEOF_LONG == 4
- #define int32 long
-#else
- #error Which one of your basic types is 32-bit signed integer?
-#endif
-
/* Find 64-bit floating-point type. */
#if SIZEOF_FLOAT == 8
#define flt64 float
{
char rec_type[4] P; /* 00: Record-type code, "$FL2". */
char prod_name[60] P; /* 04: Product identification. */
- int32 layout_code P; /* 40: 2. */
- int32 case_size P; /* 44: Number of `value's per case.
+ int32_t layout_code P; /* 40: 2. */
+ int32_t case_size P; /* 44: Number of `value's per case.
Note: some systems set this to -1 */
- int32 compress P; /* 48: 1=compressed, 0=not compressed. */
- int32 weight_idx P; /* 4c: 1-based index of weighting var, or 0. */
- int32 case_cnt P; /* 50: Number of cases, -1 if unknown. */
+ int32_t compress P; /* 48: 1=compressed, 0=not compressed. */
+ int32_t weight_idx P; /* 4c: 1-based index of weighting var, or 0. */
+ int32_t case_cnt P; /* 50: Number of cases, -1 if unknown. */
flt64 bias P; /* 54: Compression bias (100.0). */
char creation_date[9] P; /* 5c: `dd mmm yy' creation date of file. */
char creation_time[8] P; /* 65: `hh:mm:ss' 24-hour creation time. */
/* Record Type 2: Variable. */
struct sysfile_variable
{
- int32 rec_type P; /* 2. */
- int32 type P; /* 0=numeric, 1-255=string width,
+ int32_t rec_type P; /* 2. */
+ int32_t type P; /* 0=numeric, 1-255=string width,
-1=continued string. */
- int32 has_var_label P; /* 1=has a variable label, 0=doesn't. */
- int32 n_missing_values P; /* Missing value code of -3,-2,0,1,2, or 3. */
- int32 print P; /* Print format. */
- int32 write P; /* Write format. */
+ int32_t has_var_label P; /* 1=has a variable label, 0=doesn't. */
+ int32_t n_missing_values P; /* Missing value code of -3,-2,0,1,2, or 3. */
+ int32_t print P; /* Print format. */
+ int32_t write P; /* Write format. */
char name[SHORT_NAME_LEN] P; /* Variable name. */
/* The rest of the structure varies. */
};
/* Reverse the byte order of 32-bit integer *X. */
static inline void
-bswap_int32 (int32 *x_)
+bswap_int32 (int32_t *x_)
{
char *x = (char *) x_;
bswap (x + 0, x + 3);
static int read_header (struct sfm_reader *,
struct dictionary *, struct sfm_read_info *);
-static int parse_format_spec (struct sfm_reader *, int32,
+static int parse_format_spec (struct sfm_reader *, int32_t,
struct fmt_spec *, const struct variable *);
static int read_value_labels (struct sfm_reader *, struct dictionary *,
struct variable **var_by_idx);
/* Read records of types 3, 4, 6, and 7. */
for (;;)
{
- int32 rec_type;
+ int32_t rec_type;
assertive_buf_read (r, &rec_type, sizeof rec_type, 0);
if (r->reverse_endian)
{
struct
{
- int32 subtype P;
- int32 size P;
- int32 count P;
+ int32_t subtype P;
+ int32_t size P;
+ int32_t count P;
}
data;
unsigned long bytes;
{
struct
{
- int32 measure P;
- int32 width P;
- int32 align P;
+ int32_t measure P;
+ int32_t width P;
+ int32_t align P;
}
params;
case 999:
{
- int32 filler;
+ int32_t filler;
assertive_buf_read (r, &filler, sizeof filler, 0);
goto success;
static int
read_machine_int32_info (struct sfm_reader *r, int size, int count)
{
- int32 data[8];
+ int32_t data[8];
int file_bigendian;
int i;
- if (size != sizeof (int32) || count != 8)
+ if (size != sizeof (int32_t) || count != 8)
lose ((ME, _("%s: Bad size (%d) or count (%d) field on record type 7, "
"subtype 3. Expected size %d, count 8."),
- fh_get_filename (r->fh), size, count, sizeof (int32)));
+ fh_get_filename (r->fh), size, count, sizeof (int32_t)));
assertive_buf_read (r, data, sizeof data, 0);
if (r->reverse_endian)
if (sv.has_var_label == 1)
{
/* Disk buffer. */
- int32 len;
+ int32_t len;
/* Read length of label. */
assertive_buf_read (r, &len, sizeof len, 0);
if ( len != 0 )
{
/* Read label into variable structure. */
- vv->label = buf_read (r, NULL, ROUND_UP (len, sizeof (int32)), len + 1);
+ vv->label = buf_read (r, NULL, ROUND_UP (len, sizeof (int32_t)), len + 1);
if (vv->label == NULL)
goto error;
vv->label[len] = '\0';
/* Translates the format spec from sysfile format to internal
format. */
static int
-parse_format_spec (struct sfm_reader *r, int32 s,
+parse_format_spec (struct sfm_reader *r, int32_t s,
struct fmt_spec *f, const struct variable *v)
{
f->type = translate_fmt ((s >> 16) & 0xff);
};
struct label *labels = NULL;
- int32 n_labels; /* Number of labels. */
+ int32_t n_labels; /* Number of labels. */
struct variable **var = NULL; /* Associated variables. */
- int32 n_vars; /* Number of associated variables. */
+ int32_t n_vars; /* Number of associated variables. */
int i;
if (r->reverse_endian)
bswap_int32 (&n_labels);
- if ( n_labels >= ((int32) ~0) / sizeof *labels)
+ if ( n_labels >= ((int32_t) ~0) / sizeof *labels)
{
corrupt_msg(MW, _("%s: Invalid number of labels: %d. Ignoring labels."),
fh_get_filename (r->fh), n_labels);
/* Read record type of type 4 record. */
{
- int32 rec_type;
+ int32_t rec_type;
assertive_buf_read (r, &rec_type, sizeof rec_type, 0);
if (r->reverse_endian)
var = xnmalloc (n_vars, sizeof *var);
for (i = 0; i < n_vars; i++)
{
- int32 var_idx;
+ int32_t var_idx;
struct variable *v;
/* Read variable index, check range. */
static int
read_documents (struct sfm_reader *r, struct dictionary *dict)
{
- int32 line_cnt;
+ int32_t line_cnt;
char *documents;
if (dict_get_documents (dict) != NULL)
{
struct
{
- int32 rec_type P;
- int32 filler P;
+ int32_t rec_type P;
+ int32_t filler P;
}
rec_999;
/* Translates format spec from internal form in SRC to system file
format in DEST. */
static inline void
-write_format_spec (struct fmt_spec *src, int32 *dest)
+write_format_spec (struct fmt_spec *src, int32_t *dest)
{
*dest = (formats[src->type].spss << 16) | (src->w << 8) | src->d;
}
{
struct label
{
- int32 label_len P;
+ int32_t label_len P;
char label[255] P;
}
l;
{
struct value_label_rec
{
- int32 rec_type P;
- int32 n_labels P;
+ int32_t rec_type P;
+ int32_t n_labels P;
flt64 labels[1] P;
};
struct var_idx_rec
{
- int32 rec_type P;
- int32 n_vars P;
- int32 vars[1] P;
+ int32_t rec_type P;
+ int32_t n_vars P;
+ int32_t vars[1] P;
};
struct val_labs_iterator *i;
{
struct
{
- int32 rec_type P; /* Always 6. */
- int32 n_lines P; /* Number of lines of documents. */
+ int32_t rec_type P; /* Always 6. */
+ int32_t n_lines P; /* Number of lines of documents. */
}
rec_6;
struct
{
- int32 rec_type P;
- int32 subtype P;
- int32 elem_size P;
- int32 n_elem P;
+ int32_t rec_type P;
+ int32_t subtype P;
+ int32_t elem_size P;
+ int32_t n_elem P;
} vdp_hdr;
vdp_hdr.rec_type = 7;
struct variable *v;
struct
{
- int32 measure P;
- int32 width P;
- int32 align P;
+ int32_t measure P;
+ int32_t width P;
+ int32_t align P;
}
params;
{
struct
{
- int32 rec_type P;
- int32 subtype P;
- int32 elem_size P;
- int32 n_elem P;
+ int32_t rec_type P;
+ int32_t subtype P;
+ int32_t elem_size P;
+ int32_t n_elem P;
}
lv_hdr;
{
struct
{
- int32 rec_type_3 P;
- int32 subtype_3 P;
- int32 data_type_3 P;
- int32 n_elem_3 P;
- int32 elem_3[8] P;
- int32 rec_type_4 P;
- int32 subtype_4 P;
- int32 data_type_4 P;
- int32 n_elem_4 P;
+ int32_t rec_type_3 P;
+ int32_t subtype_3 P;
+ int32_t data_type_3 P;
+ int32_t n_elem_3 P;
+ int32_t elem_3[8] P;
+ int32_t rec_type_4 P;
+ int32_t subtype_4 P;
+ int32_t data_type_4 P;
+ int32_t n_elem_4 P;
flt64 elem_4[3] P;
}
rec_7;
rec_7.rec_type_3 = 7;
rec_7.subtype_3 = 3;
- rec_7.data_type_3 = sizeof (int32);
+ rec_7.data_type_3 = sizeof (int32_t);
rec_7.n_elem_3 = 8;
rec_7.elem_3[0] = version_component[0];
rec_7.elem_3[1] = version_component[1];
if (ok && !fseek (w->file, offsetof (struct sysfile_header, case_cnt),
SEEK_SET))
{
- int32 case_cnt = w->case_cnt;
+ int32_t case_cnt = w->case_cnt;
fwrite (&case_cnt, sizeof case_cnt, 1, w->file);
clearerr (w->file);
}