+static int
+parse_interactions (struct lexer *lexer, const struct variable **interaction_vars, int n_members,
+ int max_members, struct dataset *ds)
+{
+ if (lex_match (lexer, '*'))
+ {
+ if (n_members > max_members)
+ {
+ max_members *= 2;
+ xnrealloc (interaction_vars, max_members, sizeof (*interaction_vars));
+ }
+ interaction_vars[n_members] = parse_variable (lexer, dataset_dict (ds));
+ parse_interactions (lexer, interaction_vars, n_members++, max_members, ds);
+ }
+ return n_members;
+}
+/* Parser for the design subcommand. */
+static int
+glm_custom_design (struct lexer *lexer, struct dataset *ds,
+ struct cmd_glm *cmd UNUSED, void *aux UNUSED)
+{
+ size_t n_allocated = 2;
+ size_t n_members;
+ struct variable **interaction_vars;
+ struct variable *this_var;
+
+ interactions = xnmalloc (n_allocated, sizeof (*interactions));
+ n_inter = 1;
+ while (lex_token (lexer) != T_STOP && lex_token (lexer) != '.')
+ {
+ this_var = parse_variable (lexer, dataset_dict (ds));
+ if (lex_match (lexer, '('))
+ {
+ lex_force_match (lexer, ')');
+ }
+ else if (lex_match (lexer, '*'))
+ {
+ interaction_vars = xnmalloc (2 * n_inter, sizeof (*interaction_vars));
+ n_members = parse_interactions (lexer, interaction_vars, 1, 2 * n_inter, ds);
+ if (n_allocated < n_inter)
+ {
+ n_allocated *= 2;
+ xnrealloc (interactions, n_allocated, sizeof (*interactions));
+ }
+ interactions [n_inter - 1] =
+ interaction_variable_create (interaction_vars, n_members);
+ n_inter++;
+ free (interaction_vars);
+ }
+ }
+ return 1;
+}