+ See the large comment on split file handling in pivot-table.h for more
+ information. */
+void
+pivot_splits_new_split (struct pivot_splits *ps, const struct ccase *example)
+{
+ if (!ps)
+ return;
+
+ size_t n_new = 0;
+ for (size_t i = 0; i < ps->n; i++)
+ {
+ struct pivot_splits_var *psvar = &ps->vars[i];
+ const union value *value = case_data (example, psvar->var);
+ struct pivot_splits_value *psval = pivot_splits_value_find (psvar, value);
+ if (!psval)
+ {
+ psval = xmalloc (sizeof *psval);
+ hmap_insert (&psvar->values, &psval->hmap_node,
+ value_hash (value, psvar->width, 0));
+ value_clone (&psval->value, value, psvar->width);
+ 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 (!n_new)
+ {
+ if (ps->warnings_left-- > 0)
+ {
+ struct string s = DS_EMPTY_INITIALIZER;
+ for (size_t i = 0; i < ps->n; i++)
+ {
+ if (i > 0)
+ ds_put_cstr (&s, ", ");
+
+ struct pivot_splits_var *psvar = &ps->vars[i];
+ const union value *value = case_data (example, psvar->var);
+ ds_put_format (&s, "%s = ", var_get_name (psvar->var));
+
+ char *s2 = data_out (value, ps->encoding,
+ var_get_print_format (psvar->var),
+ settings_get_fmt_settings ());
+ ds_put_cstr (&s, s2 + strspn (s2, " "));
+ free (s2);
+ }
+ msg (SW, _("When SPLIT FILE is in effect, the input data must be "
+ "sorted by the split variables (for example, using SORT "
+ "CASES), but multiple runs of cases with the same split "
+ "values were found separated by cases with different "
+ "values. Each run will be analyzed separately. The "
+ "duplicate split values are: %s"), ds_cstr (&s));
+ ds_destroy (&s);
+ }
+
+ struct pivot_splits_var *psvar = &ps->vars[0];
+ const union value *value = case_data (example, psvar->var);
+ ps->dindexes[0] = pivot_category_create_leaf (
+ psvar->dimension->root,
+ pivot_value_new_var_value (psvar->var, value));
+ }
+}
+
+static size_t
+pivot_splits_get_dindexes (const struct pivot_splits *ps, size_t *dindexes)
+{
+ if (!ps)
+ return 0;
+
+ assert (ps->dindexes[0] != SIZE_MAX);
+ for (size_t i = 0; i < ps->n; i++)
+ dindexes[i] = ps->dindexes[i];
+ return ps->n;
+}
+
+/* Puts VALUE in the cell in TABLE with index IDX1. TABLE must have 1
+ dimension plus the split file dimensions from PS (if nonnull). Takes
+ ownership of VALUE.
+
+ See the large comment on split file handling in pivot-table.h for more
+ information. */
+void
+pivot_splits_put1 (struct pivot_splits *ps, struct pivot_table *table,
+ size_t idx1, struct pivot_value *value)
+{
+ size_t dindexes[1 + MAX_SPLITS];
+ size_t *p = dindexes;
+ *p++ = idx1;
+ p += pivot_splits_get_dindexes (ps, p);
+ pivot_table_put (table, dindexes, p - dindexes, value);
+}
+
+/* Puts VALUE in the cell in TABLE with index (IDX1, IDX2). TABLE must have 2
+ dimensions plus the split file dimensions from PS (if nonnull). Takes
+ ownership of VALUE.
+
+ See the large comment on split file handling in pivot-table.h for more
+ information. */
+void
+pivot_splits_put2 (struct pivot_splits *ps, struct pivot_table *table,
+ size_t idx1, size_t idx2, struct pivot_value *value)
+{
+ size_t dindexes[2 + MAX_SPLITS];
+ size_t *p = dindexes;
+ *p++ = idx1;
+ *p++ = idx2;
+ p += pivot_splits_get_dindexes (ps, p);
+ pivot_table_put (table, dindexes, p - dindexes, value);
+}
+
+/* Puts VALUE in the cell in TABLE with index (IDX1, IDX2, IDX3). TABLE must
+ have 3 dimensions plus the split file dimensions from PS (if nonnull).
+ Takes ownership of VALUE.
+
+ See the large comment on split file handling in pivot-table.h for more
+ information. */
+void
+pivot_splits_put3 (struct pivot_splits *ps, struct pivot_table *table,
+ size_t idx1, size_t idx2, size_t idx3,
+ struct pivot_value *value)
+{
+ size_t dindexes[3 + MAX_SPLITS];
+ size_t *p = dindexes;
+ *p++ = idx1;
+ *p++ = idx2;
+ *p++ = idx3;
+ p += pivot_splits_get_dindexes (ps, p);
+ pivot_table_put (table, dindexes, p - dindexes, value);
+}
+
+/* Puts VALUE in the cell in TABLE with index (IDX1, IDX2, IDX3, IDX4). TABLE
+ must have 4 dimensions plus the split file dimensions from PS (if nonnull).
+ Takes ownership of VALUE.
+
+ See the large comment on split file handling in pivot-table.h for more
+ information. */
+void
+pivot_splits_put4 (struct pivot_splits *ps, struct pivot_table *table,
+ size_t idx1, size_t idx2, size_t idx3, size_t idx4,
+ struct pivot_value *value)
+{
+ size_t dindexes[4 + MAX_SPLITS];
+ size_t *p = dindexes;
+ *p++ = idx1;
+ *p++ = idx2;
+ *p++ = idx3;
+ *p++ = idx4;
+ p += pivot_splits_get_dindexes (ps, p);
+ pivot_table_put (table, dindexes, p - dindexes, value);
+}