X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fdata%2Fsys-file-writer.c;h=e923b9d5e43e56b5975511e20e53bddc0f38b6f1;hb=8a7f5c28b68af3cd03a524329c1d6e7eba355158;hp=ddfb4ae75c47288ec4d4ff2683c89ed76c2091fd;hpb=3e393e4601620af7583ca2b748def2ed08b468ec;p=pspp-builds.git diff --git a/src/data/sys-file-writer.c b/src/data/sys-file-writer.c index ddfb4ae7..e923b9d5 100644 --- a/src/data/sys-file-writer.c +++ b/src/data/sys-file-writer.c @@ -20,7 +20,6 @@ #include #include "sys-file-writer.h" -#include "sfm-private.h" #include "sys-file-private.h" #include @@ -54,6 +53,60 @@ #include "gettext.h" #define _(msgid) gettext (msgid) +/* Find 64-bit floating-point type. */ +#if SIZEOF_FLOAT == 8 + #define flt64 float + #define FLT64_MAX FLT_MAX +#elif SIZEOF_DOUBLE == 8 + #define flt64 double + #define FLT64_MAX DBL_MAX +#elif SIZEOF_LONG_DOUBLE == 8 + #define flt64 long double + #define FLT64_MAX LDBL_MAX +#else + #error Which one of your basic types is 64-bit floating point? +#endif + +/* Figure out SYSMIS value for flt64. */ +#include +#if SIZEOF_DOUBLE == 8 +#define second_lowest_flt64 second_lowest_value +#else +#error Must define second_lowest_flt64 for your architecture. +#endif + +/* Record Type 1: General Information. */ +struct sysfile_header + { + char rec_type[4] ; /* 00: Record-type code, "$FL2". */ + char prod_name[60] ; /* 04: Product identification. */ + int32_t layout_code ; /* 40: 2. */ + int32_t nominal_case_size ; /* 44: Number of `value's per case. + Note: some systems set this to -1 */ + int32_t compress ; /* 48: 1=compressed, 0=not compressed. */ + int32_t weight_idx ; /* 4c: 1-based index of weighting var, or 0. */ + int32_t case_cnt ; /* 50: Number of cases, -1 if unknown. */ + flt64 bias ; /* 54: Compression bias (100.0). */ + char creation_date[9] ; /* 5c: `dd mmm yy' creation date of file. */ + char creation_time[8] ; /* 65: `hh:mm:ss' 24-hour creation time. */ + char file_label[64] ; /* 6d: File label. */ + char padding[3] ; /* ad: Ignored padding. */ + } ATTRIBUTE((packed)) ; + +/* Record Type 2: Variable. */ +struct sysfile_variable + { + int32_t rec_type ; /* 2. */ + int32_t type ; /* 0=numeric, 1-255=string width, + -1=continued string. */ + int32_t has_var_label ; /* 1=has a variable label, 0=doesn't. */ + int32_t n_missing_values ; /* Missing value code of -3,-2,0,1,2, or 3. */ + int32_t print ; /* Print format. */ + int32_t write ; /* Write format. */ + char name[SHORT_NAME_LEN] ; /* Variable name. */ + /* The rest of the structure varies. */ + } ATTRIBUTE((packed)) ; + /* Compression bias used by PSPP. Values between (1 - COMPRESSION_BIAS) and (251 - COMPRESSION_BIAS) inclusive can be compressed. */