int value_cnt; /* Number of 8-byte units per case. */
struct sfm_var *vars; /* Variables. */
size_t var_cnt; /* Number of variables. */
+ bool has_long_var_names; /* File has a long variable name map */
bool has_vls; /* File has one or more very long strings? */
/* Decompression. */
r->error = false;
r->value_cnt = 0;
r->has_vls = false;
+ r->has_long_var_names = false;
r->opcode_idx = sizeof r->opcodes;
if (setjmp (r->bail_out))
rec_type = read_int32 (r);
}
+
+ if ( ! r->has_long_var_names )
+ {
+ int i;
+ for (i = 0; i < dict_get_var_cnt (*dict); i++)
+ {
+ struct variable *var = dict_get_var (*dict, i);
+ char short_name [SHORT_NAME_LEN + 1];
+ char long_name [SHORT_NAME_LEN + 1];
+
+ strcpy (short_name, var_get_name (var));
+
+ strcpy (long_name, short_name);
+ str_lowercase (long_name);
+
+ /* Set long name. Renaming a variable may clear the short
+ name, but we want to retain it, so re-set it
+ explicitly. */
+ dict_rename_var (*dict, var, long_name);
+ var_set_short_name (var, short_name);
+ }
+
+ r->has_long_var_names = true;
+ }
+
/* Read record 999 data, which is just filler. */
read_int32 (r);
len = read_int32 (r);
if (len >= sizeof label)
- sys_error (r, _("Variable %s has label of invalid length %d."),
- name, len);
+ sys_error (r, _("Variable %s has label of invalid length %u."),
+ name, (unsigned int) len);
read_string (r, label, len + 1);
var_set_label (var, label);
int expected_integer_format;
if (size != 4 || count != 8)
- sys_error (r, _("Bad size (%d) or count (%d) field on record type 7, "
+ sys_error (r, _("Bad size (%u) or count (%u) field on record type 7, "
"subtype 3."),
- size, count);
+ (unsigned int) size, (unsigned int) count);
/* Check floating point format. */
if (r->float_format == FLOAT_IEEE_DOUBLE_BE
double lowest = read_flt64 (r);
if (size != 8 || count != 3)
- sys_error (r, _("Bad size (%d) or count (%d) on extension 4."),
- size, count);
+ sys_error (r, _("Bad size (%u) or count (%u) on extension 4."),
+ (unsigned int) size, (unsigned int) count);
if (sysmis != SYSMIS)
sys_warn (r, _("File specifies unexpected value %g as SYSMIS."), sysmis);
int i;
if (count % 3 || n_vars != dict_get_var_cnt (dict))
- sys_error (r, _("Bad size (%d) or count (%d) on extension 11."),
- size, count);
+ sys_error (r, _("Bad size (%u) or count (%u) on extension 11."),
+ (unsigned int) size, (unsigned int) count);
for (i = 0; i < n_vars; ++i)
{
int measure = read_int32 (r);
int width = read_int32 (r);
int align = read_int32 (r);
- struct variable *v;
+ struct variable *v = dict_get_var (dict, i);
+
+ /* spss v14 sometimes seems to set string variables' measure to zero */
+ if ( 0 == measure && var_is_alpha (v) ) measure = 1;
+
- if (!measure_is_valid (measure) || !alignment_is_valid (align))
+ if (measure < 1 || measure > 3 || align < 0 || align > 2)
{
if (!warned)
sys_warn (r, _("Invalid variable display parameters. "
continue;
}
- v = dict_get_var (dict, i);
- var_set_measure (v, measure);
+ var_set_measure (v, (measure == 1 ? MEASURE_NOMINAL
+ : measure == 2 ? MEASURE_ORDINAL
+ : MEASURE_SCALE));
var_set_display_width (v, width);
- var_set_alignment (v, align);
+ var_set_alignment (v, (align == 0 ? ALIGN_LEFT
+ : align == 1 ? ALIGN_RIGHT
+ : ALIGN_CENTRE));
}
}
var_set_short_name (var, short_name);
}
close_variable_to_value_map (r, map);
+ r->has_long_var_names = true;
}
/* Reads record type 7, subtype 14, which gives the real length
var_cnt = read_int32 (r);
if (var_cnt < 1 || var_cnt > dict_get_var_cnt (dict))
sys_error (r, _("Number of variables associated with a value label (%d) "
- "is not between 1 and the number of variables (%d)."),
- var_cnt, dict_get_var_cnt (dict));
+ "is not between 1 and the number of variables (%u)."),
+ var_cnt, (unsigned int) dict_get_var_cnt (dict));
/* Read the list of variables. */
var = pool_nalloc (subpool, var_cnt, sizeof *var);