hmap_delete (&ct->postcomputes, &pc->hmap_node);
free (pc);
}
+ hmap_destroy (&ct->postcomputes);
fmt_settings_uninit (&ct->ctables_formats);
pivot_table_look_unref (ct->look);
case CTPO_CAT_NRANGE:
case CTPO_CAT_SRANGE:
+ case CTPO_CAT_MISSING:
+ case CTPO_CAT_OTHERNM:
{
struct ctables_cell_value cv = {
.category = ctables_find_category_for_postcompute (ctx->section->table->ctables->dict, ctx->cats, ctx->parse_format, e)
}
case CTPO_CAT_NUMBER:
- case CTPO_CAT_MISSING:
- case CTPO_CAT_OTHERNM:
case CTPO_CAT_SUBTOTAL:
case CTPO_CAT_TOTAL:
{
s = xmalloc (width);
buf_copy_rpad (s, width, e->string.string, e->string.length, ' ');
}
- struct ctables_cell_value cv = {
- .category = ctables_find_category_for_postcompute (ctx->section->table->ctables->dict, ctx->cats, ctx->parse_format, e),
- .value = { .s = CHAR_CAST (uint8_t *, s ? s : e->string.string) },
- };
- assert (cv.category != NULL);
+
+ const struct ctables_category *category
+ = ctables_find_category_for_postcompute (
+ ctx->section->table->ctables->dict,
+ ctx->cats, ctx->parse_format, e);
+ assert (category != NULL);
+
+ struct ctables_cell_value cv = { .category = category };
+ if (category->type == CCT_NUMBER)
+ cv.value.f = category->number;
+ else if (category->type == CCT_STRING)
+ cv.value.s = CHAR_CAST (uint8_t *, s ? s : e->string.string);
+ else
+ NOT_REACHED ();
+
double retval = ctables_pcexpr_evaluate_category (ctx, &cv);
free (s);
return retval;