spv-legacy-decoder: Set data_index and presentation_index in leaves.
authorBen Pfaff <blp@cs.stanford.edu>
Sat, 9 Jan 2021 06:16:11 +0000 (22:16 -0800)
committerBen Pfaff <blp@cs.stanford.edu>
Sat, 9 Jan 2021 06:16:11 +0000 (22:16 -0800)
This allows the new assertions in clone_category() to pass.

src/output/pivot-table.c
src/output/spv/spv-legacy-decoder.c

index 5bcc6dc7ccc2ff5a170b53af99155b23d68461f9..01a4a859f159a93b6b70c2aed48123fa36985a3b 100644 (file)
@@ -988,7 +988,10 @@ clone_category (struct pivot_category *old,
 
   if (pivot_category_is_leaf (old))
     {
+      assert (new->data_index < new_dimension->n_leaves);
       new->dimension->data_leaves[new->data_index] = new;
+
+      assert (new->presentation_index < new_dimension->n_leaves);
       new->dimension->presentation_leaves[new->presentation_index] = new;
     }
 
index b8005de5be890d3412c39090f68c557f58c44a0f..78b1780b1748b5a3a2fdca15c06d19dd3c810b89 100644 (file)
@@ -1272,6 +1272,11 @@ add_dimension (struct spv_series **series, size_t n,
   /* Now drop unnamed 1-category groups and add parent pointers. */
   for (size_t j = 0; j < n_cats; j++)
     add_parents (cats[j], d->root, j);
+  for (size_t j = 0; j < d->n_leaves; j++)
+    {
+      d->data_leaves[j]->data_index = j;
+      d->presentation_leaves[j]->presentation_index = j;
+    }
 
   d->root->subs = cats;
   d->root->n_subs = n_cats;