label = var_to_string (v);
/* Do not overwrite the variable's name. */
strncpy (tmp, label, MAX_STRING);
- if (v->type == ALPHA)
+ if (var_is_alpha (v))
{
/*
Append the value associated with this coefficient.
{
coeff = c->coeff[i];
v = pspp_coeff_get_var (coeff, 0);
- if (v->type == ALPHA)
+ if (var_is_alpha (v))
{
if (!reg_inserted (v, varlist, n_vars))
{
fprintf (fp, "struct pspp_reg_categorical_variable %s;\n\t",
- v->name);
+ var_get_name (v));
varlist[n_vars] = (struct variable *) v;
n_vars++;
}
n_vars);
for (i = 0; i < n_vars - 1; i++)
{
- fprintf (fp, "&%s,\n\t\t", varlist[i]->name);
+ fprintf (fp, "&%s,\n\t\t", var_get_name (varlist[i]));
}
- fprintf (fp, "&%s};\n\t", varlist[i]->name);
+ fprintf (fp, "&%s};\n\t", var_get_name (varlist[i]));
for (i = 0; i < n_vars; i++)
{
coeff = c->coeff[i];
- fprintf (fp, "%s.name = \"%s\";\n\t", varlist[i]->name,
- varlist[i]->name);
- fprintf (fp, "%s.n_vals = %d;\n\t", varlist[i]->name,
+ fprintf (fp, "%s.name = \"%s\";\n\t",
+ var_get_name (varlist[i]),
+ var_get_name (varlist[i]));
+ fprintf (fp, "%s.n_vals = %d;\n\t",
+ var_get_name (varlist[i]),
varlist[i]->obs_vals->n_categories);
for (j = 0; j < varlist[i]->obs_vals->n_categories; j++)
{
val = cat_subscript_to_value ((const size_t) j, varlist[i]);
- fprintf (fp, "%s.values[%d] = \"%s\";\n\t", varlist[i]->name, j,
+ fprintf (fp, "%s.values[%d] = \"%s\";\n\t",
+ var_get_name (varlist[i]), j,
value_to_string (val, varlist[i]));
}
}
{
coeff = c->coeff[i];
v = pspp_coeff_get_var (coeff, 0);
- fprintf (fp, "\"%s\",\n\t\t", v->name);
+ fprintf (fp, "\"%s\",\n\t\t", var_get_name (v));
}
coeff = c->coeff[i];
v = pspp_coeff_get_var (coeff, 0);
- fprintf (fp, "\"%s\"};\n\t", v->name);
+ fprintf (fp, "\"%s\"};\n\t", var_get_name (v));
}
static void
reg_print_getvar (FILE * fp, pspp_linreg_cache * c)
for (i = 1; i < c->n_coeffs; i++)
{
v = pspp_coeff_get_var (c->coeff[i], 0);
- if (v->type == ALPHA)
- {
- return 1;
- }
+ if (var_is_alpha (v))
+ return 1;
}
return 0;
}
}
static int
-regression_custom_export (struct dataset *ds UNUSED, struct cmd_regression *cmd UNUSED, void *aux UNUSED)
+regression_custom_export (struct lexer *lexer, struct dataset *ds UNUSED, struct cmd_regression *cmd UNUSED, void *aux UNUSED)
{
/* 0 on failure, 1 on success, 2 on failure that should result in syntax error */
- if (!lex_force_match ('('))
+ if (!lex_force_match (lexer, '('))
return 0;
- if (lex_match ('*'))
+ if (lex_match (lexer, '*'))
model_file = NULL;
else
{
- model_file = fh_parse (FH_REF_FILE);
+ model_file = fh_parse (lexer, FH_REF_FILE);
if (model_file == NULL)
return 0;
}
- if (!lex_force_match (')'))
+ if (!lex_force_match (lexer, ')'))
return 0;
return 1;
}
int
-cmd_regression (struct dataset *ds)
+cmd_regression (struct lexer *lexer, struct dataset *ds)
{
- if (!parse_regression (ds, &cmd, NULL))
+ if (!parse_regression (lexer, ds, &cmd, NULL))
return CMD_FAILURE;
models = xnmalloc (cmd.n_dependent, sizeof *models);
val = case_data (&c, v->fv);
cat_value_update (v, val);
- if (mv_is_value_missing (&v->miss, val))
+ if (var_is_value_missing (v, val))
{
if (!is_missing_case[row])
{
/* Parser for the variables sub command */
static int
-regression_custom_variables (struct dataset *ds,
+regression_custom_variables (struct lexer *lexer, struct dataset *ds,
struct cmd_regression *cmd UNUSED,
void *aux UNUSED)
{
const struct dictionary *dict = dataset_dict (ds);
- lex_match ('=');
+ lex_match (lexer, '=');
- if ((token != T_ID || dict_lookup_var (dict, tokid) == NULL)
- && token != T_ALL)
+ if ((lex_token (lexer) != T_ID || dict_lookup_var (dict, lex_tokid (lexer)) == NULL)
+ && lex_token (lexer) != T_ALL)
return 2;
- if (!parse_variables (dict, &v_variables, &n_variables, PV_NONE))
+ if (!parse_variables (lexer, dict, &v_variables, &n_variables, PV_NONE))
{
free (v_variables);
return 0;
{
indep_vars[j] = v_variables[i];
j++;
- if (v_variables[i]->type == ALPHA)
+ if (var_is_alpha (v_variables[i]))
{
/* Make a place to hold the binary vectors
corresponding to this variable's values. */
for (i = 0; i < cmd.n_dependent; i++)
{
- if (cmd.v_dependent[i]->type != NUMERIC)
+ if (!var_is_numeric (cmd.v_dependent[i]))
{
msg (SE, gettext ("Dependent variable must be numeric."));
pspp_reg_rc = CMD_FAILURE;
*/
if (!is_depvar (i, cmd.v_dependent[k]))
{
- if (v_variables[i]->type == ALPHA)
+ if (var_is_alpha (v_variables[i]))
{
design_matrix_set_categorical (X, row,
v_variables[i], val);
}
- else if (v_variables[i]->type == NUMERIC)
+ else
{
design_matrix_set_numeric (X, row, v_variables[i],
val);