{
for (size_t i = 0; i < set->n; i++)
ctables_summary_spec_uninit (&set->specs[i]);
+ free (set->listwise_vars);
free (set->specs);
}
else
{
if (!lex_force_string (lexer))
- return false;
+ {
+ ss_dealloc (&s);
+ return false;
+ }
struct substring sr1 = parse_substring (lexer, dict);
*cat = cct_srange (s, sr1);
}
free (nest->vars);
for (enum ctables_summary_variant sv = 0; sv < N_CSVS; sv++)
ctables_summary_spec_set_uninit (&nest->specs[sv]);
+ for (enum ctables_domain_type dt = 0; dt < N_CTDTS; dt++)
+ free (nest->domains[dt]);
}
static void
size_t allocate = a->n + b->n;
struct variable **vars = xnmalloc (allocate, sizeof *vars);
- enum pivot_axis_type *axes = xnmalloc (allocate, sizeof *axes);
size_t n = 0;
for (size_t k = 0; k < a->n; k++)
vars[n++] = a->vars[k];
listwise_vars[n++] = other_nest->vars[other_nest->scale_idx];
}
}
- for (size_t j = 0; j < N_CSVS; j++)
+ for (enum ctables_summary_variant sv = 0; sv < N_CSVS; sv++)
{
- nest->specs[j].listwise_vars = listwise_vars;
- nest->specs[j].n_listwise_vars = n;
+ if (sv > 0)
+ listwise_vars = xmemdup (listwise_vars,
+ n * sizeof *listwise_vars);
+ nest->specs[sv].listwise_vars = listwise_vars;
+ nest->specs[sv].n_listwise_vars = n;
}
}
}
for (size_t i = 0; i < nest->n; i++)
hmap_destroy (&s->occurrences[a][i]);
free (s->occurrences[a]);
- for (enum ctables_domain_type dt = 0; dt < N_CTDTS; dt++)
- {
- free (nest->domains[dt]);
- nest->domains[dt] = NULL;
- }
}
hmap_destroy (&s->cells);
};
static const struct operator *
-ctable_pcexpr_match_operator (struct lexer *lexer,
+ctables_pcexpr_match_operator (struct lexer *lexer,
const struct operator ops[], size_t n_ops)
{
for (const struct operator *op = ops; op < ops + n_ops; op++)
}
static struct ctables_pcexpr *
-ctable_pcexpr_parse_binary_operators__ (
+ctables_pcexpr_parse_binary_operators__ (
struct lexer *lexer, struct dictionary *dict,
const struct operator ops[], size_t n_ops,
parse_recursively_func *parse_next_level,
for (int op_count = 0; ; op_count++)
{
const struct operator *op
- = ctable_pcexpr_match_operator (lexer, ops, n_ops);
+ = ctables_pcexpr_match_operator (lexer, ops, n_ops);
if (!op)
{
if (op_count > 1 && chain_warning)
}
static struct ctables_pcexpr *
-ctable_pcexpr_parse_binary_operators (struct lexer *lexer,
- struct dictionary *dict,
- const struct operator ops[], size_t n_ops,
- parse_recursively_func *parse_next_level,
- const char *chain_warning)
+ctables_pcexpr_parse_binary_operators (
+ struct lexer *lexer, struct dictionary *dict,
+ const struct operator ops[], size_t n_ops,
+ parse_recursively_func *parse_next_level, const char *chain_warning)
{
struct ctables_pcexpr *lhs = parse_next_level (lexer, dict);
if (!lhs)
return NULL;
- return ctable_pcexpr_parse_binary_operators__ (lexer, dict, ops, n_ops,
+ return ctables_pcexpr_parse_binary_operators__ (lexer, dict, ops, n_ops,
parse_next_level,
chain_warning, lhs);
}
-static struct ctables_pcexpr *ctable_pcexpr_parse_add (struct lexer *,
- struct dictionary *);
+static struct ctables_pcexpr *ctables_pcexpr_parse_add (struct lexer *,
+ struct dictionary *);
static struct ctables_pcexpr
ctpo_cat_nrange (double low, double high)
}
static struct ctables_pcexpr *
-ctable_pcexpr_parse_primary (struct lexer *lexer, struct dictionary *dict)
+ctables_pcexpr_parse_primary (struct lexer *lexer, struct dictionary *dict)
{
int start_ofs = lex_ofs (lexer);
struct ctables_pcexpr e;
}
else if (lex_match (lexer, T_LPAREN))
{
- struct ctables_pcexpr *ep = ctable_pcexpr_parse_add (lexer, dict);
+ struct ctables_pcexpr *ep = ctables_pcexpr_parse_add (lexer, dict);
if (!ep)
return NULL;
if (!lex_force_match (lexer, T_RPAREN))
}
static struct ctables_pcexpr *
-ctable_pcexpr_parse_exp (struct lexer *lexer, struct dictionary *dict)
+ctables_pcexpr_parse_exp (struct lexer *lexer, struct dictionary *dict)
{
static const struct operator op = { T_EXP, CTPO_POW };
"To disable this warning, insert parentheses.");
if (lex_token (lexer) != T_NEG_NUM || lex_next_token (lexer, 1) != T_EXP)
- return ctable_pcexpr_parse_binary_operators (lexer, dict, &op, 1,
- ctable_pcexpr_parse_primary,
- chain_warning);
+ return ctables_pcexpr_parse_binary_operators (lexer, dict, &op, 1,
+ ctables_pcexpr_parse_primary,
+ chain_warning);
/* Special case for situations like "-5**6", which must be parsed as
-(5**6). */
};
lex_get (lexer);
- struct ctables_pcexpr *node = ctable_pcexpr_parse_binary_operators__ (
+ struct ctables_pcexpr *node = ctables_pcexpr_parse_binary_operators__ (
lexer, dict, &op, 1,
- ctable_pcexpr_parse_primary, chain_warning, lhs);
+ ctables_pcexpr_parse_primary, chain_warning, lhs);
if (!node)
return NULL;
/* Parses the unary minus level. */
static struct ctables_pcexpr *
-ctable_pcexpr_parse_neg (struct lexer *lexer, struct dictionary *dict)
+ctables_pcexpr_parse_neg (struct lexer *lexer, struct dictionary *dict)
{
int start_ofs = lex_ofs (lexer);
if (!lex_match (lexer, T_DASH))
- return ctable_pcexpr_parse_exp (lexer, dict);
+ return ctables_pcexpr_parse_exp (lexer, dict);
- struct ctables_pcexpr *inner = ctable_pcexpr_parse_neg (lexer, dict);
+ struct ctables_pcexpr *inner = ctables_pcexpr_parse_neg (lexer, dict);
if (!inner)
return NULL;
/* Parses the multiplication and division level. */
static struct ctables_pcexpr *
-ctable_pcexpr_parse_mul (struct lexer *lexer, struct dictionary *dict)
+ctables_pcexpr_parse_mul (struct lexer *lexer, struct dictionary *dict)
{
static const struct operator ops[] =
{
{ T_SLASH, CTPO_DIV },
};
- return ctable_pcexpr_parse_binary_operators (lexer, dict, ops,
+ return ctables_pcexpr_parse_binary_operators (lexer, dict, ops,
sizeof ops / sizeof *ops,
- ctable_pcexpr_parse_neg, NULL);
+ ctables_pcexpr_parse_neg, NULL);
}
/* Parses the addition and subtraction level. */
static struct ctables_pcexpr *
-ctable_pcexpr_parse_add (struct lexer *lexer, struct dictionary *dict)
+ctables_pcexpr_parse_add (struct lexer *lexer, struct dictionary *dict)
{
static const struct operator ops[] =
{
{ T_NEG_NUM, CTPO_ADD },
};
- return ctable_pcexpr_parse_binary_operators (lexer, dict,
+ return ctables_pcexpr_parse_binary_operators (lexer, dict,
ops, sizeof ops / sizeof *ops,
- ctable_pcexpr_parse_mul, NULL);
+ ctables_pcexpr_parse_mul, NULL);
}
static struct ctables_postcompute *
}
int expr_start = lex_ofs (lexer);
- struct ctables_pcexpr *expr = ctable_pcexpr_parse_add (lexer, dict);
+ struct ctables_pcexpr *expr = ctables_pcexpr_parse_add (lexer, dict);
int expr_end = lex_ofs (lexer) - 1;
if (!expr || !lex_force_match (lexer, T_RPAREN))
{
+ ctables_pcexpr_destroy (expr);
free (name);
return false;
}