pivot-table: fix split file support
authorBen Pfaff <blp@cs.stanford.edu>
Sun, 14 Aug 2022 22:51:41 +0000 (15:51 -0700)
committerBen Pfaff <blp@cs.stanford.edu>
Sun, 14 Aug 2022 22:51:41 +0000 (15:51 -0700)
src/output/pivot-table.c

index ec652e50de0b532e1230a93941369a99e3cdb7c1..f81be9df22576755d4cb532e7697f01085789fd2 100644 (file)
@@ -3165,7 +3165,7 @@ pivot_splits_new_split (struct pivot_splits *ps, const struct ccase *example)
   if (!ps)
     return;
 
-  size_t n_new = 0;
+  size_t n_changed = 0;
   for (size_t i = 0; i < ps->n; i++)
     {
       struct pivot_splits_var *psvar = &ps->vars[i];
@@ -3180,13 +3180,16 @@ pivot_splits_new_split (struct pivot_splits *ps, const struct ccase *example)
           psval->leaf = pivot_category_create_leaf (
             psvar->dimension->root,
             pivot_value_new_var_value (psvar->var, value));
-          n_new++;
         }
 
-      ps->dindexes[i] = psval->leaf;
+      if (ps->dindexes[i] != psval->leaf)
+        {
+          ps->dindexes[i] = psval->leaf;
+          n_changed++;
+        }
     }
 
-  if (!n_new)
+  if (!n_changed)
     {
       if (ps->warnings_left-- > 0)
         {
@@ -3231,7 +3234,7 @@ pivot_splits_get_dindexes (const struct pivot_splits *ps, size_t *dindexes)
 
   assert (ps->dindexes[0] != SIZE_MAX);
   for (size_t i = 0; i < ps->n; i++)
-    dindexes[i] = ps->dindexes[i];
+    dindexes[ps->n - i - 1] = ps->dindexes[i];
   return ps->n;
 }