totals can go first as well as last
[pspp] / src / language / stats / ctables.c
index 24924a35783a87389ce1a1f0a07181f832f0e35c..18fd30b683b3a438dd41036f2a596773a18b53cc 100644 (file)
@@ -2127,8 +2127,11 @@ ctables_categories_match (const struct ctables_categories *c,
 static const struct ctables_category *
 ctables_categories_total (const struct ctables_categories *c)
 {
-  const struct ctables_category *total = &c->cats[c->n_cats - 1];
-  return total->type == CCT_TOTAL ? total : NULL;
+  const struct ctables_category *first = &c->cats[0];
+  const struct ctables_category *last = &c->cats[c->n_cats - 1];
+  return (first->type == CCT_TOTAL ? first
+          : last->type == CCT_TOTAL ? last
+          : NULL);
 }
 
 static void
@@ -2404,7 +2407,7 @@ ctables_execute (struct dataset *ds, struct ctables *ct)
         (t->title
          ? pivot_value_new_user_text (t->title, SIZE_MAX)
          : pivot_value_new_text (N_("Custom Tables"))),
-        NULL);
+        "Custom Tables");
       if (t->caption)
         pivot_table_set_caption (
           pt, pivot_value_new_user_text (t->caption, SIZE_MAX));