+/*
+ Set V to contain an array of pointers to the variables
+ used in the model. V must be at least C->N_COEFFS in length.
+ The return value is the number of distinct variables found.
+ */
+int
+pspp_linreg_get_vars (const void *c_, const struct variable **v)
+{
+ const pspp_linreg_cache *c = c_;
+ const struct variable *tmp;
+ int i;
+ int j;
+ int result = 0;
+
+ /*
+ Make sure the caller doesn't try to sneak a variable
+ into V that is not in the model.
+ */
+ for (i = 0; i < c->n_coeffs; i++)
+ {
+ v[i] = NULL;
+ }
+ for (j = 0; j < c->n_coeffs; j++)
+ {
+ tmp = pspp_coeff_get_var (c->coeff[j], 0);
+ assert (tmp != NULL);
+ /* Repeated variables are likely to bunch together, at the end
+ of the array. */
+ i = result - 1;
+ while (i >= 0 && v[i] != tmp)
+ {
+ i--;
+ }
+ if (i < 0 && result < c->n_coeffs)
+ {
+ v[result] = tmp;
+ result++;
+ }
+ }
+ return result;
+}
+