From: Ben Pfaff Date: Sun, 16 Apr 2006 02:52:28 +0000 (+0000) Subject: Get rid of our own int32 type in favor of the standard int32_t type. X-Git-Tag: v0.6.0~986 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?p=pspp-builds.git;a=commitdiff_plain;h=0e8ce9b60375ae15ddd8dafc27bad1cc26856b08 Get rid of our own int32 type in favor of the standard int32_t type. --- diff --git a/ChangeLog b/ChangeLog index eec290a4..6f1daa73 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +Sat Apr 15 19:51:22 2006 Ben Pfaff + + 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 * configure.ac, acinclude.m4: Complain about missing prerequisites diff --git a/configure.ac b/configure.ac index 02ef4a5b..6c8820c7 100644 --- a/configure.ac +++ b/configure.ac @@ -62,10 +62,6 @@ AC_C_INLINE 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) diff --git a/src/data/ChangeLog b/src/data/ChangeLog index ffe2b80f..91f45fd5 100644 --- a/src/data/ChangeLog +++ b/src/data/ChangeLog @@ -1,3 +1,15 @@ +Sat Apr 15 19:48:57 2006 Ben Pfaff + + 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 . + + * 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 Remove ill-considered file routines that are no longer used. diff --git a/src/data/sfm-private.h b/src/data/sfm-private.h index 3864ca39..9aa1e31d 100644 --- a/src/data/sfm-private.h +++ b/src/data/sfm-private.h @@ -21,6 +21,7 @@ structures. */ #include +#include #include "variable.h" /* This attribute might avoid some problems. On the other hand... */ @@ -30,17 +31,6 @@ #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 @@ -70,12 +60,12 @@ struct sysfile_header { 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. */ @@ -86,13 +76,13 @@ struct sysfile_header /* 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. */ }; diff --git a/src/data/sys-file-reader.c b/src/data/sys-file-reader.c index 8a3cdf51..5f3e26bd 100644 --- a/src/data/sys-file-reader.c +++ b/src/data/sys-file-reader.c @@ -99,7 +99,7 @@ bswap (char *a, char *b) /* 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); @@ -170,7 +170,7 @@ static void *buf_read (struct sfm_reader *, void *buf, size_t byte_cnt, 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); @@ -279,7 +279,7 @@ sfm_open_reader (struct file_handle *fh, struct dictionary **dict, /* 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) @@ -307,9 +307,9 @@ sfm_open_reader (struct file_handle *fh, struct dictionary **dict, { 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; @@ -361,9 +361,9 @@ sfm_open_reader (struct file_handle *fh, struct dictionary **dict, { struct { - int32 measure P; - int32 width P; - int32 align P; + int32_t measure P; + int32_t width P; + int32_t align P; } params; @@ -476,7 +476,7 @@ sfm_open_reader (struct file_handle *fh, struct dictionary **dict, case 999: { - int32 filler; + int32_t filler; assertive_buf_read (r, &filler, sizeof filler, 0); goto success; @@ -509,15 +509,15 @@ error: 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) @@ -881,7 +881,7 @@ read_variables (struct sfm_reader *r, 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); @@ -897,7 +897,7 @@ read_variables (struct sfm_reader *r, 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'; @@ -978,7 +978,7 @@ error: /* 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); @@ -1024,10 +1024,10 @@ read_value_labels (struct sfm_reader *r, }; 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; @@ -1040,7 +1040,7 @@ read_value_labels (struct sfm_reader *r, 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); @@ -1077,7 +1077,7 @@ read_value_labels (struct sfm_reader *r, /* 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) @@ -1103,7 +1103,7 @@ read_value_labels (struct sfm_reader *r, 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. */ @@ -1251,7 +1251,7 @@ buf_unread(struct sfm_reader *r, size_t byte_cnt) 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) diff --git a/src/data/sys-file-writer.c b/src/data/sys-file-writer.c index 8abf052e..21b06139 100644 --- a/src/data/sys-file-writer.c +++ b/src/data/sys-file-writer.c @@ -217,8 +217,8 @@ sfm_open_writer (struct file_handle *fh, struct dictionary *d, { struct { - int32 rec_type P; - int32 filler P; + int32_t rec_type P; + int32_t filler P; } rec_999; @@ -372,7 +372,7 @@ write_header (struct sfm_writer *w, const struct dictionary *d) /* 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; } @@ -425,7 +425,7 @@ write_variable (struct sfm_writer *w, struct variable *v) { struct label { - int32 label_len P; + int32_t label_len P; char label[255] P; } l; @@ -468,16 +468,16 @@ write_value_labels (struct sfm_writer *w, struct variable *v, int idx) { 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; @@ -530,8 +530,8 @@ write_documents (struct sfm_writer *w, const struct dictionary *d) { 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; @@ -556,10 +556,10 @@ write_variable_display_parameters (struct sfm_writer *w, 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; @@ -574,9 +574,9 @@ write_variable_display_parameters (struct sfm_writer *w, 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; @@ -596,10 +596,10 @@ write_longvar_table (struct sfm_writer *w, const struct dictionary *dict) { 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; @@ -633,15 +633,15 @@ write_rec_7_34 (struct sfm_writer *w) { 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; @@ -664,7 +664,7 @@ write_rec_7_34 (struct sfm_writer *w) 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]; @@ -885,7 +885,7 @@ sfm_close_writer (struct sfm_writer *w) 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); }