int line_length; /* Number of characters so far on this line. */
char cc; /* Current character. */
char *trans; /* 256-byte character set translation table. */
- int var_cnt; /* Number of variables. */
+ int n_vars; /* Number of variables. */
int weight_index; /* 0-based index of weight variable, or -1. */
struct caseproto *proto; /* Format of output cases. */
bool ok; /* Set false on I/O error. */
ds_put_vformat (&text, msg, args);
va_end (args);
- struct msg m = {
+ struct msg *m = xmalloc (sizeof *m);
+ *m = (struct msg) {
.category = MSG_C_GENERAL,
.severity = MSG_S_ERROR,
- .text = ds_cstr (&text),
+ .text = ds_steal_cstr (&text),
};
- msg_emit (&m);
+ msg_emit (m);
r->ok = false;
ds_put_vformat (&text, msg, args);
va_end (args);
- struct msg m = {
+ struct msg *m = xmalloc (sizeof *m);
+ *m = (struct msg) {
.category = MSG_C_GENERAL,
.severity = MSG_S_WARNING,
- .text = ds_cstr (&text),
+ .text = ds_steal_cstr (&text),
};
- msg_emit (&m);
+ msg_emit (m);
}
/* Close and destroy R.
r->line_length = 0;
r->weight_index = -1;
r->trans = NULL;
- r->var_cnt = 0;
+ r->n_vars = 0;
r->proto = NULL;
r->ok = true;
if (setjmp (r->bail_out))
info->float_format = FLOAT_NATIVE_DOUBLE;
info->integer_format = INTEGER_NATIVE;
info->compression = ANY_COMP_NONE;
- info->case_cnt = -1;
+ info->n_cases = -1;
/* Date. */
info->creation_date = xmalloc (11);
if (!match (r, '4'))
error (r, _("Expected variable count record."));
- r->var_cnt = read_int (r);
- if (r->var_cnt <= 0)
- error (r, _("Invalid number of variables %d."), r->var_cnt);
+ r->n_vars = read_int (r);
+ if (r->n_vars <= 0)
+ error (r, _("Invalid number of variables %d."), r->n_vars);
if (match (r, '5'))
read_int (r);
error (r, _("Weight variable name (%s) truncated."), weight_name);
}
- for (i = 0; i < r->var_cnt; i++)
+ for (i = 0; i < r->n_vars; i++)
{
int width;
char name[256];
static void
read_documents (struct pfm_reader *r, struct dictionary *dict)
{
- int line_cnt;
- int i;
-
- line_cnt = read_int (r);
- for (i = 0; i < line_cnt; i++)
+ int n_lines = read_int (r);
+ for (int i = 0; i < n_lines; i++)
{
char line[256];
read_string (r, line);
return NULL;
}
- for (i = 0; i < r->var_cnt; i++)
+ for (i = 0; i < r->n_vars; i++)
{
int width = caseproto_get_width (r->proto, i);
if (width == 0)
- case_data_rw_idx (c, i)->f = read_float (r);
+ *case_num_rw_idx (c, i) = read_float (r);
else
{
uint8_t buf[256];
{
unsigned char header[464];
char trans[256];
- int cooked_cnt, raw_cnt, line_len;
+ int n_cooked, n_raws, line_len;
int i;
- cooked_cnt = raw_cnt = 0;
+ n_cooked = n_raws = 0;
line_len = 0;
- while (cooked_cnt < sizeof header)
+ while (n_cooked < sizeof header)
{
int c = getc (file);
- if (c == EOF || raw_cnt++ > 512)
+ if (c == EOF || n_raws++ > 512)
return ferror (file) ? -errno : 0;
else if (c == '\n')
{
- while (line_len < 80 && cooked_cnt < sizeof header)
+ while (line_len < 80 && n_cooked < sizeof header)
{
- header[cooked_cnt++] = ' ';
+ header[n_cooked++] = ' ';
line_len++;
}
line_len = 0;
}
else if (c != '\r')
{
- header[cooked_cnt++] = c;
+ header[n_cooked++] = c;
line_len++;
}
}