{
int width; /* 0=numeric, otherwise string width. */
int case_index; /* Index into case. */
{
int width; /* 0=numeric, otherwise string width. */
int case_index; /* Index into case. */
setup_weight (r, weight_idx, var_by_value_idx, *dict);
/* Read all the rest of the dictionary records. */
setup_weight (r, weight_idx, var_by_value_idx, *dict);
/* Read all the rest of the dictionary records. */
dictionary and may destroy or modify its variables. */
r->var_cnt = dict_get_var_cnt (*dict);
r->vars = pool_nalloc (r->pool, r->var_cnt, sizeof *r->vars);
dictionary and may destroy or modify its variables. */
r->var_cnt = dict_get_var_cnt (*dict);
r->vars = pool_nalloc (r->pool, r->var_cnt, sizeof *r->vars);
{
struct variable *v = dict_get_var (*dict, i);
struct sfm_var *sv = &r->vars[i];
sv->width = var_get_width (v);
{
struct variable *v = dict_get_var (*dict, i);
struct sfm_var *sv = &r->vars[i];
sv->width = var_get_width (v);
{
msg (ME, _("Error closing system file \"%s\": %s."),
fh_get_file_name (r->fh), strerror (errno));
{
msg (ME, _("Error closing system file \"%s\": %s."),
fh_get_file_name (r->fh), strerror (errno));
{
char rec_type[5];
if (fread (rec_type, 4, 1, file) != 1)
return false;
rec_type[4] = '\0';
{
char rec_type[5];
if (fread (rec_type, 4, 1, file) != 1)
return false;
rec_type[4] = '\0';
Sets *CLAIMED_FLT64_CNT to the number of values that the file
claims to have (although it is not always correct).
If INFO is non-null, initializes *INFO with header
Sets *CLAIMED_FLT64_CNT to the number of values that the file
claims to have (although it is not always correct).
If INFO is non-null, initializes *INFO with header
static void
read_header (struct sfm_reader *r, struct dictionary *dict,
int *weight_idx, int *claimed_flt64_cnt,
static void
read_header (struct sfm_reader *r, struct dictionary *dict,
int *weight_idx, int *claimed_flt64_cnt,
read_string (r, rec_type, sizeof rec_type);
read_string (r, eye_catcher, sizeof eye_catcher);
read_string (r, rec_type, sizeof rec_type);
read_string (r, eye_catcher, sizeof eye_catcher);
if (strcmp ("$FL2", rec_type) != 0)
sys_error (r, _("This is not an SPSS system file."));
if (strcmp ("$FL2", rec_type) != 0)
sys_error (r, _("This is not an SPSS system file."));
read_string (r, creation_time, sizeof creation_time);
read_string (r, file_label, sizeof file_label);
skip_bytes (r, 3);
read_string (r, creation_time, sizeof creation_time);
read_string (r, file_label, sizeof file_label);
skip_bytes (r, 3);
file_label_ss = ss_cstr (file_label);
ss_trim (&file_label_ss, ss_cstr (" "));
file_label_ss = ss_cstr (file_label);
ss_trim (&file_label_ss, ss_cstr (" "));
{
ss_data (file_label_ss)[ss_length (file_label_ss)] = '\0';
dict_set_label (dict, ss_data (file_label_ss));
{
ss_data (file_label_ss)[ss_length (file_label_ss)] = '\0';
dict_set_label (dict, ss_data (file_label_ss));
if (width < 0 || width > 255)
sys_error (r, _("Bad variable width %d."), width);
var = dict_create_var (dict, name, width);
if (width < 0 || width > 255)
sys_error (r, _("Bad variable width %d."), width);
var = dict_create_var (dict, name, width);
name, (unsigned int) len);
read_string (r, label, len + 1);
var_set_label (var, label);
name, (unsigned int) len);
read_string (r, label, len + 1);
var_set_label (var, label);
{
struct missing_values mv;
mv_init (&mv, var_get_width (var));
{
struct missing_values mv;
mv_init (&mv, var_get_width (var));
sys_error (r, _("String variable %s may not have missing "
"values specified as a range."),
name);
sys_error (r, _("String variable %s may not have missing "
"values specified as a range."),
name);
/* Variable label fields on continuation records have
been spotted in system files created by "SPSS Power
Macintosh Release 6.1". */
/* Variable label fields on continuation records have
been spotted in system files created by "SPSS Power
Macintosh Release 6.1". */
if (!fmt_from_io (raw_type, &f.type))
sys_error (r, _("Unknown variable format %d."), (int) raw_type);
f.w = w;
if (!fmt_from_io (raw_type, &f.type))
sys_error (r, _("Unknown variable format %d."), (int) raw_type);
f.w = w;
{
if (which == PRINT_FORMAT)
var_set_print_format (v, &f);
{
if (which == PRINT_FORMAT)
var_set_print_format (v, &f);
case 11:
read_display_parameters (r, size, count, dict);
return;
case 11:
read_display_parameters (r, size, count, dict);
return;
default:
sys_warn (r, _("Unrecognized record type 7, subtype %d."), subtype);
break;
default:
sys_warn (r, _("Unrecognized record type 7, subtype %d."), subtype);
break;
sys_error (r, _("Bad size (%u) or count (%u) on extension 11."),
(unsigned int) size, (unsigned int) count);
sys_error (r, _("Bad size (%u) or count (%u) on extension 11."),
(unsigned int) size, (unsigned int) count);
map = open_variable_to_value_map (r, size * count);
while (read_variable_to_value_map (r, dict, map, &var, &long_name,
&warning_cnt))
map = open_variable_to_value_map (r, size * count);
while (read_variable_to_value_map (r, dict, map, &var, &long_name,
&warning_cnt))
/* Identify any duplicates. */
if (strcasecmp (short_name, long_name)
&& dict_lookup_var (dict, long_name) != NULL)
/* Identify any duplicates. */
if (strcasecmp (short_name, long_name)
&& dict_lookup_var (dict, long_name) != NULL)
and delete all but the first. */
remaining_length = length;
for (idx = var_get_dict_index (var); remaining_length > 0; idx++)
and delete all but the first. */
remaining_length = length;
for (idx = var_get_dict_index (var); remaining_length > 0; idx++)
remaining_length -= MIN (var_get_width (dict_get_var (dict, idx)),
EFFECTIVE_LONG_STRING_LENGTH);
else
remaining_length -= MIN (var_get_width (dict_get_var (dict, idx)),
EFFECTIVE_LONG_STRING_LENGTH);
else
var_is_numeric (var[i]) ? _("numeric") : _("string"));
/* Fill in labels[].value, now that we know the desired type. */
var_is_numeric (var[i]) ? _("numeric") : _("string"));
/* Fill in labels[].value, now that we know the desired type. */
if (var_is_alpha (var[0]))
buf_copy_rpad (label->value.s, sizeof label->value.s,
label->raw_value, sizeof label->raw_value);
else
label->value.f = flt64_to_double (r, (uint8_t *) label->raw_value);
}
if (var_is_alpha (var[0]))
buf_copy_rpad (label->value.s, sizeof label->value.s,
label->raw_value, sizeof label->raw_value);
else
label->value.f = flt64_to_double (r, (uint8_t *) label->raw_value);
}
{
if (var_is_numeric (var[0]))
sys_warn (r, _("Duplicate value label for %g on %s."),
{
if (var_is_numeric (var[0]))
sys_warn (r, _("Duplicate value label for %g on %s."),
else
sys_warn (r, _("Duplicate value label for \"%.*s\" on %s."),
var_get_width (v), label->value.s,
else
sys_warn (r, _("Duplicate value label for \"%.*s\" on %s."),
var_get_width (v), label->value.s,
{
/* Fast path. Read the whole case directly. */
if (!try_read_bytes (r, case_data_all_rw (c),
{
/* Fast path. Read the whole case directly. */
if (!try_read_bytes (r, case_data_all_rw (c),
- float_convert (r->float_format, d, FLOAT_NATIVE_DOUBLE, d);
+ float_convert (r->float_format, d, FLOAT_NATIVE_DOUBLE, d);
struct sfm_var *sv = &r->vars[i];
union value *v = case_data_rw_idx (c, sv->case_index);
struct sfm_var *sv = &r->vars[i];
union value *v = case_data_rw_idx (c, sv->case_index);
for (ofs = 0; ofs < sv->width; ofs += chunk_size)
{
chunk_size = MIN (max_chunk, sv->width - ofs);
for (ofs = 0; ofs < sv->width; ofs += chunk_size)
{
chunk_size = MIN (max_chunk, sv->width - ofs);
{
int bytes_read = (sv->width / max_chunk * 256
+ ROUND_UP (sv->width % max_chunk, 8));
int total_bytes = sfm_width_to_bytes (sv->width);
int excess_bytes = total_bytes - bytes_read;
{
int bytes_read = (sv->width / max_chunk * 256
+ ROUND_UP (sv->width % max_chunk, 8));
int total_bytes = sfm_width_to_bytes (sv->width);
int excess_bytes = total_bytes - bytes_read;
{
size_t whole = ROUND_DOWN (length, 8);
size_t partial = length % 8;
{
size_t whole = ROUND_DOWN (length, 8);
size_t partial = length % 8;
var_by_value_idx = pool_nmalloc (r->pool,
r->flt64_cnt, sizeof *var_by_value_idx);
var_by_value_idx = pool_nmalloc (r->pool,
r->flt64_cnt, sizeof *var_by_value_idx);
{
struct variable *v = dict_get_var (dict, i);
int nv = var_is_numeric (v) ? 1 : DIV_RND_UP (var_get_width (v), 8);
{
struct variable *v = dict_get_var (dict, i);
int nv = var_is_numeric (v) ? 1 : DIV_RND_UP (var_get_width (v), 8);
if (value_idx < 1 || value_idx > r->flt64_cnt)
sys_error (r, _("Variable index %d not in valid range 1...%d."),
value_idx, r->flt64_cnt);
if (value_idx < 1 || value_idx > r->flt64_cnt)
sys_error (r, _("Variable index %d not in valid range 1...%d."),
value_idx, r->flt64_cnt);
{
var = dict_get_var (d, i);
if (!strcasecmp (var_get_short_name (var), short_name))
{
var = dict_get_var (d, i);
if (!strcasecmp (var_get_short_name (var), short_name))
/* Reads SIZE bytes into a "variable=value" map for R,
and returns the map. */
static struct variable_to_value_map *
/* Reads SIZE bytes into a "variable=value" map for R,
and returns the map. */
static struct variable_to_value_map *
{
struct variable_to_value_map *map = pool_alloc (r->pool, sizeof *map);
char *buffer = pool_malloc (r->pool, size + 1);
{
struct variable_to_value_map *map = pool_alloc (r->pool, sizeof *map);
char *buffer = pool_malloc (r->pool, size + 1);
but can be used to free it earlier. */
static void
close_variable_to_value_map (struct sfm_reader *r,
but can be used to free it earlier. */
static void
close_variable_to_value_map (struct sfm_reader *r,
read_variable_to_value_map (struct sfm_reader *r, struct dictionary *dict,
struct variable_to_value_map *map,
struct variable **var, char **value,
read_variable_to_value_map (struct sfm_reader *r, struct dictionary *dict,
struct variable_to_value_map *map,
struct variable **var, char **value,
{
struct substring short_name_ss, value_ss;
if (!ss_tokenize (map->buffer, ss_cstr ("="), &map->pos, &short_name_ss)
|| !ss_tokenize (map->buffer, ss_buffer ("\t\0", 2), &map->pos,
{
struct substring short_name_ss, value_ss;
if (!ss_tokenize (map->buffer, ss_cstr ("="), &map->pos, &short_name_ss)
|| !ss_tokenize (map->buffer, ss_buffer ("\t\0", 2), &map->pos,
{
if (*warning_cnt > max_warnings)
sys_warn (r, _("Suppressed %d additional variable map warnings."),
*warning_cnt - max_warnings);
{
if (*warning_cnt > max_warnings)
sys_warn (r, _("Suppressed %d additional variable map warnings."),
*warning_cnt - max_warnings);
map->pos += ss_span (ss_substr (map->buffer, map->pos, SIZE_MAX),
ss_buffer ("\t\0", 2));
map->pos += ss_span (ss_substr (map->buffer, map->pos, SIZE_MAX),
ss_buffer ("\t\0", 2));
va_start (args, format);
sys_msg (r, MW, format, args);
va_end (args);
va_start (args, format);
sys_msg (r, MW, format, args);
va_end (args);
marks it as in an error state,
and aborts reading it using longjmp. */
static void
marks it as in an error state,
and aborts reading it using longjmp. */
static void
va_start (args, format);
sys_msg (r, ME, format, args);
va_end (args);
va_start (args, format);
sys_msg (r, ME, format, args);
va_end (args);
/* Returns the value of the 32-bit signed integer at INT32,
converted from the format used by R to the host format. */
static int32_t
/* Returns the value of the 32-bit signed integer at INT32,
converted from the format used by R to the host format. */
static int32_t
{
sys_file_casereader_read,
sys_file_casereader_destroy,
{
sys_file_casereader_read,
sys_file_casereader_destroy,